Logemerald->Emzuli Rework + PipeEvents

Modified Logemerald:
-Added ability to paint items as they are extracted
-Renamed to Emzuli, texture and recipe changed accordingly

PipeEvents:
-Added PipeEvents a replacement for Hook interfaces, precursor to 1.7
Pipe API
-Implement methods with signature "eventHandler(PipeEventClass event)"
to receive events

Widgets:
-General improvements for use as a button
This commit is contained in:
CovertJaguar 2013-11-24 06:23:02 -08:00
parent 14dc0014c9
commit 6f57b4a80d
44 changed files with 859 additions and 345 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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) {

View file

@ -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 <http://www.railcraft.info/>
*/
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) {
}
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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 <http://www.railcraft.info/>
*/
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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -157,7 +157,7 @@ public enum EnumColor {
return NAMES[ordinal()];
}
public String getTranslatedName() {
public String getLocalizedName() {
return StringUtils.localize(getTag());
}

View file

@ -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 <http://www.railcraft.info>
*/
public class RevolvingList<T> extends ForwardingCollection<T> {
private Deque<T> list = new LinkedList<T>();
public RevolvingList() {
}
public RevolvingList(Collection<? extends T> collection) {
list.addAll(collection);
}
@Override
protected Collection<T> 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();
}
}
}
}

View file

@ -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())

View file

@ -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);
}

View file

@ -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<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item);

View file

@ -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<T extends PipeTransport> implements IPipe, IDropContr
@SuppressWarnings("rawtypes")
private static Map<Class, TilePacketWrapper> networkWrappers = new HashMap<Class, TilePacketWrapper>();
public SafeTimeTracker actionTracker = new SafeTimeTracker();
private static Map<Class<? extends Pipe>, Map<Class<? extends PipeEvent>, EventHandler>> eventHandlers = new HashMap<Class<? extends Pipe>, Map<Class<? extends PipeEvent>, EventHandler>>();
public Pipe(T transport, int itemID) {
this.transport = transport;
@ -65,6 +67,39 @@ public abstract class Pipe<T extends PipeTransport> 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<Class<? extends PipeEvent>, EventHandler> handlerMap = eventHandlers.get(getClass());
if (handlerMap == null) {
handlerMap = new HashMap<Class<? extends PipeEvent>, 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<T extends PipeTransport> implements IPipe, IDropContr
transport.dropContents();
}
public void onDropped(EntityItem item) {
}
/**
* If this pipe is open on one side, return it.
*/

View file

@ -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);

View file

@ -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"),
//

View file

@ -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<ForgeDirection> listOfPossibleMovements = getPossibleMovements(data);
List<ForgeDirection> 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<ForgeDirection> getPossibleMovements(TravelingItem item) {
public List<ForgeDirection> getPossibleMovements(TravelingItem item) {
LinkedList<ForgeDirection> result = new LinkedList<ForgeDirection>();
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() {
}

View file

@ -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);

View file

@ -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;

View file

@ -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<EnumColor> colors = new RevolvingList<EnumColor>();
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")));
}
};
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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<PipeTransportItems> implements IPipeTransportItemsHook {
public class PipeItemsDaizuli extends Pipe<PipeTransportItems> {
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<PipeTransportItems> implements IPipeT
return true;
}
@Override
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
public void eventHandler(PipeEventItem.FindDest event) {
LinkedList<ForgeDirection> newMovements = new LinkedList<ForgeDirection>();
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

View file

@ -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<PipeTransportItems> implements IPipeTransportItemsHook, IClientState {
public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IClientState {
private SimpleInventory filters = new SimpleInventory(54, "Filters", 1);
@ -76,6 +74,11 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> 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<PipeTransportItems> implements IPipeT
return true;
}
@Override
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
public void eventHandler(PipeEventItem.FindDest event) {
LinkedList<ForgeDirection> filteredOrientations = new LinkedList<ForgeDirection>();
LinkedList<ForgeDirection> defaultOrientations = new LinkedList<ForgeDirection>();
// 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<PipeTransportItems> 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);

View file

@ -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<IAction, Boolean> actions) {
super.actionsActivated(actions);
activeFlags.clear();
for (Entry<IAction, Boolean> 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<IAction> getActions() {
LinkedList<IAction> 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());
}
}

View file

@ -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<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> 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));
}
}

View file

@ -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<PipeTransportItems> implements IItemTravelingHook, IPipeTransportItemsHook {
public class PipeItemsLapis extends Pipe<PipeTransportItems> {
public PipeItemsLapis(int itemID) {
super(new PipeTransportItems(), itemID);
transport.travelHook = this;
}
@Override
@ -48,7 +44,7 @@ public class PipeItemsLapis extends Pipe<PipeTransportItems> 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<PipeTransportItems> 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<PipeTransportItems> implements IItemTra
}
}
@Override
public LinkedList<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem travellingItem) {
return possibleOrientations;
}
@Override
public void entityEntered(TravelingItem travellingItem, ForgeDirection orientation) {
}
@Override
protected void actionsActivated(Map<IAction, Boolean> actions) {
super.actionsActivated(actions);

View file

@ -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<PipeTransportItems> 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) {

View file

@ -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<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
return possibleOrientations;
}
@Override
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
}
}

View file

@ -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<ForgeDirection> filterPossibleMovements(LinkedList<ForgeDirection> possibleOrientations, Position pos, TravelingItem item) {
return possibleOrientations;
}
@Override
public void entityEntered(TravelingItem item, ForgeDirection orientation) {
}
}

View file

@ -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<PipeTransportItems> implements IItemTravelingHook {
public class PipeItemsVoid extends Pipe<PipeTransportItems> {
public PipeItemsVoid(int itemID) {
super(new PipeTransportItems(), itemID);
transport.travelHook = this;
}
@Override
@ -37,20 +34,11 @@ public class PipeItemsVoid extends Pipe<PipeTransportItems> 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);
}
}

View file

@ -139,13 +139,17 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> 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

View file

@ -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 <http://www.railcraft.info/>
*/
public abstract class PipeEvent {
}

View file

@ -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 <http://www.railcraft.info/>
*/
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<ForgeDirection> destinations;
public FindDest(TravelingItem item, List<ForgeDirection> destinations) {
super(item);
this.destinations = destinations;
}
}
public static class AdjustSpeed extends PipeEventItem {
public boolean handled = false;
public AdjustSpeed(TravelingItem item) {
super(item);
}
}
}

View file

@ -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