Filter redundancy

- Brass tunnels now distribute across matching filtered outputs exclusively before sending items to unfiltered sides
- Less chute logic on render thread pls
This commit is contained in:
simibubi 2020-11-27 18:26:17 +01:00
parent b24648b431
commit a49aad24c2
2 changed files with 36 additions and 13 deletions

View file

@ -132,23 +132,30 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
if (allFull || allEmpty) if (allFull || allEmpty)
syncSet.forEach(te -> te.syncedOutputActive = notifySyncedOut); syncSet.forEach(te -> te.syncedOutputActive = notifySyncedOut);
} }
if (validOutputs == null) if (validOutputs == null)
return; return;
if (stackToDistribute.isEmpty()) if (stackToDistribute.isEmpty())
return; return;
for (Pair<BrassTunnelTileEntity, Direction> pair : validOutputs) { for (boolean filterPass : Iterate.trueAndFalse) {
BrassTunnelTileEntity tunnel = pair.getKey(); for (Pair<BrassTunnelTileEntity, Direction> pair : validOutputs) {
Direction output = pair.getValue(); BrassTunnelTileEntity tunnel = pair.getKey();
if (insertIntoTunnel(tunnel, output, stackToDistribute, true) == null) Direction output = pair.getValue();
continue; if (filterPass && tunnel.flapFilterEmpty(output))
distributionTargets.add(Pair.of(tunnel.pos, output)); continue;
int distance = tunnel.pos.getX() + tunnel.pos.getZ() - pos.getX() - pos.getZ(); if (insertIntoTunnel(tunnel, output, stackToDistribute, true) == null)
if (distance < 0) continue;
distributionDistanceLeft = Math.max(distributionDistanceLeft, -distance); distributionTargets.add(Pair.of(tunnel.pos, output));
else int distance = tunnel.pos.getX() + tunnel.pos.getZ() - pos.getX() - pos.getZ();
distributionDistanceRight = Math.max(distributionDistanceRight, distance); if (distance < 0)
distributionDistanceLeft = Math.max(distributionDistanceLeft, -distance);
else
distributionDistanceRight = Math.max(distributionDistanceRight, distance);
}
if (!distributionTargets.isEmpty() && filterPass)
break;
} }
if (distributionTargets.isEmpty()) if (distributionTargets.isEmpty())
@ -317,6 +324,21 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
return filtering.test(side, stack); return filtering.test(side, stack);
} }
public boolean flapFilterEmpty(Direction side) {
if (filtering == null)
return false;
if (filtering.get(side) == null) {
FilteringBehaviour adjacentFilter =
TileEntityBehaviour.get(world, pos.offset(side), FilteringBehaviour.TYPE);
if (adjacentFilter == null)
return true;
return adjacentFilter.getFilter()
.isEmpty();
}
return filtering.getFilter(side)
.isEmpty();
}
@Override @Override
public void initialize() { public void initialize() {
if (filtering == null) { if (filtering == null) {

View file

@ -134,7 +134,8 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
public void tick() { public void tick() {
super.tick(); super.tick();
canPickUpItems = canDirectlyInsert(); if (!world.isRemote)
canPickUpItems = canDirectlyInsert();
float itemMotion = getItemMotion(); float itemMotion = getItemMotion();
if (itemMotion != 0 && world != null && world.isRemote) if (itemMotion != 0 && world != null && world.isRemote)