diff --git a/gradle.properties b/gradle.properties index 99614aa..b90d9f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.4 +minecraft_version=1.21 +yarn_mappings=1.21+build.1 loader_version=0.15.11 # Mod Properties @@ -14,5 +14,5 @@ maven_group=xyz.ryhon.replanterplus archives_base_name=replanter-plus # Dependencies -fabric_version=0.91.6+1.20.2 -modmenu_version=8.0.1 \ No newline at end of file +fabric_version=0.100.1+1.21 +modmenu_version=11.0.0-beta.1 \ No newline at end of file diff --git a/src/main/java/xyz/ryhon/replanterplus/ConfigScreen.java b/src/main/java/xyz/ryhon/replanterplus/ConfigScreen.java index 7fef345..c566406 100644 --- a/src/main/java/xyz/ryhon/replanterplus/ConfigScreen.java +++ b/src/main/java/xyz/ryhon/replanterplus/ConfigScreen.java @@ -128,8 +128,8 @@ protected void updateMessage() { } public class SwitchButton extends ToggleButtonWidget { - private static final ButtonTextures TEXTURES = new ButtonTextures(new Identifier("widget/button"), - new Identifier("widget/button"), new Identifier("widget/button_highlighted")); + private static final ButtonTextures TEXTURES = new ButtonTextures(Identifier.of("widget/button"), + Identifier.of("widget/button"), Identifier.of("widget/button_highlighted")); public SwitchButton(int x, int y, int width, int height, boolean toggled) { super(x, y, width, height, toggled); @@ -146,8 +146,8 @@ protected boolean clicked(double mouseX, double mouseY) { } @Override - public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { - super.renderButton(context, mouseX, mouseY, delta); + public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + super.renderWidget(context, mouseX, mouseY, delta); context.drawCenteredTextWithShadow(textRenderer, Text.translatable("replanter.switchbutton.label." + (toggled ? "on" : "off")), getX() + (width / 2), getY() + (height / 2) - (textRenderer.fontHeight / 2), diff --git a/src/main/java/xyz/ryhon/replanterplus/ReplanterPlus.java b/src/main/java/xyz/ryhon/replanterplus/ReplanterPlus.java index daf6068..72a1643 100644 --- a/src/main/java/xyz/ryhon/replanterplus/ReplanterPlus.java +++ b/src/main/java/xyz/ryhon/replanterplus/ReplanterPlus.java @@ -2,6 +2,7 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.util.Optional; import org.lwjgl.glfw.GLFW; import org.slf4j.Logger; @@ -22,6 +23,7 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; +import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.player.PlayerEntity; @@ -29,6 +31,8 @@ import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -252,8 +256,12 @@ void holdFortuneItem(PlayerEntity p) { int slot = -1; PlayerInventory pi = p.getInventory(); + Optional> fortune = p.getWorld().getRegistryManager().get(RegistryKeys.ENCHANTMENT).getEntry(Enchantments.FORTUNE); + // Server removed the Fortune enchantment???? + if(!fortune.isPresent()) return; + for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { - int lvl = EnchantmentHelper.getLevel(Enchantments.FORTUNE, pi.getStack(i)); + int lvl = EnchantmentHelper.getLevel(fortune.get(), pi.getStack(i)); if (lvl > maxLevel) { maxLevel = lvl; slot = i; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ab1a68b..6cf8a1e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -25,8 +25,8 @@ }, "accessWidener": "replanter.accesswidener", "depends": { - "fabricloader": ">=0.15.0", - "minecraft": "~1.20.2", + "fabricloader": "*", + "minecraft": "~1.21", "java": ">=17", "fabric-api": "*" },