PocketMine-MP 5.37.1 git-da6732df2656426fbd1b7898ed06c8286969d2f1
Loading...
Searching...
No Matches
pocketmine\network\mcpe\convert\TypeConverter Class Reference
+ Collaboration diagram for pocketmine\network\mcpe\convert\TypeConverter:

Public Member Functions

 coreGameModeToProtocol (GameMode $gamemode)
 
 coreItemStackToNet (Item $itemStack)
 
 coreRecipeIngredientToNet (?RecipeIngredient $ingredient)
 
 deserializeItemStackExtraData (string $extraData, int $id)
 
 getBlockTranslator ()
 
 getItemTranslator ()
 
 getItemTypeDictionary ()
 
 getSkinAdapter ()
 
 netItemStackToCore (ItemStack $itemStack)
 
 netRecipeIngredientToCore (ProtocolRecipeIngredient $ingredient)
 
 protocolGameModeToCore (int $gameMode)
 
 setSkinAdapter (SkinAdapter $skinAdapter)
 

Protected Member Functions

 cleanupUnnecessaryItemNBT (CompoundTag $original)
 
 hashNBT (Tag $tag)
 
 stripBlockEntityNBT (CompoundTag $tag)
 
 stripContainedItemNonVisualNBT (CompoundTag $tag)
 

Detailed Description

Definition at line 66 of file TypeConverter.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\network\mcpe\convert\TypeConverter::__construct ( )

Definition at line 82 of file TypeConverter.php.

Member Function Documentation

◆ cleanupUnnecessaryItemNBT()

pocketmine\network\mcpe\convert\TypeConverter::cleanupUnnecessaryItemNBT ( CompoundTag $original)
protected

TODO: HACK! Creates a copy of an item's NBT with non-viewable data stripped. This is a pretty yucky hack that's mainly needed because of inventories inside blockitems containing blockentity data. There isn't really a good way to deal with this due to the way tiles currently require a position, otherwise we could just keep a copy of the tile context and ask it for persistent vs network NBT as needed. Unfortunately, making this nice will require significant BC breaks, so this will have to do for now.

Definition at line 273 of file TypeConverter.php.

◆ coreGameModeToProtocol()

pocketmine\network\mcpe\convert\TypeConverter::coreGameModeToProtocol ( GameMode $gamemode)

Returns a client-friendly gamemode of the specified real gamemode This function takes care of handling gamemodes known to MCPE (as of 1.1.0.3, that includes Survival, Creative and Adventure)

Definition at line 125 of file TypeConverter.php.

◆ coreItemStackToNet()

pocketmine\network\mcpe\convert\TypeConverter::coreItemStackToNet ( Item $itemStack)

Definition at line 289 of file TypeConverter.php.

◆ coreRecipeIngredientToNet()

pocketmine\network\mcpe\convert\TypeConverter::coreRecipeIngredientToNet ( ?RecipeIngredient $ingredient)

Definition at line 145 of file TypeConverter.php.

◆ deserializeItemStackExtraData()

pocketmine\network\mcpe\convert\TypeConverter::deserializeItemStackExtraData ( string $extraData,
int $id )

Definition at line 362 of file TypeConverter.php.

◆ getBlockTranslator()

pocketmine\network\mcpe\convert\TypeConverter::getBlockTranslator ( )

Definition at line 107 of file TypeConverter.php.

◆ getItemTranslator()

pocketmine\network\mcpe\convert\TypeConverter::getItemTranslator ( )

Definition at line 111 of file TypeConverter.php.

◆ getItemTypeDictionary()

pocketmine\network\mcpe\convert\TypeConverter::getItemTypeDictionary ( )

Definition at line 109 of file TypeConverter.php.

◆ getSkinAdapter()

pocketmine\network\mcpe\convert\TypeConverter::getSkinAdapter ( )

Definition at line 113 of file TypeConverter.php.

◆ hashNBT()

pocketmine\network\mcpe\convert\TypeConverter::hashNBT ( Tag $tag)
protected

Computes a hash of an item's server-side NBT. This is baked into an item's network NBT to make sure the client doesn't try to stack items with the same network NBT but different server-side NBT.

Definition at line 260 of file TypeConverter.php.

◆ netItemStackToCore()

pocketmine\network\mcpe\convert\TypeConverter::netItemStackToCore ( ItemStack $itemStack)

WARNING: Avoid this in server-side code. If you need to compare ItemStacks provided by the client to the server, prefer encoding the server's itemstack and comparing the serialized ItemStack, instead of converting the client's ItemStack to a core Item. This method will fully decode the item's extra data, which can be very costly if the item has a lot of NBT data.

Exceptions
TypeConversionException

Definition at line 336 of file TypeConverter.php.

◆ netRecipeIngredientToCore()

pocketmine\network\mcpe\convert\TypeConverter::netRecipeIngredientToCore ( ProtocolRecipeIngredient $ingredient)

Definition at line 172 of file TypeConverter.php.

◆ protocolGameModeToCore()

pocketmine\network\mcpe\convert\TypeConverter::protocolGameModeToCore ( int $gameMode)

Definition at line 134 of file TypeConverter.php.

◆ setSkinAdapter()

pocketmine\network\mcpe\convert\TypeConverter::setSkinAdapter ( SkinAdapter $skinAdapter)

Definition at line 115 of file TypeConverter.php.

◆ stripBlockEntityNBT()

pocketmine\network\mcpe\convert\TypeConverter::stripBlockEntityNBT ( CompoundTag $tag)
protected

Strips unnecessary block actor NBT from items that have it. This tag can potentially be extremely large, and is not read by the client anyway.

Definition at line 215 of file TypeConverter.php.

References pocketmine\nbt\tag\CompoundTag\removeTag().

+ Here is the call graph for this function:

◆ stripContainedItemNonVisualNBT()

pocketmine\network\mcpe\convert\TypeConverter::stripContainedItemNonVisualNBT ( CompoundTag $tag)
protected

Strips non-viewable data from shulker boxes and similar blocks The lore for shulker boxes only requires knowing the type & count of items and possibly custom name We don't need to, and should not allow, sending nested inventories across the network.

Definition at line 229 of file TypeConverter.php.


The documentation for this class was generated from the following file: