Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Oct 1, 2024
1 parent 9f175bf commit afaf3aa
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 14 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${paper.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!-- Testing dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Enchantment> enchantments = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> 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);
}
}
}

Expand Down Expand Up @@ -207,14 +209,16 @@ 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) {
Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e);
}

return null;
} else {
throw new IllegalStateException("BlockExplodeEvent constructor not found");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand All @@ -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[] {
Expand All @@ -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[] {
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/biomes/1.20.5+.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@
"minecraft:jagged_peaks",
"minecraft:stony_peaks",
"minecraft:cherry_grove",
"minecraft:custom",
"minecraft:custom"
]
2 changes: 1 addition & 1 deletion src/test/resources/biomes/1.20.x.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@
"minecraft:jagged_peaks",
"minecraft:stony_peaks",
"minecraft:cherry_grove",
"minecraft:custom",
"minecraft:custom"
]
67 changes: 67 additions & 0 deletions src/test/resources/biomes/1.21.x.json
Original file line number Diff line number Diff line change
@@ -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"
]

0 comments on commit afaf3aa

Please sign in to comment.