mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Merge branch 'stable' into minor-next
This commit is contained in:
commit
a3046eb6fa
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
.github/readme/pocketmine-dark-rgb.gif
vendored
Normal file
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
BIN
.github/readme/pocketmine-rgb.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 173 KiB |
8
.github/workflows/build-docker-image.yml
vendored
8
.github/workflows/build-docker-image.yml
vendored
@ -53,7 +53,7 @@ jobs:
|
||||
run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build image for tag
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v4.1.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
|
||||
- name: Build image for major tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v4.1.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
|
||||
- name: Build image for minor tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v4.1.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -92,7 +92,7 @@ jobs:
|
||||
|
||||
- name: Build image for latest tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v4.0.0
|
||||
uses: docker/build-push-action@v4.1.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
|
@ -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" />
|
||||
<![endif]-->
|
||||
<picture>
|
||||
<source srcset="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine-dark.png" media="(prefers-color-scheme: dark)">
|
||||
<img src="https://github.com/pmmp/PocketMine-MP/raw/stable/.github/readme/pocketmine.png" loading="eager" />
|
||||
<source srcset="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-dark-rgb.gif" media="(prefers-color-scheme: dark)">
|
||||
<img src="https://raw.githubusercontent.com/pmmp/PocketMine-MP/stable/.github/readme/pocketmine-rgb.gif" loading="eager" />
|
||||
</picture>
|
||||
</a><br>
|
||||
<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
24
composer.lock
generated
@ -224,16 +224,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-data",
|
||||
"version": "2.3.0+bedrock-1.20.0",
|
||||
"version": "2.3.1+bedrock-1.20.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockData.git",
|
||||
"reference": "b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9"
|
||||
"reference": "fb89ccdc039252462d8d068a769635e24151b7e2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9",
|
||||
"reference": "b3dd3f4b8e3b6759c5d84de6ec85bb20b668c3a9",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/fb89ccdc039252462d8d068a769635e24151b7e2",
|
||||
"reference": "fb89ccdc039252462d8d068a769635e24151b7e2",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
@ -244,9 +244,9 @@
|
||||
"description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP",
|
||||
"support": {
|
||||
"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",
|
||||
@ -1937,16 +1937,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "10.2.1",
|
||||
"version": "10.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "599b33294350e8f51163119d5670512f98b0490d"
|
||||
"reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/599b33294350e8f51163119d5670512f98b0490d",
|
||||
"reference": "599b33294350e8f51163119d5670512f98b0490d",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1ab521b24b88b88310c40c26c0cc4a94ba40ff95",
|
||||
"reference": "1ab521b24b88b88310c40c26c0cc4a94ba40ff95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2018,7 +2018,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"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": [
|
||||
{
|
||||
@ -2034,7 +2034,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-06-05T05:15:51+00:00"
|
||||
"time": "2023-06-11T06:15:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
@ -177,6 +177,7 @@ final class ItemSerializer{
|
||||
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();
|
||||
|
||||
return new Data($itemNameId, 0, $blockStateData);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\convert;
|
||||
|
||||
use pocketmine\data\bedrock\item\BlockItemIdMap;
|
||||
use pocketmine\data\bedrock\item\ItemDeserializer;
|
||||
use pocketmine\data\bedrock\item\ItemSerializer;
|
||||
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.
|
||||
*/
|
||||
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(
|
||||
private ItemTypeDictionary $itemTypeDictionary,
|
||||
private BlockStateDictionary $blockStateDictionary,
|
||||
private ItemSerializer $itemSerializer,
|
||||
private ItemDeserializer $itemDeserializer
|
||||
private ItemDeserializer $itemDeserializer,
|
||||
private BlockItemIdMap $blockItemIdMap
|
||||
){}
|
||||
|
||||
/**
|
||||
* @return int[]|null
|
||||
* @phpstan-return array{int, int, int}|null
|
||||
* @phpstan-return array{int, int, ?int}|null
|
||||
*/
|
||||
public function toNetworkIdQuiet(Item $item) : ?array{
|
||||
try{
|
||||
@ -60,7 +62,7 @@ final class ItemTranslator{
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @phpstan-return array{int, int, int}
|
||||
* @phpstan-return array{int, int, ?int}
|
||||
*
|
||||
* @throws ItemTypeSerializeException
|
||||
*/
|
||||
@ -78,7 +80,7 @@ final class ItemTranslator{
|
||||
throw new AssumptionFailedError("Unmapped blockstate returned by blockstate serializer: " . $blockStateData->toNbt());
|
||||
}
|
||||
}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];
|
||||
@ -106,11 +108,13 @@ final class ItemTranslator{
|
||||
}
|
||||
|
||||
$blockStateData = null;
|
||||
if($networkBlockRuntimeId !== self::NO_BLOCK_RUNTIME_ID){
|
||||
if($this->blockItemIdMap->lookupBlockId($stringId) !== null){
|
||||
$blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkBlockRuntimeId);
|
||||
if($blockStateData === null){
|
||||
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{
|
||||
|
@ -82,7 +82,8 @@ class TypeConverter{
|
||||
$this->itemTypeDictionary,
|
||||
$this->blockTranslator->getBlockStateDictionary(),
|
||||
GlobalItemDataHandlers::getSerializer(),
|
||||
GlobalItemDataHandlers::getDeserializer()
|
||||
GlobalItemDataHandlers::getDeserializer(),
|
||||
$this->blockItemIdMap
|
||||
);
|
||||
|
||||
$this->skinAdapter = new LegacySkinAdapter();
|
||||
@ -147,7 +148,7 @@ class TypeConverter{
|
||||
}elseif($ingredient instanceof ExactRecipeIngredient){
|
||||
$item = $ingredient->getItem();
|
||||
[$id, $meta, $blockRuntimeId] = $this->itemTranslator->toNetworkId($item);
|
||||
if($blockRuntimeId !== ItemTranslator::NO_BLOCK_RUNTIME_ID){
|
||||
if($blockRuntimeId !== null){
|
||||
$meta = $this->blockTranslator->getBlockStateDictionary()->getMetaFromStateId($blockRuntimeId);
|
||||
if($meta === null){
|
||||
throw new AssumptionFailedError("Every block state should have an associated meta value");
|
||||
@ -230,7 +231,7 @@ class TypeConverter{
|
||||
$id,
|
||||
$meta,
|
||||
$itemStack->getCount(),
|
||||
$blockRuntimeId,
|
||||
$blockRuntimeId ?? ItemTranslator::NO_BLOCK_RUNTIME_ID,
|
||||
$nbt,
|
||||
[],
|
||||
[],
|
||||
|
@ -33,6 +33,7 @@ use pocketmine\crafting\json\ShapelessRecipeData;
|
||||
use pocketmine\crafting\json\SmithingTransformRecipeData;
|
||||
use pocketmine\crafting\json\SmithingTrimRecipeData;
|
||||
use pocketmine\data\bedrock\block\BlockStateData;
|
||||
use pocketmine\data\bedrock\item\BlockItemIdMap;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -40,6 +41,7 @@ use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\network\mcpe\convert\BlockStateDictionary;
|
||||
use pocketmine\network\mcpe\convert\BlockTranslator;
|
||||
use pocketmine\network\mcpe\convert\ItemTranslator;
|
||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
|
||||
@ -110,6 +112,7 @@ class ParserPacketHandler extends PacketHandler{
|
||||
|
||||
public ?ItemTypeDictionary $itemTypeDictionary = null;
|
||||
private BlockTranslator $blockTranslator;
|
||||
private BlockItemIdMap $blockItemIdMap;
|
||||
|
||||
public function __construct(private string $bedrockDataPath){
|
||||
$this->blockTranslator = new BlockTranslator(
|
||||
@ -119,6 +122,7 @@ class ParserPacketHandler extends PacketHandler{
|
||||
),
|
||||
GlobalBlockStateHandlers::getSerializer()
|
||||
);
|
||||
$this->blockItemIdMap = BlockItemIdMap::getInstance();
|
||||
}
|
||||
|
||||
private static function blockStatePropertiesToString(BlockStateData $blockStateData) : string{
|
||||
@ -136,7 +140,8 @@ class ParserPacketHandler extends PacketHandler{
|
||||
if($this->itemTypeDictionary === null){
|
||||
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){
|
||||
$data->count = $itemStack->getCount();
|
||||
@ -146,7 +151,7 @@ class ParserPacketHandler extends PacketHandler{
|
||||
if($meta === 32767){
|
||||
$meta = 0; //kick wildcard magic bullshit
|
||||
}
|
||||
if($itemStack->getBlockRuntimeId() !== 0){
|
||||
if($this->blockItemIdMap->lookupBlockId($itemStringId) !== null){
|
||||
if($meta !== 0){
|
||||
throw new PacketHandlingException("Unexpected non-zero blockitem meta");
|
||||
}
|
||||
@ -159,6 +164,8 @@ class ParserPacketHandler extends PacketHandler{
|
||||
if(count($stateProperties) > 0){
|
||||
$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){
|
||||
$data->meta = $meta;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user