diff --git a/CHANGELOG.md b/CHANGELOG.md index b7bc9ea..4339063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,4 @@ ### Fixed: - ### Changed: -- Updated to mc 1.20.6 \ No newline at end of file +- Updated to mc 1.21 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6a361e1..c2f5b85 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs = -Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.20.6 - yarn_mappings=1.20.6+build.1 - loader_version=0.15.10 + minecraft_version=1.21 + yarn_mappings=1.21+build.2 + loader_version=0.15.11 # Mod Properties mod_version = 1.2.15 @@ -13,7 +13,7 @@ org.gradle.jvmargs = -Xmx1G archives_base_name = backslot # Dependencies - fabric_version=0.97.8+1.20.6 - cloth_config_version=14.0.126 - mod_menu_version=10.0.0-beta.1 + fabric_version=0.100.3+1.21 + cloth_config_version=15.0.127 + mod_menu_version=11.0.0 amecs_version=1.5.5+mc1.20.2 diff --git a/jitpack.yml b/jitpack.yml index 80847d7..f84ce2a 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,5 +1,5 @@ jdk: - - openjdk17 + - openjdk21 before_install: - - sdk install java 17.0.3-tem - - sdk use java 17.0.3-tem + - sdk install java 21.0.0-tem + - sdk use java 21.0.0-tem diff --git a/src/main/java/net/backslot/BackSlotMain.java b/src/main/java/net/backslot/BackSlotMain.java index bf0d407..ceebc08 100644 --- a/src/main/java/net/backslot/BackSlotMain.java +++ b/src/main/java/net/backslot/BackSlotMain.java @@ -16,8 +16,8 @@ public class BackSlotMain implements ModInitializer { public static BackSlotConfig CONFIG = new BackSlotConfig(); - public static final TagKey BACKSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, new Identifier("backslot", "backslot_items")); - public static final TagKey BELTSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, new Identifier("backslot", "beltslot_items")); + public static final TagKey BACKSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("backslot", "backslot_items")); + public static final TagKey BELTSLOT_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("backslot", "beltslot_items")); public static final boolean isMedievalWeaponsLoaded = FabricLoader.getInstance().isModLoaded("medievalweapons"); public static final boolean isMcdwLoaded = FabricLoader.getInstance().isModLoaded("mcdw"); @@ -30,6 +30,4 @@ public void onInitialize() { BackSlotServerPacket.init(); } - - } \ No newline at end of file diff --git a/src/main/java/net/backslot/client/key/SwitchKey.java b/src/main/java/net/backslot/client/key/SwitchKey.java index e0343eb..d528e3f 100644 --- a/src/main/java/net/backslot/client/key/SwitchKey.java +++ b/src/main/java/net/backslot/client/key/SwitchKey.java @@ -20,8 +20,8 @@ public class SwitchKey { public static void init() { - backSlotKeyBind = new AmecsKeyBinding(new Identifier("backslot", "switch_backslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers()); - beltSlotKeyBind = new AmecsKeyBinding(new Identifier("backslot", "switch_beltslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers().setShift(true)); + backSlotKeyBind = new AmecsKeyBinding(Identifier.of("backslot", "switch_backslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers()); + beltSlotKeyBind = new AmecsKeyBinding(Identifier.of("backslot", "switch_beltslot"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, "category.backslot.key", new KeyModifiers().setShift(true)); KeyBindingHelper.registerKeyBinding(backSlotKeyBind); KeyBindingHelper.registerKeyBinding(beltSlotKeyBind); ClientTickEvents.END_CLIENT_TICK.register(client -> { diff --git a/src/main/java/net/backslot/client/sprite/BackSlotSprites.java b/src/main/java/net/backslot/client/sprite/BackSlotSprites.java index 1d745c2..37304ab 100644 --- a/src/main/java/net/backslot/client/sprite/BackSlotSprites.java +++ b/src/main/java/net/backslot/client/sprite/BackSlotSprites.java @@ -16,14 +16,14 @@ @Environment(EnvType.CLIENT) public class BackSlotSprites { - public static final Identifier EMPTY_BACK_SLOT_TEXTURE = new Identifier("backslot", "gui/empty_back_slot"); - public static final Identifier EMPTY_BELT_SLOT_TEXTURE = new Identifier("backslot", "gui/empty_belt_slot"); + public static final Identifier EMPTY_BACK_SLOT_TEXTURE = Identifier.of("backslot", "gui/empty_back_slot"); + public static final Identifier EMPTY_BELT_SLOT_TEXTURE = Identifier.of("backslot", "gui/empty_belt_slot"); - public static final Identifier HOTBAR_BACK_SLOT_TEXTURE = new Identifier("backslot", "textures/gui/hotbar_back_slot.png"); - public static final Identifier HOTBAR_BELT_SLOT_TEXTURE = new Identifier("backslot", "textures/gui/hotbar_back_slot.png"); + public static final Identifier HOTBAR_BACK_SLOT_TEXTURE = Identifier.of("backslot", "textures/gui/hotbar_back_slot.png"); + public static final Identifier HOTBAR_BELT_SLOT_TEXTURE = Identifier.of("backslot", "textures/gui/hotbar_back_slot.png"); public static void init() { - HudRenderCallback.EVENT.register((drawContext, tickDelta) -> { + HudRenderCallback.EVENT.register((drawContext, tickCounter) -> { MinecraftClient client = MinecraftClient.getInstance(); if (!client.options.hudHidden) { PlayerEntity playerEntity = client.player; @@ -41,14 +41,16 @@ public static void init() { RenderSystem.enableBlend(); drawContext.drawTexture(HOTBAR_BELT_SLOT_TEXTURE, i - 90 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p - 3 + BackSlotMain.CONFIG.hudSlotY, 0, 0, 22, 22, 22, 22); - renderHotbarItem(drawContext, client, i - 87 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity, backSlotStack, 0); + renderHotbarItem(drawContext, client, i - 87 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickCounter.getTickDelta(true), playerEntity, + backSlotStack, 0); } if (!beltSlotStack.isEmpty()) { // Required RenderSystem.enableBlend(); drawContext.drawTexture(HOTBAR_BACK_SLOT_TEXTURE, i - 112 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p - 3 + BackSlotMain.CONFIG.hudSlotY, 0, 0, 22, 22, 22, 22); - renderHotbarItem(drawContext, client, i - 109 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickDelta, playerEntity, beltSlotStack, 0); + renderHotbarItem(drawContext, client, i - 109 + leftHandX + BackSlotMain.CONFIG.hudSlotX, p + BackSlotMain.CONFIG.hudSlotY, tickCounter.getTickDelta(true), playerEntity, + beltSlotStack, 0); } } } diff --git a/src/main/java/net/backslot/mixin/ExperienceOrbEntityMixin.java b/src/main/java/net/backslot/mixin/ExperienceOrbEntityMixin.java index bb1c4a4..0bcb5bf 100644 --- a/src/main/java/net/backslot/mixin/ExperienceOrbEntityMixin.java +++ b/src/main/java/net/backslot/mixin/ExperienceOrbEntityMixin.java @@ -7,7 +7,6 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.At; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ExperienceOrbEntity; @@ -21,8 +20,12 @@ public class ExperienceOrbEntityMixin { private Map.Entry repairPlayerGearsMixin(Map.Entry original, PlayerEntity player, int amount) { ItemStack backStack = player.getInventory().getStack(41); ItemStack beltStack = player.getInventory().getStack(42); - boolean backSlotRepairable = !backStack.isEmpty() && backStack.isDamaged() && EnchantmentHelper.getLevel(Enchantments.MENDING, backStack) > 0; - boolean beltSlotRepairable = !beltStack.isEmpty() && beltStack.isDamaged() && EnchantmentHelper.getLevel(Enchantments.MENDING, beltStack) > 0; + boolean backSlotRepairable = !backStack.isEmpty() && backStack.isDamaged() + && beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry())); + boolean beltSlotRepairable = !beltStack.isEmpty() && beltStack.isDamaged() + && beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry())); + + beltStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.MENDING.getRegistry())); if (backSlotRepairable || beltSlotRepairable) { if (original != null) { if (backSlotRepairable && beltSlotRepairable) { diff --git a/src/main/java/net/backslot/mixin/PlayerScreenHandlerMixin.java b/src/main/java/net/backslot/mixin/PlayerScreenHandlerMixin.java index dee9ac9..308f769 100644 --- a/src/main/java/net/backslot/mixin/PlayerScreenHandlerMixin.java +++ b/src/main/java/net/backslot/mixin/PlayerScreenHandlerMixin.java @@ -10,8 +10,9 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; +import net.minecraft.recipe.CraftingRecipe; +import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.screen.AbstractRecipeScreenHandler; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.ScreenHandlerType; @@ -22,10 +23,10 @@ import net.backslot.network.SwitchPacketReceiver; import net.fabricmc.api.Environment; import net.fabricmc.api.EnvType; -import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; @Mixin(value = PlayerScreenHandler.class, priority = 999) -public abstract class PlayerScreenHandlerMixin extends AbstractRecipeScreenHandler { +public abstract class PlayerScreenHandlerMixin extends AbstractRecipeScreenHandler { private static boolean changeArrangement = BackSlotMain.CONFIG.changeSlotArrangement; public PlayerScreenHandlerMixin(ScreenHandlerType screenHandlerType, int i) { @@ -62,7 +63,9 @@ public boolean canInsert(ItemStack stack) { @Override public boolean canTakeItems(PlayerEntity playerEntity) { ItemStack itemStack = this.getStack(); - return !itemStack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemStack) ? false : super.canTakeItems(playerEntity); + return !itemStack.isEmpty() && !playerEntity.isCreative() + && itemStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.BINDING_CURSE.getRegistry())) ? false + : super.canTakeItems(playerEntity); } @Environment(EnvType.CLIENT) @@ -87,7 +90,9 @@ public boolean canInsert(ItemStack stack) { @Override public boolean canTakeItems(PlayerEntity playerEntity) { ItemStack itemStack = this.getStack(); - return !itemStack.isEmpty() && !playerEntity.isCreative() && EnchantmentHelper.hasBindingCurse(itemStack) ? false : super.canTakeItems(playerEntity); + return !itemStack.isEmpty() && !playerEntity.isCreative() + && itemStack.getEnchantments().getEnchantments().stream().anyMatch(entry -> entry.matchesId(Enchantments.BINDING_CURSE.getRegistry())) ? false + : super.canTakeItems(playerEntity); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/net/backslot/mixin/client/InventoryScreenMixin.java b/src/main/java/net/backslot/mixin/client/InventoryScreenMixin.java index 2d1dbf0..aa6d87e 100644 --- a/src/main/java/net/backslot/mixin/client/InventoryScreenMixin.java +++ b/src/main/java/net/backslot/mixin/client/InventoryScreenMixin.java @@ -25,7 +25,7 @@ @Mixin(InventoryScreen.class) public abstract class InventoryScreenMixin extends AbstractInventoryScreen implements RecipeBookProvider { - private static final Identifier BACK_TEXTURE = new Identifier("backslot", "textures/gui/blank.png"); + private static final Identifier BACK_TEXTURE = Identifier.of("backslot", "textures/gui/blank.png"); @Shadow @Mutable @Final diff --git a/src/main/java/net/backslot/network/SwitchPacket.java b/src/main/java/net/backslot/network/SwitchPacket.java index 5955d67..2fc1aeb 100644 --- a/src/main/java/net/backslot/network/SwitchPacket.java +++ b/src/main/java/net/backslot/network/SwitchPacket.java @@ -7,7 +7,7 @@ public record SwitchPacket(int slotId) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier("backslot", "switch_item")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of("backslot", "switch_item")); public static final PacketCodec PACKET_CODEC = PacketCodec.of((value, buf) -> { buf.writeInt(value.slotId); diff --git a/src/main/java/net/backslot/network/VisibilityPacket.java b/src/main/java/net/backslot/network/VisibilityPacket.java index e4973a0..94a4af1 100644 --- a/src/main/java/net/backslot/network/VisibilityPacket.java +++ b/src/main/java/net/backslot/network/VisibilityPacket.java @@ -8,7 +8,7 @@ public record VisibilityPacket(int entityId, int slotId, ItemStack itemStack) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier("backslot", "visibility_packet")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of("backslot", "visibility_packet")); // public static final PacketCodec PACKET_CODEC = PacketCodec.of((value, buf) -> { // buf.writeInt(value.entityId); diff --git a/src/main/java/net/backslot/sound/BackSlotSounds.java b/src/main/java/net/backslot/sound/BackSlotSounds.java index a8578dd..1a6ba27 100644 --- a/src/main/java/net/backslot/sound/BackSlotSounds.java +++ b/src/main/java/net/backslot/sound/BackSlotSounds.java @@ -6,9 +6,9 @@ import net.minecraft.util.Identifier; public class BackSlotSounds { - public static final Identifier PACK_UP_ITEM = new Identifier("backslot:pack_up_item"); + public static final Identifier PACK_UP_ITEM = Identifier.of("backslot:pack_up_item"); public static SoundEvent PACK_UP_ITEM_EVENT = SoundEvent.of(PACK_UP_ITEM); - public static final Identifier SHEATH_SWORD = new Identifier("backslot:sheath_sword"); + public static final Identifier SHEATH_SWORD = Identifier.of("backslot:sheath_sword"); public static SoundEvent SHEATH_SWORD_EVENT = SoundEvent.of(SHEATH_SWORD); public static void init() { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 546dbc8..c235692 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ "backslot.mixins.json" ], "depends": { - "java": ">=17", + "java": ">=21", "minecraft": ">=${minecraft_version}", "fabric-api": ">=${fabric_version}", "fabricloader": ">=${loader_version}",