mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Allow stopping conveyor inserters with redstone
A stopped inserted will still take items to its own inventory, but won't insert them into the inventory it is facing. Useful for taking out stuff from overflowing outputs, if you want to maintain a particular slot distribution.
This commit is contained in:
parent
fa075a3bd4
commit
9a7124c8ff
@ -68,17 +68,19 @@ public class CraneInserter extends BlockCraneBase implements IEnterableBlock {
|
|||||||
|
|
||||||
ItemStack toAdd = entity.getItemStack().copy();
|
ItemStack toAdd = entity.getItemStack().copy();
|
||||||
|
|
||||||
int[] access = null;
|
if (!world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||||
|
int[] access = null;
|
||||||
|
|
||||||
if(te instanceof ISidedInventory) {
|
if(te instanceof ISidedInventory) {
|
||||||
ISidedInventory sided = (ISidedInventory) te;
|
ISidedInventory sided = (ISidedInventory) te;
|
||||||
access = InventoryUtil.masquerade(sided, outputDirection.getOpposite().ordinal());
|
access = InventoryUtil.masquerade(sided, outputDirection.getOpposite().ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(te instanceof IInventory) {
|
if(te instanceof IInventory) {
|
||||||
IInventory inv = (IInventory) te;
|
IInventory inv = (IInventory) te;
|
||||||
|
|
||||||
addToInventory(inv, access, toAdd, outputDirection.getOpposite().ordinal());
|
addToInventory(inv, access, toAdd, outputDirection.getOpposite().ordinal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityCraneInserter inserter = null;
|
TileEntityCraneInserter inserter = null;
|
||||||
|
|||||||
@ -40,48 +40,49 @@ public class TileEntityCraneInserter extends TileEntityCraneBase implements IGUI
|
|||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
ForgeDirection outputSide = getOutputSide();
|
if (!this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {ForgeDirection outputSide = getOutputSide();
|
||||||
TileEntity te = worldObj.getTileEntity(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
TileEntity te = worldObj.getTileEntity(xCoord + outputSide.offsetX, yCoord + outputSide.offsetY, zCoord + outputSide.offsetZ);
|
||||||
|
|
||||||
int[] access = null;
|
int[] access = null;
|
||||||
|
|
||||||
if(te instanceof ISidedInventory) {
|
if(te instanceof ISidedInventory) {
|
||||||
ISidedInventory sided = (ISidedInventory) te;
|
ISidedInventory sided = (ISidedInventory) te;
|
||||||
//access = sided.getAccessibleSlotsFromSide(dir.ordinal());
|
//access = sided.getAccessibleSlotsFromSide(dir.ordinal());
|
||||||
access = InventoryUtil.masquerade(sided, outputSide.getOpposite().ordinal());
|
access = InventoryUtil.masquerade(sided, outputSide.getOpposite().ordinal());
|
||||||
}
|
|
||||||
|
|
||||||
if(te instanceof IInventory) {
|
|
||||||
for(int i = 0; i < slots.length; i++) {
|
|
||||||
|
|
||||||
ItemStack stack = slots[i];
|
|
||||||
|
|
||||||
if(stack != null) {
|
|
||||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
|
||||||
|
|
||||||
if(ret == null || ret.stackSize != stack.stackSize) {
|
|
||||||
slots[i] = ret;
|
|
||||||
this.markDirty();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the previous operation fails, repeat but use single items instead of the whole stack instead
|
if(te instanceof IInventory) {
|
||||||
//this should fix cases where the inserter can't insert into something that has a stack size limitation
|
for(int i = 0; i < slots.length; i++) {
|
||||||
for(int i = 0; i < slots.length; i++) {
|
|
||||||
|
|
||||||
ItemStack stack = slots[i];
|
|
||||||
|
|
||||||
if(stack != null) {
|
|
||||||
stack = stack.copy();
|
|
||||||
stack.stackSize = 1;
|
|
||||||
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
|
||||||
|
|
||||||
if(ret == null || ret.stackSize != stack.stackSize) {
|
ItemStack stack = slots[i];
|
||||||
this.decrStackSize(i, 1);
|
|
||||||
this.markDirty();
|
if(stack != null) {
|
||||||
return;
|
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
||||||
|
|
||||||
|
if(ret == null || ret.stackSize != stack.stackSize) {
|
||||||
|
slots[i] = ret;
|
||||||
|
this.markDirty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if the previous operation fails, repeat but use single items instead of the whole stack instead
|
||||||
|
//this should fix cases where the inserter can't insert into something that has a stack size limitation
|
||||||
|
for(int i = 0; i < slots.length; i++) {
|
||||||
|
|
||||||
|
ItemStack stack = slots[i];
|
||||||
|
|
||||||
|
if(stack != null) {
|
||||||
|
stack = stack.copy();
|
||||||
|
stack.stackSize = 1;
|
||||||
|
ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, stack.copy(), outputSide.getOpposite().ordinal());
|
||||||
|
|
||||||
|
if(ret == null || ret.stackSize != stack.stackSize) {
|
||||||
|
this.decrStackSize(i, 1);
|
||||||
|
this.markDirty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user