Add entity meta support for WrappedBlockState.#39
Conversation
WalkthroughNew methods were added to several metadata classes to provide higher-level accessors and mutators for block state information using the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant MetaClass
participant PacketEvents
participant WrappedBlockState
Caller->>MetaClass: setBlockState(WrappedBlockState)
MetaClass->>WrappedBlockState: getGlobalId()
MetaClass->>MetaClass: set internal block ID
Caller->>MetaClass: getBlockState()
MetaClass->>PacketEvents: getAPI().getServerManager().getVersion()
MetaClass->>WrappedBlockState: fromGlobalId(blockId, clientVersion)
MetaClass-->>Caller: WrappedBlockState
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
api/src/main/java/me/tofaa/entitylib/meta/other/FallingBlockMeta.java (1)
43-45: Consider renaming for API consistency.The method name
setBlockStateId(WrappedBlockState blockState)is confusing since it takes aWrappedBlockStateparameter but has "Id" in the name. For consistency with other classes in this PR, consider renaming it tosetBlockState(WrappedBlockState blockState).- public void setBlockStateId(WrappedBlockState blockState) { + public void setBlockState(WrappedBlockState blockState) { setBlockStateId(blockState.getGlobalId()); }api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/EndermanMeta.java (1)
35-37: Consider adding null parameter validation.The
setCarriedBlockState()method doesn't handle the case whereblockStateparameter is null. Consider adding null validation or document the expected behavior.public void setCarriedBlockState(WrappedBlockState blockState) { + if (blockState == null) { + setCarriedBlockID(null); + return; + } setCarriedBlockID(blockState.getGlobalId()); }Alternatively, add
@Nullableannotation to the parameter and document the behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
api/src/main/java/me/tofaa/entitylib/meta/display/BlockDisplayMeta.java(2 hunks)api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/EndermanMeta.java(3 hunks)api/src/main/java/me/tofaa/entitylib/meta/other/FallingBlockMeta.java(2 hunks)api/src/main/java/me/tofaa/entitylib/meta/other/TntMeta.java(2 hunks)
🔇 Additional comments (11)
api/src/main/java/me/tofaa/entitylib/meta/display/BlockDisplayMeta.java (3)
3-3: LGTM: Import statements added correctly.The necessary imports for
PacketEventsandWrappedBlockStateare properly added to support the new functionality.Also applies to: 5-5
25-27: LGTM: Well-implemented getter method.The
getBlockState()method correctly converts the internal block ID to aWrappedBlockStateusing the appropriate client version context.
29-31: LGTM: Clean setter implementation.The
setBlockState()method properly extracts the global ID from theWrappedBlockStateand delegates to the existingsetBlockId()method, maintaining consistency with the existing API.api/src/main/java/me/tofaa/entitylib/meta/other/FallingBlockMeta.java (2)
3-3: LGTM: Import statements added correctly.The necessary imports for
PacketEventsandWrappedBlockStateare properly added.Also applies to: 5-5
39-41: LGTM: Correct getter implementation.The
getBlockState()method properly converts the block state ID to aWrappedBlockStateinstance using the appropriate version context.api/src/main/java/me/tofaa/entitylib/meta/other/TntMeta.java (3)
3-3: LGTM: Import statements added correctly.The necessary imports are properly added to support the new
WrappedBlockStatefunctionality.Also applies to: 5-5
34-36: LGTM: Consistent with existing API.The
getBlockState()method correctly usesgetBlockData()to maintain consistency with the existing TntMeta API terminology and properly converts toWrappedBlockState.
38-40: LGTM: Clean delegation pattern.The
setBlockState()method properly delegates to the existingsetBlockData()method, maintaining API consistency.api/src/main/java/me/tofaa/entitylib/meta/mobs/monster/EndermanMeta.java (3)
3-3: LGTM: Import statements added correctly.The necessary imports for
PacketEventsandWrappedBlockStateare properly added.Also applies to: 5-5
29-33: LGTM: Proper null handling in getter.The
getCarriedBlockState()method correctly handles the case where no block is carried by checking for null and returning null appropriately.
48-48: LGTM: Minor formatting improvement.The whitespace adjustment improves code consistency.
|
LGTM <3 |
Summary by CodeRabbit