Skip to content

Commit 7332c6b

Browse files
committed
Properly update mappings and fix walls
1 parent 11f76b6 commit 7332c6b

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,16 @@
3434
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
3535
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
3636
import it.unimi.dsi.fastutil.ints.IntSet;
37-
import it.unimi.dsi.fastutil.objects.*;
38-
import org.cloudburstmc.nbt.*;
37+
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
38+
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
39+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
40+
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
41+
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
42+
import org.cloudburstmc.nbt.NBTInputStream;
43+
import org.cloudburstmc.nbt.NbtMap;
44+
import org.cloudburstmc.nbt.NbtMapBuilder;
45+
import org.cloudburstmc.nbt.NbtType;
46+
import org.cloudburstmc.nbt.NbtUtils;
3947
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
4048
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
4149
import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712;
@@ -63,7 +71,15 @@
6371
import java.io.DataInputStream;
6472
import java.io.InputStream;
6573
import java.nio.charset.StandardCharsets;
66-
import java.util.*;
74+
import java.util.ArrayList;
75+
import java.util.Arrays;
76+
import java.util.BitSet;
77+
import java.util.Comparator;
78+
import java.util.Iterator;
79+
import java.util.List;
80+
import java.util.Locale;
81+
import java.util.Map;
82+
import java.util.Set;
6783
import java.util.stream.Stream;
6884
import java.util.zip.GZIPInputStream;
6985

