diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index a7c9c1c0fb..d33dc442d1 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -77,7 +77,7 @@ final class EntityFactory{ //TODO: index them by version to allow proper multi-save compatibility $this->register(Arrow::class, function(World $world, CompoundTag $nbt) : Arrow{ - return new Arrow(EntityDataHelper::parseLocation($nbt, $world), null, false, $nbt); //TODO: missing critical flag + return new Arrow(EntityDataHelper::parseLocation($nbt, $world), null, $nbt->getByte(Arrow::TAG_CRIT, 0) === 1, $nbt); }, ['Arrow', 'minecraft:arrow'], EntityLegacyIds::ARROW); $this->register(Egg::class, function(World $world, CompoundTag $nbt) : Egg{ diff --git a/src/entity/projectile/Arrow.php b/src/entity/projectile/Arrow.php index d296b4092d..f0a1181fd8 100644 --- a/src/entity/projectile/Arrow.php +++ b/src/entity/projectile/Arrow.php @@ -50,6 +50,7 @@ class Arrow extends Projectile{ public const PICKUP_CREATIVE = 2; private const TAG_PICKUP = "pickup"; //TAG_Byte + public const TAG_CRIT = "crit"; //TAG_Byte protected $gravity = 0.05; protected $drag = 0.01; @@ -80,12 +81,14 @@ class Arrow extends Projectile{ parent::initEntity($nbt); $this->pickupMode = $nbt->getByte(self::TAG_PICKUP, self::PICKUP_ANY); + $this->critical = $nbt->getByte(self::TAG_CRIT, 0) === 1; $this->collideTicks = $nbt->getShort("life", $this->collideTicks); } public function saveNBT() : CompoundTag{ $nbt = parent::saveNBT(); $nbt->setByte(self::TAG_PICKUP, $this->pickupMode); + $nbt->setByte(self::TAG_CRIT, $this->critical ? 1 : 0); $nbt->setShort("life", $this->collideTicks); return $nbt; }