Assemble 1.21.0

This commit is contained in:
Dylan K. Taylor
2024-06-13 18:41:41 +01:00
parent 08c6e63aac
commit f121654452
21 changed files with 251 additions and 160 deletions

View File

@ -96,6 +96,7 @@ class InventoryManager{
private array $complexSlotToInventoryMap = [];
private int $lastInventoryNetworkId = ContainerIds::FIRST;
private int $currentWindowType = WindowTypes::CONTAINER;
private int $clientSelectedHotbarSlot = -1;
@ -327,9 +328,15 @@ class InventoryManager{
foreach($this->containerOpenCallbacks as $callback){
$pks = $callback($windowId, $inventory);
if($pks !== null){
$windowType = null;
foreach($pks as $pk){
if($pk instanceof ContainerOpenPacket){
//workaround useless bullshit in 1.21 - ContainerClose requires a type now for some reason
$windowType = $pk->windowType;
}
$this->session->sendDataPacket($pk);
}
$this->currentWindowType = $windowType ?? WindowTypes::CONTAINER;
$this->syncContents($inventory);
return;
}
@ -378,10 +385,11 @@ class InventoryManager{
$this->openWindowDeferred(function() : void{
$windowId = $this->getNewWindowId();
$this->associateIdWithInventory($windowId, $this->player->getInventory());
$this->currentWindowType = WindowTypes::INVENTORY;
$this->session->sendDataPacket(ContainerOpenPacket::entityInv(
$windowId,
WindowTypes::INVENTORY,
$this->currentWindowType,
$this->player->getId()
));
});
@ -390,7 +398,7 @@ class InventoryManager{
public function onCurrentWindowRemove() : void{
if(isset($this->networkIdToInventoryMap[$this->lastInventoryNetworkId])){
$this->remove($this->lastInventoryNetworkId);
$this->session->sendDataPacket(ContainerClosePacket::create($this->lastInventoryNetworkId, true));
$this->session->sendDataPacket(ContainerClosePacket::create($this->lastInventoryNetworkId, $this->currentWindowType, true));
if($this->pendingCloseWindowId !== null){
throw new AssumptionFailedError("We should not have opened a new window while a window was waiting to be closed");
}
@ -411,7 +419,7 @@ class InventoryManager{
//Always send this, even if no window matches. If we told the client to close a window, it will behave as if it
//initiated the close and expect an ack.
$this->session->sendDataPacket(ContainerClosePacket::create($id, false));
$this->session->sendDataPacket(ContainerClosePacket::create($id, $this->currentWindowType, false));
if($this->pendingCloseWindowId === $id){
$this->pendingCloseWindowId = null;

View File

@ -36,6 +36,7 @@ use pocketmine\network\mcpe\protocol\types\recipe\FurnaceRecipeBlockName;
use pocketmine\network\mcpe\protocol\types\recipe\IntIdMetaItemDescriptor;
use pocketmine\network\mcpe\protocol\types\recipe\PotionContainerChangeRecipe as ProtocolPotionContainerChangeRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\PotionTypeRecipe as ProtocolPotionTypeRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\RecipeUnlockingRequirement;
use pocketmine\network\mcpe\protocol\types\recipe\ShapedRecipe as ProtocolShapedRecipe;
use pocketmine\network\mcpe\protocol\types\recipe\ShapelessRecipe as ProtocolShapelessRecipe;
use pocketmine\timings\Timings;
@ -79,6 +80,7 @@ final class CraftingDataCache{
$converter = TypeConverter::getInstance();
$recipesWithTypeIds = [];
$noUnlockingRequirement = new RecipeUnlockingRequirement(null);
foreach($manager->getCraftingRecipeIndex() as $index => $recipe){
if($recipe instanceof ShapelessRecipe){
$typeTag = match($recipe->getType()){
@ -95,6 +97,7 @@ final class CraftingDataCache{
$nullUUID,
$typeTag,
50,
$noUnlockingRequirement,
$index
);
}elseif($recipe instanceof ShapedRecipe){
@ -114,6 +117,7 @@ final class CraftingDataCache{
CraftingRecipeBlockName::CRAFTING_TABLE,
50,
true,
$noUnlockingRequirement,
$index,
);
}else{