aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Machines.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
index b95a1728d1..fb8a9cbe89 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
@@ -244,13 +244,16 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem {
if (tNBT == null) return;
if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) ||
(tNBT.hasKey("mFluid") && FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")).amount > 64000)) {
- double tFluidAmount = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")).amount;
- double tMiddlePoint = 4096000;
- double tSmoothingCoefficient = 2000000;
- int tMaxLastingTime = 12000;
- double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient;
- int tLasing = (int) (Math.exp(tmp) / (Math.exp(tmp) + Math.exp(-tmp)) * tMaxLastingTime);
- if (tFluidAmount == 0) tLasing = 1200;
+ FluidStack tFluid = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid"));
+ int tLasing = 1200;
+ if (tFluid != null) {
+ double tFluidAmount = tFluid.amount;
+ double tMiddlePoint = 4096000;
+ double tSmoothingCoefficient = 2000000;
+ int tMaxLastingTime = 12000;
+ double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient;
+ tLasing = (int) (Math.exp(tmp) / (Math.exp(tmp) + Math.exp(-tmp)) * tMaxLastingTime);
+ }
tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, tLasing, 4));
tPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, tLasing, 4));
tPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, tLasing, 4));