From e60da64bab9834db14d5213f6de37ed8df237a3f Mon Sep 17 00:00:00 2001 From: SEONGGWAN AHN <51251620+ahnsunggwan45@users.noreply.github.com> Date: Thu, 11 Dec 2025 22:45:04 +0900 Subject: [PATCH 1/4] Add proper `boxes` structure to minecraft:collision_box for Bedrock 1.21.130 --- src/block/component/CollisionBoxComponent.php | 94 ++++++++++++------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/src/block/component/CollisionBoxComponent.php b/src/block/component/CollisionBoxComponent.php index e0e641a..82986bb 100644 --- a/src/block/component/CollisionBoxComponent.php +++ b/src/block/component/CollisionBoxComponent.php @@ -7,40 +7,62 @@ use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\ListTag; -class CollisionBoxComponent implements BlockComponent { - - private bool $useCollisionBox; - private Vector3 $origin; - private Vector3 $size; - - /** - * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities is disabled. If this component is omitted, default values are used. - * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. - */ - 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 getName(): string { - return "minecraft:collision_box"; - } - - public function getValue(): CompoundTag { - return CompoundTag::create() - ->setByte("enabled", $this->useCollisionBox ? 1 : 0) - ->setTag("origin", new ListTag([ - new FloatTag($this->origin->getX()), - new FloatTag($this->origin->getY()), - new FloatTag($this->origin->getZ()) - ])) - ->setTag("size", new ListTag([ - new FloatTag($this->size->getX()), - new FloatTag($this->size->getY()), - new FloatTag($this->size->getZ()) - ])); - } +class CollisionBoxComponent implements BlockComponent +{ + + private bool $useCollisionBox; + private Vector3 $origin; + private Vector3 $size; + + /** + * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities is disabled. If this component is omitted, default values are used. + * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. + */ + 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 getName(): string + { + return "minecraft:collision_box"; + } + + public function getValue(): CompoundTag + { + + $minX = max(0, $this->origin->getX() + 8); + $minY = max(0, $this->origin->getY()); + $minZ = max(0, $this->origin->getZ() + 8); + + $maxX = min(16, $minX + $this->size->getX()); + $maxY = min(16, $minY + $this->size->getY()); + $maxZ = min(16, $minZ + $this->size->getZ()); + + $box = CompoundTag::create() + ->setFloat("minX", $minX) + ->setFloat("minY", $minY) + ->setFloat("minZ", $minZ) + ->setFloat("maxX", $maxX) + ->setFloat("maxY", $maxY) + ->setFloat("maxZ", $maxZ); + $boxes = new ListTag([$box]); + return CompoundTag::create() + ->setByte("enabled", $this->useCollisionBox ? 1 : 0) + ->setTag("origin", new ListTag([ + new FloatTag($this->origin->getX()), + new FloatTag($this->origin->getY()), + new FloatTag($this->origin->getZ()) + ])) + ->setTag("size", new ListTag([ + new FloatTag($this->size->getX()), + new FloatTag($this->size->getY()), + new FloatTag($this->size->getZ()) + ])) + ->setTag("boxes", $boxes); + } } \ No newline at end of file From f34d711572d44c2f6406485501743924b669f72f Mon Sep 17 00:00:00 2001 From: Ilhan Ates Date: Mon, 22 Dec 2025 13:02:07 +0100 Subject: [PATCH 2/4] CollissionBoxComponent: Fix formatting --- src/block/component/CollisionBoxComponent.php | 99 ++++++++++--------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/block/component/CollisionBoxComponent.php b/src/block/component/CollisionBoxComponent.php index 82986bb..a3c0377 100644 --- a/src/block/component/CollisionBoxComponent.php +++ b/src/block/component/CollisionBoxComponent.php @@ -10,59 +10,60 @@ class CollisionBoxComponent implements BlockComponent { - private bool $useCollisionBox; - private Vector3 $origin; - private Vector3 $size; + private bool $useCollisionBox; + private Vector3 $origin; + private Vector3 $size; - /** - * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities is disabled. If this component is omitted, default values are used. - * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. - */ - 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; - } + /** + * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities + * is disabled. If this component is omitted, default values are used. + * + * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, + * -8) to (8, 16, 8), inclusive. + * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, + * -8) to (8, 16, 8), inclusive. + * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. + */ + 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 getName(): string - { - return "minecraft:collision_box"; - } + public function getName() : string { + return "minecraft:collision_box"; + } - public function getValue(): CompoundTag - { + public function getValue() : CompoundTag { - $minX = max(0, $this->origin->getX() + 8); - $minY = max(0, $this->origin->getY()); - $minZ = max(0, $this->origin->getZ() + 8); + $minX = max(0, $this->origin->getX() + 8); + $minY = max(0, $this->origin->getY()); + $minZ = max(0, $this->origin->getZ() + 8); - $maxX = min(16, $minX + $this->size->getX()); - $maxY = min(16, $minY + $this->size->getY()); - $maxZ = min(16, $minZ + $this->size->getZ()); + $maxX = min(16, $minX + $this->size->getX()); + $maxY = min(16, $minY + $this->size->getY()); + $maxZ = min(16, $minZ + $this->size->getZ()); - $box = CompoundTag::create() - ->setFloat("minX", $minX) - ->setFloat("minY", $minY) - ->setFloat("minZ", $minZ) - ->setFloat("maxX", $maxX) - ->setFloat("maxY", $maxY) - ->setFloat("maxZ", $maxZ); - $boxes = new ListTag([$box]); - return CompoundTag::create() - ->setByte("enabled", $this->useCollisionBox ? 1 : 0) - ->setTag("origin", new ListTag([ - new FloatTag($this->origin->getX()), - new FloatTag($this->origin->getY()), - new FloatTag($this->origin->getZ()) - ])) - ->setTag("size", new ListTag([ - new FloatTag($this->size->getX()), - new FloatTag($this->size->getY()), - new FloatTag($this->size->getZ()) - ])) - ->setTag("boxes", $boxes); - } + $box = CompoundTag::create() + ->setFloat("minX", $minX) + ->setFloat("minY", $minY) + ->setFloat("minZ", $minZ) + ->setFloat("maxX", $maxX) + ->setFloat("maxY", $maxY) + ->setFloat("maxZ", $maxZ); + $boxes = new ListTag([$box]); + return CompoundTag::create() + ->setByte("enabled", $this->useCollisionBox ? 1 : 0) + ->setTag("origin", new ListTag([ + new FloatTag($this->origin->getX()), + new FloatTag($this->origin->getY()), + new FloatTag($this->origin->getZ()), + ])) + ->setTag("size", new ListTag([ + new FloatTag($this->size->getX()), + new FloatTag($this->size->getY()), + new FloatTag($this->size->getZ()), + ])) + ->setTag("boxes", $boxes); + } } \ No newline at end of file From 25c0eb44a55bbc84a1c480322a1179a8888e8b6f Mon Sep 17 00:00:00 2001 From: Ilhan Ates Date: Mon, 22 Dec 2025 13:05:08 +0100 Subject: [PATCH 3/4] CollissionBoxComponent: Fix formatting for correct format --- src/block/component/CollisionBoxComponent.php | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/block/component/CollisionBoxComponent.php b/src/block/component/CollisionBoxComponent.php index a3c0377..82986bb 100644 --- a/src/block/component/CollisionBoxComponent.php +++ b/src/block/component/CollisionBoxComponent.php @@ -10,60 +10,59 @@ class CollisionBoxComponent implements BlockComponent { - private bool $useCollisionBox; - private Vector3 $origin; - private Vector3 $size; + private bool $useCollisionBox; + private Vector3 $origin; + private Vector3 $size; - /** - * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities - * is disabled. If this component is omitted, default values are used. - * - * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, - * -8) to (8, 16, 8), inclusive. - * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, - * -8) to (8, 16, 8), inclusive. - * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. - */ - 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; - } + /** + * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities is disabled. If this component is omitted, default values are used. + * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. + */ + 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 getName() : string { - return "minecraft:collision_box"; - } + public function getName(): string + { + return "minecraft:collision_box"; + } - public function getValue() : CompoundTag { + public function getValue(): CompoundTag + { - $minX = max(0, $this->origin->getX() + 8); - $minY = max(0, $this->origin->getY()); - $minZ = max(0, $this->origin->getZ() + 8); + $minX = max(0, $this->origin->getX() + 8); + $minY = max(0, $this->origin->getY()); + $minZ = max(0, $this->origin->getZ() + 8); - $maxX = min(16, $minX + $this->size->getX()); - $maxY = min(16, $minY + $this->size->getY()); - $maxZ = min(16, $minZ + $this->size->getZ()); + $maxX = min(16, $minX + $this->size->getX()); + $maxY = min(16, $minY + $this->size->getY()); + $maxZ = min(16, $minZ + $this->size->getZ()); - $box = CompoundTag::create() - ->setFloat("minX", $minX) - ->setFloat("minY", $minY) - ->setFloat("minZ", $minZ) - ->setFloat("maxX", $maxX) - ->setFloat("maxY", $maxY) - ->setFloat("maxZ", $maxZ); - $boxes = new ListTag([$box]); - return CompoundTag::create() - ->setByte("enabled", $this->useCollisionBox ? 1 : 0) - ->setTag("origin", new ListTag([ - new FloatTag($this->origin->getX()), - new FloatTag($this->origin->getY()), - new FloatTag($this->origin->getZ()), - ])) - ->setTag("size", new ListTag([ - new FloatTag($this->size->getX()), - new FloatTag($this->size->getY()), - new FloatTag($this->size->getZ()), - ])) - ->setTag("boxes", $boxes); - } + $box = CompoundTag::create() + ->setFloat("minX", $minX) + ->setFloat("minY", $minY) + ->setFloat("minZ", $minZ) + ->setFloat("maxX", $maxX) + ->setFloat("maxY", $maxY) + ->setFloat("maxZ", $maxZ); + $boxes = new ListTag([$box]); + return CompoundTag::create() + ->setByte("enabled", $this->useCollisionBox ? 1 : 0) + ->setTag("origin", new ListTag([ + new FloatTag($this->origin->getX()), + new FloatTag($this->origin->getY()), + new FloatTag($this->origin->getZ()) + ])) + ->setTag("size", new ListTag([ + new FloatTag($this->size->getX()), + new FloatTag($this->size->getY()), + new FloatTag($this->size->getZ()) + ])) + ->setTag("boxes", $boxes); + } } \ No newline at end of file From 73936d23848d346e0b3178df48be92eae30e3836 Mon Sep 17 00:00:00 2001 From: Ilhan Ates Date: Mon, 22 Dec 2025 13:05:36 +0100 Subject: [PATCH 4/4] oh my god... --- src/block/component/CollisionBoxComponent.php | 101 +++++++++--------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/block/component/CollisionBoxComponent.php b/src/block/component/CollisionBoxComponent.php index 82986bb..4bbf412 100644 --- a/src/block/component/CollisionBoxComponent.php +++ b/src/block/component/CollisionBoxComponent.php @@ -7,62 +7,61 @@ use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\ListTag; -class CollisionBoxComponent implements BlockComponent -{ +class CollisionBoxComponent implements BlockComponent { - private bool $useCollisionBox; - private Vector3 $origin; - private Vector3 $size; + private bool $useCollisionBox; + private Vector3 $origin; + private Vector3 $size; - /** - * Defines the area of the block that collides with entities. If set to true, default values are used. If set to false, the block's collision with entities is disabled. If this component is omitted, default values are used. - * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. - * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. - */ - 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; - } + /** + * Defines the area of the block that collides with entities. If set to true, default values are used. If set to + * false, the block's collision with entities is disabled. If this component is omitted, default values are used. + * @param Vector3 $origin Minimal position of the bounds of the collision box. "origin" is specified as [x, y, z] + * and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param Vector3 $size Size of each side of the collision box. Size is specified as [x, y, z]. "origin" + "size" + * must be in the range (-8, 0, -8) to (8, 16, 8), inclusive. + * @param bool $useCollisionBox If collision should be enabled, default is set to `true`. + */ + 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 getName(): string - { - return "minecraft:collision_box"; - } + public function getName(): string { + return "minecraft:collision_box"; + } - public function getValue(): CompoundTag - { + public function getValue(): CompoundTag { - $minX = max(0, $this->origin->getX() + 8); - $minY = max(0, $this->origin->getY()); - $minZ = max(0, $this->origin->getZ() + 8); + $minX = max(0, $this->origin->getX() + 8); + $minY = max(0, $this->origin->getY()); + $minZ = max(0, $this->origin->getZ() + 8); - $maxX = min(16, $minX + $this->size->getX()); - $maxY = min(16, $minY + $this->size->getY()); - $maxZ = min(16, $minZ + $this->size->getZ()); + $maxX = min(16, $minX + $this->size->getX()); + $maxY = min(16, $minY + $this->size->getY()); + $maxZ = min(16, $minZ + $this->size->getZ()); - $box = CompoundTag::create() - ->setFloat("minX", $minX) - ->setFloat("minY", $minY) - ->setFloat("minZ", $minZ) - ->setFloat("maxX", $maxX) - ->setFloat("maxY", $maxY) - ->setFloat("maxZ", $maxZ); - $boxes = new ListTag([$box]); - return CompoundTag::create() - ->setByte("enabled", $this->useCollisionBox ? 1 : 0) - ->setTag("origin", new ListTag([ - new FloatTag($this->origin->getX()), - new FloatTag($this->origin->getY()), - new FloatTag($this->origin->getZ()) - ])) - ->setTag("size", new ListTag([ - new FloatTag($this->size->getX()), - new FloatTag($this->size->getY()), - new FloatTag($this->size->getZ()) - ])) - ->setTag("boxes", $boxes); - } + $box = CompoundTag::create() + ->setFloat("minX", $minX) + ->setFloat("minY", $minY) + ->setFloat("minZ", $minZ) + ->setFloat("maxX", $maxX) + ->setFloat("maxY", $maxY) + ->setFloat("maxZ", $maxZ); + $boxes = new ListTag([$box]); + return CompoundTag::create() + ->setByte("enabled", $this->useCollisionBox ? 1 : 0) + ->setTag("origin", new ListTag([ + new FloatTag($this->origin->getX()), + new FloatTag($this->origin->getY()), + new FloatTag($this->origin->getZ()) + ])) + ->setTag("size", new ListTag([ + new FloatTag($this->size->getX()), + new FloatTag($this->size->getY()), + new FloatTag($this->size->getZ()) + ])) + ->setTag("boxes", $boxes); + } } \ No newline at end of file