mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 11:18:52 +00:00
Fixed trapdoor rotation
This commit is contained in:
parent
e808b7aac4
commit
101b71ed02
@ -186,7 +186,7 @@ final class BlockStateDeserializerHelper{
|
||||
/** @throws BlockStateDeserializeException */
|
||||
public static function decodeTrapdoor(Trapdoor $block, BlockStateReader $in) : Trapdoor{
|
||||
return $block
|
||||
->setFacing($in->readLegacyHorizontalFacing())
|
||||
->setFacing($in->read5MinusHorizontalFacing())
|
||||
->setTop($in->readBool(BlockStateNames::UPSIDE_DOWN_BIT))
|
||||
->setOpen($in->readBool(BlockStateNames::OPEN_BIT));
|
||||
}
|
||||
|
@ -158,6 +158,19 @@ final class BlockStateReader{
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for trapdoors, because Mojang botched the conversion in 1.13
|
||||
* @throws BlockStateDeserializeException
|
||||
*/
|
||||
public function read5MinusHorizontalFacing() : int{
|
||||
return $this->parseFacingValue($this->readInt(BlockStateNames::DIRECTION), [
|
||||
0 => Facing::EAST,
|
||||
1 => Facing::WEST,
|
||||
2 => Facing::SOUTH,
|
||||
3 => Facing::NORTH
|
||||
]);
|
||||
}
|
||||
|
||||
/** @throws BlockStateDeserializeException */
|
||||
public function readColor() : DyeColor{
|
||||
// * color (StringTag) = black, blue, brown, cyan, gray, green, light_blue, lime, magenta, orange, pink, purple, red, silver, white, yellow
|
||||
|
@ -237,7 +237,7 @@ final class BlockStateSerializerHelper{
|
||||
|
||||
public static function encodeTrapdoor(Trapdoor $block, BlockStateWriter $out) : BlockStateWriter{
|
||||
return $out
|
||||
->writeLegacyHorizontalFacing($block->getFacing())
|
||||
->write5MinusHorizontalFacing($block->getFacing())
|
||||
->writeBool(BlockStateNames::UPSIDE_DOWN_BIT, $block->isTop())
|
||||
->writeBool(BlockStateNames::OPEN_BIT, $block->isOpen());
|
||||
}
|
||||
|
@ -118,6 +118,20 @@ final class BlockStateWriter{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for trapdoors, because Mojang botched the conversion in 1.13
|
||||
* @return $this
|
||||
*/
|
||||
public function write5MinusHorizontalFacing(int $value) : self{
|
||||
return $this->writeInt(BlockStateNames::DIRECTION, match($value){
|
||||
Facing::EAST => 0,
|
||||
Facing::WEST => 1,
|
||||
Facing::SOUTH => 2,
|
||||
Facing::NORTH => 3,
|
||||
default => throw new BlockStateSerializeException("Invalid horizontal facing $value")
|
||||
});
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function writeColor(DyeColor $color) : self{
|
||||
$this->writeString(BlockStateNames::COLOR, match($color->id()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user