mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Clean up ID flattening hacks
This commit is contained in:
parent
89fce7712a
commit
635fb5dde4
@ -49,8 +49,8 @@ class Anvil extends Transparent implements Fallable{
|
||||
return Bearing::fromFacing($this->facing);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -87,10 +87,10 @@ abstract class BaseRail extends Flowable{
|
||||
return $this->getMetaForState($this->connections);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$connections = $this->getConnectionsFromMeta($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$connections = $this->getConnectionsFromMeta($stateMeta);
|
||||
if($connections === null){
|
||||
throw new InvalidBlockStateException("Invalid rail type meta $meta");
|
||||
throw new InvalidBlockStateException("Invalid rail type meta $stateMeta");
|
||||
}
|
||||
$this->connections = $connections;
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ class Bed extends Transparent{
|
||||
($this->head ? self::BITFLAG_HEAD : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
$this->occupied = ($meta & self::BITFLAG_OCCUPIED) !== 0;
|
||||
$this->head = ($meta & self::BITFLAG_HEAD) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->occupied = ($stateMeta & self::BITFLAG_OCCUPIED) !== 0;
|
||||
$this->head = ($stateMeta & self::BITFLAG_HEAD) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -133,10 +133,12 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $meta
|
||||
* @param int $id
|
||||
* @param int $stateMeta
|
||||
*
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@ -176,7 +178,10 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given block has an equivalent type to this one.
|
||||
* Returns whether the given block has an equivalent type to this one. This compares base legacy ID and variant.
|
||||
*
|
||||
* Note: This ignores additional IDs used to represent additional states. This means that, for example, a lit
|
||||
* furnace and unlit furnace are considered the same type.
|
||||
*
|
||||
* @param Block $other
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ use pocketmine\block\BlockIdentifier as BID;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\PillarRotationTrait;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\level\Position;
|
||||
@ -107,8 +106,7 @@ class BlockFactory{
|
||||
self::register(new CocoaBlock(new BID(Block::COCOA), "Cocoa Block"));
|
||||
self::register(new CraftingTable(new BID(Block::CRAFTING_TABLE), "Crafting Table"));
|
||||
self::register(new Dandelion(new BID(Block::DANDELION), "Dandelion"));
|
||||
self::register($daylightSensor = new DaylightSensor(new BlockIdentifierFlattened(Block::DAYLIGHT_DETECTOR, Block::DAYLIGHT_DETECTOR_INVERTED), "Daylight Sensor"));
|
||||
self::register((clone $daylightSensor)->setInverted()); //flattening hack
|
||||
self::register(new DaylightSensor(new BlockIdentifierFlattened(Block::DAYLIGHT_DETECTOR, Block::DAYLIGHT_DETECTOR_INVERTED), "Daylight Sensor"));
|
||||
self::register(new DeadBush(new BID(Block::DEADBUSH), "Dead Bush"));
|
||||
self::register(new DetectorRail(new BID(Block::DETECTOR_RAIL), "Detector Rail"));
|
||||
self::register(new Diamond(new BID(Block::DIAMOND_BLOCK), "Diamond Block"));
|
||||
@ -148,8 +146,7 @@ class BlockFactory{
|
||||
self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_RED_TULIP), "Red Tulip"));
|
||||
self::register(new Flower(new BID(Block::RED_FLOWER, Flower::TYPE_WHITE_TULIP), "White Tulip"));
|
||||
self::register(new FlowerPot(new BID(Block::FLOWER_POT_BLOCK, 0, ItemIds::FLOWER_POT, \pocketmine\tile\FlowerPot::class), "Flower Pot"));
|
||||
self::register($furnace = new Furnace(new BlockIdentifierFlattened(Block::FURNACE, Block::LIT_FURNACE, 0, null, \pocketmine\tile\Furnace::class), "Furnace"));
|
||||
self::register((clone $furnace)->setLit()); //flattening hack
|
||||
self::register(new Furnace(new BlockIdentifierFlattened(Block::FURNACE, Block::LIT_FURNACE, 0, null, \pocketmine\tile\Furnace::class), "Furnace"));
|
||||
self::register(new Glass(new BID(Block::GLASS), "Glass"));
|
||||
self::register(new GlassPane(new BID(Block::GLASS_PANE), "Glass Pane"));
|
||||
self::register(new GlazedTerracotta(new BID(Block::BLACK_GLAZED_TERRACOTTA), "Black Glazed Terracotta"));
|
||||
@ -192,8 +189,7 @@ class BlockFactory{
|
||||
self::register(new Ladder(new BID(Block::LADDER), "Ladder"));
|
||||
self::register(new Lapis(new BID(Block::LAPIS_BLOCK), "Lapis Lazuli Block"));
|
||||
self::register(new LapisOre(new BID(Block::LAPIS_ORE), "Lapis Lazuli Ore"));
|
||||
self::register($lava = new Lava(new BlockIdentifierFlattened(Block::FLOWING_LAVA, Block::STILL_LAVA), "Lava"));
|
||||
self::register((clone $lava)->setStill()); //flattening hack
|
||||
self::register(new Lava(new BlockIdentifierFlattened(Block::FLOWING_LAVA, Block::STILL_LAVA), "Lava"));
|
||||
self::register(new Lever(new BID(Block::LEVER), "Lever"));
|
||||
self::register(new LitPumpkin(new BID(Block::JACK_O_LANTERN), "Jack o'Lantern"));
|
||||
self::register(new Magma(new BID(Block::MAGMA), "Magma Block"));
|
||||
@ -239,14 +235,10 @@ class BlockFactory{
|
||||
self::register(new RedMushroom(new BID(Block::RED_MUSHROOM), "Red Mushroom"));
|
||||
self::register(new RedMushroomBlock(new BID(Block::RED_MUSHROOM_BLOCK), "Red Mushroom Block"));
|
||||
self::register(new Redstone(new BID(Block::REDSTONE_BLOCK), "Redstone Block"));
|
||||
self::register($redstoneLamp = new RedstoneLamp(new BlockIdentifierFlattened(Block::REDSTONE_LAMP, Block::LIT_REDSTONE_LAMP), "Redstone Lamp"));
|
||||
self::register((clone $redstoneLamp)->setLit()); //flattening hack
|
||||
self::register($redstoneOre = new RedstoneOre(new BlockIdentifierFlattened(Block::REDSTONE_ORE, Block::LIT_REDSTONE_ORE), "Redstone Ore"));
|
||||
self::register((clone $redstoneOre)->setLit()); //flattening hack
|
||||
self::register($repeater = new RedstoneRepeater(new BlockIdentifierFlattened(Block::UNPOWERED_REPEATER, Block::POWERED_REPEATER, 0, ItemIds::REPEATER), "Redstne Repeater"));
|
||||
self::register((clone $repeater)->setPowered());
|
||||
self::register($redstoneTorch = new RedstoneTorch(new BlockIdentifierFlattened(Block::REDSTONE_TORCH, Block::UNLIT_REDSTONE_TORCH), "Redstone Torch"));
|
||||
self::register((clone $redstoneTorch)->setLit(false)); //flattening hack
|
||||
self::register(new RedstoneLamp(new BlockIdentifierFlattened(Block::REDSTONE_LAMP, Block::LIT_REDSTONE_LAMP), "Redstone Lamp"));
|
||||
self::register(new RedstoneOre(new BlockIdentifierFlattened(Block::REDSTONE_ORE, Block::LIT_REDSTONE_ORE), "Redstone Ore"));
|
||||
self::register(new RedstoneRepeater(new BlockIdentifierFlattened(Block::UNPOWERED_REPEATER, Block::POWERED_REPEATER, 0, ItemIds::REPEATER), "Redstne Repeater"));
|
||||
self::register(new RedstoneTorch(new BlockIdentifierFlattened(Block::REDSTONE_TORCH, Block::UNLIT_REDSTONE_TORCH), "Redstone Torch"));
|
||||
self::register(new RedstoneWire(new BID(Block::REDSTONE_WIRE, 0, ItemIds::REDSTONE), "Redstone"));
|
||||
self::register(new Reserved6(new BID(Block::RESERVED6), "reserved6"));
|
||||
self::register(new Sand(new BID(Block::SAND), "Sand"));
|
||||
@ -275,6 +267,22 @@ class BlockFactory{
|
||||
self::register(new StoneBricks(new BID(Block::STONEBRICK, StoneBricks::NORMAL), "Stone Bricks"));
|
||||
self::register(new StoneButton(new BID(Block::STONE_BUTTON), "Stone Button"));
|
||||
self::register(new StonePressurePlate(new BID(Block::STONE_PRESSURE_PLATE), "Stone Pressure Plate"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 0), "Stone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 1), "Sandstone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 2), "Fake Wooden"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 3), "Cobblestone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 4), "Brick"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 5), "Stone Brick"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 6), "Quartz"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 7), "Nether Brick"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 0), "Red Sandstone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1), "Purpur"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 2), "Prismarine"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 3), "Dark Prismarine"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 4), "Prismarine Bricks"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 5), "Mossy Cobblestone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 6), "Smooth Sandstone"));
|
||||
self::register(new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 7), "Red Nether Brick"));
|
||||
self::register(new Stonecutter(new BID(Block::STONECUTTER), "Stonecutter"));
|
||||
self::register(new Sugarcane(new BID(Block::REEDS_BLOCK, 0, ItemIds::REEDS), "Sugarcane"));
|
||||
self::register(new TNT(new BID(Block::TNT), "TNT"));
|
||||
@ -295,8 +303,7 @@ class BlockFactory{
|
||||
self::register(new Vine(new BID(Block::VINE), "Vines"));
|
||||
self::register(new WallBanner(new BID(Block::WALL_BANNER, 0, ItemIds::BANNER, \pocketmine\tile\Banner::class), "Wall Banner"));
|
||||
self::register(new WallSign(new BID(Block::WALL_SIGN, 0, ItemIds::SIGN, \pocketmine\tile\Sign::class), "Wall Sign"));
|
||||
self::register($water = new Water(new BlockIdentifierFlattened(Block::FLOWING_WATER, Block::STILL_WATER), "Water"));
|
||||
self::register((clone $water)->setStill()); //flattening hack
|
||||
self::register(new Water(new BlockIdentifierFlattened(Block::FLOWING_WATER, Block::STILL_WATER), "Water"));
|
||||
self::register(new WaterLily(new BID(Block::LILY_PAD), "Lily Pad"));
|
||||
self::register(new WeightedPressurePlateHeavy(new BID(Block::HEAVY_WEIGHTED_PRESSURE_PLATE), "Weighted Pressure Plate Heavy"));
|
||||
self::register(new WeightedPressurePlateLight(new BID(Block::LIGHT_WEIGHTED_PRESSURE_PLATE), "Weighted Pressure Plate Light"));
|
||||
@ -322,6 +329,7 @@ class BlockFactory{
|
||||
self::register(new Planks(new BID(Block::PLANKS, $magicNumber), $name . " Planks"));
|
||||
self::register(new Sapling(new BID(Block::SAPLING, $magicNumber), $name . " Sapling", $treeType));
|
||||
self::register(new WoodenFence(new BID(Block::FENCE, $magicNumber), $name . " Fence"));
|
||||
self::register(new WoodenSlab(new BlockIdentifierFlattened(Block::WOODEN_SLAB, Block::DOUBLE_WOODEN_SLAB, $treeType->getMagicNumber()), $treeType->getDisplayName()));
|
||||
|
||||
//TODO: find a better way to deal with this split
|
||||
self::register(new Leaves(new BID($magicNumber >= 4 ? Block::LEAVES2 : Block::LEAVES, $magicNumber & 0x03), $name . " Leaves", $treeType));
|
||||
@ -352,33 +360,6 @@ class BlockFactory{
|
||||
self::register(new Wool(new BID(Block::WOOL, $color->getMagicNumber()), $color->getDisplayName() . " Wool"));
|
||||
}
|
||||
|
||||
/** @var Slab[] $slabTypes */
|
||||
$slabTypes = [
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 0), "Stone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 1), "Sandstone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 2), "Fake Wooden"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 3), "Cobblestone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 4), "Brick"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 5), "Stone Brick"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 6), "Quartz"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 7), "Nether Brick"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 0), "Red Sandstone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1), "Purpur"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 2), "Prismarine"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 3), "Dark Prismarine"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 4), "Prismarine Bricks"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 5), "Mossy Cobblestone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 6), "Smooth Sandstone"),
|
||||
new StoneSlab(new BlockIdentifierFlattened(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 7), "Red Nether Brick")
|
||||
];
|
||||
foreach(TreeType::getAll() as $woodType){
|
||||
$slabTypes[] = new WoodenSlab(new BlockIdentifierFlattened(Block::WOODEN_SLAB, Block::DOUBLE_WOODEN_SLAB, $woodType->getMagicNumber()), $woodType->getDisplayName());
|
||||
}
|
||||
foreach($slabTypes as $type){
|
||||
self::register($type);
|
||||
self::register((clone $type)->setSlabType(SlabType::DOUBLE())); //flattening hack
|
||||
}
|
||||
|
||||
static $wallTypes = [
|
||||
CobblestoneWall::ANDESITE_WALL => "Andesite",
|
||||
CobblestoneWall::BRICK_WALL => "Brick",
|
||||
@ -533,7 +514,6 @@ class BlockFactory{
|
||||
* $override parameter.
|
||||
*/
|
||||
public static function register(Block $block, bool $override = false) : void{
|
||||
$id = $block->getId();
|
||||
$variant = $block->getIdInfo()->getVariant();
|
||||
|
||||
$stateMask = $block->getStateBitmask();
|
||||
@ -541,36 +521,38 @@ class BlockFactory{
|
||||
throw new \InvalidArgumentException("Block variant collides with state bitmask");
|
||||
}
|
||||
|
||||
if(!$override and self::isRegistered($id, $variant)){
|
||||
throw new \InvalidArgumentException("Block registration $id:$variant conflicts with an existing block");
|
||||
}
|
||||
|
||||
for($m = $variant; $m <= ($variant | $stateMask); ++$m){
|
||||
if(($m & ~$stateMask) !== $variant){
|
||||
continue;
|
||||
foreach($block->getIdInfo()->getAllBlockIds() as $id){
|
||||
if(!$override and self::isRegistered($id, $variant)){
|
||||
throw new \InvalidArgumentException("Block registration $id:$variant conflicts with an existing block");
|
||||
}
|
||||
|
||||
if(!$override and self::isRegistered($id, $m)){
|
||||
throw new \InvalidArgumentException("Block registration " . get_class($block) . " has states which conflict with other blocks");
|
||||
}
|
||||
|
||||
$index = ($id << 4) | $m;
|
||||
|
||||
$v = clone $block;
|
||||
try{
|
||||
$v->readStateFromMeta($m & $stateMask);
|
||||
if($v->getDamage() !== $m){
|
||||
throw new InvalidBlockStateException("Corrupted meta"); //don't register anything that isn't the same when we read it back again
|
||||
for($m = $variant; $m <= ($variant | $stateMask); ++$m){
|
||||
if(($m & ~$stateMask) !== $variant){
|
||||
continue;
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination
|
||||
continue;
|
||||
|
||||
if(!$override and self::isRegistered($id, $m)){
|
||||
throw new \InvalidArgumentException("Block registration " . get_class($block) . " has states which conflict with other blocks");
|
||||
}
|
||||
|
||||
$index = ($id << 4) | $m;
|
||||
|
||||
$v = clone $block;
|
||||
try{
|
||||
$v->readStateFromData($id, $m & $stateMask);
|
||||
if($v->getDamage() !== $m){
|
||||
throw new InvalidBlockStateException("Corrupted meta"); //don't register anything that isn't the same when we read it back again
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination
|
||||
continue;
|
||||
}
|
||||
|
||||
self::fillStaticArrays($index, $v);
|
||||
}
|
||||
|
||||
self::fillStaticArrays($index, $v);
|
||||
}
|
||||
|
||||
if(!self::isRegistered($id, $variant)){
|
||||
self::fillStaticArrays(($id << 4) | $variant, $block); //register default state mapped to variant, for blocks which don't use 0 as valid state
|
||||
if(!self::isRegistered($id, $variant)){
|
||||
self::fillStaticArrays(($id << 4) | $variant, $block); //register default state mapped to variant, for blocks which don't use 0 as valid state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,13 @@ class BlockIdentifier{
|
||||
return $this->blockId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->blockId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -39,4 +39,8 @@ class BlockIdentifierFlattened extends BlockIdentifier{
|
||||
public function getSecondId() : int{
|
||||
return $this->secondId;
|
||||
}
|
||||
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->getBlockId(), $this->getSecondId()];
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ class BrewingStand extends Transparent{
|
||||
return ($this->eastSlot ? 0x01 : 0) | ($this->southwestSlot ? 0x02 : 0) | ($this->northwestSlot ? 0x04 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->eastSlot = ($meta & 0x01) !== 0;
|
||||
$this->southwestSlot = ($meta & 0x02) !== 0;
|
||||
$this->northwestSlot = ($meta & 0x04) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->eastSlot = ($stateMeta & 0x01) !== 0;
|
||||
$this->southwestSlot = ($stateMeta & 0x02) !== 0;
|
||||
$this->northwestSlot = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -41,10 +41,10 @@ abstract class Button extends Flowable{
|
||||
return $this->facing | ($this->powered ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
//TODO: in PC it's (6 - facing) for every meta except 0 (down)
|
||||
$this->facing = BlockDataValidator::readFacing($meta & 0x07);
|
||||
$this->powered = ($meta & 0x08) !== 0;
|
||||
$this->facing = BlockDataValidator::readFacing($stateMeta & 0x07);
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -43,8 +43,8 @@ class Cactus extends Transparent{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -42,8 +42,8 @@ class Cake extends Transparent implements FoodSource{
|
||||
return $this->bites;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->bites = BlockDataValidator::readBoundedInt("bites", $meta, 0, 6);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->bites = BlockDataValidator::readBoundedInt("bites", $stateMeta, 0, 6);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -40,8 +40,8 @@ class Chest extends Transparent{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -45,9 +45,9 @@ class CocoaBlock extends Transparent{
|
||||
return Bearing::fromFacing(Facing::opposite($this->facing)) | ($this->age << 2);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = Facing::opposite(BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03));
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta >> 2, 0, 2);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = Facing::opposite(BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03));
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta >> 2, 0, 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,8 +39,8 @@ abstract class Crops extends Flowable{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta, 0, 7);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 7);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -52,8 +52,9 @@ class DaylightSensor extends Transparent{
|
||||
return $this->power;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
|
||||
$this->inverted = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -56,14 +56,14 @@ abstract class Door extends Transparent{
|
||||
return Bearing::fromFacing(Facing::rotateY($this->facing, true)) | ($this->open ? 0x04 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->top = $meta & 0x08;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->top = $stateMeta & 0x08;
|
||||
if($this->top){
|
||||
$this->hingeRight = ($meta & 0x01) !== 0;
|
||||
$this->powered = ($meta & 0x02) !== 0;
|
||||
$this->hingeRight = ($stateMeta & 0x01) !== 0;
|
||||
$this->powered = ($stateMeta & 0x02) !== 0;
|
||||
}else{
|
||||
$this->facing = Facing::rotateY(BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03), false);
|
||||
$this->open = ($meta & 0x04) !== 0;
|
||||
$this->facing = Facing::rotateY(BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03), false);
|
||||
$this->open = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ class DoublePlant extends Flowable{
|
||||
return ($this->top ? self::BITFLAG_TOP : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->top = ($meta & self::BITFLAG_TOP) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->top = ($stateMeta & self::BITFLAG_TOP) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -42,9 +42,9 @@ class EndPortalFrame extends Solid{
|
||||
return Bearing::fromFacing($this->facing) | ($this->eye ? 0x04 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
$this->eye = ($meta & 0x04) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->eye = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -42,12 +42,12 @@ class EndRod extends Flowable{
|
||||
return $this->facing ^ 1; //TODO: in PC this is always the same as facing, just PE is stupid
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
if($meta !== 0 and $meta !== 1){
|
||||
$meta ^= 1;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
if($stateMeta !== 0 and $stateMeta !== 1){
|
||||
$stateMeta ^= 1;
|
||||
}
|
||||
|
||||
$this->facing = BlockDataValidator::readFacing($meta);
|
||||
$this->facing = BlockDataValidator::readFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -38,8 +38,8 @@ class Farmland extends Transparent{
|
||||
return $this->wetness;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->wetness = BlockDataValidator::readBoundedInt("wetness", $meta, 0, 7);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->wetness = BlockDataValidator::readBoundedInt("wetness", $stateMeta, 0, 7);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -44,10 +44,10 @@ class FenceGate extends Transparent{
|
||||
return Bearing::fromFacing($this->facing) | ($this->open ? 0x04 : 0) | ($this->inWall ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
$this->open = ($meta & 0x04) !== 0;
|
||||
$this->inWall = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->open = ($stateMeta & 0x04) !== 0;
|
||||
$this->inWall = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -44,8 +44,8 @@ class Fire extends Flowable{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,8 +39,8 @@ class FlowerPot extends Flowable{
|
||||
return $this->occupied ? 1 : 0;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->occupied = $meta !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->occupied = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -48,8 +48,9 @@ class Furnace extends Solid{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
$this->lit = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -40,8 +40,8 @@ class GlazedTerracotta extends Solid{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -42,9 +42,9 @@ class ItemFrame extends Flowable{
|
||||
return (5 - $this->facing) | ($this->hasMap ? 0x04 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($meta & 0x03));
|
||||
$this->hasMap = ($meta & 0x04) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->hasMap = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -40,8 +40,8 @@ class Ladder extends Transparent{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -51,9 +51,9 @@ class Leaves extends Transparent{
|
||||
return ($this->noDecay ? 0x04 : 0) | ($this->checkDecay ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->noDecay = ($meta & 0x04) !== 0;
|
||||
$this->checkDecay = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->noDecay = ($stateMeta & 0x04) !== 0;
|
||||
$this->checkDecay = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -53,8 +53,8 @@ class Lever extends Flowable{
|
||||
return $rotationMeta | ($this->powered ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$rotationMeta = $meta & 0x07;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$rotationMeta = $stateMeta & 0x07;
|
||||
if($rotationMeta === 5 or $rotationMeta === 6){
|
||||
$this->position = self::TOP;
|
||||
$this->facing = $rotationMeta === 5 ? Facing::SOUTH : Facing::EAST;
|
||||
@ -66,7 +66,7 @@ class Lever extends Flowable{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(6 - $rotationMeta);
|
||||
}
|
||||
|
||||
$this->powered = ($meta & 0x08) !== 0;
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -71,9 +71,10 @@ abstract class Liquid extends Transparent{
|
||||
return $this->decay | ($this->falling ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->decay = BlockDataValidator::readBoundedInt("decay", $meta & 0x07, 0, 7);
|
||||
$this->falling = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->decay = BlockDataValidator::readBoundedInt("decay", $stateMeta & 0x07, 0, 7);
|
||||
$this->falling = ($stateMeta & 0x08) !== 0;
|
||||
$this->still = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -40,8 +40,8 @@ class NetherReactor extends Solid{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->state = BlockDataValidator::readBoundedInt("state", $meta, 0, 2);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->state = BlockDataValidator::readBoundedInt("state", $stateMeta, 0, 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -41,8 +41,8 @@ class NetherWartPlant extends Flowable{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta, 0, 3);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 3);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -35,8 +35,8 @@ class Pumpkin extends Solid{
|
||||
/** @var int */
|
||||
protected $facing = Facing::NORTH;
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
|
@ -41,8 +41,8 @@ class RedMushroomBlock extends Solid{
|
||||
return $this->rotationData;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->rotationData = $meta;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotationData = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,6 +39,10 @@ class RedstoneLamp extends Solid{
|
||||
return $this->lit ? $this->idInfo->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->lit = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function isLit() : bool{
|
||||
return $this->lit;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ class RedstoneOre extends Solid{
|
||||
return $this->lit ? $this->idInfo->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->lit = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 3;
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ abstract class RedstoneRail extends BaseRail{
|
||||
return parent::writeStateToMeta() | ($this->powered ? self::FLAG_POWERED : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
parent::readStateFromMeta($meta);
|
||||
$this->powered = ($meta & self::FLAG_POWERED) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
parent::readStateFromData($id, $stateMeta);
|
||||
$this->powered = ($stateMeta & self::FLAG_POWERED) !== 0;
|
||||
}
|
||||
|
||||
protected function getConnectionsFromMeta(int $meta) : ?array{
|
||||
|
@ -50,9 +50,10 @@ class RedstoneRepeater extends Flowable{
|
||||
return $this->powered ? $this->idInfo->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
$this->delay = BlockDataValidator::readBoundedInt("delay", ($meta >> 2) + 1, 1, 4);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->delay = BlockDataValidator::readBoundedInt("delay", ($stateMeta >> 2) + 1, 1, 4);
|
||||
$this->powered = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function writeStateToMeta() : int{
|
||||
|
@ -39,6 +39,11 @@ class RedstoneTorch extends Torch{
|
||||
return $this->lit ? parent::getId() : $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
parent::readStateFromData($id, $stateMeta);
|
||||
$this->lit = $id !== $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function isLit() : bool{
|
||||
return $this->lit;
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ class RedstoneWire extends Flowable{
|
||||
/** @var int */
|
||||
protected $power = 0;
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
|
@ -48,8 +48,8 @@ class Sapling extends Flowable{
|
||||
return ($this->ready ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->ready = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->ready = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,8 +39,8 @@ class SignPost extends Transparent{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->rotation = $meta;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -46,8 +46,8 @@ class Skull extends Flowable{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = $meta === 1 ? Facing::UP : BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = $stateMeta === 1 ? Facing::UP : BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -53,9 +53,11 @@ abstract class Slab extends Transparent{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
if($this->slabType !== SlabType::DOUBLE()){
|
||||
$this->slabType = ($meta & 0x08) !== 0 ? SlabType::TOP() : SlabType::BOTTOM();
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
if($id === $this->idInfo->getSecondId()){
|
||||
$this->slabType = SlabType::DOUBLE();
|
||||
}else{
|
||||
$this->slabType = ($stateMeta & 0x08) !== 0 ? SlabType::TOP() : SlabType::BOTTOM();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
return $this->layers - 1;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->layers = BlockDataValidator::readBoundedInt("layers", $meta + 1, 1, 8);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->layers = BlockDataValidator::readBoundedInt("layers", $stateMeta + 1, 1, 8);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -33,8 +33,8 @@ class Sponge extends Solid{
|
||||
return $this->wet ? 1 : 0;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->wet = $meta !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->wet = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -48,9 +48,9 @@ abstract class Stair extends Transparent{
|
||||
return (5 - $this->facing) | ($this->upsideDown ? 0x04 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($meta & 0x03));
|
||||
$this->upsideDown = ($meta & 0x04) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->upsideDown = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -42,8 +42,8 @@ class StandingBanner extends Transparent{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->rotation = $meta;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -34,8 +34,8 @@ class StonePressurePlate extends Transparent{
|
||||
return $this->powered ? 1 : 0;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->powered = $meta !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->powered = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,8 +39,8 @@ class Sugarcane extends Flowable{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -38,8 +38,8 @@ class Torch extends Flowable{
|
||||
return 6 - $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = $meta === 5 ? Facing::UP : BlockDataValidator::readHorizontalFacing(6 - $meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = $stateMeta === 5 ? Facing::UP : BlockDataValidator::readHorizontalFacing(6 - $stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -46,12 +46,12 @@ class Trapdoor extends Transparent{
|
||||
return (5 - $this->facing) | ($this->top ? self::MASK_UPPER : 0) | ($this->open ? self::MASK_OPENED : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
//TODO: in PC the values are reversed (facing - 2)
|
||||
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($meta & 0x03));
|
||||
$this->top = ($meta & self::MASK_UPPER) !== 0;
|
||||
$this->open = ($meta & self::MASK_OPENED) !== 0;
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->top = ($stateMeta & self::MASK_UPPER) !== 0;
|
||||
$this->open = ($stateMeta & self::MASK_OPENED) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -39,10 +39,10 @@ class Tripwire extends Flowable{
|
||||
return ($this->triggered ? 0x01 : 0) | ($this->connected ? 0x04 : 0) | ($this->disarmed ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->triggered = ($meta & 0x01) !== 0;
|
||||
$this->connected = ($meta & 0x04) !== 0;
|
||||
$this->disarmed = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->triggered = ($stateMeta & 0x01) !== 0;
|
||||
$this->connected = ($stateMeta & 0x04) !== 0;
|
||||
$this->disarmed = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -43,10 +43,10 @@ class TripwireHook extends Flowable{
|
||||
return Bearing::fromFacing($this->facing) | ($this->connected ? 0x04 : 0) | ($this->powered ? 0x08 : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($meta & 0x03);
|
||||
$this->connected = ($meta & 0x04) !== 0;
|
||||
$this->powered = ($meta & 0x08) !== 0;
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->connected = ($stateMeta & 0x04) !== 0;
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -50,11 +50,11 @@ class Vine extends Flowable{
|
||||
(isset($this->faces[Facing::EAST]) ? self::FLAG_EAST : 0);
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->setFaceFromMeta($meta, self::FLAG_SOUTH, Facing::SOUTH);
|
||||
$this->setFaceFromMeta($meta, self::FLAG_WEST, Facing::WEST);
|
||||
$this->setFaceFromMeta($meta, self::FLAG_NORTH, Facing::NORTH);
|
||||
$this->setFaceFromMeta($meta, self::FLAG_EAST, Facing::EAST);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->setFaceFromMeta($stateMeta, self::FLAG_SOUTH, Facing::SOUTH);
|
||||
$this->setFaceFromMeta($stateMeta, self::FLAG_WEST, Facing::WEST);
|
||||
$this->setFaceFromMeta($stateMeta, self::FLAG_NORTH, Facing::NORTH);
|
||||
$this->setFaceFromMeta($stateMeta, self::FLAG_EAST, Facing::EAST);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -35,8 +35,8 @@ class WallBanner extends StandingBanner{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -35,8 +35,8 @@ class WallSign extends SignPost{
|
||||
return $this->facing;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -35,8 +35,8 @@ class WeightedPressurePlateLight extends Transparent{
|
||||
return $this->power;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $meta, 0, 15);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
|
@ -43,11 +43,13 @@ trait PillarRotationTrait{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Block::readStateFromMeta()
|
||||
* @param int $meta
|
||||
* @see Block::readStateFromData()
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $stateMeta
|
||||
*/
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->readAxisFromMeta($meta);
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->readAxisFromMeta($stateMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user