Fixed end rod up/down state

This commit is contained in:
Dylan K. Taylor 2022-02-01 13:56:05 +00:00
parent 1a800cf4df
commit ccfe485c06
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 14 additions and 3 deletions

View File

@ -430,7 +430,7 @@ final class BlockStateDeserializer{
});
$this->map(Ids::END_ROD, function(BlockStateReader $in) : Block{
return VanillaBlocks::END_ROD()
->setFacing($in->readFacingDirection());
->setFacing($in->readEndRodFacingDirection());
});
$this->map(Ids::END_STONE, fn() => VanillaBlocks::END_STONE());
$this->map(Ids::ENDER_CHEST, function(BlockStateReader $in) : Block{

View File

@ -125,6 +125,12 @@ final class BlockStateReader{
]);
}
/** @throws BlockStateDeserializeException */
public function readEndRodFacingDirection() : int{
$result = $this->readFacingDirection();
return Facing::axis($result) === Axis::Y ? Facing::opposite($result) : $result;
}
/** @throws BlockStateDeserializeException */
public function readHorizontalFacing() : int{
return $this->parseFacingValue($this->readInt(BlockStateNames::FACING_DIRECTION), [

View File

@ -595,9 +595,8 @@ final class BlockStateSerializer{
->writeLegacyHorizontalFacing($block->getFacing());
});
$this->map(VanillaBlocks::END_ROD(), function(EndRod $block) : Writer{
//TODO: not sure if this needs down/up to be flipped like legacy metadata?
return Writer::create(Ids::END_ROD)
->writeFacingDirection($block->getFacing());
->writeEndRodFacingDirection($block->getFacing());
});
$this->map(VanillaBlocks::END_STONE(), fn() => new Writer(Ids::END_STONE));
$this->map(VanillaBlocks::END_STONE_BRICKS(), fn() => new Writer(Ids::END_BRICKS));

View File

@ -79,6 +79,12 @@ final class BlockStateWriter{
return $this;
}
/** @return $this */
public function writeEndRodFacingDirection(int $value) : self{
//end rods are stupid in bedrock and have up/down the wrong way round
return $this->writeFacingDirection(Facing::axis($value) === Axis::Y ? Facing::opposite($value) : $value);
}
/** @return $this */
public function writeHorizontalFacing(int $value) : self{
if($value === Facing::UP || $value === Facing::DOWN){