diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..adb7fb8632 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +default: help + +.PHONY: help +help: + @echo " * gen-biomes version= - Generate biomes for the given version" + +.PHONY: gen-biomes +gen-biomes: + @echo "Generating biomes for $(version)" + @curl "https://raw.githubusercontent.com/MockBukkit/MockBukkit/refs/heads/v$(version)/src/main/resources/keyed/worldgen/biome.json" -s \ + | jq '[ .values[].key]' \ + > "src/test/resources/biomes/$(version).x.json" diff --git a/pom.xml b/pom.xml index 5bc0d0d651..be95bc63b9 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ jar - Slimefun is a Spigot/Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server. + Slimefun is a Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server. https://github.com/Slimefun/Slimefun4 @@ -29,8 +29,8 @@ 21 - 1.20.6 - https://hub.spigotmc.org/javadocs/spigot/ + 1.21.1 + https://hub.spigotmc.org/javadocs/spigot/ Slimefun_Slimefun4 @@ -238,7 +238,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.7.0 + 3.10.0 ${project.basedir} @@ -251,7 +251,7 @@ - ${spigot.javadocs} + ${paper.javadocs} @@ -367,6 +367,14 @@ compile + + + io.papermc.paper + paper-api + ${paper.version}-R0.1-SNAPSHOT + provided + + org.junit.jupiter @@ -389,7 +397,7 @@ com.github.MockBukkit MockBukkit - c7cc678834 + v3.130.2 test @@ -401,13 +409,6 @@ - - - io.papermc.paper - paper-api - 1.20.6-R0.1-SNAPSHOT - test - @@ -515,12 +516,6 @@ 2.6 compile - - org.spigotmc - spigot-api - ${spigot.version}-R0.1-SNAPSHOT - provided - com.mojang authlib 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 4fc0160ac6..afad06e3bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -55,6 +55,12 @@ public enum MinecraftVersion { */ MINECRAFT_1_20_5(20, 5, "1.20.5+"), + /** + * This constant represents Minecraft (Java Edition) Version 1.21 + * ("Tricky Trials") + */ + MINECRAFT_1_21(21, 0, "1.21.x"), + /** * This constant represents an exceptional state in which we were unable * to identify the Minecraft Version we are using diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java index 611e85df6d..8ae4a86baa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java @@ -307,7 +307,7 @@ public void lock() { @Override public ItemStack clone() { - return new SlimefunItemStack(id, this); + return new SlimefunItemStack(id, super.clone()); } @Override 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 33e54e7544..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,7 +50,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r super(itemGroup, item, recipeType, recipe); for (Material mat : Material.values()) { - if (Slimefun.instance().isUnitTest() && mat.isLegacy()) 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 6fe1174e4f..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 @@ -1,7 +1,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,6 +11,7 @@ import dev.lone.itemsadder.api.CustomBlock; import org.bukkit.Bukkit; import org.bukkit.Effect; +import org.bukkit.ExplosionResult; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -17,6 +20,7 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -48,6 +52,17 @@ public class ExplosiveTool extends SimpleSlimefunItem implements private final ItemSetting damageOnUse = new ItemSetting<>(this, "damage-on-use", true); private final ItemSetting callExplosionEvent = new ItemSetting<>(this, "call-explosion-event", false); + private static Constructor pre21ExplodeEventConstructor; + static { + 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); + } + } + } + @ParametersAreNonnullByDefault public ExplosiveTool(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); @@ -78,7 +93,7 @@ private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, L List blocksToDestroy = new ArrayList<>(); if (callExplosionEvent.getValue()) { - BlockExplodeEvent blockExplodeEvent = new BlockExplodeEvent(b, blocks, 0); + BlockExplodeEvent blockExplodeEvent = createNewBlockExplodeEvent(b, blocks, 0); Bukkit.getServer().getPluginManager().callEvent(blockExplodeEvent); if (!blockExplodeEvent.isCancelled()) { @@ -186,4 +201,24 @@ private void breakBlock(BlockBreakEvent e, Player p, ItemStack item, Block b, Li damageItem(p, item); } + private BlockExplodeEvent createNewBlockExplodeEvent( + Block block, + List blocks, + float yield + ) { + var version = Slimefun.getMinecraftVersion(); + if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_21)) { + return new BlockExplodeEvent(block, block.getState(), blocks, yield, ExplosionResult.DESTROY); + } else if (pre21ExplodeEventConstructor != null) { + try { + return (BlockExplodeEvent) pre21ExplodeEventConstructor.newInstance(block, blocks, yield); + } catch (Exception e) { + Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e); + } + + return null; + } else { + throw new IllegalStateException("BlockExplodeEvent constructor not found"); + } + } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java index 1bd21a0d3f..c2f07b5b99 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java @@ -9,8 +9,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemException; @@ -110,7 +108,7 @@ void testRecipeType() { void testIsItem() { ItemStack item = new CustomItemStack(Material.BEACON, "&cItem Test"); String id = "IS_ITEM_TEST"; - SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, id, item); + SlimefunItem sfItem = TestUtilities.mockSlimefunItem(plugin, id, new CustomItemStack(Material.BEACON, "&cItem Test")); sfItem.register(plugin); Assertions.assertTrue(sfItem.isItem(sfItem.getItem())); 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..4a954bbbba --- /dev/null +++ b/src/test/resources/biomes/1.21.x.json @@ -0,0 +1,67 @@ +[ + "minecraft:badlands", + "minecraft:bamboo_jungle", + "minecraft:basalt_deltas", + "minecraft:beach", + "minecraft:birch_forest", + "minecraft:cherry_grove", + "minecraft:cold_ocean", + "minecraft:crimson_forest", + "minecraft:custom", + "minecraft:dark_forest", + "minecraft:deep_cold_ocean", + "minecraft:deep_dark", + "minecraft:deep_frozen_ocean", + "minecraft:deep_lukewarm_ocean", + "minecraft:deep_ocean", + "minecraft:desert", + "minecraft:dripstone_caves", + "minecraft:end_barrens", + "minecraft:end_highlands", + "minecraft:end_midlands", + "minecraft:eroded_badlands", + "minecraft:flower_forest", + "minecraft:forest", + "minecraft:frozen_ocean", + "minecraft:frozen_peaks", + "minecraft:frozen_river", + "minecraft:grove", + "minecraft:ice_spikes", + "minecraft:jagged_peaks", + "minecraft:jungle", + "minecraft:lukewarm_ocean", + "minecraft:lush_caves", + "minecraft:mangrove_swamp", + "minecraft:meadow", + "minecraft:mushroom_fields", + "minecraft:nether_wastes", + "minecraft:ocean", + "minecraft:old_growth_birch_forest", + "minecraft:old_growth_pine_taiga", + "minecraft:old_growth_spruce_taiga", + "minecraft:plains", + "minecraft:river", + "minecraft:savanna", + "minecraft:savanna_plateau", + "minecraft:small_end_islands", + "minecraft:snowy_beach", + "minecraft:snowy_plains", + "minecraft:snowy_slopes", + "minecraft:snowy_taiga", + "minecraft:soul_sand_valley", + "minecraft:sparse_jungle", + "minecraft:stony_peaks", + "minecraft:stony_shore", + "minecraft:sunflower_plains", + "minecraft:swamp", + "minecraft:taiga", + "minecraft:the_end", + "minecraft:the_void", + "minecraft:warm_ocean", + "minecraft:warped_forest", + "minecraft:windswept_forest", + "minecraft:windswept_gravelly_hills", + "minecraft:windswept_hills", + "minecraft:windswept_savanna", + "minecraft:wooded_badlands" +]