Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.21.0 #6480

Merged
merged 49 commits into from
Nov 3, 2024
Merged

5.21.0 #6480

Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
371eccd
Make access modifier consistent with parent abstract class (#6341)
ItsMax123 May 7, 2024
5ae1320
Merge branch 'stable' into merge-stable
IvanCraft623 Jun 21, 2024
428e38f
Merge branch 'stable' into minor-next
IvanCraft623 Jun 21, 2024
b342c49
Added 1.21 banner patterns.
ipad54 Jun 23, 2024
f6c0b22
Add flow and guster banner patterns
IvanCraft623 Jul 4, 2024
2ffc38c
Implement campfire & soul campfire (#4696)
ipad54 Jul 7, 2024
accaa0a
Implement ICopper interface for blocks with common properties (#6390)
ipad54 Jul 10, 2024
ef9791e
Merge pull request #6397 from pmmp/stable
dktapps Jul 10, 2024
d6c48fd
Implement new 1.21 paintings (#6393)
IvanCraft623 Jul 12, 2024
787afb6
Implement all new 1.21 tuff blocks (#6391)
IvanCraft623 Jul 23, 2024
bdb5845
Allow name flattening rules where multiple old values map to the same…
dktapps Aug 5, 2024
be2437a
Support for flattening TAG_Byte and TAG_Int properties
dktapps Aug 5, 2024
d0d7a99
Add a TODO in BlockStateUpgrader
dktapps Aug 5, 2024
2aa64dc
Simplify phpstan-doc type hint for better readability
IvanCraft623 Aug 5, 2024
c4a2b64
Implement Aqua Affinity enchantment (#6408)
zSALLAZAR Aug 6, 2024
26761c2
Blockstate schema tool now supports testing schemas as well as genera…
dktapps Aug 9, 2024
33dc995
blockstate-upgrade-schema-utils: added a command to update old schema…
dktapps Aug 9, 2024
ee17ac5
Merge branch 'stable' of github.com:pmmp/PocketMine-MP into minor-next
dktapps Aug 9, 2024
e017780
Merge branch 'stable' of github.com:pmmp/PocketMine-MP into minor-next
invalid-email-address Aug 13, 2024
1ce774a
Merge 'stable' into 'minor-next'
invalid-email-address Aug 13, 2024
13f5cc9
ChiseledBookshelf: fixed function visibility (#6421)
ipad54 Aug 13, 2024
994fa5f
Merge 'stable' into 'minor-next'
invalid-email-address Aug 13, 2024
92f380b
Merge branch 'stable' into sync-minor-next
IvanCraft623 Aug 17, 2024
c44e6c5
Merge pull request #6430 from pmmp/sync-minor-next
dktapps Aug 18, 2024
93a270d
Merge 'stable' into 'minor-next'
invalid-email-address Aug 19, 2024
5241118
Merge branch 'minor-next' into blockstate-schema-generator-improvements
dktapps Aug 19, 2024
8cb2e57
Implement missing last interacted slot property in chiseled bookshelf…
ipad54 Sep 2, 2024
f6e2a1e
Validate transaction slots (#6304)
ShockedPlot7560 Sep 9, 2024
a4a07a8
Merge 'stable' into 'minor-next'
invalid-email-address Sep 23, 2024
4e6b34f
Implement new 1.21 copper blocks (#6366)
IvanCraft623 Sep 25, 2024
f6e6f15
Implemented a proper way to handle items cooldown (#6405)
ipad54 Sep 25, 2024
c8f567b
Fix missing arg count check
dktapps Oct 17, 2024
3ef7001
Merge branch 'stable' into blockstate-schema-generator-improvements
dktapps Oct 17, 2024
c4e72c8
Merge 'stable' into 'minor-next'
invalid-email-address Oct 17, 2024
d945cbf
Merge remote-tracking branch 'origin/minor-next' into blockstate-sche…
dktapps Oct 17, 2024
7e34361
Rename ICopper to CopperMaterial (#6470)
ipad54 Oct 23, 2024
7f9e79c
Automatically test new schemas to ensure they produce the results pre…
dktapps Oct 24, 2024
acbfb0a
Support for updating a batch of schemas using BlockPaletteArchive
dktapps Oct 24, 2024
22718c4
Add support for specialized flattenedProperties in schema format
dktapps Oct 24, 2024
847f931
Merge branch 'minor-next' into blockstate-schema-generator-improvements
dktapps Oct 24, 2024
d01203d
Reduce code duplication
dktapps Oct 24, 2024
3c96e72
Merge remote-tracking branch 'origin/stable' into minor-next
dktapps Nov 3, 2024
c0b74b0
Update BlockStateUpgrader.php
dktapps Nov 3, 2024
9e19391
Merge branch 'minor-next' into blockstate-schema-generator-improvements
dktapps Nov 3, 2024
82c4166
Merge pull request #6416 from pmmp/blockstate-schema-generator-improv…
dktapps Nov 3, 2024
c63d0ef
Fix dodgy ignored PHPStan error
dktapps Nov 3, 2024
72fc138
Regenerate PHPStan baselines
dktapps Nov 3, 2024
84464cd
Update BedrockBlockUpgradeSchema
dktapps Nov 3, 2024
96b12bd
Prepare 5.21.0 release
dktapps Nov 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement missing last interacted slot property in chiseled bookshelf (
ipad54 authored Sep 2, 2024
commit 8cb2e577a1aca3f99d6504e48f34cbe75249c2ae
40 changes: 40 additions & 0 deletions src/block/ChiseledBookshelf.php
Original file line number Diff line number Diff line change
@@ -48,11 +48,32 @@ class ChiseledBookshelf extends Opaque{
*/
private array $slots = [];

private ?ChiseledBookshelfSlot $lastInteractedSlot = null;

protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->enumSet($this->slots, ChiseledBookshelfSlot::cases());
}

public function readStateFromWorld() : Block{
$tile = $this->position->getWorld()->getTile($this->position);
if($tile instanceof TileChiseledBookshelf){
$this->lastInteractedSlot = $tile->getLastInteractedSlot();
}else{
$this->lastInteractedSlot = null;
}
return $this;
}

public function writeStateToWorld() : void{
parent::writeStateToWorld();

$tile = $this->position->getWorld()->getTile($this->position);
if($tile instanceof TileChiseledBookshelf){
$tile->setLastInteractedSlot($this->lastInteractedSlot);
}
}

/**
* Returns whether the given slot is displayed as occupied.
* This doesn't guarantee that there is or isn't a book in the bookshelf's inventory.
@@ -92,6 +113,23 @@ public function getSlots() : array{
return $this->slots;
}

/**
* Returns the last slot interacted by a player or null if no slot has been interacted with yet.
*/
public function getLastInteractedSlot() : ?ChiseledBookshelfSlot{
return $this->lastInteractedSlot;
}

/**
* Sets the last slot interacted by a player.
*
* @return $this
*/
public function setLastInteractedSlot(?ChiseledBookshelfSlot $lastInteractedSlot) : self{
$this->lastInteractedSlot = $lastInteractedSlot;
return $this;
}

public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
if($face !== $this->facing){
return false;
@@ -112,10 +150,12 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player
$returnedItems[] = $inventory->getItem($slot->value);
$inventory->clear($slot->value);
$this->setSlot($slot, false);
$this->lastInteractedSlot = $slot;
}elseif($item instanceof WritableBookBase || $item instanceof Book || $item instanceof EnchantedBook){
//TODO: type tags like blocks would be better for this
$inventory->setItem($slot->value, $item->pop());
$this->setSlot($slot, true);
$this->lastInteractedSlot = $slot;
}else{
return true;
}
22 changes: 22 additions & 0 deletions src/block/tile/ChiseledBookshelf.php
Original file line number Diff line number Diff line change
@@ -40,8 +40,12 @@
class ChiseledBookshelf extends Tile implements Container{
use ContainerTrait;

private const TAG_LAST_INTERACTED_SLOT = "LastInteractedSlot"; //TAG_Int

private SimpleInventory $inventory;

private ?ChiseledBookshelfSlot $lastInteractedSlot = null;

public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos);
$this->inventory = new SimpleInventory(count(ChiseledBookshelfSlot::cases()));
@@ -55,12 +59,30 @@ public function getRealInventory() : SimpleInventory{
return $this->inventory;
}

public function getLastInteractedSlot() : ?ChiseledBookshelfSlot{
return $this->lastInteractedSlot;
}

public function setLastInteractedSlot(?ChiseledBookshelfSlot $lastInteractedSlot) : void{
$this->lastInteractedSlot = $lastInteractedSlot;
}

public function readSaveData(CompoundTag $nbt) : void{
$this->loadItems($nbt);

$lastInteractedSlot = $nbt->getInt(self::TAG_LAST_INTERACTED_SLOT, 0);
if($lastInteractedSlot !== 0){
$this->lastInteractedSlot = ChiseledBookshelfSlot::tryFrom($lastInteractedSlot - 1);
}
}

protected function writeSaveData(CompoundTag $nbt) : void{
$this->saveItems($nbt);

$nbt->setInt(self::TAG_LAST_INTERACTED_SLOT, $this->lastInteractedSlot !== null ?
$this->lastInteractedSlot->value + 1 :
0
);
}

protected function loadItems(CompoundTag $tag) : void{