Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryhon0 committed Jun 13, 2024
1 parent 43430ed commit 5e8ed6d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
fabric_version=0.100.1+1.21
modmenu_version=11.0.0-beta.1
8 changes: 4 additions & 4 deletions src/main/java/xyz/ryhon/replanterplus/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/xyz/ryhon/replanterplus/ReplanterPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,13 +23,16 @@
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;
import net.minecraft.entity.player.PlayerInventory;
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;
Expand Down Expand Up @@ -252,8 +256,12 @@ void holdFortuneItem(PlayerEntity p) {
int slot = -1;

PlayerInventory pi = p.getInventory();
Optional<RegistryEntry.Reference<Enchantment>> 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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"accessWidener": "replanter.accesswidener",
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": "~1.20.2",
"fabricloader": "*",
"minecraft": "~1.21",
"java": ">=17",
"fabric-api": "*"
},
Expand Down

0 comments on commit 5e8ed6d

Please sign in to comment.