From afaf3aa254714dd5b85603187fe5fed09b404feb Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Tue, 1 Oct 2024 02:02:59 +0100 Subject: [PATCH] Update to 1.21 --- pom.xml | 1 + .../slimefun4/api/MinecraftVersion.java | 2 +- .../items/magical/runes/EnchantmentRune.java | 3 +- .../items/tools/ExplosiveTool.java | 14 ++-- .../biomes/TestBiomeMapCompatibility.java | 12 ++-- src/test/resources/biomes/1.20.5+.json | 2 +- src/test/resources/biomes/1.20.x.json | 2 +- src/test/resources/biomes/1.21.x.json | 67 +++++++++++++++++++ 8 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 src/test/resources/biomes/1.21.x.json diff --git a/pom.xml b/pom.xml index 6942925c42..be95bc63b9 100644 --- a/pom.xml +++ b/pom.xml @@ -372,6 +372,7 @@ io.papermc.paper paper-api ${paper.version}-R0.1-SNAPSHOT + provided diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index 570a8e6854..afad06e3bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -59,7 +59,7 @@ public enum MinecraftVersion { * This constant represents Minecraft (Java Edition) Version 1.21 * ("Tricky Trials") */ - MINECRAFT_1_21(21, 0, "1.21+"), + MINECRAFT_1_21(21, 0, "1.21.x"), /** * This constant represents an exceptional state in which we were unable diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java index 420d78a778..d7a2f03c08 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java @@ -50,8 +50,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r super(itemGroup, item, recipeType, recipe); for (Material mat : Material.values()) { - // TODO: FIgure out behaviour here - we fail on WATER because it isn't an item - if (Slimefun.instance().isUnitTest() && (mat.isLegacy() || !mat.isItem())) continue; + if (mat.isLegacy() || !mat.isItem()) continue; List enchantments = new ArrayList<>(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index 0e09ed2008..59fcd86d00 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -54,10 +54,12 @@ public class ExplosiveTool extends SimpleSlimefunItem implements private static Constructor pre21ExplodeEventConstructor; static { - try { - pre21ExplodeEventConstructor = BlockExplodeEvent.class.getConstructor(Block.class, List.class, float.class); - } catch (Exception e) { - Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e); + if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_21)) { + try { + pre21ExplodeEventConstructor = BlockExplodeEvent.class.getConstructor(Block.class, List.class, float.class); + } catch (Exception e) { + Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e); + } } } @@ -207,7 +209,7 @@ private BlockExplodeEvent createNewBlockExplodeEvent( var version = Slimefun.getMinecraftVersion(); if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_21)) { return new BlockExplodeEvent(block, block.getState(), blocks, yield, ExplosionResult.DESTROY); - } else { + } else if (pre21ExplodeEventConstructor != null) { try { return (BlockExplodeEvent) pre21ExplodeEventConstructor.newInstance(block, blocks, yield); } catch (Exception e) { @@ -215,6 +217,8 @@ private BlockExplodeEvent createNewBlockExplodeEvent( } return null; + } else { + throw new IllegalStateException("BlockExplodeEvent constructor not found"); } } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java index 99f7c6100f..d7ffca7d79 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java @@ -106,7 +106,8 @@ void testCompatibilities(String name, MinecraftVersion version) { MinecraftVersion.MINECRAFT_1_17, MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, - MinecraftVersion.MINECRAFT_1_20 + MinecraftVersion.MINECRAFT_1_20, + MinecraftVersion.MINECRAFT_1_21 }); testCases.put("oil_v1.16", new MinecraftVersion[] { @@ -117,7 +118,8 @@ void testCompatibilities(String name, MinecraftVersion version) { testCases.put("oil_v1.18", new MinecraftVersion[] { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, - MinecraftVersion.MINECRAFT_1_20 + MinecraftVersion.MINECRAFT_1_20, + MinecraftVersion.MINECRAFT_1_21 }); testCases.put("salt_v1.16", new MinecraftVersion[] { @@ -128,7 +130,8 @@ void testCompatibilities(String name, MinecraftVersion version) { testCases.put("salt_v1.18", new MinecraftVersion[] { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, - MinecraftVersion.MINECRAFT_1_20 + MinecraftVersion.MINECRAFT_1_20, + MinecraftVersion.MINECRAFT_1_21 }); testCases.put("uranium_v1.16", new MinecraftVersion[] { @@ -142,7 +145,8 @@ void testCompatibilities(String name, MinecraftVersion version) { testCases.put("uranium_v1.18", new MinecraftVersion[] { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, - MinecraftVersion.MINECRAFT_1_20 + MinecraftVersion.MINECRAFT_1_20, + MinecraftVersion.MINECRAFT_1_21 }); // @formatter:on diff --git a/src/test/resources/biomes/1.20.5+.json b/src/test/resources/biomes/1.20.5+.json index dfe92f1834..d6b3e4ece5 100644 --- a/src/test/resources/biomes/1.20.5+.json +++ b/src/test/resources/biomes/1.20.5+.json @@ -63,5 +63,5 @@ "minecraft:jagged_peaks", "minecraft:stony_peaks", "minecraft:cherry_grove", - "minecraft:custom", + "minecraft:custom" ] \ No newline at end of file diff --git a/src/test/resources/biomes/1.20.x.json b/src/test/resources/biomes/1.20.x.json index dfe92f1834..d6b3e4ece5 100644 --- a/src/test/resources/biomes/1.20.x.json +++ b/src/test/resources/biomes/1.20.x.json @@ -63,5 +63,5 @@ "minecraft:jagged_peaks", "minecraft:stony_peaks", "minecraft:cherry_grove", - "minecraft:custom", + "minecraft:custom" ] \ No newline at end of file diff --git a/src/test/resources/biomes/1.21.x.json b/src/test/resources/biomes/1.21.x.json new file mode 100644 index 0000000000..332b493d21 --- /dev/null +++ b/src/test/resources/biomes/1.21.x.json @@ -0,0 +1,67 @@ +[ + "minecraft:ocean", + "minecraft:plains", + "minecraft:desert", + "minecraft:windswept_hills", + "minecraft:forest", + "minecraft:taiga", + "minecraft:swamp", + "minecraft:mangrove_swamp", + "minecraft:river", + "minecraft:nether_wastes", + "minecraft:the_end", + "minecraft:frozen_ocean", + "minecraft:frozen_river", + "minecraft:snowy_plains", + "minecraft:mushroom_fields", + "minecraft:beach", + "minecraft:jungle", + "minecraft:sparse_jungle", + "minecraft:deep_ocean", + "minecraft:stony_shore", + "minecraft:snowy_beach", + "minecraft:birch_forest", + "minecraft:dark_forest", + "minecraft:snowy_taiga", + "minecraft:old_growth_pine_taiga", + "minecraft:windswept_forest", + "minecraft:savanna", + "minecraft:savanna_plateau", + "minecraft:badlands", + "minecraft:wooded_badlands", + "minecraft:small_end_islands", + "minecraft:end_midlands", + "minecraft:end_highlands", + "minecraft:end_barrens", + "minecraft:warm_ocean", + "minecraft:lukewarm_ocean", + "minecraft:cold_ocean", + "minecraft:deep_lukewarm_ocean", + "minecraft:deep_cold_ocean", + "minecraft:deep_frozen_ocean", + "minecraft:the_void", + "minecraft:sunflower_plains", + "minecraft:windswept_gravelly_hills", + "minecraft:flower_forest", + "minecraft:ice_spikes", + "minecraft:old_growth_birch_forest", + "minecraft:old_growth_spruce_taiga", + "minecraft:windswept_savanna", + "minecraft:eroded_badlands", + "minecraft:bamboo_jungle", + "minecraft:soul_sand_valley", + "minecraft:crimson_forest", + "minecraft:warped_forest", + "minecraft:basalt_deltas", + "minecraft:dripstone_caves", + "minecraft:lush_caves", + "minecraft:deep_dark", + "minecraft:meadow", + "minecraft:grove", + "minecraft:snowy_slopes", + "minecraft:frozen_peaks", + "minecraft:jagged_peaks", + "minecraft:stony_peaks", + "minecraft:cherry_grove", + "minecraft:custom" + ] \ No newline at end of file