@@ -112,40 +128,7 @@ private static void registerBedrockBlocks() {
112128
.put(ObjectIntPair.of("1_20_80", Bedrock_v671.CODEC.getProtocolVersion()), Conversion685_671::remapBlock)
113129
.put(ObjectIntPair.of("1_21_0", Bedrock_v685.CODEC.getProtocolVersion()), Conversion712_685::remapBlock)
114130
.put(ObjectIntPair.of("1_21_20", Bedrock_v712.CODEC.getProtocolVersion()), Conversion729_712::remapBlock)
115-
.put(ObjectIntPair.of("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()), tag -> { // TODO: Remove me when mappings is updated
116-
String name = tag.getString("name");
117-
if ("minecraft:sponge".equals(name)) {
118-
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
119-
builder.remove("sponge_type");
120-
NbtMap states = builder.build();
121-
return tag.toBuilder().putCompound("states", states).build();
122-
}
123-
if ("minecraft:tnt".equals(name)) {
124-
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
125-
builder.remove("allow_underwater_bit");
126-
NbtMap states = builder.build();
127-
return tag.toBuilder().putCompound("states", states).build();
128-
}
129-
if ("minecraft:cobblestone_wall".equals(name)) {
130-
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
131-
builder.remove("wall_block_type");
132-
NbtMap states = builder.build();
133-
return tag.toBuilder().putCompound("states", states).build();
134-
}
135-
if ("minecraft:purpur_block".equals(name)) {
136-
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
137-
builder.remove("chisel_type");
138-
NbtMap states = builder.build();
139-
return tag.toBuilder().putCompound("states", states).build();
140-
}
141-
if ("minecraft:structure_void".equals(name)) {
142-
NbtMapBuilder builder = tag.getCompound("states").toBuilder();
143-
builder.remove("structure_void_type");
144-
NbtMap states = builder.build();
145-
return tag.toBuilder().putCompound("states", states).build();
146-
}
147-
return tag;
148-
})
131+
.put(ObjectIntPair.of("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()), tag -> tag)
149132
.build();
150133

151134
// We can keep this strong as nothing should be garbage collected

core/src/main/java/org/geysermc/geyser/registry/populator/Conversion712_685.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class Conversion712_685 {
3232
private static final List<String> NEW_BLOCKS = Stream.of(NEW_STONE_BLOCK_SLABS_2, NEW_STONE_BLOCK_SLABS_3, NEW_STONE_BLOCK_SLABS_4, NEW_DOUBLE_STONE_BLOCK_SLABS, NEW_DOUBLE_STONE_BLOCK_SLABS_2, NEW_DOUBLE_STONE_BLOCK_SLABS_3, NEW_DOUBLE_STONE_BLOCK_SLABS_4, NEW_PRISMARINE_BLOCKS, NEW_CORAL_FAN_HANGS, NEW_CORAL_FAN_HANGS_2, NEW_CORAL_FAN_HANGS_3, NEW_MONSTER_EGGS, NEW_STONEBRICK_BLOCKS, NEW_LIGHT_BLOCKS, NEW_SANDSTONE_BLOCKS, NEW_QUARTZ_BLOCKS, NEW_RED_SANDSTONE_BLOCKS, NEW_SAND_BLOCKS, NEW_DIRT_BLOCKS, NEW_ANVILS, NEW_YELLOW_FLOWERS).flatMap(List::stream).toList();
3333

3434
static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
35+
mapping = Conversion729_712.remapItem(item, mapping);
36+
3537
String identifer = mapping.getBedrockIdentifier();
3638

3739
if (!NEW_BLOCKS.contains(identifer)) {
@@ -153,6 +155,8 @@ static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
153155
}
154156

155157
static NbtMap remapBlock(NbtMap tag) {
158+
tag = Conversion729_712.remapBlock(tag);
159+
156160
final String name = tag.getString("name");
157161

158162
if (!NEW_BLOCKS.contains(name)) {

core/src/main/java/org/geysermc/geyser/registry/populator/Conversion729_712.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class Conversion729_712 {
1212
private static final List<String> NEW_WALL_BLOCKS = List.of("minecraft:cobblestone_wall", "minecraft:mossy_cobblestone_wall", "minecraft:granite_wall", "minecraft:diorite_wall", "minecraft:andesite_wall", "minecraft:sandstone_wall", "minecraft:brick_wall", "minecraft:stone_brick_wall", "minecraft:mossy_stone_brick_wall", "minecraft:nether_brick_wall", "minecraft:end_stone_brick_wall", "minecraft:prismarine_wall", "minecraft:red_sandstone_wall", "minecraft:red_nether_brick_wall");
1313
private static final List<String> NEW_SPONGE_BLOCKS = List.of("minecraft:sponge", "minecraft:wet_sponge");
1414
private static final List<String> NEW_TNT_BLOCKS = List.of("minecraft:tnt", "minecraft:underwater_tnt");
15-
private static final List<String> NEW_BLOCKS = Stream.of(NEW_PURPUR_BLOCKS, NEW_WALL_BLOCKS, NEW_SPONGE_BLOCKS, NEW_TNT_BLOCKS).flatMap(List::stream).toList();
15+
private static final List<String> STRUCTURE_VOID = List.of("minecraft:structure_void");
16+
private static final List<String> NEW_BLOCKS = Stream.of(NEW_PURPUR_BLOCKS, NEW_WALL_BLOCKS, NEW_SPONGE_BLOCKS, NEW_TNT_BLOCKS, STRUCTURE_VOID).flatMap(List::stream).toList();
1617

1718
static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) {
1819
String identifier = mapping.getBedrockIdentifier();
@@ -88,7 +89,7 @@ static NbtMap remapBlock(NbtMap tag) {
8889

8990
switch (name) {
9091
case "minecraft:cobblestone_wall" -> wallType = "cobblestone";
91-
case "minecraft:mossy_cobblestone_wall" -> wallType = "mossy";
92+
case "minecraft:mossy_cobblestone_wall" -> wallType = "mossy_cobblestone";
9293
case "minecraft:granite_wall" -> wallType = "granite";
9394
case "minecraft:diorite_wall" -> wallType = "diorite";
9495
case "minecraft:andesite_wall" -> wallType = "andesite";
@@ -97,7 +98,7 @@ static NbtMap remapBlock(NbtMap tag) {
9798
case "minecraft:stone_brick_wall" -> wallType = "stone_brick";
9899
case "minecraft:mossy_stone_brick_wall" -> wallType = "mossy_stone_brick";
99100
case "minecraft:nether_brick_wall" -> wallType = "nether_brick";
100-
case "minecraft:end_stone_brick_wall" -> wallType = "end_stone_brick";
101+
case "minecraft:end_stone_brick_wall" -> wallType = "end_brick";
101102
case "minecraft:prismarine_wall" -> wallType = "prismarine";
102103
case "minecraft:red_sandstone_wall" -> wallType = "red_sandstone";
103104
case "minecraft:red_nether_brick_wall" -> wallType = "red_nether_brick";
@@ -136,6 +137,15 @@ static NbtMap remapBlock(NbtMap tag) {
136137
return tag.toBuilder().putString("name", replacement).putCompound("states", states).build();
137138
}
138139

140+
if (STRUCTURE_VOID.contains(name)) {
141+
NbtMap states = tag.getCompound("states")
142+
.toBuilder()
143+
.putString("structure_void_type", "air")
144+
.build();
145+
146+
return tag.toBuilder().putCompound("states", states).build();
147+
}
148+
139149
return tag;
140150
}
141151
}

core/src/main/resources/mappings

0 commit comments

Comments
 (0)