Skip to content

Commit

Permalink
Readd Insertion Pipe capabilities. People complained and then kissed …
Browse files Browse the repository at this point in the history
…ass.
  • Loading branch information
da3dsoul committed Feb 23, 2015
1 parent f02bfcb commit c68d9ea
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 124 deletions.
16 changes: 1 addition & 15 deletions .gradle/gradle.log
Original file line number Diff line number Diff line change
Expand Up @@ -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
218 changes: 109 additions & 109 deletions src/main/java/abo/pipes/items/PipeItemsInsertion.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,112 +24,112 @@

public class PipeItemsInsertion extends ABOPipe<PipeTransportItems> {

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<ForgeDirection> nonPipesList = new LinkedList<ForgeDirection>();
LinkedList<ForgeDirection> pipesList = new LinkedList<ForgeDirection>();

List<ForgeDirection> result = event.destinations;
TravelingItem item = event.item;

result.clear();

EnumSet<ForgeDirection> 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<ForgeDirection> nonPipesList = new LinkedList<ForgeDirection>();
LinkedList<ForgeDirection> pipesList = new LinkedList<ForgeDirection>();

List<ForgeDirection> result = event.destinations;
TravelingItem item = event.item;

result.clear();

EnumSet<ForgeDirection> 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;
}

}

0 comments on commit c68d9ea

Please sign in to comment.