PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
ItemStackContainerIdTranslator.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\network\mcpe\handler;
25
29
31
32 private function __construct(){
33 //NOOP
34 }
35
41 public static function translate(int $containerInterfaceId, int $currentWindowId, int $slotId) : array{
42 return match($containerInterfaceId){
43 ContainerUIIds::ARMOR => [ContainerIds::ARMOR, $slotId],
44
45 ContainerUIIds::HOTBAR,
46 ContainerUIIds::INVENTORY,
47 ContainerUIIds::COMBINED_HOTBAR_AND_INVENTORY => [ContainerIds::INVENTORY, $slotId],
48
49 //TODO: HACK! The client sends an incorrect slot ID for the offhand as of 1.19.70 (though this doesn't really matter since the offhand has only 1 slot anyway)
50 ContainerUIIds::OFFHAND => [ContainerIds::OFFHAND, 0],
51
52 ContainerUIIds::ANVIL_INPUT,
53 ContainerUIIds::ANVIL_MATERIAL,
54 ContainerUIIds::BEACON_PAYMENT,
55 ContainerUIIds::CARTOGRAPHY_ADDITIONAL,
56 ContainerUIIds::CARTOGRAPHY_INPUT,
57 ContainerUIIds::COMPOUND_CREATOR_INPUT,
58 ContainerUIIds::CRAFTING_INPUT,
59 ContainerUIIds::CREATED_OUTPUT,
60 ContainerUIIds::CURSOR,
61 ContainerUIIds::ENCHANTING_INPUT,
62 ContainerUIIds::ENCHANTING_MATERIAL,
63 ContainerUIIds::GRINDSTONE_ADDITIONAL,
64 ContainerUIIds::GRINDSTONE_INPUT,
65 ContainerUIIds::LAB_TABLE_INPUT,
66 ContainerUIIds::LOOM_DYE,
67 ContainerUIIds::LOOM_INPUT,
68 ContainerUIIds::LOOM_MATERIAL,
69 ContainerUIIds::MATERIAL_REDUCER_INPUT,
70 ContainerUIIds::MATERIAL_REDUCER_OUTPUT,
71 ContainerUIIds::SMITHING_TABLE_INPUT,
72 ContainerUIIds::SMITHING_TABLE_MATERIAL,
73 ContainerUIIds::SMITHING_TABLE_TEMPLATE,
74 ContainerUIIds::STONECUTTER_INPUT,
75 ContainerUIIds::TRADE2_INGREDIENT1,
76 ContainerUIIds::TRADE2_INGREDIENT2,
77 ContainerUIIds::TRADE_INGREDIENT1,
78 ContainerUIIds::TRADE_INGREDIENT2 => [ContainerIds::UI, $slotId],
79
80 ContainerUIIds::BARREL,
81 ContainerUIIds::BLAST_FURNACE_INGREDIENT,
82 ContainerUIIds::BREWING_STAND_FUEL,
83 ContainerUIIds::BREWING_STAND_INPUT,
84 ContainerUIIds::BREWING_STAND_RESULT,
85 ContainerUIIds::FURNACE_FUEL,
86 ContainerUIIds::FURNACE_INGREDIENT,
87 ContainerUIIds::FURNACE_RESULT,
88 ContainerUIIds::HORSE_EQUIP,
89 ContainerUIIds::LEVEL_ENTITY, //chest
90 ContainerUIIds::SHULKER_BOX,
91 ContainerUIIds::SMOKER_INGREDIENT => [$currentWindowId, $slotId],
92
93 //all preview slots are ignored, since the client shouldn't be modifying those directly
94
95 default => throw new PacketHandlingException("Unexpected container UI ID $containerInterfaceId")
96 };
97 }
98}
static translate(int $containerInterfaceId, int $currentWindowId, int $slotId)