mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
parent
920eb7cce5
commit
532d57eec7
@ -77,7 +77,7 @@ final class EntityFactory{
|
|||||||
//TODO: index them by version to allow proper multi-save compatibility
|
//TODO: index them by version to allow proper multi-save compatibility
|
||||||
|
|
||||||
$this->register(Arrow::class, function(World $world, CompoundTag $nbt) : Arrow{
|
$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);
|
}, ['Arrow', 'minecraft:arrow'], EntityLegacyIds::ARROW);
|
||||||
|
|
||||||
$this->register(Egg::class, function(World $world, CompoundTag $nbt) : Egg{
|
$this->register(Egg::class, function(World $world, CompoundTag $nbt) : Egg{
|
||||||
|
@ -50,6 +50,7 @@ class Arrow extends Projectile{
|
|||||||
public const PICKUP_CREATIVE = 2;
|
public const PICKUP_CREATIVE = 2;
|
||||||
|
|
||||||
private const TAG_PICKUP = "pickup"; //TAG_Byte
|
private const TAG_PICKUP = "pickup"; //TAG_Byte
|
||||||
|
public const TAG_CRIT = "crit"; //TAG_Byte
|
||||||
|
|
||||||
protected $gravity = 0.05;
|
protected $gravity = 0.05;
|
||||||
protected $drag = 0.01;
|
protected $drag = 0.01;
|
||||||
@ -80,12 +81,14 @@ class Arrow extends Projectile{
|
|||||||
parent::initEntity($nbt);
|
parent::initEntity($nbt);
|
||||||
|
|
||||||
$this->pickupMode = $nbt->getByte(self::TAG_PICKUP, self::PICKUP_ANY);
|
$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);
|
$this->collideTicks = $nbt->getShort("life", $this->collideTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveNBT() : CompoundTag{
|
public function saveNBT() : CompoundTag{
|
||||||
$nbt = parent::saveNBT();
|
$nbt = parent::saveNBT();
|
||||||
$nbt->setByte(self::TAG_PICKUP, $this->pickupMode);
|
$nbt->setByte(self::TAG_PICKUP, $this->pickupMode);
|
||||||
|
$nbt->setByte(self::TAG_CRIT, $this->critical ? 1 : 0);
|
||||||
$nbt->setShort("life", $this->collideTicks);
|
$nbt->setShort("life", $this->collideTicks);
|
||||||
return $nbt;
|
return $nbt;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user