pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.27k stars 1.55k forks source link

Blue Candle missing from Creative Inventory #5818

Closed diamond-gold closed 1 year ago

diamond-gold commented 1 year ago

Issue description

Blue Candle is missing from Creative Inventory

Steps to reproduce the issue

  1. Search for it in creative inventory
  2. Notice all candles are present except for blue candle

OS and versions

Plugins

None

dktapps commented 1 year ago

The creative inventory is riddled with bugs that don't make any sense. The item is implemented and you can obtain it using /give.

diamond-gold commented 1 year ago

It is missing from server-side creative inventory, not a client issue

foreach (CreativeInventory::getInstance()->getAll() as $item) {
    $block = $item->getBlock();
    if($block instanceof DyedCandle) {
        var_dump($block->getColor()->getDisplayName());
    }
}
string(5) "White"
string(6) "Orange"
string(7) "Magenta"
string(10) "Light Blue"
string(6) "Yellow"
string(4) "Lime"
string(4) "Pink"
string(4) "Gray"
string(10) "Light Gray"
string(4) "Cyan"
string(6) "Purple"
string(5) "Brown"
string(5) "Green"
string(3) "Red"
string(5) "Black"

If it is added like this it appears in the creative inventory correctly

CreativeInventory::getInstance()->add(VanillaBlocks::DYED_CANDLE()->setColor(DyeColor::BLUE())->asItem());
dktapps commented 1 year ago

That is strange indeed. It does appear in creativeitems.json here:

https://github.com/pmmp/BedrockData/blob/master/creativeitems.json#L4288

However, the blockstate data appears to be missing, which is likely why the item is missing - most likely an exception was thrown because of the missing properties, which would have been caught here: https://github.com/pmmp/PocketMine-MP/blob/stable/src/crafting/CraftingManagerFromDataHelper.php#L145

dktapps commented 1 year ago

Bear in mind that creativeitems.json was generated from BDS using a MITM tool though - there's a possibility that the data sent by BDS itself is bogus. In any case, I'll look into it.

dktapps commented 1 year ago

It looks like blue_candle is the first block to appear in the palette, so its first state has a runtimeID of 0.

That results in this check thinking there is no interesting data: https://github.com/pmmp/PocketMine-MP/blob/stable/tools/generate-bedrock-data-from-packets.php#L149

Since 0 is a valid blockstate ID, but 0 is also used to signify "no blockstate", this is problematic to fix.