mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Prevent Belts under Tunnels from picking up item entities
This commit is contained in:
parent
ba0e851487
commit
813a1ccaba
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.contraptions.relays.belt.transport.BeltTunnelInteractionHandler;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
@ -198,6 +200,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
|
||||
return;
|
||||
if (!entityIn.isAlive())
|
||||
return;
|
||||
if (BeltTunnelInteractionHandler.getTunnelOnPosition(worldIn, pos) != null)
|
||||
return;
|
||||
withTileEntityDo(worldIn, pos, te -> {
|
||||
ItemEntity itemEntity = (ItemEntity) entityIn;
|
||||
IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
|
@ -43,7 +43,7 @@ public class BeltTunnelInteractionHandler {
|
||||
World world = beltInventory.belt.getWorld();
|
||||
boolean onServer = !world.isRemote || beltInventory.belt.isVirtual();
|
||||
boolean removed = false;
|
||||
BeltTunnelTileEntity nextTunnel = getTunnelOnSegement(beltInventory, upcomingSegment);
|
||||
BeltTunnelTileEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment);
|
||||
|
||||
if (nextTunnel instanceof BrassTunnelTileEntity) {
|
||||
BrassTunnelTileEntity brassTunnel = (BrassTunnelTileEntity) nextTunnel;
|
||||
@ -124,25 +124,25 @@ public class BeltTunnelInteractionHandler {
|
||||
}
|
||||
|
||||
public static void flapTunnel(BeltInventory beltInventory, int offset, Direction side, boolean inward) {
|
||||
BeltTunnelTileEntity te = getTunnelOnSegement(beltInventory, offset);
|
||||
BeltTunnelTileEntity te = getTunnelOnSegment(beltInventory, offset);
|
||||
if (te == null)
|
||||
return;
|
||||
te.flap(side, inward);
|
||||
}
|
||||
|
||||
protected static BeltTunnelTileEntity getTunnelOnSegement(BeltInventory beltInventory, int offset) {
|
||||
protected static BeltTunnelTileEntity getTunnelOnSegment(BeltInventory beltInventory, int offset) {
|
||||
BeltTileEntity belt = beltInventory.belt;
|
||||
if (belt.getBlockState()
|
||||
.get(BeltBlock.SLOPE) != BeltSlope.HORIZONTAL)
|
||||
return null;
|
||||
BlockPos pos = BeltHelper.getPositionForOffset(belt, offset)
|
||||
.up();
|
||||
if (!(belt.getWorld()
|
||||
.getBlockState(pos)
|
||||
.getBlock() instanceof BeltTunnelBlock))
|
||||
return getTunnelOnPosition(belt.getWorld(), BeltHelper.getPositionForOffset(belt, offset));
|
||||
}
|
||||
|
||||
public static BeltTunnelTileEntity getTunnelOnPosition(World world, BlockPos pos) {
|
||||
pos = pos.up();
|
||||
if (!(world.getBlockState(pos).getBlock() instanceof BeltTunnelBlock))
|
||||
return null;
|
||||
TileEntity te = belt.getWorld()
|
||||
.getTileEntity(pos);
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te == null || !(te instanceof BeltTunnelTileEntity))
|
||||
return null;
|
||||
return ((BeltTunnelTileEntity) te);
|
||||
|
Loading…
Reference in New Issue
Block a user