From c68d9ea792a932523ed8912631ceee2d1e3e6d75 Mon Sep 17 00:00:00 2001 From: da3dsoul Date: Mon, 23 Feb 2015 16:43:53 -0500 Subject: [PATCH] Readd Insertion Pipe capabilities. People complained and then kissed ass. --- .gradle/gradle.log | 16 +- .../abo/pipes/items/PipeItemsInsertion.java | 218 +++++++++--------- 2 files changed, 110 insertions(+), 124 deletions(-) diff --git a/.gradle/gradle.log b/.gradle/gradle.log index 993662d..d00e35f 100644 --- a/.gradle/gradle.log +++ b/.gradle/gradle.log @@ -5,21 +5,7 @@ R4wk, ZeuX, IngisKahn, bspkrs MCP Data version : unknown **************************** -:compileApiJava UP-TO-DATE -:processApiResources UP-TO-DATE -:apiClasses UP-TO-DATE -:sourceMainJava UP-TO-DATE -:compileJava UP-TO-DATE -:processResources -:classes -:jar -:extractMcpData UP-TO-DATE -:getVersionJson -:extractUserDev UP-TO-DATE -:genSrgs SKIPPED -:reobf -:assemble BUILD SUCCESSFUL -Total time: 13.37 secs +Total time: 2.073 secs diff --git a/src/main/java/abo/pipes/items/PipeItemsInsertion.java b/src/main/java/abo/pipes/items/PipeItemsInsertion.java index 08df553..d791155 100644 --- a/src/main/java/abo/pipes/items/PipeItemsInsertion.java +++ b/src/main/java/abo/pipes/items/PipeItemsInsertion.java @@ -24,112 +24,112 @@ public class PipeItemsInsertion extends ABOPipe { - public PipeItemsInsertion(Item itemID) { - super(new PipeTransportItems(), itemID); - - transport.allowBouncing = true; - } - - @Override - public int getIconIndex(ForgeDirection direction) { - return PipeIcons.PipeItemsInsertion.ordinal(); - } - - @Override - public boolean blockActivated(EntityPlayer entityplayer) { - TileEntity tile = null; - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - tile = getWorld().getTileEntity(container.xCoord + side.offsetX, container.yCoord + side.offsetY, - container.zCoord + side.offsetZ); - if (tile != null && tile instanceof TileEntityEnderChest) break; - } - if (tile == null || !(tile instanceof TileEntityEnderChest)) { return false; } - if (getWorld().isRemote) { - return true; - } else { - ABO.instance.getInventoryEnderChest().func_146031_a((TileEntityEnderChest) tile); - entityplayer.displayGUIChest(ABO.instance.getInventoryEnderChest()); - return true; - } - } - - public void eventHandler(PipeEventItem.FindDest event) { - LinkedList nonPipesList = new LinkedList(); - LinkedList pipesList = new LinkedList(); - - List result = event.destinations; - TravelingItem item = event.item; - - result.clear(); - - EnumSet sides = EnumSet.complementOf(item.blacklist); - sides.remove(ForgeDirection.UNKNOWN); - - for (ForgeDirection o : sides) { - if (outputOpen(o) && canReceivePipeObjects(o, item)) { - result.add(o); - } - } - - for (ForgeDirection o : result) { - TileEntity entity = container.getTile(o); - if (entity instanceof IPipeTile) { - pipesList.add(o); - } else if (entity instanceof TileEntityEnderChest) { - nonPipesList.add(o); - } - } - - if (!nonPipesList.isEmpty()) { - result.clear(); - result.addAll(nonPipesList); - return; - } - result.clear(); - result.addAll(pipesList); - return; - } - - @Override - public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { - if (tile instanceof TileEntityEnderChest) return true; - return super.canPipeConnect(tile, side); - } - - public void eventHandler(PipeEventItem.ReachedEnd event) { - TileEntity tile = null; - TravelingItem item = event.item; - tile = event.dest; - if (tile == null) { return; } - if (tile instanceof TileEntityEnderChest) { - if (!container.getWorldObj().isRemote) { - ItemStack added = new TransactorSimple(InvUtils.getInventory((IInventory) ABO.instance - .getInventoryEnderChest())).add(item.getItemStack(), item.output.getOpposite(), true); - item.getItemStack().stackSize -= added.stackSize; - - if (item.getItemStack().stackSize <= 0) { - transport.items.scheduleRemoval(item); - } - event.handled = true; - } - } - } - - private boolean canReceivePipeObjects(ForgeDirection o, TravelingItem item) { - TileEntity entity = container.getTile(o); - - if (!container.isPipeConnected(o)) { return false; } - - if (entity instanceof TileGenericPipe) { - TileGenericPipe pipe = (TileGenericPipe) entity; - - return pipe.pipe.transport instanceof PipeTransportItems; - } else if (entity instanceof TileEntityEnderChest) { - if (new TransactorSimple(InvUtils.getInventory((IInventory) ABO.instance.getInventoryEnderChest())).add( - item.getItemStack(), o.getOpposite(), false).stackSize > 0) { return true; } - } - - return false; - } - -} + public PipeItemsInsertion(Item itemID) { + super(new PipeTransportItems(), itemID); + + transport.allowBouncing = true; + } + + @Override + public int getIconIndex(ForgeDirection direction) { + return PipeIcons.PipeItemsInsertion.ordinal(); + } + + @Override + public boolean blockActivated(EntityPlayer entityplayer) { + TileEntity tile = null; + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + tile = getWorld().getTileEntity(container.xCoord + side.offsetX, container.yCoord + side.offsetY, + container.zCoord + side.offsetZ); + if (tile != null && tile instanceof TileEntityEnderChest) break; + } + if (tile == null || !(tile instanceof TileEntityEnderChest)) { return false; } + if (getWorld().isRemote) { + return true; + } else { + ABO.instance.getInventoryEnderChest().func_146031_a((TileEntityEnderChest) tile); + entityplayer.displayGUIChest(ABO.instance.getInventoryEnderChest()); + return true; + } + } + + public void eventHandler(PipeEventItem.FindDest event) { + LinkedList nonPipesList = new LinkedList(); + LinkedList pipesList = new LinkedList(); + + List result = event.destinations; + TravelingItem item = event.item; + + result.clear(); + + EnumSet sides = EnumSet.complementOf(item.blacklist); + sides.remove(ForgeDirection.UNKNOWN); + + for (ForgeDirection o : sides) { + if (outputOpen(o) && canReceivePipeObjects(o, item)) { + result.add(o); + } + } + + for (ForgeDirection o : result) { + TileEntity entity = container.getTile(o); + if (entity instanceof IPipeTile) { + pipesList.add(o); + } else if (entity instanceof TileEntityEnderChest) { + nonPipesList.add(o); + } + } + + if (!nonPipesList.isEmpty()) { + result.clear(); + result.addAll(nonPipesList); + return; + } + result.clear(); + result.addAll(pipesList); + return; + } + + @Override + public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { + if (tile instanceof TileEntityEnderChest) return true; + return super.canPipeConnect(tile, side); + } + + public void eventHandler(PipeEventItem.ReachedEnd event) { + TileEntity tile = null; + TravelingItem item = event.item; + tile = event.dest; + if (tile == null) { return; } + if (tile instanceof TileEntityEnderChest) { + if (!container.getWorldObj().isRemote) { + ItemStack added = new TransactorSimple(InvUtils.getInventory((IInventory) ABO.instance + .getInventoryEnderChest())).add(item.getItemStack(), item.output.getOpposite(), true); + item.getItemStack().stackSize -= added.stackSize; + + if (item.getItemStack().stackSize <= 0) { + transport.items.scheduleRemoval(item); + } + event.handled = true; + } + } + } + + private boolean canReceivePipeObjects(ForgeDirection o, TravelingItem item) { + TileEntity entity = container.getTile(o); + + if (!container.isPipeConnected(o)) { return false; } + + if (entity instanceof TileGenericPipe) { + TileGenericPipe pipe = (TileGenericPipe) entity; + + return pipe.pipe.transport instanceof PipeTransportItems; + } else if (entity instanceof TileEntityEnderChest) { + if (new TransactorSimple(InvUtils.getInventory((IInventory) ABO.instance.getInventoryEnderChest())).add( + item.getItemStack(), o.getOpposite(), false).stackSize > 0) { return true; } + } + + return false; + } + +} \ No newline at end of file