mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
Deal with a bunch of easy BC breaks
This commit is contained in:
@@ -62,12 +62,7 @@ abstract class BaseBanner extends Transparent implements Colored{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
abstract protected function getOminousVersion() : Block;
|
||||||
* TODO: make this abstract in PM6 (BC break)
|
|
||||||
*/
|
|
||||||
protected function getOminousVersion() : Block{
|
|
||||||
return VanillaBlocks::AIR();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function writeStateToWorld() : void{
|
public function writeStateToWorld() : void{
|
||||||
parent::writeStateToWorld();
|
parent::writeStateToWorld();
|
||||||
|
@@ -53,7 +53,7 @@ use function strlen;
|
|||||||
abstract class BaseSign extends Transparent implements WoodMaterial{
|
abstract class BaseSign extends Transparent implements WoodMaterial{
|
||||||
use WoodTypeTrait;
|
use WoodTypeTrait;
|
||||||
|
|
||||||
protected SignText $text; //TODO: rename this (BC break)
|
protected SignText $frontText;
|
||||||
protected SignText $backText;
|
protected SignText $backText;
|
||||||
private bool $waxed = false;
|
private bool $waxed = false;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ abstract class BaseSign extends Transparent implements WoodMaterial{
|
|||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo, WoodType $woodType, \Closure $asItemCallback){
|
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo, WoodType $woodType, \Closure $asItemCallback){
|
||||||
$this->woodType = $woodType;
|
$this->woodType = $woodType;
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
$this->text = new SignText();
|
$this->frontText = new SignText();
|
||||||
$this->backText = new SignText();
|
$this->backText = new SignText();
|
||||||
$this->asItemCallback = $asItemCallback;
|
$this->asItemCallback = $asItemCallback;
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ abstract class BaseSign extends Transparent implements WoodMaterial{
|
|||||||
parent::readStateFromWorld();
|
parent::readStateFromWorld();
|
||||||
$tile = $this->position->getWorld()->getTile($this->position);
|
$tile = $this->position->getWorld()->getTile($this->position);
|
||||||
if($tile instanceof TileSign){
|
if($tile instanceof TileSign){
|
||||||
$this->text = $tile->getText();
|
$this->frontText = $tile->getFrontText();
|
||||||
$this->backText = $tile->getBackText();
|
$this->backText = $tile->getBackText();
|
||||||
$this->waxed = $tile->isWaxed();
|
$this->waxed = $tile->isWaxed();
|
||||||
$this->editorEntityRuntimeId = $tile->getEditorEntityRuntimeId();
|
$this->editorEntityRuntimeId = $tile->getEditorEntityRuntimeId();
|
||||||
@@ -90,7 +90,7 @@ abstract class BaseSign extends Transparent implements WoodMaterial{
|
|||||||
parent::writeStateToWorld();
|
parent::writeStateToWorld();
|
||||||
$tile = $this->position->getWorld()->getTile($this->position);
|
$tile = $this->position->getWorld()->getTile($this->position);
|
||||||
assert($tile instanceof TileSign);
|
assert($tile instanceof TileSign);
|
||||||
$tile->setText($this->text);
|
$tile->setFrontText($this->frontText);
|
||||||
$tile->setBackText($this->backText);
|
$tile->setBackText($this->backText);
|
||||||
$tile->setWaxed($this->waxed);
|
$tile->setWaxed($this->waxed);
|
||||||
$tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
|
$tile->setEditorEntityRuntimeId($this->editorEntityRuntimeId);
|
||||||
@@ -228,39 +228,15 @@ abstract class BaseSign extends Transparent implements WoodMaterial{
|
|||||||
return $this->position->add(0.5, 0.5, 0.5);
|
return $this->position->add(0.5, 0.5, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
abstract protected function getFacingDegrees() : float;
|
||||||
* TODO: make this abstract (BC break)
|
|
||||||
*/
|
|
||||||
protected function getFacingDegrees() : float{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an object containing information about the sign text.
|
|
||||||
* @deprecated
|
|
||||||
* @see self::getFaceText()
|
|
||||||
*/
|
|
||||||
public function getText() : SignText{
|
|
||||||
return $this->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @see self::setFaceText()
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setText(SignText $text) : self{
|
|
||||||
$this->text = $text;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFaceText(bool $frontFace) : SignText{
|
public function getFaceText(bool $frontFace) : SignText{
|
||||||
return $frontFace ? $this->text : $this->backText;
|
return $frontFace ? $this->frontText : $this->backText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function setFaceText(bool $frontFace, SignText $text) : self{
|
public function setFaceText(bool $frontFace, SignText $text) : self{
|
||||||
$frontFace ? $this->text = $text : $this->backText = $text;
|
$frontFace ? $this->frontText = $text : $this->backText = $text;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,14 +264,6 @@ abstract class BaseSign extends Transparent implements WoodMaterial{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @see self::updateFaceText()
|
|
||||||
*/
|
|
||||||
public function updateText(Player $author, SignText $text) : bool{
|
|
||||||
return $this->updateFaceText($author, true, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the player controller (network session) to update the sign text, firing events as appropriate.
|
* Called by the player controller (network session) to update the sign text, firing events as appropriate.
|
||||||
*
|
*
|
||||||
|
@@ -43,7 +43,7 @@ abstract class PressurePlate extends Transparent{
|
|||||||
BlockIdentifier $idInfo,
|
BlockIdentifier $idInfo,
|
||||||
string $name,
|
string $name,
|
||||||
BlockTypeInfo $typeInfo,
|
BlockTypeInfo $typeInfo,
|
||||||
int $deactivationDelayTicks = 20 //TODO: make this mandatory in PM6
|
int $deactivationDelayTicks
|
||||||
){
|
){
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
$this->deactivationDelayTicks = $deactivationDelayTicks;
|
$this->deactivationDelayTicks = $deactivationDelayTicks;
|
||||||
@@ -89,24 +89,15 @@ abstract class PressurePlate extends Transparent{
|
|||||||
->offsetCopy($this->position->x, $this->position->y, $this->position->z);
|
->offsetCopy($this->position->x, $this->position->y, $this->position->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
abstract protected function hasOutputSignal() : bool;
|
||||||
* TODO: make this abstract in PM6
|
|
||||||
*/
|
|
||||||
protected function hasOutputSignal() : bool{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: make this abstract in PM6
|
|
||||||
*
|
|
||||||
* @param Entity[] $entities
|
* @param Entity[] $entities
|
||||||
*
|
*
|
||||||
* @return mixed[]
|
* @return mixed[]
|
||||||
* @phpstan-return array{Block, ?bool}
|
* @phpstan-return array{Block, ?bool}
|
||||||
*/
|
*/
|
||||||
protected function calculatePlateState(array $entities) : array{
|
abstract protected function calculatePlateState(array $entities) : array;
|
||||||
return [$this, null];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters entities which don't affect the pressure plate state from the given list.
|
* Filters entities which don't affect the pressure plate state from the given list.
|
||||||
|
@@ -1182,7 +1182,7 @@ final class VanillaBlocks{
|
|||||||
self::register("mossy_stone_brick_stairs", fn(BID $id) => new Stair($id, "Mossy Stone Brick Stairs", $stoneBreakInfo));
|
self::register("mossy_stone_brick_stairs", fn(BID $id) => new Stair($id, "Mossy Stone Brick Stairs", $stoneBreakInfo));
|
||||||
self::register("stone_button", fn(BID $id) => new StoneButton($id, "Stone Button", new Info(BreakInfo::pickaxe(0.5))));
|
self::register("stone_button", fn(BID $id) => new StoneButton($id, "Stone Button", new Info(BreakInfo::pickaxe(0.5))));
|
||||||
self::register("stonecutter", fn(BID $id) => new Stonecutter($id, "Stonecutter", new Info(BreakInfo::pickaxe(3.5))));
|
self::register("stonecutter", fn(BID $id) => new Stonecutter($id, "Stonecutter", new Info(BreakInfo::pickaxe(3.5))));
|
||||||
self::register("stone_pressure_plate", fn(BID $id) => new StonePressurePlate($id, "Stone Pressure Plate", new Info(BreakInfo::pickaxe(0.5))));
|
self::register("stone_pressure_plate", fn(BID $id) => new StonePressurePlate($id, "Stone Pressure Plate", new Info(BreakInfo::pickaxe(0.5)), deactivationDelayTicks: 20));
|
||||||
|
|
||||||
$stoneSlabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
$stoneSlabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ class WoodenPressurePlate extends SimplePressurePlate implements WoodMaterial{
|
|||||||
string $name,
|
string $name,
|
||||||
BlockTypeInfo $typeInfo,
|
BlockTypeInfo $typeInfo,
|
||||||
WoodType $woodType,
|
WoodType $woodType,
|
||||||
int $deactivationDelayTicks = 20 //TODO: make this mandatory in PM6
|
int $deactivationDelayTicks
|
||||||
){
|
){
|
||||||
$this->woodType = $woodType;
|
$this->woodType = $woodType;
|
||||||
parent::__construct($idInfo, $name, $typeInfo, $deactivationDelayTicks);
|
parent::__construct($idInfo, $name, $typeInfo, $deactivationDelayTicks);
|
||||||
|
@@ -58,14 +58,14 @@ class Sign extends Spawnable{
|
|||||||
public const TAG_WAXED = "IsWaxed"; //TAG_Byte
|
public const TAG_WAXED = "IsWaxed"; //TAG_Byte
|
||||||
public const TAG_LOCKED_FOR_EDITING_BY = "LockedForEditingBy"; //TAG_Long
|
public const TAG_LOCKED_FOR_EDITING_BY = "LockedForEditingBy"; //TAG_Long
|
||||||
|
|
||||||
protected SignText $text;
|
protected SignText $frontText;
|
||||||
protected SignText $backText;
|
protected SignText $backText;
|
||||||
private bool $waxed = false;
|
private bool $waxed = false;
|
||||||
|
|
||||||
protected ?int $editorEntityRuntimeId = null;
|
protected ?int $editorEntityRuntimeId = null;
|
||||||
|
|
||||||
public function __construct(World $world, Vector3 $pos){
|
public function __construct(World $world, Vector3 $pos){
|
||||||
$this->text = new SignText();
|
$this->frontText = new SignText();
|
||||||
$this->backText = new SignText();
|
$this->backText = new SignText();
|
||||||
parent::__construct($world, $pos);
|
parent::__construct($world, $pos);
|
||||||
}
|
}
|
||||||
@@ -95,13 +95,13 @@ class Sign extends Spawnable{
|
|||||||
public function readSaveData(CompoundTag $nbt) : void{
|
public function readSaveData(CompoundTag $nbt) : void{
|
||||||
$frontTextTag = $nbt->getTag(self::TAG_FRONT_TEXT);
|
$frontTextTag = $nbt->getTag(self::TAG_FRONT_TEXT);
|
||||||
if($frontTextTag instanceof CompoundTag){
|
if($frontTextTag instanceof CompoundTag){
|
||||||
$this->text = $this->readTextTag($frontTextTag, true);
|
$this->frontText = $this->readTextTag($frontTextTag, true);
|
||||||
}elseif($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format
|
}elseif($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format
|
||||||
$lightingBugResolved = false;
|
$lightingBugResolved = false;
|
||||||
if(($lightingBugResolvedTag = $nbt->getTag(self::TAG_LEGACY_BUG_RESOLVE)) instanceof ByteTag){
|
if(($lightingBugResolvedTag = $nbt->getTag(self::TAG_LEGACY_BUG_RESOLVE)) instanceof ByteTag){
|
||||||
$lightingBugResolved = $lightingBugResolvedTag->getValue() !== 0;
|
$lightingBugResolved = $lightingBugResolvedTag->getValue() !== 0;
|
||||||
}
|
}
|
||||||
$this->text = $this->readTextTag($nbt, $lightingBugResolved);
|
$this->frontText = $this->readTextTag($nbt, $lightingBugResolved);
|
||||||
}else{
|
}else{
|
||||||
$text = [];
|
$text = [];
|
||||||
for($i = 0; $i < SignText::LINE_COUNT; ++$i){
|
for($i = 0; $i < SignText::LINE_COUNT; ++$i){
|
||||||
@@ -110,7 +110,7 @@ class Sign extends Spawnable{
|
|||||||
$text[$i] = mb_scrub($lineTag->getValue(), 'UTF-8');
|
$text[$i] = mb_scrub($lineTag->getValue(), 'UTF-8');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->text = new SignText($text);
|
$this->frontText = new SignText($text);
|
||||||
}
|
}
|
||||||
$backTextTag = $nbt->getTag(self::TAG_BACK_TEXT);
|
$backTextTag = $nbt->getTag(self::TAG_BACK_TEXT);
|
||||||
$this->backText = $backTextTag instanceof CompoundTag ? $this->readTextTag($backTextTag, true) : new SignText();
|
$this->backText = $backTextTag instanceof CompoundTag ? $this->readTextTag($backTextTag, true) : new SignText();
|
||||||
@@ -118,18 +118,18 @@ class Sign extends Spawnable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function writeSaveData(CompoundTag $nbt) : void{
|
protected function writeSaveData(CompoundTag $nbt) : void{
|
||||||
$nbt->setTag(self::TAG_FRONT_TEXT, $this->writeTextTag($this->text));
|
$nbt->setTag(self::TAG_FRONT_TEXT, $this->writeTextTag($this->frontText));
|
||||||
$nbt->setTag(self::TAG_BACK_TEXT, $this->writeTextTag($this->backText));
|
$nbt->setTag(self::TAG_BACK_TEXT, $this->writeTextTag($this->backText));
|
||||||
|
|
||||||
$nbt->setByte(self::TAG_WAXED, $this->waxed ? 1 : 0);
|
$nbt->setByte(self::TAG_WAXED, $this->waxed ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getText() : SignText{
|
public function getFrontText() : SignText{
|
||||||
return $this->text;
|
return $this->frontText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setText(SignText $text) : void{
|
public function setFrontText(SignText $frontText) : void{
|
||||||
$this->text = $text;
|
$this->frontText = $frontText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackText() : SignText{ return $this->backText; }
|
public function getBackText() : SignText{ return $this->backText; }
|
||||||
@@ -157,7 +157,7 @@ class Sign extends Spawnable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
protected function addAdditionalSpawnData(CompoundTag $nbt) : void{
|
||||||
$nbt->setTag(self::TAG_FRONT_TEXT, $this->writeTextTag($this->text));
|
$nbt->setTag(self::TAG_FRONT_TEXT, $this->writeTextTag($this->frontText));
|
||||||
$nbt->setTag(self::TAG_BACK_TEXT, $this->writeTextTag($this->backText));
|
$nbt->setTag(self::TAG_BACK_TEXT, $this->writeTextTag($this->backText));
|
||||||
$nbt->setByte(self::TAG_WAXED, $this->waxed ? 1 : 0);
|
$nbt->setByte(self::TAG_WAXED, $this->waxed ? 1 : 0);
|
||||||
$nbt->setLong(self::TAG_LOCKED_FOR_EDITING_BY, $this->editorEntityRuntimeId ?? -1);
|
$nbt->setLong(self::TAG_LOCKED_FOR_EDITING_BY, $this->editorEntityRuntimeId ?? -1);
|
||||||
|
@@ -155,14 +155,6 @@ abstract class BaseInventory implements Inventory, SlotValidatedInventory{
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: make this abstract and force implementations to implement it properly (BC break)
|
|
||||||
* This default implementation works, but is slow.
|
|
||||||
*/
|
|
||||||
public function isSlotEmpty(int $index) : bool{
|
|
||||||
return $this->getItem($index)->isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canAddItem(Item $item) : bool{
|
public function canAddItem(Item $item) : bool{
|
||||||
return $this->getAddableItemQuantity($item) === $item->getCount();
|
return $this->getAddableItemQuantity($item) === $item->getCount();
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,11 @@ final class SlotChangeActionBuilder extends BaseInventory{
|
|||||||
return $this->inventoryWindow->getInventory()->getMatchingItemCount($slot, $test, $checkTags);
|
return $this->inventoryWindow->getInventory()->getMatchingItemCount($slot, $test, $checkTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSlotEmpty(int $index) : bool{
|
||||||
|
$slotItem = $this->changedSlots[$index] ?? null;
|
||||||
|
return $slotItem !== null ? $slotItem->isNull() : $this->inventoryWindow->getInventory()->isSlotEmpty($index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SlotChangeAction[]
|
* @return SlotChangeAction[]
|
||||||
*/
|
*/
|
||||||
|
@@ -281,7 +281,6 @@ class World implements ChunkManager{
|
|||||||
private float $sunAnglePercentage = 0.0;
|
private float $sunAnglePercentage = 0.0;
|
||||||
private int $skyLightReduction = 0;
|
private int $skyLightReduction = 0;
|
||||||
|
|
||||||
private string $folderName;
|
|
||||||
private string $displayName;
|
private string $displayName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -482,11 +481,10 @@ class World implements ChunkManager{
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private Server $server,
|
private Server $server,
|
||||||
string $name, //TODO: this should be folderName (named arguments BC break)
|
private string $folderName,
|
||||||
private WritableWorldProvider $provider,
|
private WritableWorldProvider $provider,
|
||||||
private AsyncPool $workerPool
|
private AsyncPool $workerPool
|
||||||
){
|
){
|
||||||
$this->folderName = $name;
|
|
||||||
$this->worldId = self::$worldIdCounter++;
|
$this->worldId = self::$worldIdCounter++;
|
||||||
|
|
||||||
$this->displayName = $this->provider->getWorldData()->getName();
|
$this->displayName = $this->provider->getWorldData()->getName();
|
||||||
@@ -1487,29 +1485,18 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identical to {@link World::notifyNeighbourBlockUpdate()}, but without the Vector3 requirement. We don't want or
|
* Notify the blocks at and around the position that the block at the position may have changed.
|
||||||
* need Vector3 in the places where this is called.
|
* This will cause onNearbyBlockChange() to be called for these blocks.
|
||||||
*
|
*
|
||||||
* TODO: make this the primary method in PM6
|
* @see Block::onNearbyBlockChange()
|
||||||
*/
|
*/
|
||||||
private function internalNotifyNeighbourBlockUpdate(int $x, int $y, int $z) : void{
|
public function notifyNeighbourBlockUpdate(int $x, int $y, int $z) : void{
|
||||||
$this->tryAddToNeighbourUpdateQueue($x, $y, $z);
|
$this->tryAddToNeighbourUpdateQueue($x, $y, $z);
|
||||||
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
||||||
$this->tryAddToNeighbourUpdateQueue($x + $dx, $y + $dy, $z + $dz);
|
$this->tryAddToNeighbourUpdateQueue($x + $dx, $y + $dy, $z + $dz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify the blocks at and around the position that the block at the position may have changed.
|
|
||||||
* This will cause onNearbyBlockChange() to be called for these blocks.
|
|
||||||
* TODO: Accept plain integers in PM6 - the Vector3 requirement is an unnecessary inconvenience
|
|
||||||
*
|
|
||||||
* @see Block::onNearbyBlockChange()
|
|
||||||
*/
|
|
||||||
public function notifyNeighbourBlockUpdate(Vector3 $pos) : void{
|
|
||||||
$this->internalNotifyNeighbourBlockUpdate($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Block[]
|
* @return Block[]
|
||||||
* @phpstan-return list<Block>
|
* @phpstan-return list<Block>
|
||||||
@@ -2065,7 +2052,7 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
if($update){
|
if($update){
|
||||||
$this->updateAllLight($x, $y, $z);
|
$this->updateAllLight($x, $y, $z);
|
||||||
$this->internalNotifyNeighbourBlockUpdate($x, $y, $z);
|
$this->notifyNeighbourBlockUpdate($x, $y, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->timings->setBlock->stopTiming();
|
$this->timings->setBlock->stopTiming();
|
||||||
|
Reference in New Issue
Block a user