Removed FlowerPot update_bit hack

This commit is contained in:
Dylan K. Taylor 2021-07-19 17:39:35 +01:00
parent 5874ce582a
commit 71df15b4cc
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 11 additions and 14 deletions

View File

@ -193,7 +193,12 @@ class BlockFactory{
$this->register(new Flower(new BID(Ids::RED_FLOWER, Meta::FLOWER_POPPY), "Poppy", BlockBreakInfo::instant()));
$this->register(new Flower(new BID(Ids::RED_FLOWER, Meta::FLOWER_RED_TULIP), "Red Tulip", BlockBreakInfo::instant()));
$this->register(new Flower(new BID(Ids::RED_FLOWER, Meta::FLOWER_WHITE_TULIP), "White Tulip", BlockBreakInfo::instant()));
$this->register(new FlowerPot(new BID(Ids::FLOWER_POT_BLOCK, 0, ItemIds::FLOWER_POT, TileFlowerPot::class), "Flower Pot", BlockBreakInfo::instant()));
$flowerPot = new FlowerPot(new BID(Ids::FLOWER_POT_BLOCK, 0, ItemIds::FLOWER_POT, TileFlowerPot::class), "Flower Pot", BlockBreakInfo::instant());
$this->register($flowerPot);
for($meta = 1; $meta < 16; ++$meta){
$this->remap(Ids::FLOWER_POT_BLOCK, $meta, $flowerPot);
}
$this->register(new FrostedIce(new BID(Ids::FROSTED_ICE, 0), "Frosted Ice", new BlockBreakInfo(2.5, BlockToolType::PICKAXE)));
$this->register(new Furnace(new BIDFlattened(Ids::FURNACE, [Ids::LIT_FURNACE], 0, null, TileFurnace::class), "Furnace", new BlockBreakInfo(3.5, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel())));

View File

@ -34,22 +34,15 @@ use function assert;
class FlowerPot extends Flowable{
/**
* TODO: get rid of this hack (it's currently needed to deal with blockfactory state handling)
*/
protected bool $occupied = false;
protected ?Block $plant = null;
protected function writeStateToMeta() : int{
return $this->occupied ? BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED : 0;
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->occupied = ($stateMeta & BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED) !== 0;
//TODO: HACK! this is just to make the client actually render the plant - we purposely don't read the flag back
return $this->plant !== null ? BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED : 0;
}
public function getStateBitmask() : int{
return 0b1111; //vanilla uses various values, we only care about 1 and 0 for PE
return 0b1;
}
public function readStateFromWorld() : void{
@ -58,7 +51,7 @@ class FlowerPot extends Flowable{
if($tile instanceof TileFlowerPot){
$this->setPlant($tile->getPlant());
}else{
$this->occupied = false;
$this->setPlant(null);
}
}
@ -81,7 +74,6 @@ class FlowerPot extends Flowable{
}else{
$this->plant = clone $plant;
}
$this->occupied = $this->plant !== null;
return $this;
}

File diff suppressed because one or more lines are too long