Merge branch 'stable' into minor-next

This commit is contained in:
Dylan K. Taylor 2023-06-13 18:06:06 +01:00
commit a3046eb6fa
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
12 changed files with 43 additions and 30 deletions

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
.github/readme/pocketmine-dark-rgb.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

BIN
.github/readme/pocketmine-rgb.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

View File

@ -53,7 +53,7 @@ jobs:
run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT
- name: Build image for tag - name: Build image for tag
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.0
with: with:
push: true push: true
context: ./pocketmine-mp context: ./pocketmine-mp
@ -66,7 +66,7 @@ jobs:
- name: Build image for major tag - name: Build image for major tag
if: steps.channel.outputs.CHANNEL == 'stable' if: steps.channel.outputs.CHANNEL == 'stable'
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.0
with: with:
push: true push: true
context: ./pocketmine-mp context: ./pocketmine-mp
@ -79,7 +79,7 @@ jobs:
- name: Build image for minor tag - name: Build image for minor tag
if: steps.channel.outputs.CHANNEL == 'stable' if: steps.channel.outputs.CHANNEL == 'stable'
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.0
with: with:
push: true push: true
context: ./pocketmine-mp context: ./pocketmine-mp
@ -92,7 +92,7 @@ jobs:
- name: Build image for latest tag - name: Build image for latest tag
if: steps.channel.outputs.CHANNEL == 'stable' if: steps.channel.outputs.CHANNEL == 'stable'
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.0
with: with:
push: true push: true
context: ./pocketmine-mp context: ./pocketmine-mp

View File

@ -4,8 +4,8 @@
<img src="https://github.com/pmmp/PocketMine-MP/blob/stable/.github/readme/pocketmine.png" alt="The PocketMine-MP logo" title="PocketMine" loading="eager" /> <img src="https://github.com/pmmp/PocketMine-MP/blob/stable/.github/readme/pocketmine.png" alt="The PocketMine-MP logo" title="PocketMine" loading="eager" />
<![endif]--> <![endif]-->
<picture> <picture>
<source srcset="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine-dark.png" media="(prefers-color-scheme: dark)"> <source srcset="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-dark-rgb.gif" media="(prefers-color-scheme: dark)">
<img src="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine.png" loading="eager" /> <img src="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-rgb.gif" loading="eager" />
</picture> </picture>
</a><br> </a><br>
<b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b> <b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b>

@ -1 +1 @@
Subproject commit fcbc15f23e70d01b618cf21d090146e02254e735 Subproject commit 8cb2a2b2181fd42192665985696ea157aa4f731e

24
composer.lock generated
View File

