From 7f56bfabba5fcf57fe1088ba9743564c04be134a Mon Sep 17 00:00:00 2001
From: Jenny <jennytsonline@proton.me>
Date: Fri, 14 Mar 2025 09:30:06 +0100
Subject: [PATCH] 1.21 working

---
 gradle.properties                                    | 12 ++++++------
 src/main/java/com/jenny/xp2items/Xp2Items.java       |  4 ++--
 src/main/java/com/jenny/xp2items/items/items.java    |  5 +----
 .../java/com/jenny/xp2items/items/xpTalisman.java    |  6 +++---
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/gradle.properties b/gradle.properties
index 837c73a..1c32fbe 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +1,17 @@
 org.gradle.jvmargs=-Xmx3G
 org.gradle.daemon=false
 # The Minecraft version must agree with the Forge version to get a valid artifact
-minecraft_version=1.21.4
+minecraft_version=1.21
 # The Minecraft version range can use any release version of Minecraft as bounds.
 # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
 # as they do not follow standard versioning conventions.
-minecraft_version_range=[1.21.4,1.22)
+minecraft_version_range=[1.21]
 # The Forge version must agree with the Minecraft version to get a valid artifact
-forge_version=54.1.0
+forge_version=51.0.32
 # The Forge version range can use any version of Forge as bounds or match the loader version range
-forge_version_range=[54,)
+forge_version_range=[51,)
 # The loader version range can only use the major version of Forge/FML as bounds
-loader_version_range=[54,)
+loader_version_range=[51,)
 # The mapping channel to use for mappings.
 # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
 # Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
@@ -29,7 +29,7 @@ loader_version_range=[54,)
 mapping_channel=official
 # The mapping version to query from the mapping channel.
 # This must match the format required by the mapping channel.
-mapping_version=1.21.4
+mapping_version=1.21
 # The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
 # Must match the String constant located in the main mod class annotated with @Mod.
 mod_id=xp2items
diff --git a/src/main/java/com/jenny/xp2items/Xp2Items.java b/src/main/java/com/jenny/xp2items/Xp2Items.java
index c6924ec..50fda7b 100644
--- a/src/main/java/com/jenny/xp2items/Xp2Items.java
+++ b/src/main/java/com/jenny/xp2items/Xp2Items.java
@@ -14,8 +14,8 @@ public class Xp2Items {
 
     public static final String MODID = "xp2items";
 
-    public Xp2Items(FMLJavaModLoadingContext context) {
-        IEventBus modEventBus = context.getModEventBus();
+    public Xp2Items() {
+        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
 
         items.register(modEventBus);
         creativeTab.register(modEventBus);
diff --git a/src/main/java/com/jenny/xp2items/items/items.java b/src/main/java/com/jenny/xp2items/items/items.java
index 95d08a6..ca12a7f 100644
--- a/src/main/java/com/jenny/xp2items/items/items.java
+++ b/src/main/java/com/jenny/xp2items/items/items.java
@@ -1,8 +1,5 @@
 package com.jenny.xp2items.items;
 
-import net.minecraft.core.registries.Registries;
-import net.minecraft.resources.ResourceKey;
-import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.item.Item;
 import net.minecraftforge.eventbus.api.IEventBus;
 import net.minecraftforge.registries.DeferredRegister;
@@ -14,7 +11,7 @@ import static com.jenny.xp2items.Xp2Items.MODID;
 public class items {
     public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
 
-    public static final RegistryObject<Item> XP_TALISMAN = ITEMS.register("xp_talisman", () -> new xpTalisman(new Item.Properties().setId(ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(MODID, "xp_talisman"))).stacksTo(1)));
+    public static final RegistryObject<Item> XP_TALISMAN = ITEMS.register("xp_talisman", () -> new xpTalisman(new Item.Properties().stacksTo(1)));
 
     public static void register(IEventBus bus) {
         ITEMS.register(bus);
diff --git a/src/main/java/com/jenny/xp2items/items/xpTalisman.java b/src/main/java/com/jenny/xp2items/items/xpTalisman.java
index bc86f29..f23c871 100644
--- a/src/main/java/com/jenny/xp2items/items/xpTalisman.java
+++ b/src/main/java/com/jenny/xp2items/items/xpTalisman.java
@@ -7,7 +7,7 @@ import net.minecraft.sounds.SoundEvents;
 import net.minecraft.sounds.SoundSource;
 import net.minecraft.util.Mth;
 import net.minecraft.world.InteractionHand;
-import net.minecraft.world.InteractionResult;
+import net.minecraft.world.InteractionResultHolder;
 import net.minecraft.world.entity.item.ItemEntity;
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.Item;
@@ -68,7 +68,7 @@ public class xpTalisman extends Item {
     }
 
     @Override
-    public @NotNull InteractionResult use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
+    public InteractionResultHolder<ItemStack> use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
         if (!level.isClientSide) {
             if (ServerConfig.C_XP_AMOUNT.get() > 0) { // xp amount mode
                 spawnItem(level, (ServerPlayer) player);
@@ -78,6 +78,6 @@ public class xpTalisman extends Item {
         } else {
             effects(level, player);
         }
-        return InteractionResult.SUCCESS;
+        return InteractionResultHolder.success(player.getItemInHand(interactionHand));
     }
 }