Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Customies to version 1.4.0 with support for Minecraft Bedrock Edition 1.21.130, introducing a comprehensive component-based architecture for both items and blocks. The changes represent a significant refactoring that modernizes the codebase and aligns it with the latest Minecraft Bedrock protocol requirements.
Key Changes:
- Introduced a new block component system with components for collision boxes, selection boxes, geometry, lighting, friction, and other block properties
- Extensively refactored item components, adding 15+ new components (ShooterComponent, RecordComponent, DyeableComponent, etc.) while removing deprecated ones
- Overhauled the item and block registration system to use component-based architecture and proper creative inventory integration
- Updated protocol handling to remove ItemComponentPacket in favor of embedding components directly in ItemTypeEntry
Reviewed changes
Copilot reviewed 62 out of 63 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/item/component/WearableComponent.php | Added protection and dispensable parameters to support armor properties |
| src/item/component/UseModifiersComponent.php | Reformatted and added default parameter for useDuration |
| src/item/component/UseDurationComponent.php | Added default duration value and documentation |
| src/item/component/UseAnimationComponent.php | Added animation type constants and documentation |
| src/item/component/ThrowableComponent.php | Extended with launch power, draw duration, and scaling properties |
| src/item/component/StackedByDataComponent.php | New component for controlling item stacking behavior |
| src/item/component/ShouldDespawnComponent.php | New component for controlling item despawn behavior |
| src/item/component/ShooterComponent.php | New component for bow/crossbow-like shooting mechanics |
| src/item/component/RenderOffsetsComponent.php | Removed - functionality replaced by other components |
| src/item/component/RecordComponent.php | New component for music disc items |
| src/item/component/RarityComponent.php | Added default parameter and comprehensive documentation |
| src/item/component/ProjectileComponent.php | Added minimumCriticalPower parameter for critical hit mechanics |
| src/item/component/MaxStackSizeComponent.php | Added default value and documentation |
| src/item/component/LiquidClippedComponent.php | New component for liquid interaction behavior |
| src/item/component/KnockbackResistanceComponent.php | Removed - functionality moved to WearableComponent |
| src/item/component/InteractButtonComponent.php | New component for touch control interact button customization |
| src/item/component/IconComponent.php | Extended to support dyed and trim textures |
| src/item/component/HoverTextColorComponent.php | New component for customizing item name color |
| src/item/component/HandEquippedComponent.php | Added documentation for tool rendering |
| src/item/component/GlintComponent.php | New component replacing FoilComponent |
| src/item/component/FuelComponent.php | Added documentation for furnace fuel behavior |
| src/item/component/FoodComponent.php | Extended with nutrition, saturation, and conversion properties |
| src/item/component/FoilComponent.php | Removed - replaced by GlintComponent |
| src/item/component/EnchantableValueComponent.php | New component with enchantability constants |
| src/item/component/EnchantableSlotComponent.php | New component for enchantment slot restrictions |
| src/item/component/DyeableComponent.php | New component for dyeable items |
| src/item/component/DurabilityComponent.php | Extended with damage chance modifiers |
| src/item/component/DisplayNameComponent.php | Added documentation for item naming |
| src/item/component/DiggerComponent.php | Added use_efficiency parameter and documentation |
| src/item/component/DamageComponent.php | Renamed from AttackDamageComponent with documentation |
| src/item/component/DamageAbsorptionComponent.php | New component for armor damage absorption |
| src/item/component/CreativeGroupComponent.php | Removed - integrated into factory registration |
| src/item/component/CreativeCategoryComponent.php | Removed - integrated into factory registration |
| src/item/component/CooldownComponent.php | Added category constants and documentation |
| src/item/component/ChargeableComponent.php | Removed - functionality replaced by UseModifiersComponent |
| src/item/component/CanDestroyInCreativeComponent.php | Code formatting and documentation updates |
| src/item/component/BundleInteractionComponent.php | New component for bundle item mechanics |
| src/item/component/BlockPlacerComponent.php | Refactored to use Block objects and added useOn functionality |
| src/item/component/ArmorComponent.php | Removed - functionality moved to WearableComponent |
| src/item/component/AllowOffHandComponent.php | Added documentation for off-hand placement |
| src/item/ItemComponentsTrait.php | Refactored to return component arrays and simplified initialization |
| src/item/ItemComponents.php | Updated interface to return component arrays instead of NBT |
| src/item/CustomiesItemFactory.php | Major refactoring to support new component system and creative inventory integration |
| src/item/CreativeInventoryInfo.php | Minor formatting update |
| src/block/component/SelectionBoxComponent.php | New component for block selection box configuration |
| src/block/component/MaterialInstancesComponent.php | New component for block material definitions |
| src/block/component/LightEmissionComponent.php | New component for light emission properties |
| src/block/component/LightDampeningComponent.php | New component for light dampening properties |
| src/block/component/GeometryComponent.php | New component for custom block geometry |
| src/block/component/FrictionComponent.php | New component for block friction properties |
| src/block/component/FlammableComponent.php | New component for flammability properties |
| src/block/component/DisplayNameComponent.php | New component for block display names |
| src/block/component/DestructibleByMiningComponent.php | New component for mining hardness |
| src/block/component/DestructibleByExplosionComponent.php | New component for explosion resistance |
| src/block/component/CollisionBoxComponent.php | New component for entity collision configuration |
| src/block/component/BreathabilityComponent.php | New component for breathability properties |
| src/block/component/BlockComponent.php | New interface for block components |
| src/block/Model.php | Removed - replaced by component system |
| src/block/CustomiesBlockFactory.php | Refactored to use component system and creative inventory integration |
| src/block/BlockComponentsTrait.php | New trait for block component management |
| src/block/BlockComponents.php | New interface for blocks with components |
| src/CustomiesListener.php | Simplified to remove ItemComponentPacket handling |
| plugin.yml | Version bump to 1.4.0 |
Comments suppressed due to low confidence (1)
src/item/component/DamageComponent.php:12
- The documentation contains a spelling error: "Intger" should be "Integer".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private bool|string $interactButton; | ||
|
|
||
| /** | ||
| * Ineract Button is a boolean or string that determines if the interact button is shown in touch controls, and what text is displayed on the button. When set to 'true', the default 'Use Item' text will be used. |
There was a problem hiding this comment.
The documentation has a typo: "Ineract Button" should be "Interact Button".
|
|
||
| /** | ||
| * Defines the area of the block that is selected by the player's cursor. If set to true, default values are used. If set to false, this block is not selectable by the player's cursor. If this component is omitted, default values are used. | ||
| * @param Vector3 $origin MMinimal position of the bounds of the selection box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. |
There was a problem hiding this comment.
The documentation contains a typo with extra space: "MMinimal position" should be "Minimal position".
| * @param Vector3 $origin MMinimal position of the bounds of the selection box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. | |
| * @param Vector3 $origin Minimal position of the bounds of the selection box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. |
| public function __construct(bool $useSelectionBox = true, ?Vector3 $origin = new Vector3(-8.0, 0.0, -8.0), ?Vector3 $size = new Vector3(16.0, 16.0, 16.0)) { | ||
| $this->useSelectionBox = $useSelectionBox; | ||
| $this->origin = $origin; | ||
| $this->size = $size; |
There was a problem hiding this comment.
The default parameter values use the new keyword in the function signature, which creates new Vector3 instances at compile time. This is a PHP 8.1+ feature that may cause issues. While it's syntactically valid in newer PHP versions, it means all function calls share the same default object instances, which could lead to unexpected behavior if the Vector3 objects are modified. Consider using null as the default and creating the Vector3 instances inside the constructor body instead.
| public function __construct(bool $useSelectionBox = true, ?Vector3 $origin = new Vector3(-8.0, 0.0, -8.0), ?Vector3 $size = new Vector3(16.0, 16.0, 16.0)) { | |
| $this->useSelectionBox = $useSelectionBox; | |
| $this->origin = $origin; | |
| $this->size = $size; | |
| public function __construct(bool $useSelectionBox = true, ?Vector3 $origin = null, ?Vector3 $size = null) { | |
| $this->useSelectionBox = $useSelectionBox; | |
| $this->origin = $origin ?? new Vector3(-8.0, 0.0, -8.0); | |
| $this->size = $size ?? new Vector3(16.0, 16.0, 16.0); |
| public function __construct(bool $useCollisionBox = true, Vector3 $origin = new Vector3(-8.0, 0.0, -8.0), Vector3 $size = new Vector3(16.0, 16.0, 16.0)) { | ||
| $this->useCollisionBox = $useCollisionBox; | ||
| $this->origin = $origin; | ||
| $this->size = $size; |
There was a problem hiding this comment.
The default parameter values use the new keyword in the function signature. This is a PHP 8.1+ feature that may cause issues because all function calls share the same default object instances. If the Vector3 objects are modified, it could lead to unexpected behavior. Consider using null as the default and creating the Vector3 instances inside the constructor body instead.
| public function __construct(bool $useCollisionBox = true, Vector3 $origin = new Vector3(-8.0, 0.0, -8.0), Vector3 $size = new Vector3(16.0, 16.0, 16.0)) { | |
| $this->useCollisionBox = $useCollisionBox; | |
| $this->origin = $origin; | |
| $this->size = $size; | |
| public function __construct(bool $useCollisionBox = true, ?Vector3 $origin = null, ?Vector3 $size = null) { | |
| $this->useCollisionBox = $useCollisionBox; | |
| $this->origin = $origin ?? new Vector3(-8.0, 0.0, -8.0); | |
| $this->size = $size ?? new Vector3(16.0, 16.0, 16.0); |
| }; | ||
|
|
||
| CreativeInventory::getInstance()->add($item, $category, $group); | ||
| } |
There was a problem hiding this comment.
The trailing whitespace after the closing brace should be removed for code cleanliness.
| } | |
| } |
| /** | ||
| * Rarity Component enables the specifying of the base rarity of an item. | ||
| * The rarity of the item will determine which color it uses for its name, unless the item has a HoverTextColor component specified, in which case that hover text color will take priority and be used instead of the rarity color. | ||
| * @param string $type Sets the base rarity of the item. The rarity of an item automatically increases when enchanted, either to Rare when the base rarity is Common or Uncommon, or Epic when the base rarity is Rare |
There was a problem hiding this comment.
The parameter name in the documentation is incorrect. The parameter is named $rarity but the documentation refers to $type. The documentation should refer to the actual parameter name $rarity to maintain consistency.
| * @param float $minimumCriticalPower Specifies how long a player must charge a projectile for it to critically hit | ||
| * @param string $projectileEntity Which entity is to be fired as a projectile | ||
| */ | ||
| public function __construct(float $minimumCriticalPower, string $projectileEntity) { |
There was a problem hiding this comment.
This is a breaking API change. The constructor signature has changed from __construct(string $projectileEntity) to __construct(float $minimumCriticalPower, string $projectileEntity), which will break existing code that uses this component. The new required parameter $minimumCriticalPower should either have a default value to maintain backward compatibility, or this breaking change should be clearly documented in the migration guide.
| $this->useDuration = $useDuration; | ||
| $this->movementModifier = $movementModifier; |
There was a problem hiding this comment.
The parameter order has been swapped from the original implementation. Previously it was __construct(private float $movementModifier, private float $useDuration), and now it's __construct(float $movementModifier, float $useDuration = 0) but the assignment in the constructor body is reversed: $this->useDuration is assigned first, then $this->movementModifier. This reversed assignment order compared to the parameter order can be confusing and is inconsistent with the parameter documentation order. The assignments should match the parameter order for better code readability.
|
|
||
| if($this->getAttackPoints() > 0) { | ||
| $this->addComponent(new AttackDamageComponent($this->getAttackPoints() - 1)); | ||
| $this->addComponent(new DamageComponent($this->getAttackPoints())); |
There was a problem hiding this comment.
The damage calculation has changed from $this->getAttackPoints() - 1 to $this->getAttackPoints(). This is a breaking change that will affect all items using this trait. The previous implementation subtracted 1 from the attack points, likely to account for base damage. Removing this subtraction will increase the damage value sent to the client by 1 for all weapons. This should be verified to ensure it aligns with the intended behavior for Minecraft 1.21.130.
| $this->addComponent(new DamageComponent($this->getAttackPoints())); | |
| $this->addComponent(new DamageComponent($this->getAttackPoints() - 1)); |
| $this->addComponent(new DestructibleByMiningComponent($this->getBreakInfo()->getHardness())); | ||
| $this->addComponent(new LightEmissionComponent($this->getLightLevel())); | ||
| $this->addComponent(new LightDampeningComponent($this->getLightFilter())); | ||
| $this->addComponent(new FrictionComponent($this->getFrictionFactor())); |
There was a problem hiding this comment.
The FrictionComponent is being initialized with $this->getFrictionFactor(), but according to the FrictionComponent documentation, friction affects movement speed and higher values result in more friction. However, getFrictionFactor() typically returns a value where lower means less friction (more slippery). The component documentation says wood/dirt use 0.4 while ice uses 0.02, but PocketMine's getFrictionFactor() returns values where ice is typically 0.98 (very low friction). This suggests the value may need to be inverted or transformed (e.g., 1 - $this->getFrictionFactor()) to match Minecraft's friction model. Verify this is correct for the Bedrock protocol.
| $this->addComponent(new FrictionComponent($this->getFrictionFactor())); | |
| $this->addComponent(new FrictionComponent(1.0 - $this->getFrictionFactor())); |
No description provided.