@ -224,16 +224,16 @@
}, },
{ {
"name": "pocketmine/bedrock-data", "name": "pocketmine/bedrock-data",
"version": "2.3.0+bedrock-1.20.0", "version": "2.3.1+bedrock-1.20.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/BedrockData.git", "url": "https://github.com/pmmp/BedrockData.git",
"reference": "b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9" "reference": "fb89ccdc039252462d8d068a769635e24151b7e2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9", "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/fb89ccdc039252462d8d068a769635e24151b7e2",
"reference": "b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9", "reference": "fb89ccdc039252462d8d068a769635e24151b7e2",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -244,9 +244,9 @@
"description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP",
"support": { "support": {
"issues": "https://github.com/pmmp/BedrockData/issues", "issues": "https://github.com/pmmp/BedrockData/issues",
"source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.20.0" "source": "https://github.com/pmmp/BedrockData/tree/2.3.1+bedrock-1.20.0"
}, },
"time": "2023-06-07T19:06:47+00:00" "time": "2023-06-13T16:42:09+00:00"
}, },
{ {
"name": "pocketmine/bedrock-item-upgrade-schema", "name": "pocketmine/bedrock-item-upgrade-schema",
@ -1937,16 +1937,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "10.2.1", "version": "10.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "599b33294350e8f51163119d5670512f98b0490d" "reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/599b33294350e8f51163119d5670512f98b0490d", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1ab521b24b88b88310c40c26c0cc4a94ba40ff95",
"reference": "599b33294350e8f51163119d5670512f98b0490d", "reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2018,7 +2018,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.1" "source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.2"
}, },
"funding": [ "funding": [
{ {
@ -2034,7 +2034,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-06-05T05:15:51+00:00" "time": "2023-06-11T06:15:20+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",

View File

@ -177,6 +177,7 @@ final class ItemSerializer{
throw new ItemTypeSerializeException($e->getMessage(), 0, $e); throw new ItemTypeSerializeException($e->getMessage(), 0, $e);
} }
//TODO: this really ought to throw if there's no blockitem ID
$itemNameId = BlockItemIdMap::getInstance()->lookupItemId($blockStateData->getName()) ?? $blockStateData->getName(); $itemNameId = BlockItemIdMap::getInstance()->lookupItemId($blockStateData->getName()) ?? $blockStateData->getName();
return new Data($itemNameId, 0, $blockStateData); return new Data($itemNameId, 0, $blockStateData);

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\convert; namespace pocketmine\network\mcpe\convert;
use pocketmine\data\bedrock\item\BlockItemIdMap;
use pocketmine\data\bedrock\item\ItemDeserializer; use pocketmine\data\bedrock\item\ItemDeserializer;
use pocketmine\data\bedrock\item\ItemSerializer; use pocketmine\data\bedrock\item\ItemSerializer;
use pocketmine\data\bedrock\item\ItemTypeDeserializeException; use pocketmine\data\bedrock\item\ItemTypeDeserializeException;
@ -37,18 +38,19 @@ use pocketmine\utils\AssumptionFailedError;
* This class handles translation between network item ID+metadata to PocketMine-MP internal ID+metadata and vice versa. * This class handles translation between network item ID+metadata to PocketMine-MP internal ID+metadata and vice versa.
*/ */
final class ItemTranslator{ final class ItemTranslator{
public const NO_BLOCK_RUNTIME_ID = 0; public const NO_BLOCK_RUNTIME_ID = 0; //this is technically a valid block runtime ID, but is used to represent "no block" (derp mojang)
public function __construct( public function __construct(
private ItemTypeDictionary $itemTypeDictionary, private ItemTypeDictionary $itemTypeDictionary,
private BlockStateDictionary $blockStateDictionary, private BlockStateDictionary $blockStateDictionary,
private ItemSerializer $itemSerializer, private ItemSerializer $itemSerializer,
private ItemDeserializer $itemDeserializer private ItemDeserializer $itemDeserializer,
private BlockItemIdMap $blockItemIdMap
){} ){}
/** /**
* @return int[]|null * @return int[]|null
* @phpstan-return array{int, int, int}|null * @phpstan-return array{int, int, ?int}|null
*/ */
public function toNetworkIdQuiet(Item $item) : ?array{ public function toNetworkIdQuiet(Item $item) : ?array{
try{ try{
@ -60,7 +62,7 @@ final class ItemTranslator{
/** /**
* @return int[] * @return int[]
* @phpstan-return array{int, int, int} * @phpstan-return array{int, int, ?int}
* *
* @throws ItemTypeSerializeException * @throws ItemTypeSerializeException
*/ */
@ -78,7 +80,7 @@ final class ItemTranslator{
throw new AssumptionFailedError("Unmapped blockstate returned by blockstate serializer: " . $blockStateData->toNbt()); throw new AssumptionFailedError("Unmapped blockstate returned by blockstate serializer: " . $blockStateData->toNbt());
} }
}else{ }else{
$blockRuntimeId = self::NO_BLOCK_RUNTIME_ID; //this is technically a valid block runtime ID, but is used to represent "no block" (derp mojang) $blockRuntimeId = null;
} }
return [$numericId, $itemData->getMeta(), $blockRuntimeId]; return [$numericId, $itemData->getMeta(), $blockRuntimeId];
@ -106,11 +108,13 @@ final class ItemTranslator{
} }
$blockStateData = null; $blockStateData = null;
if($networkBlockRuntimeId !== self::NO_BLOCK_RUNTIME_ID){ if($this->blockItemIdMap->lookupBlockId($stringId) !== null){
$blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkBlockRuntimeId); $blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkBlockRuntimeId);
if($blockStateData === null){ if($blockStateData === null){
throw new TypeConversionException("Blockstate runtimeID $networkBlockRuntimeId does not correspond to any known blockstate"); throw new TypeConversionException("Blockstate runtimeID $networkBlockRuntimeId does not correspond to any known blockstate");
} }
}elseif($networkBlockRuntimeId !== self::NO_BLOCK_RUNTIME_ID){
throw new TypeConversionException("Item $stringId is not a blockitem, but runtime ID $networkBlockRuntimeId was provided");
} }
try{ try{

View File

@ -82,7 +82,8 @@ class TypeConverter{
$this->itemTypeDictionary, $this->itemTypeDictionary,
$this->blockTranslator->getBlockStateDictionary(), $this->blockTranslator->getBlockStateDictionary(),
GlobalItemDataHandlers::getSerializer(), GlobalItemDataHandlers::getSerializer(),
GlobalItemDataHandlers::getDeserializer() GlobalItemDataHandlers::getDeserializer(),
$this->blockItemIdMap
); );
$this->skinAdapter = new LegacySkinAdapter(); $this->skinAdapter = new LegacySkinAdapter();
@ -147,7 +148,7 @@ class TypeConverter{
}elseif($ingredient instanceof ExactRecipeIngredient){ }elseif($ingredient instanceof ExactRecipeIngredient){
$item = $ingredient->getItem(); $item = $ingredient->getItem();
[$id, $meta, $blockRuntimeId] = $this->itemTranslator->toNetworkId($item); [$id, $meta, $blockRuntimeId] = $this->itemTranslator->toNetworkId($item);
if($blockRuntimeId !== ItemTranslator::NO_BLOCK_RUNTIME_ID){ if($blockRuntimeId !== null){
$meta = $this->blockTranslator->getBlockStateDictionary()->getMetaFromStateId($blockRuntimeId); $meta = $this->blockTranslator->getBlockStateDictionary()->getMetaFromStateId($blockRuntimeId);
if($meta === null){ if($meta === null){
throw new AssumptionFailedError("Every block state should have an associated meta value"); throw new AssumptionFailedError("Every block state should have an associated meta value");
@ -230,7 +231,7 @@ class TypeConverter{
$id, $id,
$meta, $meta,
$itemStack->getCount(), $itemStack->getCount(),
$blockRuntimeId, $blockRuntimeId ?? ItemTranslator::NO_BLOCK_RUNTIME_ID,
$nbt, $nbt,
[], [],
[], [],

View File

@ -33,6 +33,7 @@ use pocketmine\crafting\json\ShapelessRecipeData;
use pocketmine\crafting\json\SmithingTransformRecipeData; use pocketmine\crafting\json\SmithingTransformRecipeData;
use pocketmine\crafting\json\SmithingTrimRecipeData; use pocketmine\crafting\json\SmithingTrimRecipeData;
use pocketmine\data\bedrock\block\BlockStateData; use pocketmine\data\bedrock\block\BlockStateData;
use pocketmine\data\bedrock\item\BlockItemIdMap;
use pocketmine\nbt\LittleEndianNbtSerializer; use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
@ -40,6 +41,7 @@ use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\TreeRoot; use pocketmine\nbt\TreeRoot;
use pocketmine\network\mcpe\convert\BlockStateDictionary; use pocketmine\network\mcpe\convert\BlockStateDictionary;
use pocketmine\network\mcpe\convert\BlockTranslator; use pocketmine\network\mcpe\convert\BlockTranslator;
use pocketmine\network\mcpe\convert\ItemTranslator;
use pocketmine\network\mcpe\handler\PacketHandler; use pocketmine\network\mcpe\handler\PacketHandler;
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket; use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket; use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
@ -110,6 +112,7 @@ class ParserPacketHandler extends PacketHandler{
public ?ItemTypeDictionary $itemTypeDictionary = null; public ?ItemTypeDictionary $itemTypeDictionary = null;
private BlockTranslator $blockTranslator; private BlockTranslator $blockTranslator;
private BlockItemIdMap $blockItemIdMap;
public function __construct(private string $bedrockDataPath){ public function __construct(private string $bedrockDataPath){
$this->blockTranslator = new BlockTranslator( $this->blockTranslator = new BlockTranslator(
@ -119,6 +122,7 @@ class ParserPacketHandler extends PacketHandler{
), ),
GlobalBlockStateHandlers::getSerializer() GlobalBlockStateHandlers::getSerializer()
); );
$this->blockItemIdMap = BlockItemIdMap::getInstance();
} }
private static function blockStatePropertiesToString(BlockStateData $blockStateData) : string{ private static function blockStatePropertiesToString(BlockStateData $blockStateData) : string{
@ -136,7 +140,8 @@ class ParserPacketHandler extends PacketHandler{
if($this->itemTypeDictionary === null){ if($this->itemTypeDictionary === null){
throw new PacketHandlingException("Can't process item yet; haven't received item type dictionary"); throw new PacketHandlingException("Can't process item yet; haven't received item type dictionary");
} }
$data = new ItemStackData($this->itemTypeDictionary->fromIntId($itemStack->getId())); $itemStringId = $this->itemTypeDictionary->fromIntId($itemStack->getId());
$data = new ItemStackData($itemStringId);
if($itemStack->getCount() !== 1){ if($itemStack->getCount() !== 1){
$data->count = $itemStack->getCount(); $data->count = $itemStack->getCount();
@ -146,7 +151,7 @@ class ParserPacketHandler extends PacketHandler{
if($meta === 32767){ if($meta === 32767){
$meta = 0; //kick wildcard magic bullshit $meta = 0; //kick wildcard magic bullshit
} }
if($itemStack->getBlockRuntimeId() !== 0){ if($this->blockItemIdMap->lookupBlockId($itemStringId) !== null){
if($meta !== 0){ if($meta !== 0){
throw new PacketHandlingException("Unexpected non-zero blockitem meta"); throw new PacketHandlingException("Unexpected non-zero blockitem meta");
} }
@ -159,6 +164,8 @@ class ParserPacketHandler extends PacketHandler{
if(count($stateProperties) > 0){ if(count($stateProperties) > 0){
$data->block_states = self::blockStatePropertiesToString($blockState); $data->block_states = self::blockStatePropertiesToString($blockState);
} }
}elseif($itemStack->getBlockRuntimeId() !== ItemTranslator::NO_BLOCK_RUNTIME_ID){
throw new PacketHandlingException("Non-blockitems should have a zero block runtime ID");
}elseif($meta !== 0){ }elseif($meta !== 0){
$data->meta = $meta; $data->meta = $meta;
} }