mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
ItemBlock: remember fuel time, fireproof and max stack size
this avoids repeatedly creating blocks for no reason when calling these methods. This does assume that these methods always return the same result for a given block type, but I think that's a fair enough assumption.
This commit is contained in:
parent
4dabac8420
commit
5c5d96d00b
@ -38,10 +38,18 @@ final class ItemBlock extends Item{
|
||||
private int $blockTypeId;
|
||||
private int $blockTypeData;
|
||||
|
||||
private int $fuelTime;
|
||||
private bool $fireProof;
|
||||
private int $maxStackSize;
|
||||
|
||||
public function __construct(Block $block){
|
||||
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
|
||||
$this->blockTypeId = $block->getTypeId();
|
||||
$this->blockTypeData = $block->computeTypeData();
|
||||
|
||||
$this->fuelTime = $block->getFuelTime();
|
||||
$this->fireProof = $block->isFireProofAsItem();
|
||||
$this->maxStackSize = $block->getMaxStackSize();
|
||||
}
|
||||
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
@ -60,14 +68,14 @@ final class ItemBlock extends Item{
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->getBlock()->getFuelTime();
|
||||
return $this->fuelTime;
|
||||
}
|
||||
|
||||
public function isFireProof() : bool{
|
||||
return $this->getBlock()->isFireProofAsItem();
|
||||
return $this->fireProof;
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{
|
||||
return $this->getBlock()->getMaxStackSize();
|
||||
return $this->maxStackSize;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user