mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Merge commit '8ce0022de'
# Conflicts: # resources/vanilla # src/network/mcpe/protocol/types/inventory/NetworkInventoryAction.php
This commit is contained in:
commit
c35a596079
@ -38,11 +38,13 @@ use pocketmine\network\mcpe\protocol\types\GameMode as ProtocolGameMode;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\NetworkInventoryAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UIInventorySlotOffset;
|
||||
use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient;
|
||||
use pocketmine\player\GameMode;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use function array_key_exists;
|
||||
|
||||
class TypeConverter{
|
||||
use SingletonTrait;
|
||||
@ -168,21 +170,21 @@ class TypeConverter{
|
||||
switch($action->sourceType){
|
||||
case NetworkInventoryAction::SOURCE_CONTAINER:
|
||||
if($action->windowId === ContainerIds::UI and $action->inventorySlot > 0){
|
||||
if($action->inventorySlot === 50){
|
||||
if($action->inventorySlot === UIInventorySlotOffset::CREATED_ITEM_OUTPUT){
|
||||
return null; //useless noise
|
||||
}
|
||||
if($action->inventorySlot >= 28 and $action->inventorySlot <= 31){
|
||||
if(array_key_exists($action->inventorySlot, UIInventorySlotOffset::CRAFTING2X2_INPUT)){
|
||||
$window = $player->getCraftingGrid();
|
||||
if($window->getGridWidth() !== CraftingGrid::SIZE_SMALL){
|
||||
throw new \UnexpectedValueException("Expected small crafting grid");
|
||||
}
|
||||
$slot = $action->inventorySlot - 28;
|
||||
}elseif($action->inventorySlot >= 32 and $action->inventorySlot <= 40){
|
||||
$slot = UIInventorySlotOffset::CRAFTING2X2_INPUT[$action->inventorySlot];
|
||||
}elseif(array_key_exists($action->inventorySlot, UIInventorySlotOffset::CRAFTING3X3_INPUT)){
|
||||
$window = $player->getCraftingGrid();
|
||||
if($window->getGridWidth() !== CraftingGrid::SIZE_BIG){
|
||||
throw new \UnexpectedValueException("Expected big crafting grid");
|
||||
}
|
||||
$slot = $action->inventorySlot - 32;
|
||||
$slot = UIInventorySlotOffset::CRAFTING3X3_INPUT[$action->inventorySlot];
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unhandled magic UI slot offset $action->inventorySlot");
|
||||
}
|
||||
@ -225,4 +227,4 @@ class TypeConverter{
|
||||
throw new \UnexpectedValueException("Unknown inventory source type $action->sourceType");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types\inventory;
|
||||
|
||||
final class UIInventorySlotOffset{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const CURSOR = 0;
|
||||
public const ANVIL = [
|
||||
1 => 0,
|
||||
2 => 1,
|
||||
];
|
||||
public const STONE_CUTTER_INPUT = 3;
|
||||
public const TRADE2_INGREDIENT = [
|
||||
4 => 0,
|
||||
5 => 1,
|
||||
];
|
||||
public const TRADE_INGREDIENT = [
|
||||
6 => 0,
|
||||
7 => 1,
|
||||
];
|
||||
public const MATERIAL_REDUCER_INPUT = 8;
|
||||
public const LOOM = [
|
||||
9 => 0,
|
||||
10 => 1,
|
||||
11 => 2,
|
||||
];
|
||||
public const CARTOGRAPHY_TABLE = [
|
||||
12 => 0,
|
||||
13 => 1,
|
||||
];
|
||||
public const ENCHANTING_TABLE = [
|
||||
14 => 0,
|
||||
15 => 1,
|
||||
];
|
||||
public const GRINDSTONE = [
|
||||
16 => 0,
|
||||
17 => 1,
|
||||
];
|
||||
public const COMPOUND_CREATOR_INPUT = [
|
||||
18 => 0,
|
||||
19 => 1,
|
||||
20 => 2,
|
||||
21 => 3,
|
||||
22 => 4,
|
||||
23 => 5,
|
||||
24 => 6,
|
||||
25 => 7,
|
||||
26 => 8,
|
||||
];
|
||||
public const BEACON_PAYMENT = 27;
|
||||
public const CRAFTING2X2_INPUT = [
|
||||
28 => 0,
|
||||
29 => 1,
|
||||
30 => 2,
|
||||
31 => 3,
|
||||
];
|
||||
public const CRAFTING3X3_INPUT = [
|
||||
32 => 0,
|
||||
33 => 1,
|
||||
34 => 2,
|
||||
35 => 3,
|
||||
36 => 4,
|
||||
37 => 5,
|
||||
38 => 6,
|
||||
39 => 7,
|
||||
40 => 8,
|
||||
];
|
||||
public const MATERIAL_REDUCER_OUTPUT = [
|
||||
41 => 0,
|
||||
42 => 1,
|
||||
43 => 2,
|
||||
44 => 3,
|
||||
45 => 4,
|
||||
46 => 5,
|
||||
47 => 6,
|
||||
48 => 7,
|
||||
49 => 8,
|
||||
];
|
||||
public const CREATED_ITEM_OUTPUT = 50;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user