From 191452fbbddf5341195803a6b252e4f8052bc6fe Mon Sep 17 00:00:00 2001 From: Adrian Date: Mon, 20 Jul 2015 16:49:20 +0200 Subject: [PATCH] fix bucket handling for down/up directions --- .../stripes/StripesHandlerBucket.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/common/buildcraft/transport/stripes/StripesHandlerBucket.java b/common/buildcraft/transport/stripes/StripesHandlerBucket.java index 45ecbbb1..53be65a3 100644 --- a/common/buildcraft/transport/stripes/StripesHandlerBucket.java +++ b/common/buildcraft/transport/stripes/StripesHandlerBucket.java @@ -43,40 +43,44 @@ public class StripesHandlerBucket implements IStripesHandler { ForgeDirection direction, ItemStack stack, EntityPlayer player, IStripesActivator activator) { if (world.isAirBlock(x, y, z)) { - Block underblock = world.getBlock(x, y - 1, z); - - if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, y - 1, z)) { + if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, direction.ordinal() < 2 ? y : (y - 1), z)) { activator.sendItem(emptyBucket, direction.getOpposite()); stack.stackSize--; if (stack.stackSize > 0) { activator.sendItem(stack, direction.getOpposite()); } - - return true; - } else { - if (!FluidContainerRegistry.isEmptyContainer(stack)) { - activator.sendItem(stack, direction.getOpposite()); - return true; - } - - FluidStack fluidStack = BlockUtils.drainBlock(underblock, world, x, y - 1, z, true); - ItemStack filledBucket = getFilledBucket(fluidStack, underblock); - - if (fluidStack == null || filledBucket == null) { - activator.sendItem(stack, direction.getOpposite()); - return true; - } - - activator.sendItem(filledBucket, direction.getOpposite()); - stack.stackSize--; - if (stack.stackSize > 0) { - activator.sendItem(stack, direction.getOpposite()); - } return true; } } - return false; + + if (!FluidContainerRegistry.isEmptyContainer(stack)) { + activator.sendItem(stack, direction.getOpposite()); + return true; + } + + Block targetBlock = world.getBlock(x, y, z); + FluidStack fluidStack = BlockUtils.drainBlock(targetBlock, world, x, y, z, true); + + if (fluidStack == null) { + targetBlock = world.getBlock(x, y - 1, z); + fluidStack = BlockUtils.drainBlock(targetBlock, world, x, y - 1, z, true); + } + + ItemStack filledBucket = getFilledBucket(fluidStack, targetBlock); + + if (fluidStack == null || filledBucket == null) { + activator.sendItem(stack, direction.getOpposite()); + return true; + } + + activator.sendItem(filledBucket, direction.getOpposite()); + stack.stackSize--; + if (stack.stackSize > 0) { + activator.sendItem(stack, direction.getOpposite()); + } + + return true; } }