From 7332c6b48f446ff6f7ae76e92b8da63e58b5889d Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:34:14 -0400 Subject: [PATCH] Properly update mappings and fix walls --- .../populator/BlockRegistryPopulator.java | 57 +++++++------------ .../registry/populator/Conversion712_685.java | 4 ++ .../registry/populator/Conversion729_712.java | 16 +++++- core/src/main/resources/mappings | 2 +- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java index 9603cba63..bface58da 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java @@ -34,8 +34,16 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; -import it.unimi.dsi.fastutil.objects.*; -import org.cloudburstmc.nbt.*; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectIntPair; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import org.cloudburstmc.nbt.NBTInputStream; +import org.cloudburstmc.nbt.NbtMap; +import org.cloudburstmc.nbt.NbtMapBuilder; +import org.cloudburstmc.nbt.NbtType; +import org.cloudburstmc.nbt.NbtUtils; import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671; import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685; import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712; @@ -63,7 +71,15 @@ import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack; import java.io.DataInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.stream.Stream; import java.util.zip.GZIPInputStream; @@ -112,40 +128,7 @@ public final class BlockRegistryPopulator { .put(ObjectIntPair.of("1_20_80", Bedrock_v671.CODEC.getProtocolVersion()), Conversion685_671::remapBlock) .put(ObjectIntPair.of("1_21_0", Bedrock_v685.CODEC.getProtocolVersion()), Conversion712_685::remapBlock) .put(ObjectIntPair.of("1_21_20", Bedrock_v712.CODEC.getProtocolVersion()), Conversion729_712::remapBlock) - .put(ObjectIntPair.of("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()), tag -> { // TODO: Remove me when mappings is updated - String name = tag.getString("name"); - if ("minecraft:sponge".equals(name)) { - NbtMapBuilder builder = tag.getCompound("states").toBuilder(); - builder.remove("sponge_type"); - NbtMap states = builder.build(); - return tag.toBuilder().putCompound("states", states).build(); - } - if ("minecraft:tnt".equals(name)) { - NbtMapBuilder builder = tag.getCompound("states").toBuilder(); - builder.remove("allow_underwater_bit"); - NbtMap states = builder.build(); - return tag.toBuilder().putCompound("states", states).build(); - } - if ("minecraft:cobblestone_wall".equals(name)) { - NbtMapBuilder builder = tag.getCompound("states").toBuilder(); - builder.remove("wall_block_type"); - NbtMap states = builder.build(); - return tag.toBuilder().putCompound("states", states).build(); - } - if ("minecraft:purpur_block".equals(name)) { - NbtMapBuilder builder = tag.getCompound("states").toBuilder(); - builder.remove("chisel_type"); - NbtMap states = builder.build(); - return tag.toBuilder().putCompound("states", states).build(); - } - if ("minecraft:structure_void".equals(name)) { - NbtMapBuilder builder = tag.getCompound("states").toBuilder(); - builder.remove("structure_void_type"); - NbtMap states = builder.build(); - return tag.toBuilder().putCompound("states", states).build(); - } - return tag; - }) + .put(ObjectIntPair.of("1_21_30", Bedrock_v729.CODEC.getProtocolVersion()), tag -> tag) .build(); // We can keep this strong as nothing should be garbage collected diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion712_685.java b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion712_685.java index 557a38f1f..db715e015 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion712_685.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion712_685.java @@ -32,6 +32,8 @@ public class Conversion712_685 { private static final List 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(); static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) { + mapping = Conversion729_712.remapItem(item, mapping); + String identifer = mapping.getBedrockIdentifier(); if (!NEW_BLOCKS.contains(identifer)) { @@ -153,6 +155,8 @@ public class Conversion712_685 { } static NbtMap remapBlock(NbtMap tag) { + tag = Conversion729_712.remapBlock(tag); + final String name = tag.getString("name"); if (!NEW_BLOCKS.contains(name)) { diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion729_712.java b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion729_712.java index 3b8d6d4a2..5d4ebdc47 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion729_712.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion729_712.java @@ -12,7 +12,8 @@ public class Conversion729_712 { private static final List 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"); private static final List NEW_SPONGE_BLOCKS = List.of("minecraft:sponge", "minecraft:wet_sponge"); private static final List NEW_TNT_BLOCKS = List.of("minecraft:tnt", "minecraft:underwater_tnt"); - private static final List NEW_BLOCKS = Stream.of(NEW_PURPUR_BLOCKS, NEW_WALL_BLOCKS, NEW_SPONGE_BLOCKS, NEW_TNT_BLOCKS).flatMap(List::stream).toList(); + private static final List STRUCTURE_VOID = List.of("minecraft:structure_void"); + private static final List NEW_BLOCKS = Stream.of(NEW_PURPUR_BLOCKS, NEW_WALL_BLOCKS, NEW_SPONGE_BLOCKS, NEW_TNT_BLOCKS, STRUCTURE_VOID).flatMap(List::stream).toList(); static GeyserMappingItem remapItem(Item item, GeyserMappingItem mapping) { String identifier = mapping.getBedrockIdentifier(); @@ -88,7 +89,7 @@ public class Conversion729_712 { switch (name) { case "minecraft:cobblestone_wall" -> wallType = "cobblestone"; - case "minecraft:mossy_cobblestone_wall" -> wallType = "mossy"; + case "minecraft:mossy_cobblestone_wall" -> wallType = "mossy_cobblestone"; case "minecraft:granite_wall" -> wallType = "granite"; case "minecraft:diorite_wall" -> wallType = "diorite"; case "minecraft:andesite_wall" -> wallType = "andesite"; @@ -97,7 +98,7 @@ public class Conversion729_712 { case "minecraft:stone_brick_wall" -> wallType = "stone_brick"; case "minecraft:mossy_stone_brick_wall" -> wallType = "mossy_stone_brick"; case "minecraft:nether_brick_wall" -> wallType = "nether_brick"; - case "minecraft:end_stone_brick_wall" -> wallType = "end_stone_brick"; + case "minecraft:end_stone_brick_wall" -> wallType = "end_brick"; case "minecraft:prismarine_wall" -> wallType = "prismarine"; case "minecraft:red_sandstone_wall" -> wallType = "red_sandstone"; case "minecraft:red_nether_brick_wall" -> wallType = "red_nether_brick"; @@ -136,6 +137,15 @@ public class Conversion729_712 { return tag.toBuilder().putString("name", replacement).putCompound("states", states).build(); } + if (STRUCTURE_VOID.contains(name)) { + NbtMap states = tag.getCompound("states") + .toBuilder() + .putString("structure_void_type", "air") + .build(); + + return tag.toBuilder().putCompound("states", states).build(); + } + return tag; } } diff --git a/core/src/main/resources/mappings b/core/src/main/resources/mappings index 698fd2b10..3e85fcc87 160000 --- a/core/src/main/resources/mappings +++ b/core/src/main/resources/mappings @@ -1 +1 @@ -Subproject commit 698fd2b108a9e53f1e47b8cfdc122651b70d6059 +Subproject commit 3e85fcc87d7cfa4162cd8823192fcee0830be049