use of buildcraft.transport.pluggable.LensPluggable in project BuildCraft by BuildCraft.
the class LensPluggableModel method create.
public static PerspAwareModelBase create(ItemLens lensItem, int meta) {
LensPluggable lens = new LensPluggable(new ItemStack(lensItem, 1, meta));
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
VertexFormat format = DefaultVertexFormats.ITEM;
quads.addAll(INSTANCE.bakeCutout(lens.isFilter, EnumFacing.EAST, format));
quads.addAll(INSTANCE.bakeTransclucent(lens.dyeColor, lens.isFilter, EnumFacing.EAST, format));
return new PerspAwareModelBase(format, quads.build(), spriteLensCutout, getBlockTransforms());
}
use of buildcraft.transport.pluggable.LensPluggable 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