use of buildcraft.transport.pipes.events.PipeEventPriority in project BuildCraft by BuildCraft.
the class PipeItemsClay method eventHandler.
@PipeEventPriority(priority = -200)
public void eventHandler(PipeEventItem.FindDest event) {
List<EnumSet<EnumFacing>> newDestinations = new ArrayList<>(event.destinations.size() * 2);
for (EnumSet<EnumFacing> faces : event.destinations) {
EnumSet<EnumFacing> nonPipesList = EnumSet.noneOf(EnumFacing.class);
EnumSet<EnumFacing> pipesList = EnumSet.noneOf(EnumFacing.class);
for (EnumFacing o : faces) {
if (!event.item.blacklist.contains(o) && container.pipe.outputOpen(o)) {
if (container.isPipeConnected(o)) {
TileEntity entity = container.getTile(o);
if (entity instanceof IPipeTile) {
pipesList.add(o);
} else {
nonPipesList.add(o);
}
}
}
}
if (!nonPipesList.isEmpty()) {
newDestinations.add(nonPipesList);
}
if (!pipesList.isEmpty()) {
newDestinations.add(pipesList);
}
}
event.destinations.clear();
event.destinations.addAll(newDestinations);
}
use of buildcraft.transport.pipes.events.PipeEventPriority in project BuildCraft by BuildCraft.
the class LensFilterHandler method eventHandler.
@PipeEventPriority(priority = -100)
public void eventHandler(PipeEventItem.FindDest event) {
IPipeTile container = event.pipe.getTile();
List<EnumSet<EnumFacing>> newDestinations = new ArrayList<>(event.destinations.size() * 2);
for (EnumSet<EnumFacing> dirs : event.destinations) {
EnumSet<EnumFacing> correctColored = EnumSet.noneOf(EnumFacing.class);
EnumSet<EnumFacing> notColored = EnumSet.noneOf(EnumFacing.class);
EnumDyeColor myColor = event.item.color;
for (EnumFacing dir : dirs) {
boolean hasFilter = false;
boolean hasLens = false;
EnumDyeColor sideColor = null;
EnumDyeColor sideLensColor = null;
// Get the side's color
// (1/2) From this pipe's outpost
PipePluggable pluggable = container.getPipePluggable(dir);
if (pluggable != null && pluggable instanceof LensPluggable) {
if (((LensPluggable) pluggable).isFilter) {
hasFilter = true;
sideColor = ((LensPluggable) pluggable).dyeColor;
} else {
hasLens = true;
sideLensColor = ((LensPluggable) pluggable).dyeColor;
}
}
// (2/2) From the other pipe's outpost
IPipe otherPipe = container.getNeighborPipe(dir);
if (otherPipe != null && otherPipe.getTile() != null) {
IPipeTile otherContainer = otherPipe.getTile();
pluggable = otherContainer.getPipePluggable(dir.getOpposite());
if (pluggable != null && pluggable instanceof LensPluggable && ((LensPluggable) pluggable).isFilter) {
EnumDyeColor otherColor = ((LensPluggable) pluggable).dyeColor;
if (hasFilter && otherColor != sideColor) {
// Filter colors conflict - the side is unpassable
continue;
} else if (hasLens) {
// treated as colorless
if (sideLensColor == otherColor) {
hasFilter = false;
sideColor = null;
} else {
continue;
}
} else {
hasFilter = true;
sideColor = otherColor;
}
}
}
if (hasFilter) {
if (myColor == sideColor) {
correctColored.add(dir);
}
} else {
notColored.add(dir);
}
}
if (!correctColored.isEmpty()) {
newDestinations.add(correctColored);
}
if (!notColored.isEmpty()) {
newDestinations.add(notColored);
}
}
event.destinations.clear();
event.destinations.addAll(newDestinations);
}
Aggregations