fix bucket handling for down/up directions

This commit is contained in:
Adrian 2015-07-20 16:49:20 +02:00
parent e00b6c0847
commit 191452fbbd

View file

@ -43,9 +43,7 @@ public class StripesHandlerBucket implements IStripesHandler {
ForgeDirection direction, ItemStack stack, EntityPlayer player, ForgeDirection direction, ItemStack stack, EntityPlayer player,
IStripesActivator activator) { IStripesActivator activator) {
if (world.isAirBlock(x, y, z)) { if (world.isAirBlock(x, y, z)) {
Block underblock = world.getBlock(x, y - 1, z); if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, direction.ordinal() < 2 ? y : (y - 1), z)) {
if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, y - 1, z)) {
activator.sendItem(emptyBucket, direction.getOpposite()); activator.sendItem(emptyBucket, direction.getOpposite());
stack.stackSize--; stack.stackSize--;
if (stack.stackSize > 0) { if (stack.stackSize > 0) {
@ -53,14 +51,23 @@ public class StripesHandlerBucket implements IStripesHandler {
} }
return true; return true;
} else { }
}
if (!FluidContainerRegistry.isEmptyContainer(stack)) { if (!FluidContainerRegistry.isEmptyContainer(stack)) {
activator.sendItem(stack, direction.getOpposite()); activator.sendItem(stack, direction.getOpposite());
return true; return true;
} }
FluidStack fluidStack = BlockUtils.drainBlock(underblock, world, x, y - 1, z, true); Block targetBlock = world.getBlock(x, y, z);
ItemStack filledBucket = getFilledBucket(fluidStack, underblock); 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) { if (fluidStack == null || filledBucket == null) {
activator.sendItem(stack, direction.getOpposite()); activator.sendItem(stack, direction.getOpposite());
@ -75,8 +82,5 @@ public class StripesHandlerBucket implements IStripesHandler {
return true; return true;
} }
}
return false;
}
} }