add clear filters (as requested by Forecaster)
This commit is contained in:
parent
950426071d
commit
8377eb94f7
4 changed files with 49 additions and 13 deletions
|
@ -21,6 +21,7 @@ public class LensFilterHandler {
|
|||
int myColor = event.item.color == null ? -1 : event.item.color.ordinal();
|
||||
|
||||
for (ForgeDirection dir : event.destinations) {
|
||||
boolean hasFilter = false;
|
||||
int sideColor = -1;
|
||||
int sideLensColor = -1;
|
||||
|
||||
|
@ -29,6 +30,7 @@ public class LensFilterHandler {
|
|||
PipePluggable pluggable = container.getPipePluggable(dir);
|
||||
if (pluggable != null && pluggable instanceof LensPluggable) {
|
||||
if (((LensPluggable) pluggable).isFilter) {
|
||||
hasFilter = true;
|
||||
sideColor = ((LensPluggable) pluggable).color;
|
||||
} else {
|
||||
sideLensColor = ((LensPluggable) pluggable).color;
|
||||
|
@ -42,28 +44,30 @@ public class LensFilterHandler {
|
|||
pluggable = otherContainer.getPipePluggable(dir.getOpposite());
|
||||
if (pluggable != null && pluggable instanceof LensPluggable && ((LensPluggable) pluggable).isFilter) {
|
||||
int otherColor = ((LensPluggable) pluggable).color;
|
||||
if (sideColor >= 0 && otherColor != sideColor) {
|
||||
if (hasFilter && otherColor != sideColor) {
|
||||
// Filter colors conflict - the side is unpassable
|
||||
continue;
|
||||
} else if (sideLensColor >= 0) {
|
||||
// The closer lens color differs from the further away filter color - the side is unpassable OR treated as colorless
|
||||
if (sideLensColor == otherColor) {
|
||||
hasFilter = false;
|
||||
sideColor = -1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
hasFilter = true;
|
||||
sideColor = otherColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (myColor == sideColor) {
|
||||
encounteredColor = true;
|
||||
correctColored.add(dir);
|
||||
}
|
||||
|
||||
if (sideColor == -1) {
|
||||
if (hasFilter) {
|
||||
if (myColor == sideColor) {
|
||||
encounteredColor = true;
|
||||
correctColored.add(dir);
|
||||
}
|
||||
} else {
|
||||
notColored.add(dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ public final class TransportSiliconRecipes {
|
|||
}
|
||||
}
|
||||
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:filter:16", 10000, new ItemStack(BuildCraftTransport.lensItem, 2, 32),
|
||||
"blockGlass", Blocks.iron_bars);
|
||||
|
||||
// PIPE WIRE
|
||||
if (Utils.isRegistered(PipeWire.item)) {
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:redWire", 5000, PipeWire.RED.getStack(8),
|
||||
|
|
|
@ -38,9 +38,18 @@ public class ItemLens extends ItemBuildCraft implements IPipePluggableItem {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
|
||||
if (meta == 32) {
|
||||
return icons[2];
|
||||
}
|
||||
return icons[meta >= 16 ? (1 + (pass & 1)) : (1 - (pass & 1))];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses(int metadata) {
|
||||
return metadata == 32 ? 1 : 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
|
@ -54,12 +63,19 @@ public class ItemLens extends ItemBuildCraft implements IPipePluggableItem {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
if (stack.getItemDamage() == 32) {
|
||||
return 16777215;
|
||||
}
|
||||
return pass == 0 ? ColorUtils.getRGBColor(getDye(stack)) : 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
return StringUtils.localize(itemstack.getItemDamage() >= 16 ? "item.Filter.name" : "item.Lens.name") + " (" + StringUtils.localize("color." + ColorUtils.getName(getDye(itemstack))) + ")";
|
||||
if (itemstack.getItemDamage() == 32) {
|
||||
return StringUtils.localize("item.Filter.name") + " (" + StringUtils.localize("color.clear") + ")";
|
||||
} else {
|
||||
return StringUtils.localize(itemstack.getItemDamage() >= 16 ? "item.Filter.name" : "item.Lens.name") + " (" + StringUtils.localize("color." + ColorUtils.getName(getDye(itemstack))) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +93,7 @@ public class ItemLens extends ItemBuildCraft implements IPipePluggableItem {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List itemList) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
for (int i = 0; i <= 32; i++) {
|
||||
itemList.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,11 @@ public class LensPluggable extends PipePluggable {
|
|||
zeroState[2][1] = 0.8125F;
|
||||
|
||||
if (renderPass == 1) {
|
||||
int color = ((LensPluggable) pipePluggable).color;
|
||||
if (color < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
blockStateMachine.setRenderMask(1 << side.ordinal() | (1 << (side.ordinal() ^ 1)));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -59,7 +64,7 @@ public class LensPluggable extends PipePluggable {
|
|||
zeroState[i][1] -= zFightOffset;
|
||||
}
|
||||
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeLensOverlay.ordinal()));
|
||||
((FakeBlock) blockStateMachine).setColor(ColorUtils.getRGBColor(15 - ((LensPluggable) pipePluggable).color));
|
||||
((FakeBlock) blockStateMachine).setColor(ColorUtils.getRGBColor(15 - color));
|
||||
|
||||
blockStateMachine.setRenderAllSides();
|
||||
} else {
|
||||
|
@ -87,6 +92,9 @@ public class LensPluggable extends PipePluggable {
|
|||
public LensPluggable(ItemStack stack) {
|
||||
color = stack.getItemDamage() & 15;
|
||||
isFilter = stack.getItemDamage() >= 16;
|
||||
if (isFilter && stack.getItemDamage() == 32) {
|
||||
color = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +111,12 @@ public class LensPluggable extends PipePluggable {
|
|||
|
||||
@Override
|
||||
public ItemStack[] getDropItems(IPipeTile pipe) {
|
||||
return new ItemStack[]{new ItemStack(BuildCraftTransport.lensItem, 1, color | (isFilter ? 16 : 0))};
|
||||
int meta = color | (isFilter ? 16 : 0);
|
||||
if (isFilter && color == -1) {
|
||||
meta = 32;
|
||||
}
|
||||
|
||||
return new ItemStack[]{new ItemStack(BuildCraftTransport.lensItem, 1, meta)};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,13 +160,13 @@ public class LensPluggable extends PipePluggable {
|
|||
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeByte(color | (isFilter ? 0x20 : 0));
|
||||
data.writeByte(((color + 1) & 0x1F) | (isFilter ? 0x20 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
int flags = data.readUnsignedByte();
|
||||
color = flags & 15;
|
||||
color = (flags & 31) - 1;
|
||||
isFilter = (flags & 0x20) > 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue