Make Block::decodeState() and encodeState() more codegen-friendly

This commit is contained in:
Dylan K. Taylor
2022-07-18 15:48:03 +01:00
parent b8d1b00985
commit cf34f88a67
4 changed files with 72 additions and 25 deletions

View File

@ -47,28 +47,11 @@ class BrewingStand extends Transparent{
public function getRequiredStateDataBits() : int{ return 3; }
protected function decodeState(RuntimeDataReader $r) : void{
$result = [];
foreach([
BrewingStandSlot::EAST(),
BrewingStandSlot::NORTHWEST(),
BrewingStandSlot::SOUTHWEST(),
] as $member){
if($r->readBool()){
$result[$member->id()] = $member;
}
}
$this->setSlots($result);
$this->setSlots($r->readBrewingStandSlots());
}
protected function encodeState(RuntimeDataWriter $w) : void{
foreach([
BrewingStandSlot::EAST(),
BrewingStandSlot::NORTHWEST(),
BrewingStandSlot::SOUTHWEST(),
] as $member){
$w->writeBool(isset($this->slots[$member->id()]));
}
$w->writeBrewingStandSlots($this->getSlots());
}
protected function recalculateCollisionBoxes() : array{