From 993da6eeb998b4963c06849f3128af4c1e325606 Mon Sep 17 00:00:00 2001 From: TonimatasDEV Date: Fri, 5 Jul 2024 16:37:17 +0200 Subject: [PATCH] Don't crash only log it --- .../server/level/ServerPlayerGameMode.java.patch | 3 ++- .../java/net/minecraftforge/fluids/FluidStack.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index a5b797be8c..205aa48e64 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -351,7 +351,7 @@ ItemStack itemstack = interactionresultholder.getObject(); if (itemstack == p_9264_ && itemstack.getCount() == i && itemstack.getUseDuration() <= 0 && itemstack.getDamageValue() == j) { return interactionresultholder.getResult(); -@@ -294,52 +_,127 @@ +@@ -294,52 +_,128 @@ } } @@ -467,6 +467,7 @@ } - } + return useItemOn$result; ++ // CraftBukkit end + } finally { + useItemOn$result = InteractionResult.PASS; + useItemOn$cancelled = false; diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index 8b5eeba3a8..fb46a0e65c 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.kettingpowered.ketting.core.Ketting; import java.util.Optional; @@ -172,7 +173,10 @@ public int getAmount() public void setAmount(int amount) { - if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack."); + if (getRawFluid() == Fluids.EMPTY) { + Ketting.LOGGER.error("Can't modify the empty stack."); + return; + } this.amount = amount; updateEmpty(); } @@ -197,7 +201,10 @@ public CompoundTag getTag() public void setTag(CompoundTag tag) { - if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack."); + if (getRawFluid() == Fluids.EMPTY) { + Ketting.LOGGER.error("Can't modify the empty stack."); + return; + } this.tag = tag; }