Minor changes, nothing noticeable
This commit is contained in:
parent
a80b18b412
commit
b1f2a61e20
4 changed files with 67 additions and 26 deletions
|
@ -13,7 +13,7 @@ import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.PacketHandler.Transmission;
|
import mekanism.common.PacketHandler.Transmission;
|
||||||
import mekanism.common.block.BlockMachine.MachineType;
|
import mekanism.common.block.BlockMachine.MachineType;
|
||||||
import mekanism.common.network.PacketTileEntity;
|
import mekanism.common.network.PacketTileEntity;
|
||||||
import mekanism.common.transporter.SlotInfo;
|
import mekanism.common.transporter.InvStack;
|
||||||
import mekanism.common.transporter.TransporterFilter;
|
import mekanism.common.transporter.TransporterFilter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.TransporterUtils;
|
import mekanism.common.util.TransporterUtils;
|
||||||
|
@ -78,16 +78,16 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
IInventory inventory = (IInventory)back;
|
IInventory inventory = (IInventory)back;
|
||||||
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)front;
|
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)front;
|
||||||
|
|
||||||
SlotInfo inInventory = TransporterUtils.takeItem(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal());
|
InvStack inInventory = TransporterUtils.takeItem(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal());
|
||||||
|
|
||||||
if(inInventory != null && inInventory.itemStack != null)
|
if(inInventory != null && inInventory.getStack() != null)
|
||||||
{
|
{
|
||||||
boolean hasFilter = false;
|
boolean hasFilter = false;
|
||||||
EnumColor filterColor = color;
|
EnumColor filterColor = color;
|
||||||
|
|
||||||
for(TransporterFilter filter : filters)
|
for(TransporterFilter filter : filters)
|
||||||
{
|
{
|
||||||
if(filter.canFilter(inInventory.itemStack))
|
if(filter.canFilter(inInventory.getStack()))
|
||||||
{
|
{
|
||||||
filterColor = filter.color;
|
filterColor = filter.color;
|
||||||
hasFilter = true;
|
hasFilter = true;
|
||||||
|
@ -95,13 +95,13 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((hasFilter || autoEject) && TransporterUtils.insert(this, transporter, inInventory.itemStack, filterColor))
|
if((hasFilter || autoEject) && TransporterUtils.insert(this, transporter, inInventory.getStack(), filterColor))
|
||||||
{
|
{
|
||||||
inventory.setInventorySlotContents(inInventory.slotID, null);
|
inInventory.use();
|
||||||
setActive(true);
|
setActive(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inventory.setInventorySlotContents(inInventory.slotID, inInventory.itemStack);
|
inInventory.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
common/mekanism/common/transporter/InvStack.java
Normal file
54
common/mekanism/common/transporter/InvStack.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package mekanism.common.transporter;
|
||||||
|
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public final class InvStack
|
||||||
|
{
|
||||||
|
public IInventory inventory;
|
||||||
|
public ItemStack[] itemStacks;
|
||||||
|
public int[] slotIDs;
|
||||||
|
|
||||||
|
public InvStack(IInventory inv, ItemStack[] stacks, int[] ids)
|
||||||
|
{
|
||||||
|
inventory = inv;
|
||||||
|
itemStacks = stacks;
|
||||||
|
slotIDs = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStack()
|
||||||
|
{
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
for(ItemStack stack : itemStacks)
|
||||||
|
{
|
||||||
|
size += stack.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemStacks[0] != null)
|
||||||
|
{
|
||||||
|
ItemStack ret = itemStacks[0].copy();
|
||||||
|
ret.stackSize = size;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void use()
|
||||||
|
{
|
||||||
|
for(int id : slotIDs)
|
||||||
|
{
|
||||||
|
inventory.setInventorySlotContents(id, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < slotIDs.length; i++)
|
||||||
|
{
|
||||||
|
inventory.setInventorySlotContents(slotIDs[i], itemStacks[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
package mekanism.common.transporter;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public final class SlotInfo
|
|
||||||
{
|
|
||||||
public ItemStack itemStack;
|
|
||||||
public int slotID;
|
|
||||||
|
|
||||||
public SlotInfo(ItemStack stack, int i)
|
|
||||||
{
|
|
||||||
itemStack = stack;
|
|
||||||
slotID = i;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import mekanism.api.IConfigurable;
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.api.transmitters.ITransmitter;
|
import mekanism.api.transmitters.ITransmitter;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import mekanism.common.transporter.SlotInfo;
|
import mekanism.common.transporter.InvStack;
|
||||||
import mekanism.common.transporter.TransporterStack;
|
import mekanism.common.transporter.TransporterStack;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
@ -385,10 +385,12 @@ public final class TransporterUtils
|
||||||
return toInsert;
|
return toInsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SlotInfo takeItem(IInventory inventory, int side)
|
public static InvStack takeItem(IInventory inventory, int side)
|
||||||
{
|
{
|
||||||
if(!(inventory instanceof ISidedInventory))
|
if(!(inventory instanceof ISidedInventory))
|
||||||
{
|
{
|
||||||
|
inventory = checkChestInv(inventory);
|
||||||
|
|
||||||
for(int i = inventory.getSizeInventory() - 1; i >= 0; i--)
|
for(int i = inventory.getSizeInventory() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if(inventory.getStackInSlot(i) != null)
|
if(inventory.getStackInSlot(i) != null)
|
||||||
|
@ -396,7 +398,7 @@ public final class TransporterUtils
|
||||||
ItemStack toSend = inventory.getStackInSlot(i).copy();
|
ItemStack toSend = inventory.getStackInSlot(i).copy();
|
||||||
inventory.setInventorySlotContents(i, null);
|
inventory.setInventorySlotContents(i, null);
|
||||||
|
|
||||||
return new SlotInfo(toSend, i);
|
return new InvStack(inventory, new ItemStack[] {toSend}, new int[] {i});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,7 +420,7 @@ public final class TransporterUtils
|
||||||
{
|
{
|
||||||
sidedInventory.setInventorySlotContents(slotID, null);
|
sidedInventory.setInventorySlotContents(slotID, null);
|
||||||
|
|
||||||
return new SlotInfo(toSend, slotID);
|
return new InvStack(inventory, new ItemStack[] {toSend}, new int[] {slotID});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue