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)
syncSet.forEach(te -> te.syncedOutputActive = notifySyncedOut);
}
if (validOutputs == null)
return;
if (stackToDistribute.isEmpty())
return;
for (Pair<BrassTunnelTileEntity, Direction> pair : validOutputs) {
BrassTunnelTileEntity tunnel = pair.getKey();
Direction output = pair.getValue();
if (insertIntoTunnel(tunnel, output, stackToDistribute, true) == null)
continue;
distributionTargets.add(Pair.of(tunnel.pos, output));
int distance = tunnel.pos.getX() + tunnel.pos.getZ() - pos.getX() - pos.getZ();
if (distance < 0)
distributionDistanceLeft = Math.max(distributionDistanceLeft, -distance);
else
distributionDistanceRight = Math.max(distributionDistanceRight, distance);
for (boolean filterPass : Iterate.trueAndFalse) {
for (Pair<BrassTunnelTileEntity, Direction> pair : validOutputs) {
BrassTunnelTileEntity tunnel = pair.getKey();
Direction output = pair.getValue();
if (filterPass && tunnel.flapFilterEmpty(output))
continue;
if (insertIntoTunnel(tunnel, output, stackToDistribute, true) == null)
continue;
distributionTargets.add(Pair.of(tunnel.pos, output));
int distance = tunnel.pos.getX() + tunnel.pos.getZ() - pos.getX() - pos.getZ();
if (distance < 0)
distributionDistanceLeft = Math.max(distributionDistanceLeft, -distance);
else
distributionDistanceRight = Math.max(distributionDistanceRight, distance);
}
if (!distributionTargets.isEmpty() && filterPass)
break;
}
if (distributionTargets.isEmpty())
@ -317,6 +324,21 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
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
public void initialize() {
if (filtering == null) {

View file

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