Skip to content

Patch 3#4

Merged
KanadeBlue merged 58 commits into
stablefrom
Patch-3
Mar 29, 2025
Merged

Patch 3#4
KanadeBlue merged 58 commits into
stablefrom
Patch-3

Conversation

@KanadeBlue
Copy link
Copy Markdown

@KanadeBlue KanadeBlue commented Mar 29, 2025

Related issues & PRs

Changes

API changes

Behavioural changes

Backwards compatibility

Follow-up

Tests

Summary by CodeRabbit

  • New Features

    • Introduced support for Minecraft: Bedrock Edition 1.21.70 with updated version information.
    • Added new block and item types for enhanced in-game variety.
    • Offered a new debug command for upgrade schema data.
  • Bug Fixes

    • Improved bug report instructions to clarify required version and system details.
  • Documentation

    • Updated contribution guidelines to help newcomers find “Easy task” issues.
  • Refactor/Chores

    • Refined sound event handling and block breaking mechanics.
    • Upgraded dependency versions for overall stability.

dktapps and others added 30 commits January 27, 2025 21:28
closes pmmp#6500

This fixes break time animations for mining fatigue and haste, and
improves the underwater and on-ground behaviour.

on-ground is still not quite right for reasons not related to this PR
(see pmmp#6547).
I'm also not quite sure the underwater logic is correct (in water vs
underwater?) but it's definitely better than what we have currently.
This PR significantly improves performance of entity movement calculation.

Previous attempts to optimise this were ineffective, as they used a cache to mitigate the cost of recomputing AABBs. Entities tend to move around randomly, so the non-cached pathway really needed to be optimized.

This change improves performance on multiple fronts:
1) avoiding Block allocations for blocks with 1x1x1 AABBs and with no AABBs (the most common)
2) avoiding Block allocations and overlapping intersection checks unless a stateID is specifically known to potentially exceed its cell boundaries (like fences)
3) avoiding overlapping AABB checks when overlaps can't make any difference anyway (cubes)

Together, these changes improve the performance of World->getBlockCollisionBoxes() by a factor of 5. In real-world terms, this shows up as a major performance improvement in situations with lots of entities moving in random directions. Testing with item entities showed an increase from 400 to 1200 moving items with the same CPU usage.

This change is built on the assumption that `Block->recalculateCollisionBoxes()` and its overrides don't interact with any world. This is technically possible due to the crappy design of the `Block` architecture, but should be avoided. As a world is not available during `RuntimeBlockStateRegistry` initialization, attempting to interact with a world during `recalculateCollisionBoxes()` will now cause a crash.

This turned out to be a problem for `ChorusPlant`, which was fixed by 70fb9bb. The correct solution in this case was to use dynamic states similar to how we currently deal with fence connections.
there's no technical reason not to support this, since it doesn't violate any assumptions and the type returned is a base anyway.

