mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Fixed handling of fake requests during block placement and other actions
This commit is contained in:
90
src/network/mcpe/handler/ItemStackContainerIdTranslator.php
Normal file
90
src/network/mcpe/handler/ItemStackContainerIdTranslator.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?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\handler;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerUIIds;
|
||||
use pocketmine\network\PacketHandlingException;
|
||||
|
||||
final class ItemStackContainerIdTranslator{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public static function translate(int $containerInterfaceId, int $currentWindowId) : int{
|
||||
return match($containerInterfaceId){
|
||||
ContainerUIIds::ARMOR => ContainerIds::ARMOR,
|
||||
|
||||
ContainerUIIds::HOTBAR,
|
||||
ContainerUIIds::INVENTORY,
|
||||
ContainerUIIds::COMBINED_HOTBAR_AND_INVENTORY => ContainerIds::INVENTORY,
|
||||
|
||||
ContainerUIIds::OFFHAND => ContainerIds::OFFHAND,
|
||||
|
||||
ContainerUIIds::ANVIL_INPUT,
|
||||
ContainerUIIds::ANVIL_MATERIAL,
|
||||
ContainerUIIds::BEACON_PAYMENT,
|
||||
ContainerUIIds::CARTOGRAPHY_ADDITIONAL,
|
||||
ContainerUIIds::CARTOGRAPHY_INPUT,
|
||||
ContainerUIIds::COMPOUND_CREATOR_INPUT,
|
||||
ContainerUIIds::CRAFTING_INPUT,
|
||||
ContainerUIIds::CREATED_OUTPUT,
|
||||
ContainerUIIds::CURSOR,
|
||||
ContainerUIIds::ENCHANTING_INPUT,
|
||||
ContainerUIIds::ENCHANTING_MATERIAL,
|
||||
ContainerUIIds::GRINDSTONE_ADDITIONAL,
|
||||
ContainerUIIds::GRINDSTONE_INPUT,
|
||||
ContainerUIIds::LAB_TABLE_INPUT,
|
||||
ContainerUIIds::LOOM_DYE,
|
||||
ContainerUIIds::LOOM_INPUT,
|
||||
ContainerUIIds::LOOM_MATERIAL,
|
||||
ContainerUIIds::MATERIAL_REDUCER_INPUT,
|
||||
ContainerUIIds::MATERIAL_REDUCER_OUTPUT,
|
||||
ContainerUIIds::SMITHING_TABLE_INPUT,
|
||||
ContainerUIIds::SMITHING_TABLE_MATERIAL,
|
||||
ContainerUIIds::STONECUTTER_INPUT,
|
||||
ContainerUIIds::TRADE2_INGREDIENT1,
|
||||
ContainerUIIds::TRADE2_INGREDIENT2,
|
||||
ContainerUIIds::TRADE_INGREDIENT1,
|
||||
ContainerUIIds::TRADE_INGREDIENT2 => ContainerIds::UI,
|
||||
|
||||
ContainerUIIds::BARREL,
|
||||
ContainerUIIds::BLAST_FURNACE_INGREDIENT,
|
||||
ContainerUIIds::BREWING_STAND_FUEL,
|
||||
ContainerUIIds::BREWING_STAND_INPUT,
|
||||
ContainerUIIds::BREWING_STAND_RESULT,
|
||||
ContainerUIIds::FURNACE_FUEL,
|
||||
ContainerUIIds::FURNACE_INGREDIENT,
|
||||
ContainerUIIds::FURNACE_RESULT,
|
||||
ContainerUIIds::LEVEL_ENTITY, //chest
|
||||
ContainerUIIds::SHULKER_BOX,
|
||||
ContainerUIIds::SMOKER_INGREDIENT => $currentWindowId,
|
||||
|
||||
//all preview slots are ignored, since the client shouldn't be modifying those directly
|
||||
|
||||
default => throw new PacketHandlingException("Unexpected container UI ID $containerInterfaceId")
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user