From 65412f0c89e9191c492a3a54359c769e329e885d Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 19 Dec 2023 08:02:11 +0100 Subject: [PATCH] oop forgot to push this --- .../java/com/hbm/extprop/HbmPlayerProps.java | 6 ++- .../com/hbm/handler/EntityEffectHandler.java | 45 +++++++++++++++++++ .../TileEntityMachineCrystallizer.java | 10 +++++ .../storage/TileEntityMachineFluidTank.java | 10 +++++ 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/extprop/HbmPlayerProps.java b/src/main/java/com/hbm/extprop/HbmPlayerProps.java index f51905229..4f28169c2 100644 --- a/src/main/java/com/hbm/extprop/HbmPlayerProps.java +++ b/src/main/java/com/hbm/extprop/HbmPlayerProps.java @@ -43,6 +43,8 @@ public class HbmPlayerProps implements IExtendedEntityProperties { public int reputation; + public boolean isOnLadder = false; + public HbmPlayerProps(EntityPlayer player) { this.player = player; } @@ -153,13 +155,14 @@ public class HbmPlayerProps implements IExtendedEntityProperties { public void saveNBTData(NBTTagCompound nbt) { NBTTagCompound props = new NBTTagCompound(); - + props.setBoolean("hasReceivedBook", hasReceivedBook); props.setFloat("shield", shield); props.setFloat("maxShield", maxShield); props.setBoolean("enableBackpack", enableBackpack); props.setBoolean("enableHUD", enableHUD); props.setInteger("reputation", reputation); + props.setBoolean("isOnLadder", isOnLadder); nbt.setTag("HbmPlayerProps", props); } @@ -176,6 +179,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties { this.enableBackpack = props.getBoolean("enableBackpack"); this.enableHUD = props.getBoolean("enableHUD"); this.reputation = props.getInteger("reputation"); + this.isOnLadder = props.getBoolean("isOnLadder"); } } } diff --git a/src/main/java/com/hbm/handler/EntityEffectHandler.java b/src/main/java/com/hbm/handler/EntityEffectHandler.java index c38cf5755..296724e2d 100644 --- a/src/main/java/com/hbm/handler/EntityEffectHandler.java +++ b/src/main/java/com/hbm/handler/EntityEffectHandler.java @@ -102,6 +102,51 @@ public class EntityEffectHandler { handleDashing(entity); handlePlinking(entity); + + if(entity instanceof EntityPlayer) handleFauxLadder((EntityPlayer) entity); + } + + private static void handleFauxLadder(EntityPlayer player) { + + HbmPlayerProps props = HbmPlayerProps.getData(player); + + if(props.isOnLadder) { + float f5 = 0.15F; + + if(player.motionX < (double) (-f5)) { + player.motionX = (double) (-f5); + } + + if(player.motionX > (double) f5) { + player.motionX = (double) f5; + } + + if(player.motionZ < (double) (-f5)) { + player.motionZ = (double) (-f5); + } + + if(player.motionZ > (double) f5) { + player.motionZ = (double) f5; + } + + player.fallDistance = 0.0F; + + if(player.motionY < -0.15D) { + player.motionY = -0.15D; + } + + if(player.isSneaking() && player.motionY < 0.0D) { + player.motionY = 0.0D; + } + + if(player.isCollidedHorizontally) { + player.motionY = 0.2D; + } + + props.isOnLadder = false; + + if(!player.worldObj.isRemote) ArmorUtil.resetFlightTime(player); + } } private static void handleContamination(EntityLivingBase entity) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCrystallizer.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCrystallizer.java index d91e8f629..bac1b5928 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCrystallizer.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCrystallizer.java @@ -4,6 +4,7 @@ import java.util.List; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; +import com.hbm.extprop.HbmPlayerProps; import com.hbm.inventory.UpgradeManager; import com.hbm.inventory.container.ContainerCrystallizer; import com.hbm.inventory.fluid.Fluids; @@ -111,6 +112,15 @@ public class TileEntityMachineCrystallizer extends TileEntityMachineBase impleme } } } + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 6.875, zCoord + 1).offset(dir.offsetX * 0.75 + rot.offsetX * 1.25, 0, dir.offsetZ * 0.75 + rot.offsetZ * 1.25)); + + for(EntityPlayer player : players) { + HbmPlayerProps props = HbmPlayerProps.getData(player); + props.isOnLadder = true; + } } private void updateConnections() { diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java index 3b4e8d261..dc147cbbf 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java @@ -4,6 +4,7 @@ import api.hbm.fluid.IFluidStandardTransceiver; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.explosion.vanillant.ExplosionVNT; +import com.hbm.extprop.HbmPlayerProps; import com.hbm.handler.MultiblockHandlerXR; import com.hbm.handler.pollution.PollutionHandler; import com.hbm.handler.pollution.PollutionHandler.PollutionType; @@ -168,6 +169,15 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements this.tank.writeToNBT(data, "t"); this.networkPack(data, 150); } + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2.875, zCoord + 1).offset(dir.offsetX * 0.5 - rot.offsetX * 2.25, 0, dir.offsetZ * 0.5 - rot.offsetZ * 2.25)); + + for(EntityPlayer player : players) { + HbmPlayerProps props = HbmPlayerProps.getData(player); + props.isOnLadder = true; + } } /** called when the tank breaks due to hazardous materials or external force, can be used to quickly void part of the tank or spawn a mushroom cloud */