diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png
new file mode 100644
index 00000000..0e3626ce
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllEmzuli_solid.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png
deleted file mode 100644
index 1cdefd74..00000000
Binary files a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeAllLogemerald_solid.png and /dev/null differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png
new file mode 100644
index 00000000..ee08f116
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsDiamond_item.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png
new file mode 100644
index 00000000..eedfb748
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsEmzuli_standard.png differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png
deleted file mode 100644
index 96a09f19..00000000
Binary files a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeItemsLogemerald_standard.png and /dev/null differ
diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png b/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png
new file mode 100644
index 00000000..3fd376d2
Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/gui/pipe_emzuli.png differ
diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties
index 649554c6..d80d8d87 100644
--- a/buildcraft_resources/lang/buildcraft/en_US.properties
+++ b/buildcraft_resources/lang/buildcraft/en_US.properties
@@ -2,6 +2,23 @@
chat.pipe.power.iron.mode=Switched to %d MJ/t limit
+color.black=Black
+color.blue=Blue
+color.brown=Brown
+color.cyan=Cyan
+color.gray=Gray
+color.green=Green
+color.light.blue=Light Blue
+color.light.gray=Light Gray
+color.lime=Lime
+color.magenta=Magenta
+color.orange=Orange
+color.pink=Pink
+color.purple=Purple
+color.red=Red
+color.white=White
+color.yellow=Yellow
+
fillerpattern.clear=Clear
fillerpattern.fill=Fill
fillerpattern.flatten=Flatten
@@ -23,6 +40,8 @@ gate.engine.blue=Engine Blue
gate.engine.green=Engine Green
gate.engine.yellow=Engine Yellow
gate.engine.red=Engine Red
+gate.pipe.item.color=Paint Items %s
+
gui.building.resources=Building Resources
gui.del=Del
gui.filling.resources=Filling Resources
@@ -41,7 +60,10 @@ gui.pipes.emerald.blocking=Blocking
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
gui.pipes.emerald.nonblocking=Non Blocking
gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
-gui.pipes.logemerald.title=Extraction presets
+gui.pipes.emzuli.title=Extraction Presets
+gui.pipes.emzuli.paint=Paint Items %s
+gui.pipes.emzuli.nopaint=Don't Paint Items
+
item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear
@@ -87,7 +109,7 @@ item.PipeItemsObsidian=Obsidian Transport Pipe
item.PipeItemsEmerald=Emerald Transport Pipe
item.PipeItemsLapis=Lapis Transport Pipe
item.PipeItemsDaizuli=Daizuli Transport Pipe
-item.PipeItemsLogemerald=Logemerald Transport Pipe
+item.PipeItemsEmzuli=Emzuli Transport Pipe
item.PipeFluidsWood=Wooden Fluid Pipe
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
item.PipeFluidsStone=Stone Fluid Pipe
diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java
index bef51ba0..840969c3 100644
--- a/common/buildcraft/BuildCraftTransport.java
+++ b/common/buildcraft/BuildCraftTransport.java
@@ -54,7 +54,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald;
import buildcraft.transport.pipes.PipeItemsGold;
import buildcraft.transport.pipes.PipeItemsIron;
-import buildcraft.transport.pipes.PipeItemsLogemerald;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
import buildcraft.transport.pipes.PipeItemsLapis;
import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsQuartz;
@@ -128,7 +128,7 @@ public class BuildCraftTransport {
public static Item pipeItemsDaizuli;
public static Item pipeItemsVoid;
public static Item pipeItemsSandstone;
- public static Item pipeItemsLogemerald;
+ public static Item pipeItemsEmzuli;
public static Item pipeFluidsWood;
public static Item pipeFluidsCobblestone;
public static Item pipeFluidsStone;
@@ -292,7 +292,7 @@ public class BuildCraftTransport {
pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond);
pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone);
pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone);
- pipeItemsLogemerald = buildPipe(DefaultProps.PIPE_ITEMS_LOGEMERALD_ID, PipeItemsLogemerald.class, "Logemerald Transport Pipe", "logWood", Block.glass, Item.emerald);
+ pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Block.blockLapis, Block.glass, Item.emerald);
pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood);
pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone);
diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java
index cf242bef..8a79ef0a 100644
--- a/common/buildcraft/core/DefaultProps.java
+++ b/common/buildcraft/core/DefaultProps.java
@@ -63,7 +63,7 @@ public class DefaultProps {
public static int PIPE_ITEMS_QUARTZ_ID = 19168;
public static int PIPE_ITEMS_LAPIS_ID = 19169;
public static int PIPE_ITEMS_DAIZULI_ID = 19170;
- public static int PIPE_ITEMS_LOGEMERALD_ID = 19171;
+ public static int PIPE_ITEMS_EMZULI_ID = 19171;
public static int PIPE_LIQUIDS_WOOD_ID = 19180;
public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181;
diff --git a/common/buildcraft/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java
index 80fd0979..838486a4 100644
--- a/common/buildcraft/core/gui/BuildCraftContainer.java
+++ b/common/buildcraft/core/gui/BuildCraftContainer.java
@@ -11,6 +11,11 @@ import buildcraft.core.gui.slots.IPhantomSlot;
import buildcraft.core.gui.slots.SlotBase;
import buildcraft.core.gui.widgets.Widget;
import buildcraft.core.inventory.StackHelper;
+import buildcraft.core.network.PacketGuiWidget;
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.common.network.Player;
+import java.io.DataInputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -42,6 +47,15 @@ public abstract class BuildCraftContainer extends Container {
widgets.add(widget);
}
+ public void sendWidgetDataToClient(Widget widget, ICrafting player, byte[] data) {
+ PacketGuiWidget pkt = new PacketGuiWidget(windowId, widgets.indexOf(widget), data);
+ PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), (Player) player);
+ }
+
+ public void handleWidgetClientData(int widgetId, DataInputStream data) throws IOException {
+ widgets.get(widgetId).handleClientPacketData(data);
+ }
+
@Override
public void addCraftingToCrafters(ICrafting player) {
super.addCraftingToCrafters(player);
diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java
index 29e99d48..62368652 100644
--- a/common/buildcraft/core/gui/GuiBuildCraft.java
+++ b/common/buildcraft/core/gui/GuiBuildCraft.java
@@ -97,7 +97,7 @@ public abstract class GuiBuildCraft extends GuiContainer {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.bindTexture(texture);
+ bindTexture(texture);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
@@ -108,6 +108,7 @@ public abstract class GuiBuildCraft extends GuiContainer {
for (Widget widget : container.getWidgets()) {
if (widget.hidden)
continue;
+ bindTexture(texture);
widget.draw(this, x, y, mX, mY);
}
}
@@ -138,19 +139,51 @@ public abstract class GuiBuildCraft extends GuiContainer {
// / MOUSE CLICKS
@Override
- protected void mouseClicked(int par1, int par2, int mouseButton) {
- super.mouseClicked(par1, par2, mouseButton);
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ if (!widget.isMouseOver(mX, mY))
+ continue;
+ if (widget.handleMouseClick(mX, mY, mouseButton))
+ return;
+ }
+ super.mouseClicked(mouseX, mouseY, mouseButton);
// / Handle ledger clicks
- ledgerManager.handleMouseClicked(par1, par2, mouseButton);
+ ledgerManager.handleMouseClicked(mouseX, mouseY, mouseButton);
}
@Override
- protected void mouseClickMove(int x, int y, int mouseButton, long time) {
- Slot slot = getSlotAtPosition(x, y);
+ protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long time) {
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ widget.handleMouseMove(mX, mY, mouseButton, time);
+ }
+
+ Slot slot = getSlotAtPosition(mouseX, mouseY);
if (mouseButton == 1 && slot instanceof IPhantomSlot)
return;
- super.mouseClickMove(x, y, mouseButton, time);
+ super.mouseClickMove(mouseX, mouseY, mouseButton, time);
+ }
+
+ @Override
+ protected void mouseMovedOrUp(int mouseX, int mouseY, int eventType) {
+ super.mouseMovedOrUp(mouseX, mouseY, eventType);
+
+ int mX = mouseX - guiLeft;
+ int mY = mouseY - guiTop;
+ for (Widget widget : container.getWidgets()) {
+ if (widget.hidden)
+ continue;
+ widget.handleMouseRelease(mX, mY, eventType);
+ }
}
public Slot getSlotAtPosition(int x, int y) {
diff --git a/common/buildcraft/core/gui/widgets/ButtonWidget.java b/common/buildcraft/core/gui/widgets/ButtonWidget.java
new file mode 100644
index 00000000..0cb200fc
--- /dev/null
+++ b/common/buildcraft/core/gui/widgets/ButtonWidget.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.gui.widgets;
+
+import buildcraft.core.gui.GuiBuildCraft;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class ButtonWidget extends Widget {
+
+ private boolean pressed;
+ private int buttonPressed;
+
+ public ButtonWidget(int x, int y, int u, int v, int w, int h) {
+ super(x, y, u, v, w, h);
+ }
+
+ @Override
+ public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
+ int vv = pressed ? v + h : v;
+ gui.drawTexturedModalRect(guiX + x, guiY + y, u, vv, w, h);
+ }
+
+ @Override
+ public final boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) {
+ pressed = true;
+ buttonPressed = mouseButton;
+ onPress(buttonPressed);
+ return true;
+ }
+
+ @Override
+ public final void handleMouseRelease(int mouseX, int mouseY, int eventType) {
+ if (pressed) {
+ pressed = false;
+ onRelease(buttonPressed);
+ }
+ }
+
+ @Override
+ public final void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
+ if (pressed && !isMouseOver(mouseX, mouseY)) {
+ pressed = false;
+ onRelease(buttonPressed);
+ }
+ }
+
+ public void onPress(int mouseButton) {
+ }
+
+ public void onRelease(int mouseButton) {
+ }
+}
diff --git a/common/buildcraft/core/gui/widgets/Widget.java b/common/buildcraft/core/gui/widgets/Widget.java
index 673cb9f6..3e79de41 100644
--- a/common/buildcraft/core/gui/widgets/Widget.java
+++ b/common/buildcraft/core/gui/widgets/Widget.java
@@ -13,6 +13,8 @@ import buildcraft.core.gui.tooltips.IToolTipProvider;
import buildcraft.core.gui.tooltips.ToolTip;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import java.io.DataInputStream;
+import java.io.IOException;
import net.minecraft.inventory.ICrafting;
/**
@@ -50,10 +52,22 @@ public class Widget implements IToolTipProvider {
}
@SideOnly(Side.CLIENT)
- public boolean mouseClicked(int mouseX, int mouseY, int button) {
+ public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) {
return false;
}
+ @SideOnly(Side.CLIENT)
+ public void handleMouseRelease(int mouseX, int mouseY, int eventType) {
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void handleClientPacketData(DataInputStream data) throws IOException {
+ }
+
@SideOnly(Side.CLIENT)
public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
gui.drawTexturedModalRect(guiX + x, guiY + y, u, v, w, h);
diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java
index 25b1a63b..3be79132 100644
--- a/common/buildcraft/core/network/IGuiReturnHandler.java
+++ b/common/buildcraft/core/network/IGuiReturnHandler.java
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
public abstract interface IGuiReturnHandler {
public World getWorld();
- public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException;
+ public void writeGuiData(DataOutputStream data) throws IOException;
- public void readGuiData(DataInputStream paramDataInputStream, EntityPlayer paramEntityPlayer) throws IOException;
+ public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException;
}
diff --git a/common/buildcraft/core/network/PacketGuiWidget.java b/common/buildcraft/core/network/PacketGuiWidget.java
new file mode 100644
index 00000000..e8a78843
--- /dev/null
+++ b/common/buildcraft/core/network/PacketGuiWidget.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.network;
+
+import buildcraft.core.gui.BuildCraftContainer;
+import cpw.mods.fml.client.FMLClientHandler;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+/**
+ *
+ * @author CovertJaguar
+ */
+public class PacketGuiWidget extends BuildCraftPacket {
+
+ private byte windowId, widgetId;
+ private byte[] payload;
+
+ public PacketGuiWidget() {
+ super();
+ }
+
+ public PacketGuiWidget(int windowId, int widgetId, byte[] data) {
+ this.windowId = (byte) windowId;
+ this.widgetId = (byte) widgetId;
+ this.payload = data;
+ }
+
+ @Override
+ public void writeData(DataOutputStream data) throws IOException {
+ data.writeByte(windowId);
+ data.writeByte(widgetId);
+ data.write(payload);
+ }
+
+ @Override
+ public void readData(DataInputStream data) throws IOException {
+ windowId = data.readByte();
+ widgetId = data.readByte();
+
+ EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
+
+ if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId)
+ ((BuildCraftContainer) player.openContainer).handleWidgetClientData(widgetId, data);
+ }
+
+ @Override
+ public int getID() {
+ return PacketIds.GUI_WIDGET;
+ }
+
+}
diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java
index a999117e..8c0feb94 100644
--- a/common/buildcraft/core/network/PacketHandler.java
+++ b/common/buildcraft/core/network/PacketHandler.java
@@ -37,27 +37,32 @@ public class PacketHandler implements IPacketHandler {
int packetID = data.read();
switch (packetID) {
case PacketIds.TILE_UPDATE: {
- PacketTileUpdate packetT = new PacketTileUpdate();
- packetT.readData(data);
- onTileUpdate((EntityPlayer) player, packetT);
+ PacketTileUpdate pkt = new PacketTileUpdate();
+ pkt.readData(data);
+ onTileUpdate((EntityPlayer) player, pkt);
break;
}
case PacketIds.STATE_UPDATE: {
- PacketTileState inPacket = new PacketTileState();
- inPacket.readData(data);
+ PacketTileState pkt = new PacketTileState();
+ pkt.readData(data);
World world = ((EntityPlayer) player).worldObj;
- TileEntity tile = world.getBlockTileEntity(inPacket.posX, inPacket.posY, inPacket.posZ);
+ TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ);
if (tile instanceof ISyncedTile) {
- inPacket.applyStates(data, (ISyncedTile) tile);
+ pkt.applyStates(data, (ISyncedTile) tile);
}
break;
}
case PacketIds.GUI_RETURN: {
- PacketGuiReturn packet1 = new PacketGuiReturn((EntityPlayer) player);
- packet1.readData(data);
- // onGuiReturn((EntityPlayer) player, packet1);
+ PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player);
+ pkt.readData(data);
+ break;
+ }
+
+ case PacketIds.GUI_WIDGET: {
+ PacketGuiWidget pkt = new PacketGuiWidget();
+ pkt.readData(data);
break;
}
}
diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java
index 34af2c6f..e336111a 100644
--- a/common/buildcraft/core/network/PacketIds.java
+++ b/common/buildcraft/core/network/PacketIds.java
@@ -36,6 +36,7 @@ public class PacketIds {
public static final int SELECTION_ADVANCED_WORKBENCH = 71;
public static final int GUI_RETURN = 80;
+ public static final int GUI_WIDGET = 81;
public static final int STATE_UPDATE = 100;
}
diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java
index 426f3a15..2c522f6a 100644
--- a/common/buildcraft/core/utils/EnumColor.java
+++ b/common/buildcraft/core/utils/EnumColor.java
@@ -157,7 +157,7 @@ public enum EnumColor {
return NAMES[ordinal()];
}
- public String getTranslatedName() {
+ public String getLocalizedName() {
return StringUtils.localize(getTag());
}
diff --git a/common/buildcraft/core/utils/RevolvingList.java b/common/buildcraft/core/utils/RevolvingList.java
new file mode 100644
index 00000000..c2b08343
--- /dev/null
+++ b/common/buildcraft/core/utils/RevolvingList.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.core.utils;
+
+import com.google.common.collect.ForwardingCollection;
+import java.util.*;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public class RevolvingList extends ForwardingCollection {
+
+ private Deque list = new LinkedList();
+
+ public RevolvingList() {
+ }
+
+ public RevolvingList(Collection extends T> collection) {
+ list.addAll(collection);
+ }
+
+ @Override
+ protected Collection delegate() {
+ return list;
+ }
+
+ public void rotateLeft() {
+ if (list.isEmpty())
+ return;
+ list.addFirst(list.removeLast());
+ }
+
+ public void rotateRight() {
+ if (list.isEmpty())
+ return;
+ list.addLast(list.removeFirst());
+ }
+
+ public T getCurrent() {
+ if (list.isEmpty())
+ return null;
+ return list.getFirst();
+ }
+
+ public void setCurrent(T e) {
+ if (!contains(e))
+ return;
+
+ if (e == null) {
+ while (getCurrent() != null) {
+ rotateRight();
+ }
+ } else {
+ while (getCurrent() == null || !getCurrent().equals(e)) {
+ rotateRight();
+ }
+ }
+ }
+}
diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java
index 6687a055..fd9158a0 100644
--- a/common/buildcraft/transport/GuiHandler.java
+++ b/common/buildcraft/transport/GuiHandler.java
@@ -6,15 +6,15 @@ import buildcraft.transport.gui.ContainerDiamondPipe;
import buildcraft.transport.gui.ContainerEmeraldPipe;
import buildcraft.transport.gui.ContainerFilteredBuffer;
import buildcraft.transport.gui.ContainerGateInterface;
-import buildcraft.transport.gui.ContainerLogemeraldPipe;
+import buildcraft.transport.gui.ContainerEmzuliPipe;
import buildcraft.transport.gui.GuiDiamondPipe;
import buildcraft.transport.gui.GuiEmeraldPipe;
import buildcraft.transport.gui.GuiFilteredBuffer;
import buildcraft.transport.gui.GuiGateInterface;
-import buildcraft.transport.gui.GuiLogemeraldPipe;
+import buildcraft.transport.gui.GuiEmzuliPipe;
import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald;
-import buildcraft.transport.pipes.PipeItemsLogemerald;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
import cpw.mods.fml.common.network.IGuiHandler;
import java.util.logging.Level;
import net.minecraft.entity.player.EntityPlayer;
@@ -52,7 +52,7 @@ public class GuiHandler implements IGuiHandler {
return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
case GuiIds.PIPE_LOGEMERALD_ITEM:
- return new ContainerLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe);
+ return new ContainerEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe);
case GuiIds.GATES:
if (pipe.pipe.hasGate())
@@ -96,7 +96,7 @@ public class GuiHandler implements IGuiHandler {
return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
case GuiIds.PIPE_LOGEMERALD_ITEM:
- return new GuiLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe);
+ return new GuiEmzuliPipe(player.inventory, (PipeItemsEmzuli) pipe.pipe);
case GuiIds.GATES:
if (pipe.pipe.hasGate())
diff --git a/common/buildcraft/transport/IItemTravelingHook.java b/common/buildcraft/transport/IItemTravelingHook.java
index f329947f..51abbad6 100644
--- a/common/buildcraft/transport/IItemTravelingHook.java
+++ b/common/buildcraft/transport/IItemTravelingHook.java
@@ -2,6 +2,10 @@ package buildcraft.transport;
import net.minecraft.tileentity.TileEntity;
+/**
+ * @deprecated This has been replaced by the Pipe Event system.
+ */
+@Deprecated
public interface IItemTravelingHook {
public void drop(PipeTransportItems transport, TravelingItem item);
@@ -9,13 +13,14 @@ public interface IItemTravelingHook {
public void centerReached(PipeTransportItems transport, TravelingItem item);
/**
- * Overrides default handling of what occurs when an Item reaches the end of the pipe.
- *
+ * Overrides default handling of what occurs when an Item reaches the end of
+ * the pipe.
+ *
* @param transport
* @param item
* @param tile
- * @return false if the transport code should handle the item normally, true if its been handled
+ * @return false if the transport code should handle the item normally, true
+ * if its been handled
*/
public boolean endReached(PipeTransportItems transport, TravelingItem item, TileEntity tile);
-
}
diff --git a/common/buildcraft/transport/IPipeTransportItemsHook.java b/common/buildcraft/transport/IPipeTransportItemsHook.java
index 018bc78a..3be90a42 100644
--- a/common/buildcraft/transport/IPipeTransportItemsHook.java
+++ b/common/buildcraft/transport/IPipeTransportItemsHook.java
@@ -1,18 +1,20 @@
/**
- * Copyright (c) SpaceToad, 2011
- * http://www.mod-buildcraft.com
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
- * BuildCraft is distributed under the terms of the Minecraft Mod Public
- * License 1.0, or MMPL. Please check the contents of the license located in
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
-
package buildcraft.transport;
import buildcraft.api.core.Position;
import java.util.LinkedList;
import net.minecraftforge.common.ForgeDirection;
+/**
+ * @deprecated This has been replaced by the Pipe Event system.
+ */
+@Deprecated
public interface IPipeTransportItemsHook {
public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item);
diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java
index fe0b9ebb..d0693a64 100644
--- a/common/buildcraft/transport/Pipe.java
+++ b/common/buildcraft/transport/Pipe.java
@@ -19,15 +19,16 @@ import buildcraft.core.IDropControlInventory;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.network.TilePacketWrapper;
import buildcraft.core.utils.Utils;
+import buildcraft.transport.pipes.events.PipeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -47,6 +48,7 @@ public abstract class Pipe implements IPipe, IDropContr
@SuppressWarnings("rawtypes")
private static Map networkWrappers = new HashMap();
public SafeTimeTracker actionTracker = new SafeTimeTracker();
+ private static Map, Map, EventHandler>> eventHandlers = new HashMap, Map, EventHandler>>();
public Pipe(T transport, int itemID) {
this.transport = transport;
@@ -65,6 +67,39 @@ public abstract class Pipe implements IPipe, IDropContr
transport.setTile((TileGenericPipe) tile);
}
+ private static class EventHandler {
+
+ public final Method method;
+
+ public EventHandler(Method method) {
+ this.method = method;
+ }
+ }
+
+ public final void handlePipeEvent(PipeEvent event) {
+ Map, EventHandler> handlerMap = eventHandlers.get(getClass());
+ if (handlerMap == null) {
+ handlerMap = new HashMap, EventHandler>();
+ eventHandlers.put(getClass(), handlerMap);
+ }
+ EventHandler handler = handlerMap.get(event.getClass());
+ if (handler == null) {
+ try {
+ Method method = getClass().getDeclaredMethod("eventHandler", event.getClass());
+ handler = new EventHandler(method);
+ } catch (Exception ex) {
+ handler = new EventHandler(null);
+ }
+ handlerMap.put(event.getClass(), handler);
+ }
+ if (handler.method == null)
+ return;
+ try {
+ handler.method.invoke(this, event);
+ } catch (Exception ex) {
+ }
+ }
+
public boolean blockActivated(EntityPlayer entityplayer) {
return false;
}
@@ -481,9 +516,6 @@ public abstract class Pipe implements IPipe, IDropContr
transport.dropContents();
}
- public void onDropped(EntityItem item) {
- }
-
/**
* If this pipe is open on one side, return it.
*/
diff --git a/common/buildcraft/transport/PipeConnectionBans.java b/common/buildcraft/transport/PipeConnectionBans.java
index 88db4cb8..12e2db23 100644
--- a/common/buildcraft/transport/PipeConnectionBans.java
+++ b/common/buildcraft/transport/PipeConnectionBans.java
@@ -12,7 +12,7 @@ import buildcraft.transport.pipes.PipeFluidsCobblestone;
import buildcraft.transport.pipes.PipeFluidsStone;
import buildcraft.transport.pipes.PipeFluidsWood;
import buildcraft.transport.pipes.PipeItemsCobblestone;
-import buildcraft.transport.pipes.PipeItemsLogemerald;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
import buildcraft.transport.pipes.PipeItemsObsidian;
import buildcraft.transport.pipes.PipeItemsQuartz;
import buildcraft.transport.pipes.PipeItemsStone;
@@ -43,7 +43,7 @@ public class PipeConnectionBans {
banConnection(PipeItemsObsidian.class);
- banConnection(PipeItemsLogemerald.class);
+ banConnection(PipeItemsEmzuli.class);
// Power Pipes
banConnection(PipePowerWood.class);
diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java
index 98be048d..40f951fd 100644
--- a/common/buildcraft/transport/PipeIconProvider.java
+++ b/common/buildcraft/transport/PipeIconProvider.java
@@ -15,6 +15,7 @@ public class PipeIconProvider implements IIconProvider {
//
PipeItemsCobbleStone("pipeItemsCobblestone"),
//
+ PipeItemsDiamond_Item("pipeItemsDiamond_item"),
PipeItemsDiamond_Center("pipeItemsDiamond_center"),
PipeItemsDiamond_Down("pipeItemsDiamond_down"),
PipeItemsDiamond_Up("pipeItemsDiamond_up"),
@@ -64,8 +65,8 @@ public class PipeIconProvider implements IIconProvider {
PipeItemsEmerald_Standard("pipeItemsEmerald_standard"),
PipeAllEmerald_Solid("pipeAllEmerald_solid"),
//
- PipeItemsLogemerald_Standard("pipeItemsLogemerald_standard"),
- PipeAllLogemerald_Solid("pipeAllLogemerald_solid"),
+ PipeItemsEmzuli_Standard("pipeItemsEmzuli_standard"),
+ PipeAllEmzuli_Solid("pipeAllEmzuli_solid"),
//
PipeItemsGold("pipeItemsGold"),
//
diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java
index 13254ab4..e9f2c758 100644
--- a/common/buildcraft/transport/PipeTransportItems.java
+++ b/common/buildcraft/transport/PipeTransportItems.java
@@ -22,6 +22,7 @@ import buildcraft.core.utils.BlockUtil;
import buildcraft.transport.network.PacketPipeTransportContent;
import buildcraft.transport.network.PacketPipeTransportNBT;
import buildcraft.transport.network.PacketSimpleId;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.utils.TransportUtils;
import com.google.common.collect.BiMap;
import com.google.common.collect.ForwardingSet;
@@ -125,9 +126,13 @@ public class PipeTransportItems extends PipeTransport {
}
public void readjustSpeed(TravelingItem item) {
- if (container.pipe instanceof IPipeTransportItemsHook)
+ if (container.pipe instanceof IPipeTransportItemsHook) {
((IPipeTransportItemsHook) container.pipe).readjustSpeed(item);
- else
+ return;
+ }
+ PipeEventItem.AdjustSpeed event = new PipeEventItem.AdjustSpeed(item);
+ container.pipe.handlePipeEvent(event);
+ if (!event.handled)
defaultReajustSpeed(item);
}
@@ -174,8 +179,6 @@ public class PipeTransportItems extends PipeTransport {
item.reset();
item.input = inputOrientation;
- items.add(item);
-
readjustSpeed(item);
readjustPosition(item);
@@ -188,6 +191,13 @@ public class PipeTransportItems extends PipeTransport {
((IPipeTransportItemsHook) container.pipe).entityEntered(item, inputOrientation);
}
+ PipeEventItem.Entered event = new PipeEventItem.Entered(item);
+ container.pipe.handlePipeEvent(event);
+ if (event.cancelled)
+ return;
+
+ items.add(item);
+
if (!container.worldObj.isRemote) {
sendItemPacket(item);
@@ -231,8 +241,6 @@ public class PipeTransportItems extends PipeTransport {
// stage, avoid adding it to the pipe to avoid further exceptions.
return;
- items.unscheduleRemoval(item);
-
item.toCenter = true;
item.input = item.output.getOpposite();
@@ -246,6 +254,12 @@ public class PipeTransportItems extends PipeTransport {
if (container.pipe instanceof IPipeTransportItemsHook) {
((IPipeTransportItemsHook) container.pipe).entityEntered(item, item.input);
}
+ PipeEventItem.Entered event = new PipeEventItem.Entered(item);
+ container.pipe.handlePipeEvent(event);
+ if (event.cancelled)
+ return;
+
+ items.unscheduleRemoval(item);
if (!container.worldObj.isRemote) {
sendItemPacket(item);
@@ -253,20 +267,19 @@ public class PipeTransportItems extends PipeTransport {
}
public ForgeDirection resolveDestination(TravelingItem data) {
- LinkedList listOfPossibleMovements = getPossibleMovements(data);
+ List validDestinations = getPossibleMovements(data);
- if (listOfPossibleMovements.isEmpty())
+ if (validDestinations.isEmpty())
return ForgeDirection.UNKNOWN;
- int i = container.worldObj.rand.nextInt(listOfPossibleMovements.size());
- return listOfPossibleMovements.get(i);
+ return validDestinations.get(0);
}
/**
* Returns a list of all possible movements, that is to say adjacent
* implementers of IPipeEntry or TileEntityChest.
*/
- public LinkedList getPossibleMovements(TravelingItem item) {
+ public List getPossibleMovements(TravelingItem item) {
LinkedList result = new LinkedList();
item.blacklist.add(item.input.getOpposite());
@@ -282,6 +295,8 @@ public class PipeTransportItems extends PipeTransport {
Position pos = new Position(container.xCoord, container.yCoord, container.zCoord, item.input);
result = ((IPipeTransportItemsHook) this.container.pipe).filterPossibleMovements(result, pos, item);
}
+ PipeEventItem.FindDest event = new PipeEventItem.FindDest(item, result);
+ container.pipe.handlePipeEvent(event);
if (allowBouncing && result.isEmpty()) {
if (canReceivePipeObjects(item.input.getOpposite(), item)) {
@@ -289,6 +304,8 @@ public class PipeTransportItems extends PipeTransport {
}
}
+ Collections.shuffle(result);
+
return result;
}
@@ -341,29 +358,23 @@ public class PipeTransportItems extends PipeTransport {
item.setPosition(container.xCoord + 0.5, container.yCoord + TransportUtils.getPipeFloorOf(item.getItemStack()), container.zCoord + 0.5);
if (item.output == ForgeDirection.UNKNOWN) {
- if (travelHook != null) {
- travelHook.drop(this, item);
- }
-
- EntityItem dropped = null;
-
- if (items.scheduleRemoval(item)) {
- dropped = item.toEntityItem(item.input);
- }
-
- if (dropped != null) {
- onDropped(dropped);
- }
+ if (items.scheduleRemoval(item))
+ dropItem(item);
} else {
if (travelHook != null) {
travelHook.centerReached(this, item);
}
+ PipeEventItem.ReachedCenter event = new PipeEventItem.ReachedCenter(item);
+ container.pipe.handlePipeEvent(event);
}
} else if (!item.toCenter && endReached(item)) {
TileEntity tile = container.getTile(item.output);
- boolean handleItem = true;
+ PipeEventItem.ReachedEnd event = new PipeEventItem.ReachedEnd(item, tile);
+ container.pipe.handlePipeEvent(event);
+ boolean handleItem = !event.handled;
+
if (travelHook != null) {
handleItem = !travelHook.endReached(this, item, tile);
}
@@ -404,19 +415,23 @@ public class PipeTransportItems extends PipeTransport {
reverseItem(item);
}
}
- } else {
- if (travelHook != null) {
- travelHook.drop(this, item);
- }
+ } else
+ dropItem(item);
+ }
- EntityItem dropped = item.toEntityItem(item.output);
+ private void dropItem(TravelingItem item) {
+ if (container.worldObj.isRemote)
+ return;
- if (dropped != null) {
- // On SMP, the client side doesn't actually drops
- // items
- onDropped(dropped);
- }
+ if (travelHook != null) {
+ travelHook.drop(this, item);
}
+
+ PipeEventItem.DropItem event = new PipeEventItem.DropItem(item, item.toEntityItem());
+ container.pipe.handlePipeEvent(event);
+ if (event.entity == null)
+ return;
+ container.worldObj.spawnEntityInWorld(event.entity);
}
protected boolean middleReached(TravelingItem item) {
@@ -569,10 +584,6 @@ public class PipeTransportItems extends PipeTransport {
return num;
}
- public void onDropped(EntityItem item) {
- this.container.pipe.onDropped(item);
- }
-
protected void neighborChange() {
}
diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java
index 4aece58c..84d63d10 100644
--- a/common/buildcraft/transport/TransportProxyClient.java
+++ b/common/buildcraft/transport/TransportProxyClient.java
@@ -39,7 +39,7 @@ public class TransportProxyClient extends TransportProxy {
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmerald.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLapis.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDaizuli.itemID, pipeItemRenderer);
- MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLogemerald.itemID, pipeItemRenderer);
+ MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmzuli.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsWood.itemID, pipeItemRenderer);
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsCobblestone.itemID, pipeItemRenderer);
diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java
index 4fde1ba4..54abccfa 100644
--- a/common/buildcraft/transport/TravelingItem.java
+++ b/common/buildcraft/transport/TravelingItem.java
@@ -12,6 +12,7 @@ import buildcraft.api.core.Position;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.EnumColor;
import java.util.EnumSet;
+import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
@@ -102,12 +103,19 @@ public class TravelingItem {
return extraData != null;
}
+ @Deprecated
public void setInsetionHandler(InsertionHandler handler) {
if (handler == null)
return;
this.insertionHandler = handler;
}
+ public void setInsertionHandler(InsertionHandler handler) {
+ if (handler == null)
+ return;
+ this.insertionHandler = handler;
+ }
+
public InsertionHandler getInsertionHandler() {
return insertionHandler;
}
@@ -157,25 +165,30 @@ public class TravelingItem {
data.setTag("extraData", extraData);
}
- public EntityItem toEntityItem(ForgeDirection dir) {
+ public EntityItem toEntityItem() {
if (container != null && !CoreProxy.proxy.isRenderWorld(container.worldObj)) {
if (getItemStack().stackSize <= 0)
return null;
- Position motion = new Position(0, 0, 0, dir);
+ Position motion = new Position(0, 0, 0, output);
motion.moveForwards(0.1 + getSpeed() * 2F);
- EntityItem entityitem = new EntityItem(container.worldObj, xCoord, yCoord, zCoord, getItemStack());
+ ItemStack stack = getItemStack();
+ EntityItem entity = new EntityItem(container.worldObj, xCoord, yCoord, zCoord, getItemStack());
+ if (stack.getItem().hasCustomEntity(stack)) {
+ Entity e = stack.getItem().createEntity(container.worldObj, entity, stack);
+ if (e instanceof EntityItem)
+ entity = (EntityItem) e;
+ }
- entityitem.lifespan = BuildCraftCore.itemLifespan;
- entityitem.delayBeforeCanPickup = 10;
+ entity.lifespan = BuildCraftCore.itemLifespan;
+ entity.delayBeforeCanPickup = 10;
float f3 = 0.00F + container.worldObj.rand.nextFloat() * 0.04F - 0.02F;
- entityitem.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x;
- entityitem.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y;
- entityitem.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z;
- container.worldObj.spawnEntityInWorld(entityitem);
- return entityitem;
+ entity.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x;
+ entity.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y;
+ entity.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z;
+ return entity;
}
return null;
}
@@ -194,7 +207,7 @@ public class TravelingItem {
public boolean isCorrupted() {
return getItemStack() == null || getItemStack().stackSize <= 0 || Item.itemsList[getItemStack().itemID] == null;
}
-
+
@Override
public int hashCode() {
int hash = 7;
diff --git a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java
new file mode 100644
index 00000000..cea906a5
--- /dev/null
+++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java
@@ -0,0 +1,172 @@
+/**
+ * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public License
+ * 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.gui;
+
+import buildcraft.BuildCraftTransport;
+import buildcraft.core.gui.BuildCraftContainer;
+import buildcraft.core.gui.GuiBuildCraft;
+import buildcraft.core.gui.slots.SlotPhantom;
+import buildcraft.core.gui.tooltips.ToolTip;
+import buildcraft.core.gui.tooltips.ToolTipLine;
+import buildcraft.core.gui.widgets.ButtonWidget;
+import buildcraft.core.network.IGuiReturnHandler;
+import buildcraft.core.network.PacketGuiReturn;
+import buildcraft.core.utils.EnumColor;
+import buildcraft.core.utils.RevolvingList;
+import buildcraft.core.utils.StringUtils;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+
+public class ContainerEmzuliPipe extends BuildCraftContainer {
+
+ private final PipeItemsEmzuli pipe;
+ private final IInventory filterInv;
+ private final byte[] prevSlotColors = new byte[4];
+ private final PaintWidget[] paintWidgets = new PaintWidget[4];
+
+ public ContainerEmzuliPipe(IInventory playerInventory, PipeItemsEmzuli pipe) {
+ super(pipe.getFilters().getSizeInventory());
+
+ this.pipe = pipe;
+ filterInv = pipe.getFilters();
+
+ addWidget(paintWidgets[0] = new PaintWidget(0, 51, 19));
+ addWidget(paintWidgets[1] = new PaintWidget(1, 104, 19));
+ addWidget(paintWidgets[2] = new PaintWidget(2, 51, 47));
+ addWidget(paintWidgets[3] = new PaintWidget(3, 104, 47));
+
+ addSlot(new SlotPhantom(filterInv, 0, 25, 21));
+ addSlot(new SlotPhantom(filterInv, 1, 134, 21));
+ addSlot(new SlotPhantom(filterInv, 2, 25, 49));
+ addSlot(new SlotPhantom(filterInv, 3, 134, 49));
+
+ for (int l = 0; l < 3; l++) {
+ for (int k1 = 0; k1 < 9; k1++) {
+ addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 84 + l * 18));
+ }
+ }
+
+ for (int i1 = 0; i1 < 9; i1++) {
+ addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting player) {
+ super.addCraftingToCrafters(player);
+ for (int slot = 0; slot < pipe.slotColors.length; slot++) {
+ prevSlotColors[slot] = pipe.slotColors[slot];
+ player.sendProgressBarUpdate(this, slot, pipe.slotColors[slot]);
+ }
+ }
+
+ /**
+ * Updates crafting matrix; called from onCraftMatrixChanged. Args: none
+ */
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+
+ for (int i = 0; i < crafters.size(); ++i) {
+ ICrafting player = (ICrafting) crafters.get(i);
+
+ for (int slot = 0; slot < pipe.slotColors.length; slot++) {
+ if (prevSlotColors[slot] != pipe.slotColors[slot])
+ player.sendProgressBarUpdate(this, slot, pipe.slotColors[slot]);
+ }
+ }
+ System.arraycopy(pipe.slotColors, 0, prevSlotColors, 0, pipe.slotColors.length);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int id, int data) {
+ paintWidgets[id].colors.setCurrent(data == 0 ? null : EnumColor.fromId(data - 1));
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return pipe.container.isUseableByPlayer(entityplayer);
+ }
+
+ private class PaintWidget extends ButtonWidget {
+
+ private final int slot;
+ private RevolvingList colors = new RevolvingList();
+
+ public PaintWidget(int slot, int x, int y) {
+ super(x, y, 176, 0, 20, 20);
+ this.slot = slot;
+ colors.add(null);
+ colors.addAll(Arrays.asList(EnumColor.VALUES));
+ }
+
+ @Override
+ public void draw(GuiBuildCraft gui, int guiX, int guiY, int mouseX, int mouseY) {
+ super.draw(gui, guiX, guiY, mouseX, mouseY);
+ EnumColor color = colors.getCurrent();
+ if (color != null) {
+ gui.bindTexture(TextureMap.locationItemsTexture);
+ gui.drawTexturedModelRectFromIcon(guiX + x + 2, guiY + y + 2, BuildCraftTransport.actionPipeColor[color.ordinal()].getIcon(), 16, 16);
+ } else {
+ gui.drawTexturedModalRect(guiX + x + 2, guiY + y + 2, u, v + h + h, 16, 16);
+ }
+ }
+
+ @Override
+ public void onRelease(int mouseButton) {
+ switch (mouseButton) {
+ case 0:
+ colors.rotateLeft();
+ break;
+ case 1:
+ colors.rotateRight();
+ break;
+ case 2:
+ colors.setCurrent(null);
+ break;
+ }
+ try {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ DataOutputStream data = new DataOutputStream(bytes);
+ data.writeByte(slot);
+ EnumColor color = colors.getCurrent();
+ data.writeByte(color == null ? 0 : color.ordinal() + 1);
+ PacketGuiReturn pkt = new PacketGuiReturn((IGuiReturnHandler) pipe.getContainer(), bytes.toByteArray());
+ pkt.sendPacket();
+ } catch (IOException ex) {
+ }
+ }
+
+ @Override
+ public ToolTip getToolTip() {
+ return toolTip;
+ }
+ private ToolTip toolTip = new ToolTip(500) {
+ @Override
+ public void refresh() {
+ toolTip.clear();
+ EnumColor color = colors.getCurrent();
+ if (color != null)
+ toolTip.add(new ToolTipLine(String.format(StringUtils.localize("gui.pipes.emzuli.paint"), color.getLocalizedName())));
+ else
+ toolTip.add(new ToolTipLine(StringUtils.localize("gui.pipes.emzuli.nopaint")));
+ }
+ };
+ }
+}
diff --git a/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java b/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java
deleted file mode 100644
index 931aa8cf..00000000
--- a/common/buildcraft/transport/gui/ContainerLogemeraldPipe.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
- *
- * BuildCraft is distributed under the terms of the Minecraft Mod Public License
- * 1.0, or MMPL. Please check the contents of the license located in
- * http://www.mod-buildcraft.com/MMPL-1.0.txt
- */
-package buildcraft.transport.gui;
-
-import buildcraft.core.gui.BuildCraftContainer;
-import buildcraft.core.gui.slots.SlotPhantom;
-import buildcraft.transport.pipes.PipeItemsLogemerald;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.Slot;
-
-public class ContainerLogemeraldPipe extends BuildCraftContainer {
-
- private final PipeItemsLogemerald logemeraldPipe;
-
- private final IInventory filterInv;
-
- public ContainerLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) {
- super(pipe.getFilters().getSizeInventory());
-
- logemeraldPipe = pipe;
- filterInv = logemeraldPipe.getFilters();
-
- addSlotToContainer(new SlotPhantom(filterInv, 0, 44, 21));
- addSlotToContainer(new SlotPhantom(filterInv, 1, 116, 21));
- addSlotToContainer(new SlotPhantom(filterInv, 2, 44, 49));
- addSlotToContainer(new SlotPhantom(filterInv, 3, 116, 49));
-
- for (int l = 0; l < 3; l++) {
- for (int k1 = 0; k1 < 9; k1++) {
- addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 84 + l * 18));
- }
- }
-
- for (int i1 = 0; i1 < 9; i1++) {
- addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142));
- }
- }
-
- @Override
- public boolean canInteractWith(EntityPlayer entityplayer) {
- return logemeraldPipe.container.isUseableByPlayer(entityplayer);
- }
-}
diff --git a/common/buildcraft/transport/gui/GuiLogemeraldPipe.java b/common/buildcraft/transport/gui/GuiEmzuliPipe.java
similarity index 53%
rename from common/buildcraft/transport/gui/GuiLogemeraldPipe.java
rename to common/buildcraft/transport/gui/GuiEmzuliPipe.java
index 87acd025..73aaecbd 100644
--- a/common/buildcraft/transport/gui/GuiLogemeraldPipe.java
+++ b/common/buildcraft/transport/gui/GuiEmzuliPipe.java
@@ -10,43 +10,33 @@ package buildcraft.transport.gui;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtils;
-import buildcraft.transport.pipes.PipeItemsLogemerald;
+import buildcraft.transport.pipes.PipeItemsEmzuli;
-public class GuiLogemeraldPipe extends GuiBuildCraft {
+public class GuiEmzuliPipe extends GuiBuildCraft {
- private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/logemerald_pipe_gui.png");
+ private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emzuli.png");
IInventory filterInventory;
- PipeItemsLogemerald logemeraldPipe;
+ PipeItemsEmzuli pipe;
- public GuiLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) {
- super(new ContainerLogemeraldPipe(playerInventory, pipe), pipe.getFilters());
+ public GuiEmzuliPipe(IInventory playerInventory, PipeItemsEmzuli pipe) {
+ super(new ContainerEmzuliPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE);
- logemeraldPipe = pipe;
+ this.pipe = pipe;
filterInventory = pipe.getFilters();
- xSize = 175;
+ xSize = 176;
ySize = 166;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
- String title = StringUtils.localize("gui.pipes.logemerald.title");
+ String title = StringUtils.localize("gui.pipes.emzuli.title");
fontRenderer.drawString(title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
}
-
- @Override
- protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- mc.renderEngine.bindTexture(TEXTURE);
- int j = (width - xSize) / 2;
- int k = (height - ySize) / 2;
- drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
- }
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
index cad1b80e..77532486 100644
--- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
+++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java
@@ -9,18 +9,17 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.network.TileNetworkData;
import buildcraft.core.utils.EnumColor;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.triggers.ActionPipeColor;
import buildcraft.transport.triggers.ActionPipeDirection;
import cpw.mods.fml.relauncher.Side;
@@ -35,12 +34,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsDaizuli extends Pipe implements IPipeTransportItemsHook {
+public class PipeItemsDaizuli extends Pipe {
private int standardIconIndex = PipeIconProvider.TYPE.PipeItemsDaizuli_Black.ordinal();
private int solidIconIndex = PipeIconProvider.TYPE.PipeAllDaizuli_Solid.ordinal();
@TileNetworkData
- private int color = EnumColor.WHITE.ordinal();
+ private int color = EnumColor.BLACK.ordinal();
private PipeLogicIron logic = new PipeLogicIron(this) {
@Override
protected boolean isValidConnectingTile(TileEntity tile) {
@@ -119,33 +118,31 @@ public class PipeItemsDaizuli extends Pipe implements IPipeT
return true;
}
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
+ public void eventHandler(PipeEventItem.FindDest event) {
LinkedList newMovements = new LinkedList();
EnumColor c = getColor();
- for (ForgeDirection dir : possibleOrientations) {
- if (item.color == c) {
+ for (ForgeDirection dir : event.destinations) {
+ if (event.item.color == c) {
if (dir.ordinal() == container.getBlockMetadata())
newMovements.add(dir);
} else if (dir.ordinal() != container.getBlockMetadata()) {
newMovements.add(dir);
}
}
- return newMovements;
+ event.destinations.retainAll(newMovements);
}
- @Override
- public void entityEntered(TravelingItem item, ForgeDirection orientation) {
- }
+ public void eventHandler(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
- @Override
- public void readjustSpeed(TravelingItem item) {
- if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED)
+ if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
+ }
-
- if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED)
+ if (item.getSpeed() < TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
+ }
}
@Override
diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java
index 0ea40d90..21be7f68 100644
--- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java
+++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java
@@ -21,22 +21,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
import buildcraft.core.GuiIds;
import buildcraft.core.inventory.SimpleInventory;
import buildcraft.core.inventory.StackHelper;
import buildcraft.core.network.IClientState;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.BlockGenericPipe;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
-import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, IClientState {
+public class PipeItemsDiamond extends Pipe implements IClientState {
private SimpleInventory filters = new SimpleInventory(54, "Filters", 1);
@@ -76,6 +74,11 @@ public class PipeItemsDiamond extends Pipe implements IPipeT
}
}
+ @Override
+ public int getIconIndexForItem() {
+ return PipeIconProvider.TYPE.PipeItemsDiamond_Item.ordinal();
+ }
+
@Override
public boolean blockActivated(EntityPlayer entityplayer) {
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length)
@@ -89,13 +92,12 @@ public class PipeItemsDiamond extends Pipe implements IPipeT
return true;
}
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
+ public void eventHandler(PipeEventItem.FindDest event) {
LinkedList filteredOrientations = new LinkedList();
LinkedList defaultOrientations = new LinkedList();
// Filtered outputs
- for (ForgeDirection dir : possibleOrientations) {
+ for (ForgeDirection dir : event.destinations) {
boolean foundFilter = false;
// NB: if there's several of the same match, the probability
@@ -107,29 +109,20 @@ public class PipeItemsDiamond extends Pipe implements IPipeT
if (filter != null)
foundFilter = true;
- if (StackHelper.instance().isMatchingItem(filter, item.getItemStack(), true, false))
+ if (StackHelper.instance().isMatchingItem(filter, event.item.getItemStack(), true, false))
filteredOrientations.add(dir);
-
}
if (!foundFilter)
defaultOrientations.add(dir);
}
+ event.destinations.clear();
if (!filteredOrientations.isEmpty())
- return filteredOrientations;
-
- return defaultOrientations;
+ event.destinations.addAll(filteredOrientations);
+ else
+ event.destinations.addAll(defaultOrientations);
}
- @Override
- public void entityEntered(TravelingItem item, ForgeDirection orientation) {
- }
-
- @Override
- public void readjustSpeed(TravelingItem item) {
- transport.defaultReajustSpeed(item);
- }
/* SAVING & LOADING */
-
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
diff --git a/common/buildcraft/transport/pipes/PipeItemsLogemerald.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java
similarity index 74%
rename from common/buildcraft/transport/pipes/PipeItemsLogemerald.java
rename to common/buildcraft/transport/pipes/PipeItemsEmzuli.java
index 6190d207..53a6b155 100644
--- a/common/buildcraft/transport/pipes/PipeItemsLogemerald.java
+++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java
@@ -25,27 +25,33 @@ import buildcraft.api.inventory.ISelectiveInventory;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.GuiIds;
import buildcraft.core.inventory.SimpleInventory;
+import buildcraft.core.inventory.StackHelper;
+import buildcraft.core.network.IGuiReturnHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.EnumColor;
import buildcraft.core.utils.Utils;
import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.PipeIconProvider;
-import buildcraft.transport.pipes.PipeItemsEmerald.ButtonState;
+import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.triggers.ActionExtractionPreset;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
-public class PipeItemsLogemerald extends PipeItemsWood {
+public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler {
+ public final byte[] slotColors = new byte[4];
private final SimpleInventory filters = new SimpleInventory(4, "Filters", 1);
-
- private BitSet activeFlags = new BitSet(4);
- private int filterCount = filters.getSizeInventory();
+ private final BitSet activeFlags = new BitSet(4);
+ private final int filterCount = filters.getSizeInventory();
private int currentFilter = 0;
- public PipeItemsLogemerald(int itemID) {
+ public PipeItemsEmzuli(int itemID) {
super(itemID);
- standardIconIndex = PipeIconProvider.TYPE.PipeItemsLogemerald_Standard.ordinal();
- solidIconIndex = PipeIconProvider.TYPE.PipeAllLogemerald_Solid.ordinal();
+ standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmzuli_Standard.ordinal();
+ solidIconIndex = PipeIconProvider.TYPE.PipeAllEmzuli_Solid.ordinal();
}
@Override
@@ -66,7 +72,16 @@ public class PipeItemsLogemerald extends PipeItemsWood {
return true;
}
-
+
+ @Override
+ protected TravelingItem makeItem(double x, double y, double z, ItemStack stack) {
+ TravelingItem item = super.makeItem(x, y, z, stack);
+ int color = slotColors[currentFilter % filterCount];
+ if (color > 0)
+ item.color = EnumColor.fromId(color - 1);
+ return item;
+ }
+
/**
* Return the itemstack that can be if something can be extracted from this
* inventory, null if none. On certain cases, the extractable slot depends
@@ -75,19 +90,19 @@ public class PipeItemsLogemerald extends PipeItemsWood {
@Override
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
- if (activeFlags.isEmpty()){
+ if (activeFlags.isEmpty()) {
return null;
}
-
+
incrementFilter();
- if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)){
+ if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)) {
return null;
}
-
+
/* ISELECTIVEINVENTORY */
if (inventory instanceof ISelectiveInventory) {
- ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[] { getCurrentFilter() }, false, doRemove, from, (int) powerHandler.getEnergyStored());
+ ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[]{getCurrentFilter()}, false, doRemove, from, (int) powerHandler.getEnergyStored());
if (doRemove) {
for (ItemStack stack : stacks) {
if (stack != null) {
@@ -133,9 +148,9 @@ public class PipeItemsLogemerald extends PipeItemsWood {
// This is a generic inventory
IInventory inv = Utils.getInventory(inventory);
ItemStack result = checkExtractGeneric(inv, doRemove, from);
-
+
if (result != null) {
- return new ItemStack[] { result };
+ return new ItemStack[]{result};
}
}
@@ -171,11 +186,11 @@ public class PipeItemsLogemerald extends PipeItemsWood {
public IInventory getFilters() {
return filters;
}
-
+
@Override
protected void actionsActivated(Map actions) {
super.actionsActivated(actions);
-
+
activeFlags.clear();
for (Entry action : actions.entrySet()) {
@@ -186,28 +201,28 @@ public class PipeItemsLogemerald extends PipeItemsWood {
}
private void setActivePreset(EnumColor color) {
- switch (color){
- case RED:
- activeFlags.set(0);
- break;
- case BLUE:
- activeFlags.set(1);
- break;
- case GREEN:
- activeFlags.set(2);
- break;
- case YELLOW:
- activeFlags.set(3);
- break;
- default:
- break;
+ switch (color) {
+ case RED:
+ activeFlags.set(0);
+ break;
+ case BLUE:
+ activeFlags.set(1);
+ break;
+ case GREEN:
+ activeFlags.set(2);
+ break;
+ case YELLOW:
+ activeFlags.set(3);
+ break;
+ default:
+ break;
}
}
@Override
public LinkedList getActions() {
LinkedList result = super.getActions();
-
+
result.add(BuildCraftTransport.actionExtractionPresetRed);
result.add(BuildCraftTransport.actionExtractionPresetBlue);
result.add(BuildCraftTransport.actionExtractionPresetGreen);
@@ -216,11 +231,24 @@ public class PipeItemsLogemerald extends PipeItemsWood {
return result;
}
+ @Override
+ public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException {
+ }
+
+ @Override
+ public void readGuiData(DataInputStream data, EntityPlayer paramEntityPlayer) throws IOException {
+ byte slot = data.readByte();
+ slotColors[slot] = data.readByte();
+ }
+
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
filters.readFromNBT(nbt);
currentFilter = nbt.getInteger("currentFilter");
+ for (int slot = 0; slot < slotColors.length; slot++) {
+ slotColors[slot] = nbt.getByte("slotColors[" + slot + "]");
+ }
}
@Override
@@ -228,19 +256,22 @@ public class PipeItemsLogemerald extends PipeItemsWood {
super.writeToNBT(nbt);
filters.writeToNBT(nbt);
nbt.setInteger("currentFilter", currentFilter);
+ for (int slot = 0; slot < slotColors.length; slot++) {
+ nbt.setByte("slotColors[" + slot + "]", slotColors[slot]);
+ }
}
-
+
private void incrementFilter() {
int count = 0;
currentFilter++;
-
+
while (!(filters.getStackInSlot(currentFilter % filterCount) != null && activeFlags.get(currentFilter % filterCount)) && count < filterCount) {
currentFilter++;
count++;
}
}
- private ItemStack getCurrentFilter() {
+ private ItemStack getCurrentFilter() {
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java
index cc35cc5c..1f6bf80a 100644
--- a/common/buildcraft/transport/pipes/PipeItemsGold.java
+++ b/common/buildcraft/transport/pipes/PipeItemsGold.java
@@ -9,19 +9,17 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.LinkedList;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
+public class PipeItemsGold extends Pipe {
public PipeItemsGold(int itemID) {
super(new PipeTransportItems(), itemID);
@@ -38,18 +36,9 @@ public class PipeItemsGold extends Pipe implements IPipeTransportItemsHook {
return PipeIconProvider.TYPE.PipeItemsGold.ordinal();
}
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
- return possibleOrientations;
- }
-
- @Override
- public void entityEntered(TravelingItem item, ForgeDirection orientation) {
- readjustSpeed(item);
- }
-
- @Override
- public void readjustSpeed(TravelingItem item) {
+ public void handleEvent(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 2f, TransportConstants.PIPE_NORMAL_SPEED * 20F));
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java
index 4df7a8f6..6e7d5352 100644
--- a/common/buildcraft/transport/pipes/PipeItemsLapis.java
+++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java
@@ -9,17 +9,15 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
import buildcraft.api.gates.IAction;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.utils.EnumColor;
-import buildcraft.transport.IItemTravelingHook;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.triggers.ActionPipeColor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -29,14 +27,12 @@ import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
-import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsLapis extends Pipe implements IItemTravelingHook, IPipeTransportItemsHook {
+public class PipeItemsLapis extends Pipe {
public PipeItemsLapis(int itemID) {
super(new PipeTransportItems(), itemID);
- transport.travelHook = this;
}
@Override
@@ -48,7 +44,7 @@ public class PipeItemsLapis extends Pipe implements IItemTra
@Override
public int getIconIndex(ForgeDirection direction) {
if (container == null)
- return PipeIconProvider.TYPE.PipeItemsLapis_White.ordinal();
+ return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal();
return PipeIconProvider.TYPE.PipeItemsLapis_Black.ordinal() + container.getBlockMetadata();
}
@@ -80,22 +76,14 @@ public class PipeItemsLapis extends Pipe implements IItemTra
}
}
- @Override
- public void drop(PipeTransportItems transport, TravelingItem data) {
+ public void eventHandler(PipeEventItem.ReachedCenter event) {
+ event.item.color = getColor();
}
- @Override
- public void centerReached(PipeTransportItems transport, TravelingItem item) {
- item.color = getColor();
- }
+ public void eventHandler(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
- @Override
- public boolean endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) {
- return false;
- }
-
- @Override
- public void readjustSpeed(TravelingItem item) {
if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
}
@@ -105,15 +93,6 @@ public class PipeItemsLapis extends Pipe implements IItemTra
}
}
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem travellingItem) {
- return possibleOrientations;
- }
-
- @Override
- public void entityEntered(TravelingItem travellingItem, ForgeDirection orientation) {
- }
-
@Override
protected void actionsActivated(Map actions) {
super.actionsActivated(actions);
diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java
index eff8cfb3..5cfb1405 100644
--- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java
+++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java
@@ -22,6 +22,8 @@ import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
+import buildcraft.transport.pipes.events.PipeEvent;
+import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.utils.TransportUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -234,15 +236,12 @@ public class PipeItemsObsidian extends Pipe implements IPowe
}
}
- @Override
- public void onDropped(EntityItem item) {
- if (entitiesDroppedIndex + 1 >= entitiesDropped.length) {
+ public void eventHandler(PipeEventItem.DropItem event) {
+ if (entitiesDroppedIndex + 1 >= entitiesDropped.length)
entitiesDroppedIndex = 0;
- } else {
+ else
entitiesDroppedIndex++;
- }
-
- entitiesDropped[entitiesDroppedIndex] = item.entityId;
+ entitiesDropped[entitiesDroppedIndex] = event.entity.entityId;
}
public boolean canSuck(Entity entity, int distance) {
diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java
index 13c6a0d5..6873ffde 100644
--- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java
+++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java
@@ -9,19 +9,17 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.LinkedList;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
+public class PipeItemsQuartz extends Pipe {
public PipeItemsQuartz(int itemID) {
super(new PipeTransportItems(), itemID);
@@ -39,8 +37,10 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
return PipeIconProvider.TYPE.PipeItemsQuartz.ordinal();
}
- @Override
- public void readjustSpeed(TravelingItem item) {
+ public void eventHandler(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
+
if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 4.0F);
}
@@ -49,13 +49,4 @@ public class PipeItemsQuartz extends Pipe implements IPipeTransportItemsHook {
item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
}
-
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
- return possibleOrientations;
- }
-
- @Override
- public void entityEntered(TravelingItem item, ForgeDirection orientation) {
- }
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java
index 415e5dd2..86c96858 100644
--- a/common/buildcraft/transport/pipes/PipeItemsStone.java
+++ b/common/buildcraft/transport/pipes/PipeItemsStone.java
@@ -9,19 +9,17 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.api.core.Position;
-import buildcraft.transport.IPipeTransportItemsHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.LinkedList;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
+public class PipeItemsStone extends Pipe {
public PipeItemsStone(int itemID) {
super(new PipeTransportItems(), itemID);
@@ -38,8 +36,10 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
return PipeIconProvider.TYPE.PipeItemsStone.ordinal();
}
- @Override
- public void readjustSpeed(TravelingItem item) {
+ public void eventHandler(PipeEventItem.AdjustSpeed event) {
+ event.handled = true;
+ TravelingItem item = event.item;
+
if (item.getSpeed() > TransportConstants.PIPE_NORMAL_SPEED) {
item.setSpeed(item.getSpeed() - TransportConstants.PIPE_NORMAL_SPEED / 2.0F);
}
@@ -48,13 +48,4 @@ public class PipeItemsStone extends Pipe implements IPipeTransportItemsHook {
item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED);
}
}
-
- @Override
- public LinkedList filterPossibleMovements(LinkedList possibleOrientations, Position pos, TravelingItem item) {
- return possibleOrientations;
- }
-
- @Override
- public void entityEntered(TravelingItem item, ForgeDirection orientation) {
- }
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsVoid.java b/common/buildcraft/transport/pipes/PipeItemsVoid.java
index 002f1f9c..37ff877a 100644
--- a/common/buildcraft/transport/pipes/PipeItemsVoid.java
+++ b/common/buildcraft/transport/pipes/PipeItemsVoid.java
@@ -9,21 +9,18 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
-import buildcraft.transport.IItemTravelingHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
-import buildcraft.transport.TravelingItem;
+import buildcraft.transport.pipes.events.PipeEventItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
-public class PipeItemsVoid extends Pipe implements IItemTravelingHook {
+public class PipeItemsVoid extends Pipe {
public PipeItemsVoid(int itemID) {
super(new PipeTransportItems(), itemID);
- transport.travelHook = this;
}
@Override
@@ -37,20 +34,11 @@ public class PipeItemsVoid extends Pipe implements IItemTrav
return PipeIconProvider.TYPE.PipeItemsVoid.ordinal();
}
- // This is called if the void pipe is only connected to one pipe
- @Override
- public void drop(PipeTransportItems pipe, TravelingItem item) {
- item.getItemStack().stackSize = 0;
+ public void handleEvent(PipeEventItem.DropItem event) {
+ event.entity = null;
}
- // This is called when the void pipe is connected to multiple pipes
- @Override
- public void centerReached(PipeTransportItems pipe, TravelingItem item) {
- transport.items.scheduleRemoval(item);
- }
-
- @Override
- public boolean endReached(PipeTransportItems pipe, TravelingItem item, TileEntity tile) {
- return false;
+ public void handleEvent(PipeEventItem.ReachedCenter event) {
+ transport.items.scheduleRemoval(event.item);
}
}
diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java
index e5746046..4149a055 100644
--- a/common/buildcraft/transport/pipes/PipeItemsWood.java
+++ b/common/buildcraft/transport/pipes/PipeItemsWood.java
@@ -139,13 +139,17 @@ public class PipeItemsWood extends Pipe implements IPowerRec
entityPos.moveForwards(0.6);
- TravelingItem entity = new TravelingItem(entityPos.x, entityPos.y, entityPos.z, stack);
+ TravelingItem entity = makeItem(entityPos.x, entityPos.y, entityPos.z, stack);
transport.injectItem(entity, entityPos.orientation);
}
}
}
+ protected TravelingItem makeItem(double x, double y, double z, ItemStack stack) {
+ return new TravelingItem(x, y, z, stack);
+ }
+
/**
* Return the itemstack that can be if something can be extracted from this
* inventory, null if none. On certain cases, the extractable slot depends
diff --git a/common/buildcraft/transport/pipes/events/PipeEvent.java b/common/buildcraft/transport/pipes/events/PipeEvent.java
new file mode 100644
index 00000000..8cc7177e
--- /dev/null
+++ b/common/buildcraft/transport/pipes/events/PipeEvent.java
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.pipes.events;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public abstract class PipeEvent {
+}
diff --git a/common/buildcraft/transport/pipes/events/PipeEventItem.java b/common/buildcraft/transport/pipes/events/PipeEventItem.java
new file mode 100644
index 00000000..0671c8ad
--- /dev/null
+++ b/common/buildcraft/transport/pipes/events/PipeEventItem.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) SpaceToad, 2011-2012
+ * http://www.mod-buildcraft.com
+ *
+ * BuildCraft is distributed under the terms of the Minecraft Mod Public
+ * License 1.0, or MMPL. Please check the contents of the license located in
+ * http://www.mod-buildcraft.com/MMPL-1.0.txt
+ */
+package buildcraft.transport.pipes.events;
+
+import buildcraft.transport.TravelingItem;
+import java.util.List;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+
+/**
+ *
+ * @author CovertJaguar
+ */
+public abstract class PipeEventItem extends PipeEvent {
+
+ public final TravelingItem item;
+
+ public PipeEventItem(TravelingItem item) {
+ this.item = item;
+ }
+
+ public static class Entered extends PipeEventItem {
+
+ public boolean cancelled = false;
+
+ public Entered(TravelingItem item) {
+ super(item);
+ }
+ }
+
+ public static class ReachedCenter extends PipeEventItem {
+
+ public ReachedCenter(TravelingItem item) {
+ super(item);
+ }
+ }
+
+ public static class ReachedEnd extends PipeEventItem {
+
+ public final TileEntity dest;
+ public boolean handled = false;
+
+ public ReachedEnd(TravelingItem item, TileEntity dest) {
+ super(item);
+ this.dest = dest;
+ }
+ }
+
+ public static class DropItem extends PipeEventItem {
+
+ public EntityItem entity;
+
+ public DropItem(TravelingItem item, EntityItem entity) {
+ super(item);
+ this.entity = entity;
+ }
+ }
+
+ public static class FindDest extends PipeEventItem {
+
+ public final List destinations;
+
+ public FindDest(TravelingItem item, List destinations) {
+ super(item);
+ this.destinations = destinations;
+ }
+ }
+
+ public static class AdjustSpeed extends PipeEventItem {
+
+ public boolean handled = false;
+
+ public AdjustSpeed(TravelingItem item) {
+ super(item);
+ }
+ }
+}
diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java
index 9095d2bc..6f9add53 100644
--- a/common/buildcraft/transport/triggers/ActionPipeColor.java
+++ b/common/buildcraft/transport/triggers/ActionPipeColor.java
@@ -9,6 +9,7 @@ package buildcraft.transport.triggers;
import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.EnumColor;
+import buildcraft.core.utils.StringUtils;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
@@ -26,7 +27,7 @@ public class ActionPipeColor extends BCAction {
@Override
public String getDescription() {
- return color.getName() + " Pipe Color";
+ return String.format(StringUtils.localize("gate.pipe.item.color"), color.getLocalizedName());
}
@Override