From 86a2960355404136176d76d3d55a62f0d462edc6 Mon Sep 17 00:00:00 2001 From: Alemiz Date: Thu, 16 May 2024 14:53:51 +0200 Subject: [PATCH] Add MCBE 1.21.0 updaters --- build.gradle.kts | 2 +- .../BlockStateUpdater_1_21_0.java | 113 ++++++++++++++++++ .../blockstateupdater/BlockStateUpdaters.java | 1 + 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdater_1_21_0.java diff --git a/build.gradle.kts b/build.gradle.kts index 1272778..bf3f34c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { id("signing") } -version = "1.20.80-SNAPSHOT" +version = "1.21.0-SNAPSHOT" group = "org.cloudburstmc" description = "Updates Minecraft: Bedrock Edition block states to the latest revision" diff --git a/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdater_1_21_0.java b/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdater_1_21_0.java new file mode 100644 index 0000000..cde2264 --- /dev/null +++ b/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdater_1_21_0.java @@ -0,0 +1,113 @@ +package org.cloudburstmc.blockstateupdater; + +import org.cloudburstmc.blockstateupdater.util.tagupdater.CompoundTagUpdaterContext; + +import java.util.function.Function; + +public class BlockStateUpdater_1_21_0 implements BlockStateUpdater { + + public static final BlockStateUpdater INSTANCE = new BlockStateUpdater_1_21_0(); + + @Override + public void registerUpdaters(CompoundTagUpdaterContext ctx) { + ctx.addUpdater(1, 21, 0) + .match("name", "minecraft:coral_block") + .edit("states", helper -> { + String type = (String) helper.getCompoundTag().remove("coral_color"); + Object bit = helper.getCompoundTag().remove("dead_bit"); + boolean dead = bit instanceof Byte && (byte) bit == 1 || bit instanceof Boolean && (boolean) bit; + + String newName; + switch (type) { + case "blue": + newName = "minecraft:" + (dead ? "dead_" : "") + "tube_coral_block"; + break; + case "pink": + newName = "minecraft:" + (dead ? "dead_" : "") + "brain_coral_block"; + break; + case "purple": + newName = "minecraft:" + (dead ? "dead_" : "") + "bubble_coral_block"; + break; + case "yellow": + newName = "minecraft:" + (dead ? "dead_" : "") + "horn_coral_block"; + break; + case "red": + default: + newName = "minecraft:" + (dead ? "dead_" : "") + "fire_coral_block"; + break; + } + helper.getRootTag().put("name", newName); + }); + + this.addTypeUpdater(ctx, "minecraft:double_plant", "double_plant_type", type -> { + switch (type) { + case "syringa": + return "minecraft:lilac"; + case "grass": + return "minecraft:tall_grass"; + case "fern": + return "minecraft:large_fern"; + case "rose": + return "minecraft:rose_bush"; + case "paeonia": + return "minecraft:peony"; + case "sunflower": + default: + return "minecraft:sunflower"; + } + }); + + this.addTypeUpdater(ctx, "minecraft:stone_block_slab", "stone_slab_type", type -> { + switch (type) { + case "quartz": + return "minecraft:quartz_slab"; + case "wood": + return "minecraft:petrified_oak_slab"; + case "stone_brick": + return "minecraft:stone_brick_slab"; + case "brick": + return "minecraft:brick_slab"; + case "smooth_stone": + return "minecraft:smooth_stone_slab"; + case "sandstone": + return "minecraft:sandstone_slab"; + case "nether_brick": + return "minecraft:nether_brick_slab"; + case "cobblestone": + default: + return "minecraft:cobblestone_slab"; + } + }); + + this.addTypeUpdater(ctx, "minecraft:tallgrass", "tall_grass_type", type -> { + switch (type) { + case "fern": + return "minecraft:fern"; + case "default": + default: + return "minecraft:short_grass"; + } + }); + + // These are not official updaters + + ctx.addUpdater(1, 21, 0, false, false) + .match("name", "minecraft:trial_spawner") + .visit("states") + .tryAdd("ominous", (byte) 0); + + ctx.addUpdater(1, 21, 0, false, false) + .match("name", "minecraft:vault") + .visit("states") + .tryAdd("ominous", (byte) 0); + } + + private void addTypeUpdater(CompoundTagUpdaterContext context, String identifier, String typeState, Function rename) { + context.addUpdater(1, 21, 0) + .match("name", identifier) + .visit("states") + .edit(typeState, helper -> helper.getRootTag().put("name", rename.apply((String) helper.getTag()))) + .remove(typeState); + + } +} diff --git a/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdaters.java b/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdaters.java index 89aeb1e..28abd9c 100644 --- a/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdaters.java +++ b/src/main/java/org/cloudburstmc/blockstateupdater/BlockStateUpdaters.java @@ -40,6 +40,7 @@ public class BlockStateUpdaters { updaters.add(BlockStateUpdater_1_20_60.INSTANCE); updaters.add(BlockStateUpdater_1_20_70.INSTANCE); updaters.add(BlockStateUpdater_1_20_80.INSTANCE); + updaters.add(BlockStateUpdater_1_21_0.INSTANCE); CompoundTagUpdaterContext context = new CompoundTagUpdaterContext(); updaters.forEach(updater -> updater.registerUpdaters(context));