mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
Crane extractors take items to inventory when not facing a conveyor
Allows using them as an ad-hoc hopper with a small buffer. Previously their buffer was effectively rudimentary -- it was used for output, but nothing ever inputted into it.
This commit is contained in:
parent
fa075a3bd4
commit
db109d8bcf
@ -10,6 +10,8 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IControlReceiverFilter;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -95,9 +97,11 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
|
||||
|
||||
boolean hasSent = false;
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
IConveyorBelt belt = null;
|
||||
|
||||
IConveyorBelt belt = (IConveyorBelt) b;
|
||||
if(b instanceof IConveyorBelt) {
|
||||
belt = (IConveyorBelt) b;
|
||||
}
|
||||
|
||||
/* try to send items from a connected inv, if present */
|
||||
if(te instanceof IInventory) {
|
||||
@ -116,10 +120,16 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
|
||||
if((isWhitelist && match) || (!isWhitelist && !match)) {
|
||||
stack = stack.copy();
|
||||
int toSend = Math.min(amount, stack.stackSize);
|
||||
|
||||
if (belt != null) {
|
||||
inv.decrStackSize(index, toSend);
|
||||
stack.stackSize = toSend;
|
||||
|
||||
sendItem(stack, belt, outputSide);
|
||||
} else {
|
||||
stack.stackSize = toSend;
|
||||
ItemStack remaining = InventoryUtil.tryAddItemToInventory(this.slots, stack);
|
||||
inv.decrStackSize(index, toSend - (remaining == null ? 0 : remaining.stackSize));
|
||||
}
|
||||
hasSent = true;
|
||||
break;
|
||||
}
|
||||
@ -128,7 +138,7 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
|
||||
}
|
||||
|
||||
/* if no item has been sent, send buffered items while ignoring the filter */
|
||||
if(!hasSent) {
|
||||
if(!hasSent && belt != null) {
|
||||
|
||||
for(int i = 9; i < 18; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
@ -136,16 +146,16 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
|
||||
if(stack != null){
|
||||
stack = stack.copy();
|
||||
int toSend = Math.min(amount, stack.stackSize);
|
||||
|
||||
decrStackSize(i, toSend);
|
||||
stack.stackSize = toSend;
|
||||
|
||||
sendItem(stack, belt, outputSide);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user