37
37
import org .geysermc .geyser .registry .BlockRegistries ;
38
38
import org .geysermc .geyser .registry .type .BlockMappings ;
39
39
import org .geysermc .geyser .registry .type .GeyserBedrockBlock ;
40
+ import org .geysermc .geyser .registry .type .GeyserMappingItem ;
40
41
41
42
import java .io .ByteArrayInputStream ;
42
43
import java .io .IOException ;
50
51
public class CreativeItemRegistryPopulator {
51
52
private static final List <BiPredicate <String , Integer >> JAVA_ONLY_ITEM_FILTER = List .of (
52
53
// Bedrock-only as its own item
53
- (identifier , data ) -> identifier .equals ("minecraft:empty_map" ) && data == 2 ,
54
- // Bedrock-only banner patterns
55
- (identifier , data ) -> identifier .equals ("minecraft:bordure_indented_banner_pattern" ) || identifier .equals ("minecraft:field_masoned_banner_pattern" )
54
+ (identifier , data ) -> identifier .equals ("minecraft:empty_map" ) && data == 2
56
55
);
57
56
58
- static void populate (ItemRegistryPopulator .PaletteVersion palette , Map <String , ItemDefinition > definitions , Consumer <ItemData .Builder > itemConsumer ) {
57
+ static void populate (ItemRegistryPopulator .PaletteVersion palette , Map <String , ItemDefinition > definitions , Map < String , GeyserMappingItem > items , Consumer <ItemData .Builder > itemConsumer ) {
59
58
GeyserBootstrap bootstrap = GeyserImpl .getInstance ().getBootstrap ();
60
59
61
60
// Load creative items
@@ -68,7 +67,7 @@ static void populate(ItemRegistryPopulator.PaletteVersion palette, Map<String, I
68
67
69
68
BlockMappings blockMappings = BlockRegistries .BLOCKS .forVersion (palette .protocolVersion ());
70
69
for (JsonNode itemNode : creativeItemEntries ) {
71
- ItemData .Builder itemBuilder = createItemData (itemNode , blockMappings , definitions );
70
+ ItemData .Builder itemBuilder = createItemData (itemNode , items , blockMappings , definitions );
72
71
if (itemBuilder == null ) {
73
72
continue ;
74
73
}
@@ -77,7 +76,7 @@ static void populate(ItemRegistryPopulator.PaletteVersion palette, Map<String, I
77
76
}
78
77
}
79
78
80
- private static ItemData .@ Nullable Builder createItemData (JsonNode itemNode , BlockMappings blockMappings , Map <String , ItemDefinition > definitions ) {
79
+ private static ItemData .@ Nullable Builder createItemData (JsonNode itemNode , Map < String , GeyserMappingItem > items , BlockMappings blockMappings , Map <String , ItemDefinition > definitions ) {
81
80
int count = 1 ;
82
81
int damage = 0 ;
83
82
NbtMap tag = null ;
@@ -89,6 +88,23 @@ static void populate(ItemRegistryPopulator.PaletteVersion palette, Map<String, I
89
88
}
90
89
}
91
90
91
+ // Attempt to remove items that do not exist in Java (1.21.50 has 1.21.4 items, that don't exist on 1.21.2)
92
+ // we still add the lodestone compass - we're going to translate it.
93
+ if (!items .containsKey (identifier ) && !identifier .equals ("minecraft:lodestone_compass" )) {
94
+ // bedrock identifier not found, let's make sure it's not just different
95
+ boolean found = false ;
96
+ for (var mapping : items .values ()) {
97
+ if (mapping .getBedrockIdentifier ().equals (identifier )) {
98
+ found = true ;
99
+ break ;
100
+ }
101
+ }
102
+
103
+ if (!found ) {
104
+ return null ;
105
+ }
106
+ }
107
+
92
108
JsonNode damageNode = itemNode .get ("damage" );
93
109
if (damageNode != null ) {
94
110
damage = damageNode .asInt ();
0 commit comments