Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"adhocore/json-comment": "~1.2.0",
"netresearch/jsonmapper": "~v5.0.0",
"pocketmine/bedrock-block-upgrade-schema": "~5.1.0+bedrock-1.21.60",
"pocketmine/bedrock-data": "~4.1.0+bedrock-1.21.70",
"pocketmine/bedrock-data": "dev-feature/1.21.80",
"pocketmine/bedrock-item-upgrade-schema": "~1.14.0+bedrock-1.21.50",
"pocketmine/bedrock-protocol": "~37.0.0+bedrock-1.21.70",
"pocketmine/bedrock-protocol": "dev-bedrock-1.21.80",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/color": "^0.3.0",
Expand Down
31 changes: 17 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/data/bedrock/BedrockDataFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ private function __construct(){
}

public const BANNER_PATTERNS_JSON = BEDROCK_DATA_PATH . '/banner_patterns.json';
public const BIOME_DEFINITIONS_NBT = BEDROCK_DATA_PATH . '/biome_definitions.nbt';
public const BIOME_DEFINITIONS_FULL_NBT = BEDROCK_DATA_PATH . '/biome_definitions_full.nbt';
public const BIOME_DEFINITIONS_JSON = BEDROCK_DATA_PATH . '/biome_definitions.json';
public const BIOME_ID_MAP_JSON = BEDROCK_DATA_PATH . '/biome_id_map.json';
public const BLOCK_ID_TO_ITEM_ID_MAP_JSON = BEDROCK_DATA_PATH . '/block_id_to_item_id_map.json';
public const BLOCK_PROPERTIES_TABLE_JSON = BEDROCK_DATA_PATH . '/block_properties_table.json';
Expand Down
4 changes: 2 additions & 2 deletions src/data/bedrock/block/BlockStateData.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ final class BlockStateData{
public const CURRENT_VERSION =
(1 << 24) | //major
(21 << 16) | //minor
(70 << 8) | //patch
(1); //revision
(60 << 8) | //patch
(33); //revision

public const TAG_NAME = "name";
public const TAG_STATES = "states";
Expand Down
1 change: 1 addition & 0 deletions src/data/bedrock/block/BlockStateNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private function __construct(){
public const RAIL_DATA_BIT = "rail_data_bit";
public const RAIL_DIRECTION = "rail_direction";
public const REDSTONE_SIGNAL = "redstone_signal";
public const REHYDRATION_LEVEL = "rehydration_level";
public const REPEATER_DELAY = "repeater_delay";
public const RESPAWN_ANCHOR_CHARGE = "respawn_anchor_charge";
public const ROTATION = "rotation";
Expand Down
1 change: 1 addition & 0 deletions src/data/bedrock/block/BlockTypeNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ private function __construct(){
public const DOUBLE_CUT_COPPER_SLAB = "minecraft:double_cut_copper_slab";
public const DRAGON_EGG = "minecraft:dragon_egg";
public const DRAGON_HEAD = "minecraft:dragon_head";
public const DRIED_GHAST = "minecraft:dried_ghast";
public const DRIED_KELP_BLOCK = "minecraft:dried_kelp_block";
public const DRIPSTONE_BLOCK = "minecraft:dripstone_block";
public const DROPPER = "minecraft:dropper";
Expand Down
17 changes: 17 additions & 0 deletions src/data/bedrock/item/ItemTypeNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ final class ItemTypeNames{
public const BIRCH_SIGN = "minecraft:birch_sign";
public const BLACK_BUNDLE = "minecraft:black_bundle";
public const BLACK_DYE = "minecraft:black_dye";
public const BLACK_HARNESS = "minecraft:black_harness";
public const BLADE_POTTERY_SHERD = "minecraft:blade_pottery_sherd";
public const BLAZE_POWDER = "minecraft:blaze_powder";
public const BLAZE_ROD = "minecraft:blaze_rod";
Expand All @@ -76,6 +77,7 @@ final class ItemTypeNames{
public const BLUE_BUNDLE = "minecraft:blue_bundle";
public const BLUE_DYE = "minecraft:blue_dye";
public const BLUE_EGG = "minecraft:blue_egg";
public const BLUE_HARNESS = "minecraft:blue_harness";
public const BOARD = "minecraft:board";
public const BOAT = "minecraft:boat";
public const BOGGED_SPAWN_EGG = "minecraft:bogged_spawn_egg";
Expand All @@ -95,6 +97,7 @@ final class ItemTypeNames{
public const BROWN_BUNDLE = "minecraft:brown_bundle";
public const BROWN_DYE = "minecraft:brown_dye";
public const BROWN_EGG = "minecraft:brown_egg";
public const BROWN_HARNESS = "minecraft:brown_harness";
public const BRUSH = "minecraft:brush";
public const BUCKET = "minecraft:bucket";
public const BUNDLE = "minecraft:bundle";
Expand Down Expand Up @@ -166,6 +169,7 @@ final class ItemTypeNames{
public const CROSSBOW = "minecraft:crossbow";
public const CYAN_BUNDLE = "minecraft:cyan_bundle";
public const CYAN_DYE = "minecraft:cyan_dye";
public const CYAN_HARNESS = "minecraft:cyan_harness";
public const DANGER_POTTERY_SHERD = "minecraft:danger_pottery_sherd";
public const DARK_OAK_BOAT = "minecraft:dark_oak_boat";
public const DARK_OAK_CHEST_BOAT = "minecraft:dark_oak_chest_boat";
Expand Down Expand Up @@ -265,12 +269,15 @@ final class ItemTypeNames{
public const GOLDEN_SWORD = "minecraft:golden_sword";
public const GRAY_BUNDLE = "minecraft:gray_bundle";
public const GRAY_DYE = "minecraft:gray_dye";
public const GRAY_HARNESS = "minecraft:gray_harness";
public const GREEN_BUNDLE = "minecraft:green_bundle";
public const GREEN_DYE = "minecraft:green_dye";
public const GREEN_HARNESS = "minecraft:green_harness";
public const GUARDIAN_SPAWN_EGG = "minecraft:guardian_spawn_egg";
public const GUNPOWDER = "minecraft:gunpowder";
public const GUSTER_BANNER_PATTERN = "minecraft:guster_banner_pattern";
public const GUSTER_POTTERY_SHERD = "minecraft:guster_pottery_sherd";
public const HAPPY_GHAST_SPAWN_EGG = "minecraft:happy_ghast_spawn_egg";
public const HARD_STAINED_GLASS = "minecraft:hard_stained_glass";
public const HARD_STAINED_GLASS_PANE = "minecraft:hard_stained_glass_pane";
public const HEART_OF_THE_SEA = "minecraft:heart_of_the_sea";
Expand Down Expand Up @@ -321,10 +328,13 @@ final class ItemTypeNames{
public const LIGHT_BLOCK = "minecraft:light_block";
public const LIGHT_BLUE_BUNDLE = "minecraft:light_blue_bundle";
public const LIGHT_BLUE_DYE = "minecraft:light_blue_dye";
public const LIGHT_BLUE_HARNESS = "minecraft:light_blue_harness";
public const LIGHT_GRAY_BUNDLE = "minecraft:light_gray_bundle";
public const LIGHT_GRAY_DYE = "minecraft:light_gray_dye";
public const LIGHT_GRAY_HARNESS = "minecraft:light_gray_harness";
public const LIME_BUNDLE = "minecraft:lime_bundle";
public const LIME_DYE = "minecraft:lime_dye";
public const LIME_HARNESS = "minecraft:lime_harness";
public const LINGERING_POTION = "minecraft:lingering_potion";
public const LLAMA_SPAWN_EGG = "minecraft:llama_spawn_egg";
public const LODESTONE_COMPASS = "minecraft:lodestone_compass";
Expand All @@ -333,6 +343,7 @@ final class ItemTypeNames{
public const MACE = "minecraft:mace";
public const MAGENTA_BUNDLE = "minecraft:magenta_bundle";
public const MAGENTA_DYE = "minecraft:magenta_dye";
public const MAGENTA_HARNESS = "minecraft:magenta_harness";
public const MAGMA_CREAM = "minecraft:magma_cream";
public const MAGMA_CUBE_SPAWN_EGG = "minecraft:magma_cube_spawn_egg";
public const MANGROVE_BOAT = "minecraft:mangrove_boat";
Expand Down Expand Up @@ -400,6 +411,7 @@ final class ItemTypeNames{
public const OMINOUS_TRIAL_KEY = "minecraft:ominous_trial_key";
public const ORANGE_BUNDLE = "minecraft:orange_bundle";
public const ORANGE_DYE = "minecraft:orange_dye";
public const ORANGE_HARNESS = "minecraft:orange_harness";
public const OXIDIZED_COPPER_DOOR = "minecraft:oxidized_copper_door";
public const PAINTING = "minecraft:painting";
public const PALE_OAK_BOAT = "minecraft:pale_oak_boat";
Expand All @@ -419,6 +431,7 @@ final class ItemTypeNames{
public const PILLAGER_SPAWN_EGG = "minecraft:pillager_spawn_egg";
public const PINK_BUNDLE = "minecraft:pink_bundle";
public const PINK_DYE = "minecraft:pink_dye";
public const PINK_HARNESS = "minecraft:pink_harness";
public const PITCHER_POD = "minecraft:pitcher_pod";
public const PLANKS = "minecraft:planks";
public const PLENTY_POTTERY_SHERD = "minecraft:plenty_pottery_sherd";
Expand All @@ -439,6 +452,7 @@ final class ItemTypeNames{
public const PUMPKIN_SEEDS = "minecraft:pumpkin_seeds";
public const PURPLE_BUNDLE = "minecraft:purple_bundle";
public const PURPLE_DYE = "minecraft:purple_dye";
public const PURPLE_HARNESS = "minecraft:purple_harness";
public const QUARTZ = "minecraft:quartz";
public const RABBIT = "minecraft:rabbit";
public const RABBIT_FOOT = "minecraft:rabbit_foot";
Expand All @@ -455,6 +469,7 @@ final class ItemTypeNames{
public const RED_BUNDLE = "minecraft:red_bundle";
public const RED_DYE = "minecraft:red_dye";
public const RED_FLOWER = "minecraft:red_flower";
public const RED_HARNESS = "minecraft:red_harness";
public const REDSTONE = "minecraft:redstone";
public const REPEATER = "minecraft:repeater";
public const RESIN_BRICK = "minecraft:resin_brick";
Expand Down Expand Up @@ -563,6 +578,7 @@ final class ItemTypeNames{
public const WHEAT_SEEDS = "minecraft:wheat_seeds";
public const WHITE_BUNDLE = "minecraft:white_bundle";
public const WHITE_DYE = "minecraft:white_dye";
public const WHITE_HARNESS = "minecraft:white_harness";
public const WILD_ARMOR_TRIM_SMITHING_TEMPLATE = "minecraft:wild_armor_trim_smithing_template";
public const WIND_CHARGE = "minecraft:wind_charge";
public const WITCH_SPAWN_EGG = "minecraft:witch_spawn_egg";
Expand All @@ -583,6 +599,7 @@ final class ItemTypeNames{
public const WRITTEN_BOOK = "minecraft:written_book";
public const YELLOW_BUNDLE = "minecraft:yellow_bundle";
public const YELLOW_DYE = "minecraft:yellow_dye";
public const YELLOW_HARNESS = "minecraft:yellow_harness";
public const ZOGLIN_SPAWN_EGG = "minecraft:zoglin_spawn_egg";
public const ZOMBIE_HORSE_SPAWN_EGG = "minecraft:zombie_horse_spawn_egg";
public const ZOMBIE_PIGMAN_SPAWN_EGG = "minecraft:zombie_pigman_spawn_egg";
Expand Down
64 changes: 63 additions & 1 deletion src/network/mcpe/cache/StaticPacketCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@

namespace pocketmine\network\mcpe\cache;

use pocketmine\color\Color;
use pocketmine\data\bedrock\BedrockDataFiles;
use pocketmine\data\SavedDataLoadingException;
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer;
use pocketmine\network\mcpe\protocol\types\biome\BiomeDefinitionEntry;
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
use pocketmine\utils\Filesystem;
use pocketmine\utils\SingletonTrait;
use pocketmine\utils\Utils;
use pocketmine\world\biome\model\BiomeDefinitionEntryData;
use function count;
use function get_debug_type;
use function is_array;
use function is_object;
use function json_decode;

class StaticPacketCache{
use SingletonTrait;
Expand All @@ -41,9 +51,61 @@ private static function loadCompoundFromFile(string $filePath) : CacheableNbt{
return new CacheableNbt((new NetworkNbtSerializer())->read(Filesystem::fileGetContents($filePath))->mustGetCompoundTag());
}

/**
* @return list<BiomeDefinitionEntry>
*/
private static function loadBiomeDefinitionModel(string $filePath) : array{
$biomeEntries = json_decode(Filesystem::fileGetContents($filePath), associative: true);
if(!is_array($biomeEntries)){
throw new SavedDataLoadingException("$filePath root should be an array, got " . get_debug_type($biomeEntries));
}

$jsonMapper = new \JsonMapper();
$jsonMapper->bExceptionOnMissingData = true;
$jsonMapper->bStrictObjectTypeChecking = true;
$jsonMapper->bEnforceMapType = false;

$entries = [];
foreach(Utils::promoteKeys($biomeEntries) as $biomeName => $entry){
if(!is_array($entry)){
throw new SavedDataLoadingException("$filePath should be an array of objects, got " . get_debug_type($entry));
}

try{
$biomeDefinition = $jsonMapper->map($entry, new BiomeDefinitionEntryData());

$mapWaterColour = $biomeDefinition->mapWaterColour;
$entries[] = new BiomeDefinitionEntry(
(string) $biomeName,
$biomeDefinition->id,
$biomeDefinition->temperature,
$biomeDefinition->downfall,
$biomeDefinition->redSporeDensity,
$biomeDefinition->blueSporeDensity,
$biomeDefinition->ashDensity,
$biomeDefinition->whiteAshDensity,
$biomeDefinition->depth,
$biomeDefinition->scale,
new Color(
$mapWaterColour->r,
$mapWaterColour->g,
$mapWaterColour->b,
$mapWaterColour->a
),
$biomeDefinition->rain,
count($biomeDefinition->tags) > 0 ? $biomeDefinition->tags : null,
);
}catch(\JsonMapper_Exception $e){
throw new \RuntimeException($e->getMessage(), 0, $e);
}
}

return $entries;
}

private static function make() : self{
return new self(
BiomeDefinitionListPacket::create(self::loadCompoundFromFile(BedrockDataFiles::BIOME_DEFINITIONS_NBT)),
BiomeDefinitionListPacket::create(self::loadBiomeDefinitionModel(BedrockDataFiles::BIOME_DEFINITIONS_JSON)),
AvailableActorIdentifiersPacket::create(self::loadCompoundFromFile(BedrockDataFiles::ENTITY_IDENTIFIERS_NBT))
);
}
Expand Down
5 changes: 0 additions & 5 deletions src/network/mcpe/handler/InGamePacketHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket;
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
use pocketmine\network\mcpe\protocol\serializer\BitSet;
Expand Down Expand Up @@ -781,10 +780,6 @@ public function handleBlockActorData(BlockActorDataPacket $packet) : bool{
return false;
}

public function handlePlayerInput(PlayerInputPacket $packet) : bool{
return false; //TODO
}

public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
$gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
if($gameMode !== $this->player->getGamemode()){
Expand Down
Loading
Loading