diff options
author | GlodBlock <60341015+GlodBlock@users.noreply.github.com> | 2021-12-05 22:44:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-05 15:44:11 +0100 |
commit | c63f060da10659224ff227134deece2aca166df3 (patch) | |
tree | 6129c406d0e407b7324d8f7a082ad86440c6051f /src/main/java/gregtech/common/blocks | |
parent | 28278d254c8812d85b6b4ca0bc858bc0b004d478 (diff) | |
download | GT5-Unofficial-c63f060da10659224ff227134deece2aca166df3.tar.gz GT5-Unofficial-c63f060da10659224ff227134deece2aca166df3.tar.bz2 GT5-Unofficial-c63f060da10659224ff227134deece2aca166df3.zip |
make the debuff time depend on contents (#780)
Diffstat (limited to 'src/main/java/gregtech/common/blocks')
-rw-r--r-- | src/main/java/gregtech/common/blocks/GT_Item_Machines.java | 17 |
1 files changed, 12 insertions, 5 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 b59dd1d848..b95a1728d1 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -243,11 +243,18 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { NBTTagCompound tNBT = aStack.stackTagCompound; if (tNBT == null) return; if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) || - tNBT.hasKey("mFluid")) { - tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, 12000, 4)); - tPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 12000, 4)); - tPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 12000, 4)); - tPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, 12000, 4)); + (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; + 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)); + tPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, tLasing, 4)); } } } |