diff --git a/gradle.properties b/gradle.properties index 7e3037f4..97eae240 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xmx2048m minecraft_version=1.20.1 forge_version=47.1.5 -mod_version=2.0.36 +mod_version=2.0.37 jei_mc_version=1.20.1-forge jei_version=15.1.0.19 curios_version=5.2.0-beta.3+1.20.1 diff --git a/src/main/java/reliquary/items/HeroMedallionItem.java b/src/main/java/reliquary/items/HeroMedallionItem.java index 41042d3c..203e026e 100644 --- a/src/main/java/reliquary/items/HeroMedallionItem.java +++ b/src/main/java/reliquary/items/HeroMedallionItem.java @@ -94,7 +94,7 @@ public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemS } private void drainExperienceLevel(ItemStack stack, Player player) { - int experiencePoints = player.isCreative() ? 100 : player.totalExperience - XpHelper.getExperienceForLevel(Math.max(getStopAtXpLevel(stack), player.experienceLevel - 1)); + int experiencePoints = player.isCreative() ? 100 : XpHelper.getTotalPlayerExperience(player) - XpHelper.getExperienceForLevel(Math.max(getStopAtXpLevel(stack), player.experienceLevel - 1)); if (experiencePoints > 0) { if (!player.isCreative()) { decreasePlayerExperience(player, experiencePoints); @@ -104,7 +104,7 @@ private void drainExperienceLevel(ItemStack stack, Player player) { } private void decreasePlayerExperience(Player player, int pointsToRemove) { - player.totalExperience -= pointsToRemove; + player.totalExperience = XpHelper.getTotalPlayerExperience(player) - pointsToRemove; int newLevel = XpHelper.getLevelForExperience(player.totalExperience); player.experienceLevel = newLevel; player.experienceProgress = (float) (player.totalExperience - XpHelper.getExperienceForLevel(newLevel)) / player.getXpNeededForNextLevel(); @@ -153,7 +153,7 @@ private void drainExperience(ItemStack stack, Player player, Level level, int xp spawnXpOnGround(stack, level, hitPos, xpLevels); } else { xpLevels += Math.round(player.experienceProgress); - int maxPoints = XpHelper.getExperienceForLevel(player.experienceLevel + xpLevels) - player.totalExperience; + int maxPoints = XpHelper.getExperienceForLevel(player.experienceLevel + xpLevels) - XpHelper.getTotalPlayerExperience(player); int pointsToAdd = player.isCreative() ? maxPoints : Math.min(maxPoints, getExperience(stack)); increasePlayerExperience(player, pointsToAdd); if (!player.isCreative()) { diff --git a/src/main/java/reliquary/util/XpHelper.java b/src/main/java/reliquary/util/XpHelper.java index e3c8b1ca..543cbbf4 100644 --- a/src/main/java/reliquary/util/XpHelper.java +++ b/src/main/java/reliquary/util/XpHelper.java @@ -1,5 +1,7 @@ package reliquary.util; +import net.minecraft.world.entity.player.Player; + public class XpHelper { private XpHelper() {} @@ -52,4 +54,8 @@ public static int durabilityToXp(int durability) { public static int xpToDurability(int xp) { return xp * 2; } + + public static int getTotalPlayerExperience(Player player) { + return getExperienceForLevel(player.experienceLevel) + ((int) player.experienceProgress * player.getXpNeededForNextLevel()); + } }