this enables implementing stuff like snow cauldrons in a plugin, which previously would require reflection due to the minecraft:cauldron deserializer being registered already.
it also enables overriding IDs to map to custom blocks, which might be useful for overriding some functionality (although this is inadvisable - and won't alter the usage of stuff like VanillaBlocks::WHATEVER()).

we do *not* allow overriding serializers, since type IDs are expected to be paired to block implementations, and allowing them to be reassigned could lead to crashes if the new class was incorrect. So the correct approach for overriding nether portals would be to create a custom type ID as if you were adding a fully custom item. This will also allow other plugins to distinguish between your implementation and the built-in one.
this command dumps a human-readable version of pmmp/mapping palette mapping files to a .txt file.
may be useful for debugging issues with the schema generator or the upgrade process.
see pmmp#6635 for rationale on why we want to get rid of this

for now, this rule will prevent this anti-feature from being used in new code
this makes sure wrong parameters don't show up as core errors, as seen in crash report 12373907
closes pmmp#6642
leolee3914 and others added 26 commits March 9, 2025 02:09
…mp#6643)

this was causing TNT and falling blocks to briefly appear half a block lower than their true position, because their positions are measured from the center and not the base.
these are noisy and cause conflicts. Since they also usually cause new errors to be reported, we often can't directly update it anyway. Better to test & update this locally.
this has such a big impact on performance that I think this is warranted. Should also make it more obvious what the GC is doing without needing to enable ALL debug info.
…ally registered

if not, this will cause random crashes in core code, which assumes that state IDs found on runtime chunk memory are valid and registered.

this problem exists in other places too, and probably requires a rethink of how we're dealing with this, but for now, this will do as a band-aid.
Co-authored-by: Dylan K. Taylor <dktapps@pmmp.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a broad set of modifications across repository configurations, changelogs, dependency definitions, and core system files. Updates include enhanced warning messages in bug report templates, refined dependency handling in Dependabot, and simplified support messaging in workflow files. Changelog documents for versions 5.26.0 and 5.27.0 now detail performance improvements and compatibility warnings. Several classes have been updated with new properties, methods, and refined logging while deprecating obsolete functionality. New features include enhanced copper block serialization/deserialization, improved entity sound packet structures, and robust static analysis rules, alongside minor documentation and testing adjustments.

Changes

File(s) Change Summary
.github/ISSUE_TEMPLATE/bug-report.yml, .github/dependabot.yml, .github/workflows/support.yml, README.md Updated bug report warnings; added an ignored dependency for PHPStan in Dependabot; simplified support message to focus on Discord; added contributor guidance for “Easy task” issues.
changelogs/5.26.md, changelogs/5.27.md Updated release notes with performance enhancements, gameplay adjustments, and compatibility warnings for versions 5.26.0 and 5.27.0.
composer.json, phpstan.neon.dist Upgraded dependency version constraints and added a new PHPStan rule (DisallowDynamicNewRule) for dynamic instantiation.
src/GarbageCollectorManager.php, src/VersionInfo.php, src/block/ChorusPlant.php, src/block/RuntimeBlockStateRegistry.php, src/crafting/* (CraftingManager, ShapedRecipe, ShapelessRecipe) Introduced new properties, methods and logging improvements; deprecated legacy sorting; added type validations in recipe constructors.
src/data/bedrock/* (BlockStateData, BlockTypeNames, BlockObjectToStateSerializer, BlockStateDeserializerHelper, BlockStateToObjectDeserializer, ItemDeserializer, ItemTypeNames) Adjusted version and constant definitions; restructured copper block (de)serialization logic; enhanced PHPStan annotations.
src/entity/Entity.php, src/world/World.php Modified entity spawn packet to apply an offset and encapsulated block state registry access in World.
src/world/sound/* (multiple sound event classes) Modified sound event packet creation by adding an extra parameter (often -1) and including entity IDs where applicable.
src/player/SurvivalBlockBreakHandler.php, src/inventory/transaction/InventoryTransaction.php Refactored break progress calculation with additional conditions and improved local variable usage for clarity.
Miscellaneous: src/form/Form.php, tests/phpstan/configs/actual-problems.neon, tests/phpstan/rules/DisallowDynamicNewRule.php, tools/blockstate-upgrade-schema-utils.php Minor formatting fixes; added new PHPStan error ignores and dynamic new rule implementation; introduced a new CLI command for dumping upgrade table data.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Deserialization Caller
    participant DS as BlockStateToObjectDeserializer
    participant Registry as RuntimeBlockStateRegistry
    participant Copper as Copper Deserializer Logic

    Caller->>DS: deserialize(blockStateData)
    DS->>DS: deserializeToStateId(blockStateData)
    DS->>Registry: Validate state ID exists
    Registry-->>DS: Confirm state ID
    DS->>DS: registerCopperDeserializers()
    DS->>Copper: mapCopper(...)
    Copper-->>DS: Returns copper mapping
    DS-->>Caller: Deserialized state ID
Loading
sequenceDiagram
    participant Player as Player
    participant Handler as SurvivalBlockBreakHandler
    participant Effects as Effect Checker
    participant Viewer as Client Viewer

    Player->>Handler: Initiate block break
    Handler->>Handler: calculateBreakProgressPerTick()
    Handler->>Effects: Check ground, underwater, Haste, Mining Fatigue
    Effects-->>Handler: Return modifier values
    Handler->>Viewer: update() sends new break progress packet
    Viewer-->>Player: Receives updated break progress
Loading

Poem

I'm a bunny who hops through code lines,
Burrowing into templates and upgrading designs.
With copper blocks and sound packets all in place,
I nibble on bugs and leave not a trace.
My ears twitch with joy at each fixed piece—
A merry code garden where errors cease!
Hop along, dear coder, for our builds now bring peace!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7437f2 and c6b76cb.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (43)
  • .github/ISSUE_TEMPLATE/bug-report.yml (1 hunks)
  • .github/dependabot.yml (1 hunks)
  • .github/workflows/support.yml (1 hunks)
  • README.md (1 hunks)
  • changelogs/5.26.md (1 hunks)
  • changelogs/5.27.md (1 hunks)
  • composer.json (1 hunks)
  • phpstan.neon.dist (1 hunks)
  • src/GarbageCollectorManager.php (3 hunks)
  • src/VersionInfo.php (1 hunks)
  • src/block/ChorusPlant.php (1 hunks)
  • src/block/RuntimeBlockStateRegistry.php (6 hunks)
  • src/block/utils/CopperMaterial.php (1 hunks)
  • src/crafting/CraftingManager.php (3 hunks)
  • src/crafting/ShapedRecipe.php (2 hunks)
  • src/crafting/ShapelessRecipe.php (1 hunks)
  • src/data/bedrock/block/BlockStateData.php (1 hunks)
  • src/data/bedrock/block/BlockTypeNames.php (6 hunks)
  • src/data/bedrock/block/convert/BlockObjectToStateSerializer.php (2 hunks)
  • src/data/bedrock/block/convert/BlockStateDeserializerHelper.php (3 hunks)
  • src/data/bedrock/block/convert/BlockStateToObjectDeserializer.php (5 hunks)
  • src/data/bedrock/item/ItemDeserializer.php (1 hunks)
  • src/data/bedrock/item/ItemTypeNames.php (2 hunks)
  • src/entity/Entity.php (1 hunks)
  • src/form/Form.php (1 hunks)
  • src/inventory/transaction/InventoryTransaction.php (2 hunks)
  • src/network/mcpe/cache/ChunkCache.php (2 hunks)
  • src/network/mcpe/handler/InGamePacketHandler.php (0 hunks)
  • src/player/SurvivalBlockBreakHandler.php (3 hunks)
  • src/utils/Terminal.php (4 hunks)
  • src/utils/TextFormat.php (6 hunks)
  • src/world/World.php (11 hunks)
  • src/world/format/io/data/BedrockWorldData.php (1 hunks)
  • src/world/sound/EntityAttackNoDamageSound.php (1 hunks)
  • src/world/sound/EntityAttackSound.php (1 hunks)
  • src/world/sound/EntityLandSound.php (1 hunks)
  • src/world/sound/EntityLongFallSound.php (1 hunks)
  • src/world/sound/EntityShortFallSound.php (1 hunks)
  • src/world/sound/ThrowSound.php (1 hunks)
  • src/world/sound/WaterSplashSound.php (1 hunks)
  • tests/phpstan/configs/actual-problems.neon (5 hunks)
  • tests/phpstan/rules/DisallowDynamicNewRule.php (1 hunks)
  • tools/blockstate-upgrade-schema-utils.php (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@KanadeBlue KanadeBlue merged commit 6b7fcdd into stable Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants