GeyserMC / Geyser

A bridge/proxy allowing you to connect to Minecraft: Java Edition servers with Minecraft: Bedrock Edition.
https://geysermc.org
MIT License
4.75k stars 687 forks source link

CustomItem with ModelData not working alongside Custom Blocks. #5124

Closed OmeWillem closed 1 week ago

OmeWillem commented 2 weeks ago

Describe the bug

I am converting models from Java to Bedrock using the mappings api provided by Geyser but there's a problem. I am trying to get a block to show on a specific CustomModelData like this:

        CustomItemOptions itemOptions = CustomItemOptions.builder()
                .customModelData(data.getCustomModelData())
                .build();
        CustomItemData itemData = CustomItemData.builder()
                .name(key)
                .icon("_iainternal_icon_cancel")
                .customItemOptions(itemOptions)
                .build();
        DefineCustomItemListener.itemData(itemData, data);

        CustomBlockComponents components = CustomBlockComponents.builder()
                .geometry(GeometryComponent.builder().identifier("geometry.geyser_custom." + key).build())
                .materialInstance("*", MaterialInstance.builder().renderMethod("alpha_test").build())
                .placementFilter(List.of())
                .build();
        CustomBlockData blockData = CustomBlockData.builder()
                .name(key)
                .components(components)
                .build();
        DefineCustomBlockListener.blockData(blockData, data);

This works, but it's very random. Sometimes the whole item gets ignored and seen as AIR, also allowing for dupes because you can then literally overwrite it in chests. And sometimes the item works just fine. The item always shows in item frames, but nowhere else (unless the item works fine ofcourse).

I've checked the packet listener and it does accurately send them to the client.

To Reproduce

  1. Create mappings for items like shown before.
  2. Create mappings for blocks life shown before.
  3. Restart the server.
  4. Join the server.
  5. Check the items and see if they are visible. (this is completely random, sometimes 1 item works and sometimes the other one does).

To test with accuracy you should test with atleast 25+ models, I am using a 174 models.

Expected behaviour

All items should show like normal.

Screenshots / Videos

https://github.com/user-attachments/assets/46ddb3cf-2385-4545-a83e-19177cadd4d8

Server Version and Plugins

Current Purpur Version: 1.21.1-2312-d7a7c91 Current Geyser Version: 2.4.4-Snapshot Current Floodgate Version: 2.2.3-SNAPSHOT (b113-06f2ed9) Current Minecraft Java Client version: 1.21 Current Minecraft Bedrock Client version: 1.21.44

Geyser Dump

https://dump.geysermc.org/77nexYY4m4bWhajXq2mkDDjSsNkFErWT

Geyser Version

2.4.4-Snapshot

Minecraft: Bedrock Edition Device/Version

1.21.44, PC / Windows 11

Additional Context

Pack is not required to test, aslong as you make mappings you can use one of the built-in geometries like 'geometry.bee'

OmeWillem commented 2 weeks ago

https://github.com/GeyserMC/Geyser/issues/4326 seems to be the same problem! https://github.com/GeyserMC/Geyser/issues/4090 seems to be somewhat related.

Kas-tle commented 2 weeks ago

Please provide the java resource pack, converted bedrock resource pack, and either the source of extension you are using to register the mappings, or the mappings file(s).

OmeWillem commented 2 weeks ago

Please provide the java resource pack, converted bedrock resource pack, and either the source of extension you are using to register the mappings, or the mappings file(s).

As said, the resource packs actually do not play a role in this bug. What do you mean with source of extension? I'm using a Paper plugin with the Geyser API. The way I register mappings has also been sent before.

Kas-tle commented 2 weeks ago

What you have provided is a single snippet of registering a single item and single block. For all predicates including custom model data, the order of registration/mappings matters just as the order of predicate entries in a Java resource pack matters. Therefore, the resource pack, and the full source of the Geyser extension/plugin you are using to register the items are needed. We cannot simply guess as to what you are registering and in what order.

OmeWillem commented 1 week ago

Actually got it fixed. Use the NonVanilla version and it'll work fine.