mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2245 from abel1502/abel-buffer-extractor
Make conveyor extractors take items to inventory when not facing a conveyor
This commit is contained in:
commit
4875aefba4
@ -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;
|
||||
@ -94,54 +96,62 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
|
||||
}
|
||||
|
||||
boolean hasSent = false;
|
||||
|
||||
IConveyorBelt belt = null;
|
||||
|
||||
if(b instanceof IConveyorBelt) {
|
||||
belt = (IConveyorBelt) b;
|
||||
}
|
||||
|
||||
IConveyorBelt belt = (IConveyorBelt) b;
|
||||
/* try to send items from a connected inv, if present */
|
||||
if(te instanceof IInventory) {
|
||||
|
||||
/* try to send items from a connected inv, if present */
|
||||
if(te instanceof IInventory) {
|
||||
IInventory inv = (IInventory) te;
|
||||
int size = access == null ? inv.getSizeInventory() : access.length;
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
int index = access == null ? i : access[i];
|
||||
ItemStack stack = inv.getStackInSlot(index);
|
||||
|
||||
IInventory inv = (IInventory) te;
|
||||
int size = access == null ? inv.getSizeInventory() : access.length;
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
int index = access == null ? i : access[i];
|
||||
ItemStack stack = inv.getStackInSlot(index);
|
||||
if(stack != null && (sided == null || sided.canExtractItem(index, stack, inputSide.getOpposite().ordinal()))){
|
||||
|
||||
if(stack != null && (sided == null || sided.canExtractItem(index, stack, inputSide.getOpposite().ordinal()))){
|
||||
boolean match = this.matchesFilter(stack);
|
||||
|
||||
if((isWhitelist && match) || (!isWhitelist && !match)) {
|
||||
stack = stack.copy();
|
||||
int toSend = Math.min(amount, stack.stackSize);
|
||||
|
||||
boolean match = this.matchesFilter(stack);
|
||||
|
||||
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);
|
||||
hasSent = true;
|
||||
break;
|
||||
} else {
|
||||
stack.stackSize = toSend;
|
||||
ItemStack remaining = InventoryUtil.tryAddItemToInventory(this.slots, 9, 17, stack);
|
||||
inv.decrStackSize(index, toSend - (remaining == null ? 0 : remaining.stackSize));
|
||||
}
|
||||
hasSent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if no item has been sent, send buffered items while ignoring the filter */
|
||||
if(!hasSent && belt != null) {
|
||||
|
||||
/* if no item has been sent, send buffered items while ignoring the filter */
|
||||
if(!hasSent) {
|
||||
for(int i = 9; i < 18; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
|
||||
for(int i = 9; i < 18; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
|
||||
if(stack != null){
|
||||
stack = stack.copy();
|
||||
int toSend = Math.min(amount, stack.stackSize);
|
||||
decrStackSize(i, toSend);
|
||||
stack.stackSize = toSend;
|
||||
|
||||
sendItem(stack, belt, outputSide);
|
||||
break;
|
||||
}
|
||||
if(stack != null){
|
||||
stack = stack.copy();
|
||||
int toSend = Math.min(amount, stack.stackSize);
|
||||
|
||||
decrStackSize(i, toSend);
|
||||
stack.stackSize = toSend;
|
||||
sendItem(stack, belt, outputSide);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user