mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 11:53:43 +01:00
Make Basin interaction with Funnels work
Allows Basins to interact with downward facing Funnels located at an offset below and to the side. Previously would show a connection between basin and funnel but would not interact with them.
This commit is contained in:
parent
2a19b5eb41
commit
673fc3cd8e
1 changed files with 28 additions and 10 deletions
|
@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.fluids.particle.FluidParticleDat
|
||||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||||
|
import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity;
|
||||||
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
|
||||||
import com.simibubi.create.foundation.item.SmartInventory;
|
import com.simibubi.create.foundation.item.SmartInventory;
|
||||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||||
|
@ -26,6 +27,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputB
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
|
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
|
||||||
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
|
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
|
||||||
|
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.Couple;
|
import com.simibubi.create.foundation.utility.Couple;
|
||||||
import com.simibubi.create.foundation.utility.IntAttached;
|
import com.simibubi.create.foundation.utility.IntAttached;
|
||||||
|
@ -307,9 +309,15 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
Direction direction = blockState.get(BasinBlock.FACING);
|
Direction direction = blockState.get(BasinBlock.FACING);
|
||||||
TileEntity te = world.getTileEntity(pos.down()
|
TileEntity te = world.getTileEntity(pos.down()
|
||||||
.offset(direction));
|
.offset(direction));
|
||||||
|
FilteringBehaviour filter = null;
|
||||||
|
InvManipulationBehaviour inserter = null;
|
||||||
|
if (te != null) {
|
||||||
|
filter = TileEntityBehaviour.get(world, te.getPos(), FilteringBehaviour.TYPE);
|
||||||
|
inserter = TileEntityBehaviour.get(world, te.getPos(), InvManipulationBehaviour.TYPE);
|
||||||
|
}
|
||||||
IItemHandler targetInv = te == null ? null
|
IItemHandler targetInv = te == null ? null
|
||||||
: te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite())
|
: te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite())
|
||||||
.orElse(null);
|
.orElse(inserter == null ? null : inserter.getInventory());
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
|
|
||||||
for (Iterator<ItemStack> iterator = spoutputBuffer.iterator(); iterator.hasNext();) {
|
for (Iterator<ItemStack> iterator = spoutputBuffer.iterator(); iterator.hasNext();) {
|
||||||
|
@ -321,13 +329,16 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
update = true;
|
update = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetInv == null)
|
if (targetInv == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true)
|
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true)
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
if (filter != null && !filter.test(itemStack))
|
||||||
|
continue;
|
||||||
|
|
||||||
update = true;
|
update = true;
|
||||||
ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false);
|
ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
@ -414,6 +425,9 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
|
|
||||||
IItemHandler targetInv = null;
|
IItemHandler targetInv = null;
|
||||||
IFluidHandler targetTank = null;
|
IFluidHandler targetTank = null;
|
||||||
|
TileEntity te = null;
|
||||||
|
|
||||||
|
InvManipulationBehaviour inserter = null;
|
||||||
|
|
||||||
if (direction == Direction.DOWN) {
|
if (direction == Direction.DOWN) {
|
||||||
// No output basin, gather locally
|
// No output basin, gather locally
|
||||||
|
@ -425,30 +439,34 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
||||||
// Output basin, try moving items to it
|
// Output basin, try moving items to it
|
||||||
if (!spoutputBuffer.isEmpty())
|
if (!spoutputBuffer.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
TileEntity te = world.getTileEntity(pos.down()
|
te = world.getTileEntity(pos.down()
|
||||||
.offset(direction));
|
.offset(direction));
|
||||||
if (te == null)
|
if (te == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
inserter = TileEntityBehaviour.get(world, te.getPos(), InvManipulationBehaviour.TYPE);
|
||||||
targetInv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite())
|
targetInv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite())
|
||||||
.orElse(null);
|
.orElse(inserter == null ? null : inserter.getInventory());
|
||||||
targetTank = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction.getOpposite())
|
targetTank = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, direction.getOpposite())
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetInv == null && !outputItems.isEmpty())
|
if (targetInv == null && !outputItems.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
FilteringBehaviour filter = TileEntityBehaviour.get(world, te.getPos(), FilteringBehaviour.TYPE);
|
||||||
for (ItemStack itemStack : outputItems) {
|
for (ItemStack itemStack : outputItems) {
|
||||||
// Catalyst items are never consumed
|
// Catalyst items are never consumed
|
||||||
if (itemStack.hasContainerItem() && itemStack.getContainerItem()
|
if (itemStack.hasContainerItem() && itemStack.getContainerItem()
|
||||||
.isItemEqual(itemStack))
|
.isItemEqual(itemStack))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (simulate || direction == Direction.DOWN) {
|
if (simulate || direction == Direction.DOWN) {
|
||||||
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
|
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
|
||||||
.isEmpty())
|
.isEmpty() || (filter != null && !filter.test(itemStack)))
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else {
|
||||||
spoutputBuffer.add(itemStack.copy());
|
spoutputBuffer.add(itemStack.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputFluids.isEmpty())
|
if (outputFluids.isEmpty())
|
||||||
|
|
Loading…
Reference in a new issue