Skip to content

Commit

Permalink
Allow plunger to drain all fluid when sneaking
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Jan 10, 2025
1 parent d4197ea commit 2d281ee
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
public class BehaviourPlungerFluid extends BehaviourNone {

private final int mCosts;
private final String mTooltip = GTLanguageManager
.addStringLocalization("gt.behaviour.plunger.fluid", "Clears 1000 Liters of Fluid from Tanks");
private final String mTooltip = GTLanguageManager.addStringLocalization(
"gt.behaviour.plunger.fluid",
"Clears 1000 Liters of Fluid from Tanks. Fully clears when sneaking.");

public BehaviourPlungerFluid(int aCosts) {
this.mCosts = aCosts;
Expand All @@ -34,13 +35,14 @@ public boolean onItemUseFirst(MetaBaseItem aItem, ItemStack aStack, EntityPlayer
if (aWorld.isRemote) {
return false;
}
int drainAmount = aPlayer.isSneaking() ? Integer.MAX_VALUE : 1000;
TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if ((aTileEntity instanceof IFluidHandler)) {
for (ForgeDirection tDirection : ForgeDirection.VALID_DIRECTIONS) {
if (((IFluidHandler) aTileEntity).drain(tDirection, 1000, false) != null) {
if (((IFluidHandler) aTileEntity).drain(tDirection, drainAmount, false) != null) {
if ((aPlayer.capabilities.isCreativeMode)
|| (((MetaGeneratedTool) aItem).doDamage(aStack, this.mCosts))) {
((IFluidHandler) aTileEntity).drain(tDirection, 1000, true);
((IFluidHandler) aTileEntity).drain(tDirection, drainAmount, true);
GTUtility.sendSoundToPlayers(
aWorld,
SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE,
Expand All @@ -58,7 +60,7 @@ public boolean onItemUseFirst(MetaBaseItem aItem, ItemStack aStack, EntityPlayer
IMetaTileEntity mTileEntity = tTileEntity.getMetaTileEntity();
if (mTileEntity instanceof MTEBasicTank machine) {
if (machine.mFluid != null && machine.mFluid.amount > 0)
machine.mFluid.amount = machine.mFluid.amount - Math.min(machine.mFluid.amount, 1000);
machine.mFluid.amount = machine.mFluid.amount - Math.min(machine.mFluid.amount, drainAmount);
GTUtility
.sendSoundToPlayers(aWorld, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1.0F, aX, aY, aZ);
return true;
Expand Down

0 comments on commit 2d281ee

Please sign in to comment.