mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Transition from null stacks to ItemStack.EMPTY
This commit is contained in:
1 parent
fa7b9b49bc
commit
01ab160ff9
100 files changed
+596
-616
No files matched your search
@@ -87,7 +87,7 @@ public final class GasTransmission
|
||||
*/
|
||||
public static GasStack removeGas(ItemStack itemStack, Gas type, int amount)
|
||||
{
|
||||
if(itemStack != null && itemStack.getItem() instanceof IGasItem)
|
||||
if(!itemStack.isEmpty() && itemStack.getItem() instanceof IGasItem)
|
||||
{
|
||||
IGasItem item = (IGasItem)itemStack.getItem();
|
||||
|
||||
@@ -110,7 +110,7 @@ public final class GasTransmission
|
||||
*/
|
||||
public static int addGas(ItemStack itemStack, GasStack stack)
|
||||
{
|
||||
if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas()))
|
||||
if(!itemStack.isEmpty() && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas()))
|
||||
{
|
||||
return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.api.reactor;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public interface IFusionReactor extends IHeatTransfer
|
||||
@@ -61,5 +62,5 @@ public interface IFusionReactor extends IHeatTransfer
|
||||
|
||||
public void updateTemperatures();
|
||||
|
||||
public ItemStack[] getInventory();
|
||||
public NonNullList<ItemStack> getInventory();
|
||||
}
|
||||
@@ -5,13 +5,14 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public final class StackUtils
|
||||
{
|
||||
public static List<ItemStack> split(ItemStack stack)
|
||||
{
|
||||
if(stack == null || stack.getCount() == 0)
|
||||
if(stack.isEmpty() || stack.getCount() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ public final class StackUtils
|
||||
|
||||
public static Item getItem(ItemStack stack)
|
||||
{
|
||||
if(stack == null)
|
||||
if(stack.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public final class StackUtils
|
||||
|
||||
public static boolean diffIgnoreNull(ItemStack stack1, ItemStack stack2)
|
||||
{
|
||||
if(stack1 == null || stack2 == null)
|
||||
if(stack1.isEmpty() || stack2.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public final class StackUtils
|
||||
|
||||
public static boolean equalsWildcard(ItemStack wild, ItemStack check)
|
||||
{
|
||||
if(wild == null || check == null)
|
||||
if(wild.isEmpty() || check.isEmpty())
|
||||
{
|
||||
return check == wild;
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public final class StackUtils
|
||||
{
|
||||
boolean wildcard = equalsWildcard(wild, check);
|
||||
|
||||
if(wild == null || check == null)
|
||||
if(wild.isEmpty() || check.isEmpty())
|
||||
{
|
||||
return wildcard;
|
||||
}
|
||||
@@ -127,7 +128,7 @@ public final class StackUtils
|
||||
{
|
||||
if(stack1 == null)
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else if(stack2 == null)
|
||||
{
|
||||
@@ -139,9 +140,9 @@ public final class StackUtils
|
||||
|
||||
public static ItemStack size(ItemStack stack, int size)
|
||||
{
|
||||
if(size <= 0 || stack == null)
|
||||
if(size <= 0 || stack.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack ret = stack.copy();
|
||||
@@ -152,9 +153,9 @@ public final class StackUtils
|
||||
|
||||
public static ItemStack copy(ItemStack stack)
|
||||
{
|
||||
if(stack == null)
|
||||
if(stack.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return stack.copy();
|
||||
@@ -162,18 +163,18 @@ public final class StackUtils
|
||||
|
||||
public static int getSize(ItemStack stack)
|
||||
{
|
||||
return stack != null ? stack.getCount() : 0;
|
||||
return !stack.isEmpty() ? stack.getCount() : 0;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getMergeRejects(ItemStack[] orig, ItemStack[] toAdd)
|
||||
public static List<ItemStack> getMergeRejects(NonNullList<ItemStack> orig, NonNullList<ItemStack> toAdd)
|
||||
{
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for(int i = 0; i < toAdd.length; i++)
|
||||
for(int i = 0; i < toAdd.size(); i++)
|
||||
{
|
||||
if(toAdd[i] != null)
|
||||
if(!toAdd.get(i).isEmpty())
|
||||
{
|
||||
ItemStack reject = getMergeReject(orig[i], toAdd[i]);
|
||||
ItemStack reject = getMergeReject(orig.get(i), toAdd.get(i));
|
||||
|
||||
if(reject != null)
|
||||
{
|
||||
@@ -185,25 +186,25 @@ public final class StackUtils
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void merge(ItemStack[] orig, ItemStack[] toAdd)
|
||||
public static void merge(NonNullList<ItemStack> orig, NonNullList<ItemStack> toAdd)
|
||||
{
|
||||
for(int i = 0; i < toAdd.length; i++)
|
||||
for(int i = 0; i < toAdd.size(); i++)
|
||||
{
|
||||
if(toAdd[i] != null)
|
||||
if(!toAdd.get(i).isEmpty())
|
||||
{
|
||||
orig[i] = merge(orig[i], toAdd[i]);
|
||||
orig.set(i, merge(orig.get(i), toAdd.get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack merge(ItemStack orig, ItemStack toAdd)
|
||||
{
|
||||
if(orig == null)
|
||||
if(orig.isEmpty())
|
||||
{
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
if(toAdd == null)
|
||||
if(toAdd.isEmpty())
|
||||
{
|
||||
return orig;
|
||||
}
|
||||
@@ -218,12 +219,12 @@ public final class StackUtils
|
||||
|
||||
public static ItemStack getMergeReject(ItemStack orig, ItemStack toAdd)
|
||||
{
|
||||
if(orig == null)
|
||||
if(orig.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if(toAdd == null)
|
||||
if(toAdd.isEmpty())
|
||||
{
|
||||
return orig;
|
||||
}
|
||||
@@ -246,7 +247,7 @@ public final class StackUtils
|
||||
|
||||
public static int hashItemStack(ItemStack stack)
|
||||
{
|
||||
if(stack == null || stack.getItem() == null)
|
||||
if(stack.isEmpty() || stack.getItem() == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
ItemStack stack = tileEntity.formula.input[i];
|
||||
ItemStack stack = tileEntity.formula.input.get(i);
|
||||
|
||||
if(stack != null)
|
||||
{
|
||||
@@ -222,8 +222,8 @@ public class GuiFormulaicAssemblicator extends GuiMekanism
|
||||
|
||||
private boolean canEncode()
|
||||
{
|
||||
return tileEntity.formula == null && tileEntity.inventory[2] != null && tileEntity.inventory[2].getItem() instanceof ItemCraftingFormula &&
|
||||
((ItemCraftingFormula)tileEntity.inventory[2].getItem()).getInventory(tileEntity.inventory[2]) == null;
|
||||
return tileEntity.formula == null && !tileEntity.inventory.get(2).isEmpty() && tileEntity.inventory.get(2).getItem() instanceof ItemCraftingFormula &&
|
||||
((ItemCraftingFormula)tileEntity.inventory.get(2).getItem()).getInventory(tileEntity.inventory.get(2)) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -549,7 +549,7 @@ public class Mekanism
|
||||
));
|
||||
MachineType.RESISTIVE_HEATER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 4), new Object[] {
|
||||
"CRC", "RHR", "CEC", Character.valueOf('C'), "ingotTin", Character.valueOf('R'), "dustRedstone", Character.valueOf('H'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem()
|
||||
}));;
|
||||
}));
|
||||
MachineType.QUANTUM_ENTANGLOPORTER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 0), new Object[] {
|
||||
"OCO", "ATA", "OCO", Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), MekanismItems.TeleportationCore
|
||||
}));
|
||||
|
||||
@@ -921,7 +921,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
energizedItem.setEnergy(itemStack, ((IStrictEnergyStorage)tileEntity).getEnergy());
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).inventory.length > 0)
|
||||
if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).inventory.size() > 0)
|
||||
{
|
||||
ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
|
||||
inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack);
|
||||
|
||||
@@ -6,26 +6,27 @@ import mekanism.common.util.RecipeUtils;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RecipeFormula
|
||||
{
|
||||
private InventoryCrafting dummy = MekanismUtils.getDummyCraftingInv();
|
||||
|
||||
public ItemStack[] input = new ItemStack[9];
|
||||
public NonNullList<ItemStack> input = NonNullList.withSize(9, ItemStack.EMPTY);
|
||||
|
||||
public IRecipe recipe = null;
|
||||
|
||||
public RecipeFormula(World world, ItemStack[] inv)
|
||||
public RecipeFormula(World world, NonNullList<ItemStack> inv)
|
||||
{
|
||||
this(world, inv, 0);
|
||||
}
|
||||
|
||||
public RecipeFormula(World world, ItemStack[] inv, int start)
|
||||
public RecipeFormula(World world, NonNullList<ItemStack> inv, int start)
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
input[i] = StackUtils.size(inv[start+i], 1);
|
||||
input.set(i, StackUtils.size(inv.get(start+i), 1));
|
||||
}
|
||||
|
||||
resetToRecipe();
|
||||
@@ -37,15 +38,15 @@ public class RecipeFormula
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
dummy.setInventorySlotContents(i, input[i]);
|
||||
dummy.setInventorySlotContents(i, input.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches(World world, ItemStack[] newInput, int start)
|
||||
public boolean matches(World world, NonNullList<ItemStack> newInput, int start)
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
dummy.setInventorySlotContents(i, newInput[start+i]);
|
||||
dummy.setInventorySlotContents(i, newInput.get(start+i));
|
||||
}
|
||||
|
||||
return recipe.matches(dummy, world);
|
||||
@@ -70,7 +71,7 @@ public class RecipeFormula
|
||||
return true;
|
||||
}
|
||||
|
||||
dummy.setInventorySlotContents(i, input[i]);
|
||||
dummy.setInventorySlotContents(i, input.get(i));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -13,6 +13,7 @@ import mekanism.common.content.tank.SynchronizedTankData.ValveData;
|
||||
import mekanism.common.multiblock.SynchronizedData;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerData> implements IHeatTransfer
|
||||
@@ -47,7 +48,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
|
||||
|
||||
public int steamVolume;
|
||||
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
public Coord4D upperRenderLocation;
|
||||
|
||||
@@ -99,7 +100,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public class MatrixCache extends MultiblockCache<SynchronizedMatrixData>
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
@Override
|
||||
public void apply(SynchronizedMatrixData data)
|
||||
@@ -27,7 +28,7 @@ public class MatrixCache extends MultiblockCache<SynchronizedMatrixData>
|
||||
public void load(NBTTagCompound nbtTags)
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ public class MatrixCache extends MultiblockCache<SynchronizedMatrixData>
|
||||
|
||||
if(slotID >= 0 && slotID < 2)
|
||||
{
|
||||
inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound);
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,11 +49,11 @@ public class MatrixCache extends MultiblockCache<SynchronizedMatrixData>
|
||||
|
||||
for(int slotCount = 0; slotCount < 2; slotCount++)
|
||||
{
|
||||
if(inventory[slotCount] != null)
|
||||
if(!inventory.get(slotCount).isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inventory[slotCount].writeToNBT(tagCompound);
|
||||
inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.tile.TileEntityInductionCell;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SynchronizedMatrixData extends SynchronizedData<SynchronizedMatrixData>
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
public Set<Coord4D> cells = new HashSet<Coord4D>();
|
||||
|
||||
@@ -29,7 +30,7 @@ public class SynchronizedMatrixData extends SynchronizedData<SynchronizedMatrixD
|
||||
public double transferCap;
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MItemStackFilter extends MinerFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null)
|
||||
if(itemStack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MMaterialFilter extends MinerFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock))
|
||||
if(itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MModIDFilter extends MinerFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock))
|
||||
if(itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MOreDictFilter extends MinerFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock))
|
||||
if(itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class MinerFilter
|
||||
{
|
||||
nbtTags.setBoolean("requireStack", requireStack);
|
||||
|
||||
if(replaceStack != null)
|
||||
if(!replaceStack.isEmpty())
|
||||
{
|
||||
nbtTags.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public abstract class MinerFilter
|
||||
{
|
||||
data.add(requireStack);
|
||||
|
||||
if(replaceStack != null)
|
||||
if(!replaceStack.isEmpty())
|
||||
{
|
||||
data.add(true);
|
||||
data.add(MekanismUtils.getID(replaceStack));
|
||||
@@ -64,7 +64,7 @@ public abstract class MinerFilter
|
||||
replaceStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt());
|
||||
}
|
||||
else {
|
||||
replaceStack = null;
|
||||
replaceStack = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SynchronizedTankData extends SynchronizedData<SynchronizedTankData>
|
||||
@@ -20,7 +21,7 @@ public class SynchronizedTankData extends SynchronizedData<SynchronizedTankData>
|
||||
|
||||
public ContainerEditMode editMode = ContainerEditMode.BOTH;
|
||||
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
public Set<ValveData> valves = new HashSet<ValveData>();
|
||||
|
||||
@@ -47,7 +48,7 @@ public class SynchronizedTankData extends SynchronizedData<SynchronizedTankData>
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class TankCache extends MultiblockCache<SynchronizedTankData>
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
public FluidStack fluid;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class TankCache extends MultiblockCache<SynchronizedTankData>
|
||||
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
|
||||
|
||||
NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
@@ -48,7 +49,7 @@ public class TankCache extends MultiblockCache<SynchronizedTankData>
|
||||
|
||||
if(slotID >= 0 && slotID < 2)
|
||||
{
|
||||
inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound);
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,11 +68,11 @@ public class TankCache extends MultiblockCache<SynchronizedTankData>
|
||||
|
||||
for(int slotCount = 0; slotCount < 2; slotCount++)
|
||||
{
|
||||
if(inventory[slotCount] != null)
|
||||
if(!inventory.get(slotCount).isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inventory[slotCount].writeToNBT(tagCompound);
|
||||
inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class Finder
|
||||
@Override
|
||||
public boolean modifies(ItemStack stack)
|
||||
{
|
||||
if(stack == null || !(stack.getItem() instanceof ItemBlock))
|
||||
if(stack.isEmpty() || !(stack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public abstract class Finder
|
||||
@Override
|
||||
public boolean modifies(ItemStack stack)
|
||||
{
|
||||
if(stack == null || !(stack.getItem() instanceof ItemBlock))
|
||||
if(stack.isEmpty() || !(stack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class InvStack
|
||||
return ret;
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void appendStack(int id, ItemStack stack)
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StackSearcher
|
||||
{
|
||||
for(i = i - 1; i >= 0; i--)
|
||||
{
|
||||
if(theInventory.getStackInSlot(i) != null && id.modifies(theInventory.getStackInSlot(i)))
|
||||
if(!theInventory.getStackInSlot(i).isEmpty() && id.modifies(theInventory.getStackInSlot(i)))
|
||||
{
|
||||
ItemStack toSend = theInventory.getStackInSlot(i).copy();
|
||||
return new InvStack(theInventory, i, toSend);
|
||||
@@ -53,7 +53,7 @@ public class StackSearcher
|
||||
{
|
||||
int slotID = slots[i];
|
||||
|
||||
if(theInventory.getStackInSlot(slotID) != null && id.modifies(theInventory.getStackInSlot(slotID)))
|
||||
if(!theInventory.getStackInSlot(slotID).isEmpty() && id.modifies(theInventory.getStackInSlot(slotID)))
|
||||
{
|
||||
ItemStack toSend = theInventory.getStackInSlot(slotID);
|
||||
|
||||
@@ -77,10 +77,10 @@ public class StackSearcher
|
||||
{
|
||||
for(i = i - 1; i >= 0; i--)
|
||||
{
|
||||
if(theInventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(i), type))
|
||||
if(!theInventory.getStackInSlot(i).isEmpty() && StackUtils.equalsWildcard(theInventory.getStackInSlot(i), type))
|
||||
{
|
||||
ItemStack stack = theInventory.getStackInSlot(i);
|
||||
int current = ret.getStack() != null ? ret.getStack().getCount() : 0;
|
||||
int current = !ret.getStack().isEmpty() ? ret.getStack().getCount() : 0;
|
||||
|
||||
if(current+stack.getCount() <= max)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ public class StackSearcher
|
||||
ret.appendStack(i, copy);
|
||||
}
|
||||
|
||||
if(ret.getStack() != null && ret.getStack().getCount() == max)
|
||||
if(!ret.getStack().isEmpty() && ret.getStack().getCount() == max)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
@@ -109,10 +109,10 @@ public class StackSearcher
|
||||
{
|
||||
int slotID = slots[i];
|
||||
|
||||
if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(slotID), type))
|
||||
if(!sidedInventory.getStackInSlot(slotID).isEmpty() && StackUtils.equalsWildcard(theInventory.getStackInSlot(slotID), type))
|
||||
{
|
||||
ItemStack stack = sidedInventory.getStackInSlot(slotID);
|
||||
int current = ret.getStack() != null ? ret.getStack().getCount() : 0;
|
||||
int current = !ret.getStack().isEmpty() ? ret.getStack().getCount() : 0;
|
||||
|
||||
if(current+stack.getCount() <= max)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ public class StackSearcher
|
||||
}
|
||||
}
|
||||
|
||||
if(ret.getStack() != null && ret.getStack().getCount() == max)
|
||||
if(!ret.getStack().isEmpty() && ret.getStack().getCount() == max)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class StackSearcher
|
||||
}
|
||||
}
|
||||
|
||||
if(ret != null && ret.getStack() != null && ret.getStack().getCount() >= min)
|
||||
if(ret != null && !ret.getStack().isEmpty() && ret.getStack().getCount() >= min)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class TItemStackFilter extends TransporterFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null)
|
||||
if(itemStack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class TMaterialFilter extends TransporterFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock))
|
||||
if(itemStack.isEmpty() || !(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TModIDFilter extends TransporterFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null)
|
||||
if(itemStack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TOreDictFilter extends TransporterFilter
|
||||
@Override
|
||||
public boolean canFilter(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack == null)
|
||||
if(itemStack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
|
||||
@@ -79,13 +80,13 @@ public class TransporterManager
|
||||
{
|
||||
inv = InventoryUtils.checkChestInv(inv);
|
||||
|
||||
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
|
||||
NonNullList<ItemStack>ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
if(!(inv instanceof ISidedInventory))
|
||||
{
|
||||
for(int i = 0; i <= inv.getSizeInventory() - 1; i++)
|
||||
{
|
||||
ret[i] = inv.getStackInSlot(i) != null ? inv.getStackInSlot(i).copy() : null;
|
||||
ret.set(i, !inv.getStackInSlot(i).isEmpty() ? inv.getStackInSlot(i).copy() : ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -101,7 +102,7 @@ public class TransporterManager
|
||||
{
|
||||
int slotID = slots[get];
|
||||
|
||||
ret[slotID] = sidedInventory.getStackInSlot(slotID) != null ? sidedInventory.getStackInSlot(slotID).copy() : null;
|
||||
ret.set(slotID, !sidedInventory.getStackInSlot(slotID).isEmpty() ? sidedInventory.getStackInSlot(slotID).copy() : ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
if(inv instanceof TileEntityBin)
|
||||
@@ -149,13 +150,13 @@ public class TransporterManager
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack inSlot = copy.inventory[i];
|
||||
ItemStack inSlot = copy.inventory.get(i);
|
||||
|
||||
if(inSlot == null || inSlot.isEmpty())
|
||||
if(inSlot.isEmpty())
|
||||
{
|
||||
if(toInsert.getCount() <= inv.getInventoryStackLimit())
|
||||
{
|
||||
copy.inventory[i] = toInsert;
|
||||
copy.inventory.set(i, toInsert);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -167,7 +168,7 @@ public class TransporterManager
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.setCount(rejects);
|
||||
|
||||
copy.inventory[i] = toSet;
|
||||
copy.inventory.set(i, toSet);
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
@@ -181,7 +182,7 @@ public class TransporterManager
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.grow(inSlot.getCount());
|
||||
|
||||
copy.inventory[i] = toSet;
|
||||
copy.inventory.set(i, toSet);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -193,7 +194,7 @@ public class TransporterManager
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.setCount(rejects);
|
||||
|
||||
copy.inventory[i] = toSet;
|
||||
copy.inventory.set(i, toSet);
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
@@ -238,13 +239,13 @@ public class TransporterManager
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack inSlot = copy.inventory[slotID];
|
||||
ItemStack inSlot = copy.inventory.get(slotID);
|
||||
|
||||
if(inSlot == null || inSlot.isEmpty())
|
||||
if(inSlot.isEmpty())
|
||||
{
|
||||
if(toInsert.getCount() <= inv.getInventoryStackLimit())
|
||||
{
|
||||
copy.inventory[slotID] = toInsert;
|
||||
copy.inventory.set(slotID, toInsert);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -256,7 +257,7 @@ public class TransporterManager
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.setCount(rejects);
|
||||
|
||||
copy.inventory[slotID] = toSet;
|
||||
copy.inventory.set(slotID, toSet);
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
@@ -270,7 +271,7 @@ public class TransporterManager
|
||||
ItemStack toSet = toInsert.copy();
|
||||
toSet.grow(inSlot.getCount());
|
||||
|
||||
copy.inventory[slotID] = toSet;
|
||||
copy.inventory.set(slotID, toSet);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -282,7 +283,7 @@ public class TransporterManager
|
||||
ItemStack remains = toInsert.copy();
|
||||
remains.setCount(rejects);
|
||||
|
||||
copy.inventory[slotID] = toSet;
|
||||
copy.inventory.set(slotID, toSet);
|
||||
|
||||
toInsert = remains;
|
||||
}
|
||||
@@ -295,12 +296,12 @@ public class TransporterManager
|
||||
|
||||
public static boolean didEmit(ItemStack stack, ItemStack returned)
|
||||
{
|
||||
return returned == null || returned.isEmpty() || returned.getCount() < stack.getCount();
|
||||
return returned.isEmpty() || returned.getCount() < stack.getCount();
|
||||
}
|
||||
|
||||
public static ItemStack getToUse(ItemStack stack, ItemStack returned)
|
||||
{
|
||||
if(returned == null || returned.isEmpty() || returned.getCount() == 0)
|
||||
if(returned.isEmpty() || returned.getCount() == 0)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
@@ -358,17 +359,17 @@ public class TransporterManager
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack inSlot = copy.inventory[i];
|
||||
ItemStack inSlot = copy.inventory.get(i);
|
||||
|
||||
if(toInsert == null || toInsert.isEmpty())
|
||||
if(toInsert.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else if(inSlot == null || inSlot.isEmpty())
|
||||
else if(inSlot.isEmpty())
|
||||
{
|
||||
if(toInsert.getCount() <= inventory.getInventoryStackLimit())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else {
|
||||
int rejects = toInsert.getCount() - inventory.getInventoryStackLimit();
|
||||
@@ -385,7 +386,7 @@ public class TransporterManager
|
||||
|
||||
if(inSlot.getCount() + toInsert.getCount() <= max)
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.getCount() + toInsert.getCount()) - max;
|
||||
@@ -417,7 +418,7 @@ public class TransporterManager
|
||||
|
||||
if(toInsert.getCount() <= amountRemaining)
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else {
|
||||
return StackUtils.size(toInsert, toInsert.getCount()-amountRemaining);
|
||||
@@ -433,17 +434,17 @@ public class TransporterManager
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack inSlot = copy.inventory[slotID];
|
||||
ItemStack inSlot = copy.inventory.get(slotID);
|
||||
|
||||
if(toInsert == null || toInsert.isEmpty())
|
||||
if(toInsert.isEmpty())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else if(inSlot == null || inSlot.isEmpty())
|
||||
else if(inSlot.isEmpty())
|
||||
{
|
||||
if(toInsert.getCount() <= inventory.getInventoryStackLimit())
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else {
|
||||
int rejects = toInsert.getCount() - inventory.getInventoryStackLimit();
|
||||
@@ -460,7 +461,7 @@ public class TransporterManager
|
||||
|
||||
if(inSlot.getCount() + toInsert.getCount() <= max)
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else {
|
||||
int rejects = (inSlot.getCount() + toInsert.getCount()) - max;
|
||||
@@ -481,16 +482,16 @@ public class TransporterManager
|
||||
|
||||
public static class InventoryCopy
|
||||
{
|
||||
public ItemStack[] inventory;
|
||||
public NonNullList<ItemStack> inventory;
|
||||
|
||||
public int binAmount;
|
||||
|
||||
public InventoryCopy(ItemStack[] inv)
|
||||
public InventoryCopy(NonNullList<ItemStack> inv)
|
||||
{
|
||||
inventory = inv;
|
||||
}
|
||||
|
||||
public InventoryCopy(ItemStack[] inv, int amount)
|
||||
public InventoryCopy(NonNullList<ItemStack> inv, int amount)
|
||||
{
|
||||
this(inv);
|
||||
binAmount = amount;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ContainerFactory extends Container
|
||||
|
||||
if(isOutputSlot(slotID))
|
||||
{
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
else if(slotID == 2)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
else if(tileEntity.recipeType.getItemGas(slotStack) != null)
|
||||
{
|
||||
if(slotID >= tileEntity.inventory.length-1)
|
||||
if(slotID >= tileEntity.inventory.size()-1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
@@ -186,7 +186,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
else if(tileEntity.recipeType == RecipeType.INFUSING && InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.type == null || tileEntity.infuseStored.type == InfuseRegistry.getObject(slotStack).type))
|
||||
{
|
||||
if(slotID >= tileEntity.inventory.length-1)
|
||||
if(slotID >= tileEntity.inventory.size()-1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
@@ -202,14 +202,14 @@ public class ContainerFactory extends Container
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.size()-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int slotEnd = tileEntity.inventory.length-1;
|
||||
int slotEnd = tileEntity.inventory.size()-1;
|
||||
|
||||
if(slotID >= slotEnd && slotID <= (slotEnd+26))
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -35,7 +36,7 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
{
|
||||
ItemStack[] inv = getInventory(itemstack);
|
||||
NonNullList<ItemStack> inv = getInventory(itemstack);
|
||||
|
||||
if(inv != null)
|
||||
{
|
||||
@@ -43,7 +44,7 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
}
|
||||
}
|
||||
|
||||
private void addIngredientDetails(ItemStack[] inv, List list)
|
||||
private void addIngredientDetails(NonNullList<ItemStack> inv, List list)
|
||||
{
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
||||
@@ -126,7 +127,7 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
ItemDataUtils.setBoolean(stack, "invalid", invalid);
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory(ItemStack stack)
|
||||
public NonNullList<ItemStack> getInventory(ItemStack stack)
|
||||
{
|
||||
if(!ItemDataUtils.hasData(stack, "Items"))
|
||||
{
|
||||
@@ -134,7 +135,7 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
}
|
||||
|
||||
NBTTagList tagList = ItemDataUtils.getList(stack, "Items");
|
||||
ItemStack[] inventory = new ItemStack[9];
|
||||
NonNullList<ItemStack> inventory = NonNullList.withSize(9, ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
@@ -143,14 +144,14 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
|
||||
if(slotID >= 0 && slotID < 9)
|
||||
{
|
||||
inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound);
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(ItemStack stack, ItemStack[] inv)
|
||||
public void setInventory(ItemStack stack, NonNullList<ItemStack> inv)
|
||||
{
|
||||
if(inv == null)
|
||||
{
|
||||
@@ -162,11 +163,11 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
|
||||
for(int slotCount = 0; slotCount < 9; slotCount++)
|
||||
{
|
||||
if(inv[slotCount] != null)
|
||||
if(!inv.get(slotCount).isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inv[slotCount].writeToNBT(tagCompound);
|
||||
inv.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class SynchronizedData<T extends SynchronizedData<T>>
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public abstract class SynchronizedData<T extends SynchronizedData<T>>
|
||||
|
||||
public Set<Coord4D> internalLocations = new HashSet<Coord4D>();
|
||||
|
||||
public ItemStack[] getInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import mekanism.common.recipe.outputs.MachineOutput;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -493,8 +494,10 @@ public final class RecipeHandler
|
||||
for(RECIPE recipe : recipes.values())
|
||||
{
|
||||
ItemStackInput required = recipe.getInput();
|
||||
NonNullList<ItemStack> list = NonNullList.create();
|
||||
list.add(itemstack);
|
||||
|
||||
if(required.useItemStackFromInventory(new ItemStack[]{itemstack}, 0, false))
|
||||
if(required.useItemStackFromInventory(list, 0, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
|
||||
{
|
||||
@@ -40,13 +41,13 @@ public class AdvancedMachineInput extends MachineInput<AdvancedMachineInput>
|
||||
return itemStack != null && gasType != null;
|
||||
}
|
||||
|
||||
public boolean useItem(ItemStack[] inventory, int index, boolean deplete)
|
||||
public boolean useItem(NonNullList<ItemStack> inventory, int index, boolean deplete)
|
||||
{
|
||||
if(inputContains(inventory[index], itemStack))
|
||||
if(inputContains(inventory.get(index), itemStack))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], itemStack);
|
||||
inventory.set(index, StackUtils.subtract(inventory.get(index), itemStack));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/**
|
||||
* An infusion input, containing the type of and amount of infuse the operation requires, as well as the input ItemStack.
|
||||
@@ -55,13 +56,13 @@ public class InfusionInput extends MachineInput<InfusionInput>
|
||||
return infuse.type != null && inputStack != null;
|
||||
}
|
||||
|
||||
public boolean use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete)
|
||||
public boolean use(NonNullList<ItemStack> inventory, int index, InfuseStorage infuseStorage, boolean deplete)
|
||||
{
|
||||
if(inputContains(inventory[index], inputStack) && infuseStorage.contains(infuse))
|
||||
if(inputContains(inventory.get(index), inputStack) && infuseStorage.contains(infuse))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], inputStack);
|
||||
inventory.set(index, StackUtils.subtract(inventory.get(index), inputStack));
|
||||
infuseStorage.subtract(infuse);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ItemStackInput extends MachineInput<ItemStackInput>
|
||||
@@ -40,13 +41,13 @@ public class ItemStackInput extends MachineInput<ItemStackInput>
|
||||
return new ItemStackInput(new ItemStack(ingredient.getItem(), ingredient.getCount(), OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
|
||||
public boolean useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete)
|
||||
public boolean useItemStackFromInventory(NonNullList<ItemStack> inventory, int index, boolean deplete)
|
||||
{
|
||||
if(inputContains(inventory[index], ingredient))
|
||||
if(inputContains(inventory.get(index), ingredient))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], ingredient);
|
||||
inventory.set(index, StackUtils.subtract(inventory.get(index), ingredient));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -6,6 +6,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
@@ -44,18 +45,20 @@ public class PressurizedInput extends MachineInput<PressurizedInput>
|
||||
return theSolid != null && theFluid != null && theGas != null;
|
||||
}
|
||||
|
||||
public boolean use(ItemStack[] inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete)
|
||||
public boolean use(NonNullList<ItemStack> inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete)
|
||||
{
|
||||
if(meets(new PressurizedInput(inventory[index], fluidTank.getFluid(), gasTank.getGas())))
|
||||
if(meets(new PressurizedInput(inventory.get(index), fluidTank.getFluid(), gasTank.getGas())))
|
||||
{
|
||||
if(deplete)
|
||||
{
|
||||
inventory[index] = StackUtils.subtract(inventory[index], theSolid);
|
||||
inventory.set(index, StackUtils.subtract(inventory.get(index), theSolid));
|
||||
fluidTank.drain(theFluid.amount, true);
|
||||
gasTank.draw(theGas.amount, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class AdvancedMachineRecipe<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends MachineRecipe<AdvancedMachineInput, ItemStackOutput, RECIPE>
|
||||
{
|
||||
@@ -24,12 +25,12 @@ public abstract class AdvancedMachineRecipe<RECIPE extends AdvancedMachineRecipe
|
||||
this(new AdvancedMachineInput(input, gas), new ItemStackOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex, GasTank gasTank, int amount)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex, GasTank gasTank, int amount)
|
||||
{
|
||||
return getInput().useItem(inventory, inputIndex, false) && getInput().useSecondary(gasTank, amount, false) && getOutput().applyOutputs(inventory, outputIndex, false);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory, int inputIndex, int outputIndex, GasTank gasTank, int needed)
|
||||
public void operate(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex, GasTank gasTank, int needed)
|
||||
{
|
||||
if(getInput().useItem(inventory, inputIndex, true) && getInput().useSecondary(gasTank, needed, true))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.recipe.machines;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class BasicMachineRecipe<RECIPE extends BasicMachineRecipe<RECIPE>> extends MachineRecipe<ItemStackInput, ItemStackOutput, RECIPE>
|
||||
{
|
||||
@@ -16,12 +17,12 @@ public abstract class BasicMachineRecipe<RECIPE extends BasicMachineRecipe<RECIP
|
||||
this(new ItemStackInput(input), new ItemStackOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex)
|
||||
{
|
||||
return getInput().useItemStackFromInventory(inventory, inputIndex, false) && getOutput().applyOutputs(inventory, outputIndex, false);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory, int inputIndex, int outputIndex)
|
||||
public void operate(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex)
|
||||
{
|
||||
if(getInput().useItemStackFromInventory(inventory, inputIndex, true))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.recipe.machines;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class ChanceMachineRecipe<RECIPE extends ChanceMachineRecipe<RECIPE>> extends MachineRecipe<ItemStackInput, ChanceOutput, RECIPE>
|
||||
{
|
||||
@@ -11,12 +12,12 @@ public abstract class ChanceMachineRecipe<RECIPE extends ChanceMachineRecipe<REC
|
||||
super(input, output);
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, int inputIndex, int primaryIndex, int secondaryIndex)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, int inputIndex, int primaryIndex, int secondaryIndex)
|
||||
{
|
||||
return getInput().useItemStackFromInventory(inventory, inputIndex, false) && getOutput().applyOutputs(inventory, primaryIndex, secondaryIndex, false);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory)
|
||||
public void operate(NonNullList<ItemStack> inventory)
|
||||
{
|
||||
if(getInput().useItemStackFromInventory(inventory, 0, true))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class CrystallizerRecipe extends MachineRecipe<GasInput, ItemStackOutput, CrystallizerRecipe>
|
||||
{
|
||||
@@ -18,12 +19,12 @@ public class CrystallizerRecipe extends MachineRecipe<GasInput, ItemStackOutput,
|
||||
this(new GasInput(input), new ItemStackOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(GasTank gasTank, ItemStack[] inventory)
|
||||
public boolean canOperate(GasTank gasTank, NonNullList<ItemStack> inventory)
|
||||
{
|
||||
return getInput().useGas(gasTank, false, 1) && getOutput().applyOutputs(inventory, 1, false);
|
||||
}
|
||||
|
||||
public void operate(GasTank inputTank, ItemStack[] inventory)
|
||||
public void operate(GasTank inputTank, NonNullList<ItemStack> inventory)
|
||||
{
|
||||
if(getInput().useGas(inputTank, true, 1))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class DissolutionRecipe extends MachineRecipe<ItemStackInput, GasOutput, DissolutionRecipe>
|
||||
{
|
||||
@@ -18,12 +19,12 @@ public class DissolutionRecipe extends MachineRecipe<ItemStackInput, GasOutput,
|
||||
this(new ItemStackInput(input), new GasOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, GasTank outputTank)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, GasTank outputTank)
|
||||
{
|
||||
return getInput().useItemStackFromInventory(inventory, 1, false) && getOutput().applyOutputs(outputTank, false, 1);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory, GasTank outputTank)
|
||||
public void operate(NonNullList<ItemStack> inventory, GasTank outputTank)
|
||||
{
|
||||
if(getInput().useItemStackFromInventory(inventory, 1, true))
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemStackOutput, MetallurgicInfuserRecipe>
|
||||
{
|
||||
@@ -17,7 +18,7 @@ public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemS
|
||||
this(input, new ItemStackOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuse)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex, InfuseStorage infuse)
|
||||
{
|
||||
return getInput().use(inventory, inputIndex, infuse, false) && getOutput().applyOutputs(inventory, outputIndex, false);
|
||||
}
|
||||
@@ -28,7 +29,7 @@ public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemS
|
||||
return new MetallurgicInfuserRecipe(getInput(), getOutput());
|
||||
}
|
||||
|
||||
public void output(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuseStored)
|
||||
public void output(NonNullList<ItemStack> inventory, int inputIndex, int outputIndex, InfuseStorage infuseStored)
|
||||
{
|
||||
if(getInput().use(inventory, inputIndex, infuseStored, true))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.outputs.GasOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class OxidationRecipe extends MachineRecipe<ItemStackInput, GasOutput, OxidationRecipe>
|
||||
{
|
||||
@@ -24,12 +25,12 @@ public class OxidationRecipe extends MachineRecipe<ItemStackInput, GasOutput, Ox
|
||||
return new OxidationRecipe(getInput().copy(), getOutput().copy());
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, GasTank outputTank)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, GasTank outputTank)
|
||||
{
|
||||
return getInput().useItemStackFromInventory(inventory, 0, false) && getOutput().applyOutputs(outputTank, false, 1);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory, GasTank outputTank)
|
||||
public void operate(NonNullList<ItemStack> inventory, GasTank outputTank)
|
||||
{
|
||||
if(getInput().useItemStackFromInventory(inventory, 0, true))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.recipe.inputs.PressurizedInput;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
@@ -33,12 +34,12 @@ public class PressurizedRecipe extends MachineRecipe<PressurizedInput, Pressuriz
|
||||
return new PressurizedRecipe(getInput().copy(), getOutput().copy(), extraEnergy, ticks);
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank)
|
||||
public boolean canOperate(NonNullList<ItemStack> inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank)
|
||||
{
|
||||
return getInput().use(inventory, 0, inputFluidTank, inputGasTank, false) && getOutput().applyOutputs(inventory, 2, outputGasTank, false);
|
||||
}
|
||||
|
||||
public void operate(ItemStack[] inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank)
|
||||
public void operate(NonNullList<ItemStack> inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank)
|
||||
{
|
||||
if(getInput().use(inventory, 0, inputFluidTank, inputGasTank, true))
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class ChanceOutput extends MachineOutput<ChanceOutput>
|
||||
{
|
||||
@@ -54,22 +55,22 @@ public class ChanceOutput extends MachineOutput<ChanceOutput>
|
||||
return secondaryOutput != null;
|
||||
}
|
||||
|
||||
public boolean applyOutputs(ItemStack[] inventory, int primaryIndex, int secondaryIndex, boolean doEmit)
|
||||
public boolean applyOutputs(NonNullList<ItemStack> inventory, int primaryIndex, int secondaryIndex, boolean doEmit)
|
||||
{
|
||||
if(hasPrimary())
|
||||
{
|
||||
if(inventory[primaryIndex] == null)
|
||||
if(inventory.get(primaryIndex) == null)
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[primaryIndex] = primaryOutput.copy();
|
||||
inventory.set(primaryIndex, primaryOutput.copy());
|
||||
}
|
||||
}
|
||||
else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].getCount() + primaryOutput.getCount() <= inventory[primaryIndex].getMaxStackSize())
|
||||
else if(inventory.get(primaryIndex).isItemEqual(primaryOutput) && inventory.get(primaryIndex).getCount() + primaryOutput.getCount() <= inventory.get(primaryIndex).getMaxStackSize())
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[primaryIndex].grow(primaryOutput.getCount());
|
||||
inventory.get(primaryIndex).grow(primaryOutput.getCount());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -79,20 +80,20 @@ public class ChanceOutput extends MachineOutput<ChanceOutput>
|
||||
|
||||
if(hasSecondary() && (!doEmit || checkSecondary()))
|
||||
{
|
||||
if(inventory[secondaryIndex] == null)
|
||||
if(inventory.get(secondaryIndex).isEmpty())
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[secondaryIndex] = secondaryOutput.copy();
|
||||
inventory.set(secondaryIndex, secondaryOutput.copy());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].getCount() + primaryOutput.getCount() <= inventory[secondaryIndex].getMaxStackSize())
|
||||
else if(inventory.get(secondaryIndex).isItemEqual(secondaryOutput) && inventory.get(secondaryIndex).getCount() + primaryOutput.getCount() <= inventory.get(secondaryIndex).getMaxStackSize())
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[secondaryIndex].grow(secondaryOutput.getCount());
|
||||
inventory.get(secondaryIndex).grow(secondaryOutput.getCount());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.recipe.outputs;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class ItemStackOutput extends MachineOutput<ItemStackOutput>
|
||||
{
|
||||
@@ -21,26 +22,27 @@ public class ItemStackOutput extends MachineOutput<ItemStackOutput>
|
||||
output = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("output"));
|
||||
}
|
||||
|
||||
public boolean applyOutputs(ItemStack[] inventory, int index, boolean doEmit)
|
||||
public boolean applyOutputs(NonNullList<ItemStack> inventory, int index, boolean doEmit)
|
||||
{
|
||||
if(inventory[index] == null)
|
||||
if(inventory.get(index).isEmpty())
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[index] = output.copy();
|
||||
inventory.set(index, output.copy());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(inventory[index].isItemEqual(output) && inventory[index].getCount() + output.getCount() <= inventory[index].getMaxStackSize())
|
||||
else if(inventory.get(index).isItemEqual(output) && inventory.get(index).getCount() + output.getCount() <= inventory.get(index).getMaxStackSize())
|
||||
{
|
||||
if(doEmit)
|
||||
{
|
||||
inventory[index].grow(output.getCount());
|
||||
inventory.get(index).grow(output.getCount());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class PressurizedOutput extends MachineOutput<PressurizedOutput>
|
||||
{
|
||||
@@ -31,9 +32,9 @@ public class PressurizedOutput extends MachineOutput<PressurizedOutput>
|
||||
return tank.canReceive(gasOutput.getGas()) && tank.getNeeded() >= gasOutput.amount;
|
||||
}
|
||||
|
||||
public boolean canAddProducts(ItemStack[] inventory, int index)
|
||||
public boolean canAddProducts(NonNullList<ItemStack> inventory, int index)
|
||||
{
|
||||
return inventory[index] == null || (inventory[index].isItemEqual(itemOutput) && inventory[index].getCount() + itemOutput.getCount() <= inventory[index].getMaxStackSize());
|
||||
return inventory.get(index).isEmpty() || (inventory.get(index).isItemEqual(itemOutput) && inventory.get(index).getCount() + itemOutput.getCount() <= inventory.get(index).getMaxStackSize());
|
||||
}
|
||||
|
||||
public void fillTank(GasTank tank)
|
||||
@@ -41,19 +42,19 @@ public class PressurizedOutput extends MachineOutput<PressurizedOutput>
|
||||
tank.receive(gasOutput, true);
|
||||
}
|
||||
|
||||
public void addProducts(ItemStack[] inventory, int index)
|
||||
public void addProducts(NonNullList<ItemStack> inventory, int index)
|
||||
{
|
||||
if(inventory[index] == null)
|
||||
if(inventory.get(index).isEmpty())
|
||||
{
|
||||
inventory[index] = itemOutput.copy();
|
||||
inventory.set(index, itemOutput.copy());
|
||||
}
|
||||
else if(inventory[index].isItemEqual(itemOutput))
|
||||
else if(inventory.get(index).isItemEqual(itemOutput))
|
||||
{
|
||||
inventory[index].grow(itemOutput.getCount());
|
||||
inventory.get(index).grow(itemOutput.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean applyOutputs(ItemStack[] inventory, int index, GasTank tank, boolean doEmit)
|
||||
public boolean applyOutputs(NonNullList<ItemStack> inventory, int index, GasTank tank, boolean doEmit)
|
||||
{
|
||||
if(canFillTank(tank) && canAddProducts(inventory, index))
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ import mekanism.common.util.StatUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -82,7 +83,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
|
||||
gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
BASE_SECONDARY_ENERGY_PER_TICK = secondaryPerTick;
|
||||
secondaryEnergyPerTick = secondaryPerTick;
|
||||
@@ -146,11 +147,11 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
//Advanced Machine
|
||||
factory.gasTank.setGas(gasTank.getGas());
|
||||
|
||||
factory.inventory[5] = inventory[0];
|
||||
factory.inventory[4] = inventory[1];
|
||||
factory.inventory[5+3] = inventory[2];
|
||||
factory.inventory[1] = inventory[3];
|
||||
factory.inventory[0] = inventory[4];
|
||||
factory.inventory.set(5, inventory.get(0));
|
||||
factory.inventory.set(4, inventory.get(1));
|
||||
factory.inventory.set(5+3, inventory.get(2));
|
||||
factory.inventory.set(1, inventory.get(3));
|
||||
factory.inventory.set(0, inventory.get(4));
|
||||
|
||||
for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
@@ -226,21 +227,16 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[1] != null && gasTank.getNeeded() > 0)
|
||||
if(!inventory.get(1).isEmpty() && gasTank.getNeeded() > 0)
|
||||
{
|
||||
GasStack stack = getItemGas(inventory[1]);
|
||||
GasStack stack = getItemGas(inventory.get(1));
|
||||
int gasNeeded = gasTank.getNeeded();
|
||||
|
||||
if(stack != null && gasTank.canReceive(stack.getGas()) && gasNeeded >= stack.amount)
|
||||
{
|
||||
gasTank.receive(stack, true);
|
||||
|
||||
inventory[1].shrink(1);
|
||||
|
||||
if(inventory[1].getCount() == 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
inventory.get(1).shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +287,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
@Override
|
||||
public AdvancedMachineInput getInput()
|
||||
{
|
||||
return new AdvancedMachineInput(inventory[0], prevGas);
|
||||
return new AdvancedMachineInput(inventory.get(0), prevGas);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import mekanism.common.recipe.inputs.IntegerInput;
|
||||
import mekanism.common.recipe.machines.AmbientGasRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityAmbientAccumulator extends TileEntityContainerBlock implements IGasHandler, ITubeConnection
|
||||
@@ -29,7 +30,7 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple
|
||||
public TileEntityAmbientAccumulator()
|
||||
{
|
||||
super("AmbientAccumulator");
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -48,7 +49,7 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock<SynchronizedBoi
|
||||
public TileEntityBoilerCasing(String name)
|
||||
{
|
||||
super(name);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE>
|
||||
@@ -37,7 +38,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
@@ -111,7 +112,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
@Override
|
||||
public ItemStackInput getInput()
|
||||
{
|
||||
return new ItemStackInput(inventory[0]);
|
||||
return new ItemStackInput(inventory.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -43,7 +44,7 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock
|
||||
public TileEntityChargepad()
|
||||
{
|
||||
super("machine.chargepad", "Chargepad", BlockStateMachine.MachineType.CHARGEPAD.baseEnergy);
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,6 +45,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -101,7 +102,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
@@ -142,9 +143,9 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
|
||||
ChargeUtils.discharge(2, this);
|
||||
|
||||
if(inventory[0] != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas()))
|
||||
if(!inventory.get(0).isEmpty() && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas()))
|
||||
{
|
||||
inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true);
|
||||
inputTank.receive(GasTransmission.removeGas(inventory.get(0), inputTank.getGasType(), inputTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
CrystallizerRecipe recipe = getRecipe();
|
||||
|
||||
@@ -41,6 +41,7 @@ import mekanism.common.util.StatUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
super("machine.dissolution", "ChemicalDissolutionChamber", BlockStateMachine.MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@@ -120,14 +121,14 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(inventory[0] != null && injectTank.getNeeded() > 0)
|
||||
if(!inventory.get(0).isEmpty() && injectTank.getNeeded() > 0)
|
||||
{
|
||||
injectTank.receive(GasTransmission.removeGas(inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true);
|
||||
injectTank.receive(GasTransmission.removeGas(inventory.get(0), GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(inventory[2] != null && outputTank.getGas() != null)
|
||||
if(!inventory.get(2).isEmpty() && outputTank.getGas() != null)
|
||||
{
|
||||
outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true);
|
||||
outputTank.draw(GasTransmission.addGas(inventory.get(2), outputTank.getGas()), true);
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
@@ -238,7 +239,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
public ItemStackInput getInput()
|
||||
{
|
||||
return new ItemStackInput(inventory[1]);
|
||||
return new ItemStackInput(inventory.get(1));
|
||||
}
|
||||
|
||||
public boolean canOperate(DissolutionRecipe recipe)
|
||||
|
||||
@@ -41,6 +41,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -81,7 +82,7 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
super("machine.cheminfuser", "ChemicalInfuser", BlockStateMachine.MachineType.CHEMICAL_INFUSER.baseEnergy);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@@ -115,19 +116,19 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(inventory[0] != null && (leftTank.getGas() == null || leftTank.getStored() < leftTank.getMaxGas()))
|
||||
if(!inventory.get(0).isEmpty() && (leftTank.getGas() == null || leftTank.getStored() < leftTank.getMaxGas()))
|
||||
{
|
||||
leftTank.receive(GasTransmission.removeGas(inventory[0], leftTank.getGasType(), leftTank.getNeeded()), true);
|
||||
leftTank.receive(GasTransmission.removeGas(inventory.get(0), leftTank.getGasType(), leftTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(inventory[1] != null && (rightTank.getGas() == null || rightTank.getStored() < rightTank.getMaxGas()))
|
||||
if(!inventory.get(1).isEmpty() && (rightTank.getGas() == null || rightTank.getStored() < rightTank.getMaxGas()))
|
||||
{
|
||||
rightTank.receive(GasTransmission.removeGas(inventory[1], rightTank.getGasType(), rightTank.getNeeded()), true);
|
||||
rightTank.receive(GasTransmission.removeGas(inventory.get(1), rightTank.getGasType(), rightTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(inventory[2] != null && centerTank.getGas() != null)
|
||||
if(!inventory.get(2).isEmpty() && centerTank.getGas() != null)
|
||||
{
|
||||
centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true);
|
||||
centerTank.draw(GasTransmission.addGas(inventory.get(2), centerTank.getGas()), true);
|
||||
}
|
||||
|
||||
ChemicalInfuserRecipe recipe = getRecipe();
|
||||
|
||||
@@ -76,13 +76,13 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
|
||||
@Override
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem)
|
||||
if(!inventory.get(1).isEmpty() && gasTank.getNeeded() > 0 && inventory.get(1).getItem() instanceof IGasItem)
|
||||
{
|
||||
GasStack gas = ((IGasItem)inventory[1].getItem()).getGas(inventory[1]);
|
||||
GasStack gas = ((IGasItem)inventory.get(1).getItem()).getGas(inventory.get(1));
|
||||
|
||||
if(gas != null && isValidGas(gas.getGas()))
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded());
|
||||
GasStack removed = GasTransmission.removeGas(inventory.get(1), gasTank.getGasType(), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -78,7 +79,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
super("machine.oxidizer", "ChemicalOxidizer", BlockStateMachine.MachineType.CHEMICAL_OXIDIZER.baseEnergy);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@@ -112,9 +113,9 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(inventory[2] != null && gasTank.getGas() != null)
|
||||
if(!inventory.get(2).isEmpty() && gasTank.getGas() != null)
|
||||
{
|
||||
gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true);
|
||||
gasTank.draw(GasTransmission.addGas(inventory.get(2), gasTank.getGas()), true);
|
||||
}
|
||||
|
||||
OxidationRecipe recipe = getRecipe();
|
||||
@@ -216,7 +217,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
|
||||
public ItemStackInput getInput()
|
||||
{
|
||||
return new ItemStackInput(inventory[0]);
|
||||
return new ItemStackInput(inventory.get(0));
|
||||
}
|
||||
|
||||
public boolean canOperate(OxidationRecipe recipe)
|
||||
|
||||
@@ -47,6 +47,7 @@ import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -97,7 +98,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
super("machine.washer", "ChemicalWasher", BlockStateMachine.MachineType.CHEMICAL_WASHER.baseEnergy);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@@ -132,9 +133,9 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
ChargeUtils.discharge(3, this);
|
||||
manageBuckets();
|
||||
|
||||
if(inventory[2] != null && outputTank.getGas() != null)
|
||||
if(!inventory.get(2).isEmpty() && outputTank.getGas() != null)
|
||||
{
|
||||
outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true);
|
||||
outputTank.draw(GasTransmission.addGas(inventory.get(2), outputTank.getGas()), true);
|
||||
}
|
||||
|
||||
WasherRecipe recipe = getRecipe();
|
||||
@@ -199,7 +200,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
|
||||
private void manageBuckets()
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER));
|
||||
}
|
||||
|
||||
@@ -4,24 +4,23 @@ import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory, ITickable
|
||||
{
|
||||
/** The inventory slot itemstacks used by this block. */
|
||||
public ItemStack[] inventory;
|
||||
public NonNullList<ItemStack> inventory;
|
||||
|
||||
/** The full name of this machine. */
|
||||
public String fullName;
|
||||
@@ -57,7 +56,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
if(handleInventory())
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
@@ -101,62 +100,31 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inventory != null ? inventory.length : 0;
|
||||
return inventory != null ? inventory.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
return inventory != null ? inventory[slotID] : null;
|
||||
return inventory != null ? inventory.get(slotID) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
if(getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack;
|
||||
|
||||
if(getStackInSlot(slotID).getCount() <= amount)
|
||||
{
|
||||
tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
|
||||
if(getStackInSlot(slotID).getCount() == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, null);
|
||||
}
|
||||
|
||||
return tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return ItemStackHelper.getAndSplit(inventory, slotID, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slotID)
|
||||
{
|
||||
if(getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return ItemStackHelper.getAndRemove(inventory, slotID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotID, ItemStack itemstack)
|
||||
{
|
||||
inventory[slotID] = itemstack;
|
||||
inventory.set(slotID, itemstack);
|
||||
|
||||
if(itemstack != null && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
@@ -228,16 +196,16 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
return;
|
||||
}
|
||||
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
|
||||
inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
for(int slots = 0; slots < nbtTags.tagCount(); slots++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.getCompoundTagAt(slots);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < inventory.length)
|
||||
if(slotID >= 0 && slotID < inventory.size())
|
||||
{
|
||||
inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound);
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,13 +217,13 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
|
||||
if(handleInventory())
|
||||
{
|
||||
for(int slots = 0; slots < inventory.length; slots++)
|
||||
for(int slots = 0; slots < inventory.size(); slots++)
|
||||
{
|
||||
if(inventory[slots] != null)
|
||||
if(!inventory.get(slots).isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slots);
|
||||
inventory[slots].writeToNBT(tagCompound);
|
||||
inventory.get(slots).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
@@ -134,7 +135,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
public TileEntityDigitalMiner()
|
||||
{
|
||||
super("DigitalMiner", BlockStateMachine.MachineType.DIGITAL_MINER.baseEnergy);
|
||||
inventory = new ItemStack[29];
|
||||
inventory = NonNullList.withSize(29, ItemStack.EMPTY);
|
||||
radius = 10;
|
||||
|
||||
upgradeComponent.setSupported(Upgrade.ANCHOR);
|
||||
@@ -423,14 +424,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
|
||||
for(int i = 0; i < 27; i++)
|
||||
{
|
||||
if(inventory[i] != null && inventory[i].isItemEqual(filter.replaceStack))
|
||||
if(!inventory.get(i).isEmpty() && inventory.get(i).isItemEqual(filter.replaceStack))
|
||||
{
|
||||
inventory[i].shrink(1);
|
||||
|
||||
if(inventory[i].getCount() == 0)
|
||||
{
|
||||
inventory[i] = null;
|
||||
}
|
||||
inventory.get(i).shrink(1);
|
||||
|
||||
return MekanismUtils.size(filter.replaceStack, 1);
|
||||
}
|
||||
@@ -450,13 +446,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack[] copy(ItemStack[] stacks)
|
||||
public NonNullList<ItemStack> copy(NonNullList<ItemStack> stacks)
|
||||
{
|
||||
ItemStack[] toReturn = new ItemStack[stacks.length];
|
||||
NonNullList<ItemStack> toReturn = NonNullList.withSize(stacks.size(), ItemStack.EMPTY);
|
||||
|
||||
for(int i = 0; i < stacks.length; i++)
|
||||
for(int i = 0; i < stacks.size(); i++)
|
||||
{
|
||||
toReturn[i] = stacks[i] != null ? stacks[i].copy() : null;
|
||||
toReturn.set(i, !stacks.get(i).isEmpty() ? stacks.get(i).copy() : ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
@@ -466,9 +462,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
{
|
||||
for(int i = 27-1; i >= 0; i--)
|
||||
{
|
||||
ItemStack stack = inventory[i];
|
||||
ItemStack stack = inventory.get(i);
|
||||
|
||||
if(stack != null)
|
||||
if(!stack.isEmpty())
|
||||
{
|
||||
if(isReplaceStack(stack))
|
||||
{
|
||||
@@ -477,7 +473,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
|
||||
if(remove)
|
||||
{
|
||||
inventory[i] = reject;
|
||||
inventory.set(i, reject);
|
||||
}
|
||||
|
||||
return stack;
|
||||
@@ -494,7 +490,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack[] testInv = copy(inventory);
|
||||
NonNullList<ItemStack> testInv = copy(inventory);
|
||||
|
||||
int added = 0;
|
||||
|
||||
@@ -508,21 +504,21 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
|
||||
for(int i = 0; i < 27; i++)
|
||||
{
|
||||
if(testInv[i] != null && testInv[i].getItem() == null)
|
||||
if(!testInv.get(i).isEmpty() && testInv.get(i).getItem() == null)
|
||||
{
|
||||
testInv[i] = null;
|
||||
testInv.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
if(testInv[i] == null)
|
||||
if(testInv.get(i).isEmpty())
|
||||
{
|
||||
testInv[i] = stack;
|
||||
testInv.set(i, stack);
|
||||
added++;
|
||||
|
||||
continue stacks;
|
||||
}
|
||||
else if(testInv[i].isItemEqual(stack) && testInv[i].getCount()+stack.getCount() <= stack.getMaxStackSize())
|
||||
else if(testInv.get(i).isItemEqual(stack) && testInv.get(i).getCount()+stack.getCount() <= stack.getMaxStackSize())
|
||||
{
|
||||
testInv[i].grow(stack.getCount());
|
||||
testInv.get(i).grow(stack.getCount());
|
||||
added++;
|
||||
|
||||
continue stacks;
|
||||
@@ -562,15 +558,15 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
{
|
||||
for(int i = 0; i < 27; i++)
|
||||
{
|
||||
if(inventory[i] == null)
|
||||
if(inventory.get(i).isEmpty())
|
||||
{
|
||||
inventory[i] = stack;
|
||||
inventory.set(i, stack);
|
||||
|
||||
continue stacks;
|
||||
}
|
||||
else if(inventory[i].isItemEqual(stack) && inventory[i].getCount()+stack.getCount() <= stack.getMaxStackSize())
|
||||
else if(inventory.get(i).isItemEqual(stack) && inventory.get(i).getCount()+stack.getCount() <= stack.getMaxStackSize())
|
||||
{
|
||||
inventory[i].grow(stack.getCount());
|
||||
inventory.get(i).grow(stack.getCount());
|
||||
|
||||
continue stacks;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -46,7 +47,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
|
||||
public TileEntityDynamicTank(String name)
|
||||
{
|
||||
super(name);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +129,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
|
||||
{
|
||||
int needed = (structure.volume*TankUpdateProtocol.FLUID_PER_TANK)-(structure.fluidStored != null ? structure.fluidStored.amount : 0);
|
||||
|
||||
if(FluidContainerUtils.isFluidContainer(structure.inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(structure.inventory.get(0)))
|
||||
{
|
||||
structure.fluidStored = FluidContainerUtils.handleContainerItem(this, structure.inventory, structure.editMode, structure.fluidStored, needed, 0, 1, null);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ItemStackOutput, RECIPE> implements ITierUpgradeable
|
||||
{
|
||||
@@ -49,7 +50,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {3, 1, 0, 0, 0, 2});
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
@@ -107,10 +108,10 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
factory.configComponent.setEjecting(transmission, configComponent.isEjecting(transmission));
|
||||
}
|
||||
|
||||
factory.inventory[5] = inventory[0];
|
||||
factory.inventory[1] = inventory[1];
|
||||
factory.inventory[5+3] = inventory[2];
|
||||
factory.inventory[0] = inventory[3];
|
||||
factory.inventory.set(5, inventory.get(0));
|
||||
factory.inventory.set(1, inventory.get(1));
|
||||
factory.inventory.set(5+3, inventory.get(2));
|
||||
factory.inventory.set(0, inventory.get(3));
|
||||
|
||||
for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
@@ -192,7 +193,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
@Override
|
||||
public ItemStackInput getInput()
|
||||
{
|
||||
return new ItemStackInput(inventory[0]);
|
||||
return new ItemStackInput(inventory.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
@@ -89,7 +90,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
public TileEntityElectricPump()
|
||||
{
|
||||
super("ElectricPump", 10000);
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent.setSupported(Upgrade.FILTER);
|
||||
}
|
||||
@@ -103,7 +104,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -107,7 +108,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
||||
public TileEntityElectrolyticSeparator()
|
||||
{
|
||||
super("ElectrolyticSeparator", BlockStateMachine.MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy);
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,26 +141,26 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(inventory[0] != null)
|
||||
if(!inventory.get(0).isEmpty())
|
||||
{
|
||||
if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0]))
|
||||
if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory.get(0)))
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0]), true);
|
||||
fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory.get(0)), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(inventory[1] != null && leftTank.getStored() > 0)
|
||||
if(!inventory.get(1).isEmpty() && leftTank.getStored() > 0)
|
||||
{
|
||||
leftTank.draw(GasTransmission.addGas(inventory[1], leftTank.getGas()), true);
|
||||
leftTank.draw(GasTransmission.addGas(inventory.get(1), leftTank.getGas()), true);
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
if(inventory[2] != null && rightTank.getStored() > 0)
|
||||
if(!inventory.get(2).isEmpty() && rightTank.getStored() > 0)
|
||||
{
|
||||
rightTank.draw(GasTransmission.addGas(inventory[2], rightTank.getGas()), true);
|
||||
rightTank.draw(GasTransmission.addGas(inventory.get(2), rightTank.getGas()), true);
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -68,7 +69,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
configComponent.setIOConfig(TransmissionType.ENERGY);
|
||||
configComponent.setEjecting(TransmissionType.ENERGY, true);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -64,6 +64,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -175,7 +176,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
super("null", machine.machineName, machine.baseEnergy);
|
||||
|
||||
tier = type;
|
||||
inventory = new ItemStack[5+type.processes*2];
|
||||
inventory = NonNullList.withSize(5+type.processes*2, ItemStack.EMPTY);
|
||||
progress = new int[type.processes];
|
||||
isActive = false;
|
||||
|
||||
@@ -236,18 +237,18 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
for(int i = 0; i < tier.processes+5; i++)
|
||||
{
|
||||
factory.inventory[i] = inventory[i];
|
||||
factory.inventory.set(i, inventory.get(i));
|
||||
}
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
int output = getOutputSlot(i);
|
||||
|
||||
if(inventory[output] != null)
|
||||
if(!inventory.get(output).isEmpty())
|
||||
{
|
||||
int newOutput = 5+factory.tier.processes+i;
|
||||
|
||||
factory.inventory[newOutput] = inventory[output];
|
||||
factory.inventory.set(newOutput, inventory.get(output));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,13 +303,13 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
handleSecondaryFuel();
|
||||
sortInventory();
|
||||
|
||||
if(inventory[2] != null && inventory[3] == null)
|
||||
if(!inventory.get(2).isEmpty() && inventory.get(3).isEmpty())
|
||||
{
|
||||
RecipeType toSet = null;
|
||||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
if(inventory[2].isItemEqual(type.getStack()))
|
||||
if(inventory.get(2).isItemEqual(type.getStack()))
|
||||
{
|
||||
toSet = type;
|
||||
break;
|
||||
@@ -328,10 +329,10 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
upgradeComponent.write(ItemDataUtils.getDataMap(returnStack));
|
||||
upgradeComponent.setSupported(Upgrade.GAS, toSet.fuelEnergyUpgrades());
|
||||
upgradeComponent.read(ItemDataUtils.getDataMap(inventory[2]));
|
||||
upgradeComponent.read(ItemDataUtils.getDataMap(inventory.get(2)));
|
||||
|
||||
inventory[2] = null;
|
||||
inventory[3] = returnStack;
|
||||
inventory.set(2, ItemStack.EMPTY);
|
||||
inventory.set(3, returnStack);
|
||||
|
||||
recipeType = toSet;
|
||||
gasTank.setGas(null);
|
||||
@@ -377,7 +378,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
if(!canOperate(getInputSlot(process), getOutputSlot(process)))
|
||||
{
|
||||
if(!(recipeType.usesFuel() && recipeType.hasRecipe(inventory[getInputSlot(process)])))
|
||||
if(!(recipeType.usesFuel() && recipeType.hasRecipe(inventory.get(getInputSlot(process)))))
|
||||
{
|
||||
progress[process] = 0;
|
||||
}
|
||||
@@ -457,9 +458,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
if(invID1.ID == invID2.ID || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) || Math.abs(invID1.size()-invID2.size()) < 2) continue;
|
||||
|
||||
List<ItemStack> evened = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]);
|
||||
inventory[invID1.ID] = evened.get(0);
|
||||
inventory[invID2.ID] = evened.get(1);
|
||||
List<ItemStack> evened = StackUtils.even(inventory.get(invID1.ID), inventory.get(invID2.ID));
|
||||
inventory.set(invID1.ID, evened.get(0));
|
||||
inventory.set(invID2.ID, evened.get(1));
|
||||
|
||||
didOp = true;
|
||||
break;
|
||||
@@ -487,17 +488,17 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
public int size()
|
||||
{
|
||||
return stack != null ? stack.getCount() : 0;
|
||||
return !stack.isEmpty() ? stack.getCount() : 0;
|
||||
}
|
||||
|
||||
public Item item()
|
||||
{
|
||||
return stack != null ? stack.getItem() : null;
|
||||
return !stack.isEmpty() ? stack.getItem() : null;
|
||||
}
|
||||
|
||||
public static InvID get(int id, ItemStack[] inv)
|
||||
public static InvID get(int id, NonNullList<ItemStack> inv)
|
||||
{
|
||||
return new InvID(inv[id], id);
|
||||
return new InvID(inv.get(id), id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,43 +509,38 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[4] != null)
|
||||
if(!inventory.get(4).isEmpty())
|
||||
{
|
||||
if(recipeType.usesFuel() && gasTank.getNeeded() > 0)
|
||||
{
|
||||
if(inventory[4].getItem() instanceof IGasItem)
|
||||
if(inventory.get(4).getItem() instanceof IGasItem)
|
||||
{
|
||||
GasStack gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]);
|
||||
GasStack gas = ((IGasItem)inventory.get(4).getItem()).getGas(inventory.get(4));
|
||||
|
||||
if(gas != null && recipeType.isValidGas(gas.getGas()))
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGasType(), gasTank.getNeeded());
|
||||
GasStack removed = GasTransmission.removeGas(inventory.get(4), gasTank.getGasType(), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GasStack stack = recipeType.getItemGas(inventory[4]);
|
||||
GasStack stack = recipeType.getItemGas(inventory.get(4));
|
||||
int gasNeeded = gasTank.getNeeded();
|
||||
|
||||
if(stack != null && stack.amount <= gasNeeded)
|
||||
{
|
||||
gasTank.receive(stack, true);
|
||||
|
||||
inventory[4].shrink(1);
|
||||
|
||||
if(inventory[4].getCount() == 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
inventory.get(4).shrink(1);
|
||||
}
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
if(InfuseRegistry.getObject(inventory[4]) != null)
|
||||
if(InfuseRegistry.getObject(inventory.get(4)) != null)
|
||||
{
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory[4]);
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory.get(4));
|
||||
|
||||
if(infuseStored.type == null || infuseStored.type == infuse.type)
|
||||
{
|
||||
@@ -552,12 +548,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
infuseStored.amount += infuse.stored;
|
||||
infuseStored.type = infuse.type;
|
||||
inventory[4].shrink(1);
|
||||
|
||||
if(inventory[4].getCount() <= 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
inventory.get(4).shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,14 +666,14 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
public boolean canOperate(int inputSlot, int outputSlot)
|
||||
{
|
||||
if(inventory[inputSlot] == null)
|
||||
if(inventory.get(inputSlot).isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(recipeType.usesFuel())
|
||||
{
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType());
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), gasTank.getGasType());
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
|
||||
@@ -690,7 +681,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]);
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory.get(inputSlot));
|
||||
MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
|
||||
if(recipe == null)
|
||||
@@ -701,7 +692,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
return recipe.canOperate(inventory, inputSlot, outputSlot, infuseStored);
|
||||
}
|
||||
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot]);
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot));
|
||||
|
||||
return recipe != null && recipe.canOperate(inventory, inputSlot, outputSlot);
|
||||
|
||||
@@ -716,19 +707,19 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
if(recipeType.usesFuel())
|
||||
{
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType());
|
||||
AdvancedMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot), gasTank.getGasType());
|
||||
|
||||
recipe.operate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]);
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory.get(inputSlot));
|
||||
MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
|
||||
recipe.output(inventory, inputSlot, outputSlot, infuseStored);
|
||||
}
|
||||
else {
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot]);
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory.get(inputSlot));
|
||||
|
||||
recipe.operate(inventory, inputSlot, outputSlot);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -81,7 +82,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
super("FluidTank");
|
||||
|
||||
fluidTank = new FluidTank(tier.storage);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +161,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
|
||||
prevAmount = fluidTank.getFluidAmount();
|
||||
|
||||
if(inventory[0] != null)
|
||||
if(!inventory.get(0).isEmpty())
|
||||
{
|
||||
manageInventory();
|
||||
}
|
||||
@@ -210,7 +211,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
|
||||
private void manageInventory()
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
FluidStack ret = FluidContainerUtils.handleContainerItem(this, inventory, editMode, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
@@ -81,7 +82,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
public TileEntityFluidicPlenisher()
|
||||
{
|
||||
super("FluidicPlenisher", MachineType.FLUIDIC_PLENISHER.baseEnergy);
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +92,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
{
|
||||
ChargeUtils.discharge(2, this);
|
||||
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, new FluidChecker() {
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -82,7 +83,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 0, 0, 3, 1, 2});
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[36];
|
||||
inventory = NonNullList.withSize(36, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
|
||||
@@ -112,11 +113,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
RecipeFormula prev = formula;
|
||||
|
||||
if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula)
|
||||
if(!inventory.get(2).isEmpty() && inventory.get(2).getItem() instanceof ItemCraftingFormula)
|
||||
{
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem();
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory.get(2).getItem();
|
||||
|
||||
if(formula == null || lastFormulaStack != inventory[2])
|
||||
if(formula == null || lastFormulaStack != inventory.get(2))
|
||||
{
|
||||
loadFormula();
|
||||
}
|
||||
@@ -130,7 +131,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
needsFormulaUpdate = true;
|
||||
}
|
||||
|
||||
lastFormulaStack = inventory[2];
|
||||
lastFormulaStack = inventory.get(2);
|
||||
|
||||
if(autoMode && formula == null)
|
||||
{
|
||||
@@ -184,11 +185,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
public void loadFormula()
|
||||
{
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem();
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory.get(2).getItem();
|
||||
|
||||
if(item.getInventory(inventory[2]) != null && !item.isInvalid(inventory[2]))
|
||||
if(item.getInventory(inventory.get(2)) != null && !item.isInvalid(inventory.get(2)))
|
||||
{
|
||||
RecipeFormula itemFormula = new RecipeFormula(world, item.getInventory(inventory[2]));
|
||||
RecipeFormula itemFormula = new RecipeFormula(world, item.getInventory(inventory.get(2)));
|
||||
|
||||
if(itemFormula.isValidFormula(world))
|
||||
{
|
||||
@@ -204,7 +205,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
}
|
||||
else {
|
||||
formula = null;
|
||||
item.setInvalid(inventory[2], true);
|
||||
item.setInvalid(inventory.get(2), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -223,7 +224,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
dummyInv.setInventorySlotContents(i, inventory[27+i]);
|
||||
dummyInv.setInventorySlotContents(i, inventory.get(27+i));
|
||||
}
|
||||
|
||||
lastOutputStack = MekanismUtils.findMatchingRecipe(dummyInv, world);
|
||||
@@ -240,7 +241,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
dummyInv.setInventorySlotContents(i, inventory[27+i]);
|
||||
dummyInv.setInventorySlotContents(i, inventory.get(27+i));
|
||||
}
|
||||
|
||||
ItemStack output = lastOutputStack;
|
||||
@@ -251,16 +252,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int i = 27; i <= 35; i++)
|
||||
{
|
||||
if(inventory[i] != null)
|
||||
if(!inventory.get(i).isEmpty())
|
||||
{
|
||||
ItemStack stack = inventory[i];
|
||||
ItemStack stack = inventory.get(i);
|
||||
|
||||
inventory[i].shrink(1);
|
||||
|
||||
if(inventory[i].getCount() == 0)
|
||||
{
|
||||
inventory[i] = null;
|
||||
}
|
||||
inventory.get(i).shrink(1);
|
||||
|
||||
if(stack.getCount() == 0 && stack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
@@ -280,7 +276,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
tryMoveToOutput(container.copy(), true);
|
||||
}
|
||||
|
||||
inventory[i] = move ? null : container.copy();
|
||||
inventory.set(i, move ? ItemStack.EMPTY : container.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,17 +324,17 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int i = 27; i <= 35; i++)
|
||||
{
|
||||
if(formula.isIngredientInPos(world, inventory[i], i-27))
|
||||
if(formula.isIngredientInPos(world, inventory.get(i), i-27))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(inventory[i] != null)
|
||||
if(!inventory.get(i).isEmpty())
|
||||
{
|
||||
inventory[i] = tryMoveToInput(inventory[i]);
|
||||
inventory.set(i, tryMoveToInput(inventory.get(i)));
|
||||
markDirty();
|
||||
|
||||
if(inventory[i] != null)
|
||||
if(!inventory.get(i).isEmpty())
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
@@ -348,15 +344,10 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int j = 3; j <= 20; j++)
|
||||
{
|
||||
if(inventory[j] != null && formula.isIngredientInPos(world, inventory[j], i-27))
|
||||
if(!inventory.get(j).isEmpty() && formula.isIngredientInPos(world, inventory.get(j), i-27))
|
||||
{
|
||||
inventory[i] = StackUtils.size(inventory[j], 1);
|
||||
inventory[j].shrink(1);
|
||||
|
||||
if(inventory[j].getCount() == 0)
|
||||
{
|
||||
inventory[j] = null;
|
||||
}
|
||||
inventory.set(i, StackUtils.size(inventory.get(j), 1));
|
||||
inventory.get(j).shrink(1);
|
||||
|
||||
markDirty();
|
||||
found = true;
|
||||
@@ -384,9 +375,9 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
for(int i = 27; i <= 35; i++)
|
||||
{
|
||||
if(inventory[i] != null && (forcePush || (formula != null && !formula.isIngredientInPos(world, inventory[i], i-27))))
|
||||
if(!inventory.get(i).isEmpty() && (forcePush || (formula != null && !formula.isIngredientInPos(world, inventory.get(i), i-27))))
|
||||
{
|
||||
inventory[i] = tryMoveToInput(inventory[i]);
|
||||
inventory.set(i, tryMoveToInput(inventory.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,17 +406,17 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int i = 3; i <= 20; i++)
|
||||
{
|
||||
if(inventory[i] == null)
|
||||
if(inventory.get(i).isEmpty())
|
||||
{
|
||||
inventory[i] = stack;
|
||||
inventory.set(i, stack);
|
||||
|
||||
return null;
|
||||
}
|
||||
else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].getCount() < inventory[i].getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(stack, inventory.get(i)) && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize())
|
||||
{
|
||||
int toUse = Math.min(stack.getCount(), inventory[i].getMaxStackSize()-inventory[i].getCount());
|
||||
int toUse = Math.min(stack.getCount(), inventory.get(i).getMaxStackSize()-inventory.get(i).getCount());
|
||||
|
||||
inventory[i].grow(toUse);
|
||||
inventory.get(i).grow(toUse);
|
||||
stack.shrink(toUse);
|
||||
|
||||
if(stack.getCount() == 0)
|
||||
@@ -444,22 +435,22 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int i = 21; i <= 26; i++)
|
||||
{
|
||||
if(inventory[i] == null)
|
||||
if(inventory.get(i).isEmpty())
|
||||
{
|
||||
if(doMove)
|
||||
{
|
||||
inventory[i] = stack;
|
||||
inventory.set(i, stack);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].getCount() < inventory[i].getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(stack, inventory.get(i)) && inventory.get(i).getCount() < inventory.get(i).getMaxStackSize())
|
||||
{
|
||||
int toUse = Math.min(stack.getCount(), inventory[i].getMaxStackSize()-inventory[i].getCount());
|
||||
int toUse = Math.min(stack.getCount(), inventory.get(i).getMaxStackSize()-inventory.get(i).getCount());
|
||||
|
||||
if(doMove)
|
||||
{
|
||||
inventory[i].grow(toUse);
|
||||
inventory.get(i).grow(toUse);
|
||||
}
|
||||
|
||||
stack.shrink(toUse);
|
||||
@@ -476,17 +467,17 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
private void encodeFormula()
|
||||
{
|
||||
if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula)
|
||||
if(inventory.get(2).isEmpty() && inventory.get(2).getItem() instanceof ItemCraftingFormula)
|
||||
{
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem();
|
||||
ItemCraftingFormula item = (ItemCraftingFormula)inventory.get(2).getItem();
|
||||
|
||||
if(item.getInventory(inventory[2]) == null)
|
||||
if(item.getInventory(inventory.get(2)) == null)
|
||||
{
|
||||
RecipeFormula formula = new RecipeFormula(world, inventory, 27);
|
||||
|
||||
if(formula.isValidFormula(world))
|
||||
{
|
||||
item.setInventory(inventory[2], formula.input);
|
||||
item.setInventory(inventory.get(2), formula.input);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,13 +605,13 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
ItemStack[] inv = new ItemStack[9];
|
||||
NonNullList<ItemStack> inv = NonNullList.withSize(9, ItemStack.EMPTY);
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
inv[i] = PacketHandler.readStack(dataStream);
|
||||
inv.set(i, PacketHandler.readStack(dataStream));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,10 +644,10 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
if(formula.input[i] != null)
|
||||
if(!formula.input.get(i).isEmpty())
|
||||
{
|
||||
data.add(true);
|
||||
data.add(formula.input[i]);
|
||||
data.add(formula.input.get(i));
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
|
||||
public TileEntityFuelwoodHeater()
|
||||
{
|
||||
super("FuelwoodHeater");
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,17 +87,17 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
|
||||
burning = true;
|
||||
}
|
||||
else {
|
||||
if(inventory[0] != null)
|
||||
if(!inventory.get(0).isEmpty())
|
||||
{
|
||||
maxBurnTime = burnTime = TileEntityFurnace.getItemBurnTime(inventory[0])/2;
|
||||
maxBurnTime = burnTime = TileEntityFurnace.getItemBurnTime(inventory.get(0))/2;
|
||||
|
||||
if(burnTime > 0)
|
||||
{
|
||||
inventory[0].shrink(1);
|
||||
inventory.get(0).shrink(1);
|
||||
|
||||
if(inventory[0].getCount() == 0)
|
||||
if(inventory.get(0).getCount() == 0)
|
||||
{
|
||||
inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
|
||||
inventory.set(0, inventory.get(0).getItem().getContainerItem(inventory.get(0)));
|
||||
}
|
||||
|
||||
burning = true;
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -84,7 +85,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
configComponent.setEjecting(TransmissionType.GAS, true);
|
||||
|
||||
gasTank = new GasTank(tier.storage);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
dumping = GasMode.IDLE;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
@@ -98,14 +99,14 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(inventory[0] != null && gasTank.getGas() != null)
|
||||
if(!inventory.get(0).isEmpty() && gasTank.getGas() != null)
|
||||
{
|
||||
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), tier != GasTankTier.CREATIVE);
|
||||
gasTank.draw(GasTransmission.addGas(inventory.get(0), gasTank.getGas()), tier != GasTankTier.CREATIVE);
|
||||
}
|
||||
|
||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||
if(!inventory.get(1).isEmpty() && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||
{
|
||||
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
gasTank.receive(GasTransmission.removeGas(inventory.get(1), gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
|
||||
if(tier == GasTankTier.CREATIVE && gasTank.getGas() != null)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
public TileEntityInductionCasing(String name)
|
||||
{
|
||||
super(name);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc
|
||||
public TileEntityLaser()
|
||||
{
|
||||
super("machine.laser", "Laser", 2*usage.laserUsage);
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -58,7 +59,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
|
||||
public TileEntityLaserAmplifier()
|
||||
{
|
||||
super("LaserAmplifier");
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -44,7 +45,7 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme
|
||||
public TileEntityLaserTractorBeam()
|
||||
{
|
||||
super("LaserTractorBeam");
|
||||
inventory = new ItemStack[27];
|
||||
inventory = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,15 +161,15 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme
|
||||
outer:
|
||||
for(ItemStack drop : drops)
|
||||
{
|
||||
for(int i = 0; i < inventory.length; i++)
|
||||
for(int i = 0; i < inventory.size(); i++)
|
||||
{
|
||||
if(inventory[i] == null)
|
||||
if(inventory.get(i).isEmpty())
|
||||
{
|
||||
inventory[i] = drop;
|
||||
inventory.set(i, drop);
|
||||
continue outer;
|
||||
}
|
||||
|
||||
ItemStack slot = inventory[i];
|
||||
ItemStack slot = inventory.get(i);
|
||||
|
||||
if(StackUtils.equalsWildcardWithNBT(slot, drop))
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
@@ -75,7 +76,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
public TileEntityLogisticalSorter()
|
||||
{
|
||||
super("LogisticalSorter", BlockStateMachine.MachineType.LOGISTICAL_SORTER.baseEnergy);
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
doAutoSync = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -103,7 +104,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 0, 0, 3, 1, 2});
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
@@ -144,11 +145,11 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if(inventory[1] != null)
|
||||
if(!inventory.get(1).isEmpty())
|
||||
{
|
||||
if(InfuseRegistry.getObject(inventory[1]) != null)
|
||||
if(InfuseRegistry.getObject(inventory.get(1)) != null)
|
||||
{
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory[1]);
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory.get(1));
|
||||
|
||||
if(infuseStored.type == null || infuseStored.type == infuse.type)
|
||||
{
|
||||
@@ -156,12 +157,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
{
|
||||
infuseStored.amount += infuse.stored;
|
||||
infuseStored.type = infuse.type;
|
||||
inventory[1].shrink(1);
|
||||
|
||||
if(inventory[1].getCount() <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
inventory.get(1).shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,11 +253,11 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
//Infuser
|
||||
factory.infuseStored = infuseStored;
|
||||
|
||||
factory.inventory[5] = inventory[2];
|
||||
factory.inventory[1] = inventory[4];
|
||||
factory.inventory[5+3] = inventory[3];
|
||||
factory.inventory[0] = inventory[0];
|
||||
factory.inventory[4] = inventory[1];
|
||||
factory.inventory.set(5, inventory.get(2));
|
||||
factory.inventory.set(1, inventory.get(4));
|
||||
factory.inventory.set(5+3, inventory.get(3));
|
||||
factory.inventory.set(0, inventory.get(0));
|
||||
factory.inventory.set(4, inventory.get(1));
|
||||
|
||||
for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
@@ -335,7 +331,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
|
||||
public InfusionInput getInput()
|
||||
{
|
||||
return new InfusionInput(infuseStored, inventory[2]);
|
||||
return new InfusionInput(infuseStored, inventory.get(2));
|
||||
}
|
||||
|
||||
public void operate(MetallurgicInfuserRecipe recipe)
|
||||
|
||||
@@ -275,7 +275,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
return structure != null && getSynchronizedData().getInventory() != null ? getSynchronizedData().getInventory()[slotID] : null;
|
||||
return structure != null && getSynchronizedData().getInventory() != null ? getSynchronizedData().getInventory().get(slotID) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -283,7 +283,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
{
|
||||
if(structure != null && getSynchronizedData().getInventory() != null)
|
||||
{
|
||||
getSynchronizedData().getInventory()[slotID] = itemstack;
|
||||
getSynchronizedData().getInventory().set(slotID, itemstack);
|
||||
|
||||
if(itemstack != null && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -52,7 +53,7 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple
|
||||
{
|
||||
super(BlockStateMachine.MachineType.OREDICTIONIFICATOR.machineName);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
doAutoSync = false;
|
||||
}
|
||||
|
||||
@@ -71,34 +72,34 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple
|
||||
|
||||
didProcess = false;
|
||||
|
||||
if(MekanismUtils.canFunction(this) && inventory[0] != null && getValidName(inventory[0]) != null)
|
||||
if(MekanismUtils.canFunction(this) && !inventory.get(0).isEmpty() && getValidName(inventory.get(0)) != null)
|
||||
{
|
||||
ItemStack result = getResult(inventory[0]);
|
||||
ItemStack result = getResult(inventory.get(0));
|
||||
|
||||
if(result != null)
|
||||
{
|
||||
if(inventory[1] == null)
|
||||
if(inventory.get(1) == null)
|
||||
{
|
||||
inventory[0].shrink(1);
|
||||
inventory.get(0).shrink(1);
|
||||
|
||||
if(inventory[0].getCount() <= 0)
|
||||
if(inventory.get(0).getCount() <= 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
inventory.set(0, null);
|
||||
}
|
||||
|
||||
inventory[1] = result;
|
||||
inventory.set(1, result);
|
||||
didProcess = true;
|
||||
}
|
||||
else if(inventory[1].isItemEqual(result) && inventory[1].getCount() < inventory[1].getMaxStackSize())
|
||||
else if(inventory.get(1).isItemEqual(result) && inventory.get(1).getCount() < inventory.get(1).getMaxStackSize())
|
||||
{
|
||||
inventory[0].shrink(1);
|
||||
inventory.get(0).shrink(1);
|
||||
|
||||
if(inventory[0].getCount() <= 0)
|
||||
if(inventory.get(0).getCount() <= 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
inventory.set(0, null);
|
||||
}
|
||||
|
||||
inventory[1].grow(1);
|
||||
inventory.get(1).grow(1);
|
||||
didProcess = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -80,7 +81,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
@@ -180,7 +181,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
@Override
|
||||
public PressurizedInput getInput()
|
||||
{
|
||||
return new PressurizedInput(inventory[0], inputFluidTank.getFluid(), inputGasTank.getGas());
|
||||
return new PressurizedInput(inventory.get(0), inputFluidTank.getFluid(), inputGasTank.getGas());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements
|
||||
public TileEntityPersonalChest()
|
||||
{
|
||||
super("PersonalChest");
|
||||
inventory = new ItemStack[54];
|
||||
inventory = NonNullList.withSize(54, ItemStack.EMPTY);
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
||||
@Override
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem)
|
||||
if(!inventory.get(1).isEmpty() && gasTank.getNeeded() > 0 && inventory.get(1).getItem() instanceof IGasItem)
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[1], GasRegistry.getGas("oxygen"), gasTank.getNeeded());
|
||||
GasStack removed = GasTransmission.removeGas(inventory.get(1), GasRegistry.getGas("oxygen"), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -82,7 +83,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
}
|
||||
}
|
||||
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
|
||||
configComponent.getOutputs(TransmissionType.ITEM).get(2).availableSlots = new int[] {0};
|
||||
configComponent.getOutputs(TransmissionType.FLUID).get(2).availableSlots = new int[] {0};
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
|
||||
public TileEntityResistiveHeater()
|
||||
{
|
||||
super("machine.resistiveheater", "ResistiveHeater", MachineType.RESISTIVE_HEATER.baseEnergy);
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,6 +43,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -89,7 +90,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
public TileEntityRotaryCondensentrator()
|
||||
{
|
||||
super("RotaryCondensentrator", BlockStateMachine.MachineType.ROTARY_CONDENSENTRATOR.baseEnergy);
|
||||
inventory = new ItemStack[6];
|
||||
inventory = NonNullList.withSize(6, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,12 +128,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
|
||||
if(mode == 0)
|
||||
{
|
||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getStored() < gasTank.getMaxGas()))
|
||||
if(!inventory.get(1).isEmpty() && (gasTank.getGas() == null || gasTank.getStored() < gasTank.getMaxGas()))
|
||||
{
|
||||
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
gasTank.receive(GasTransmission.removeGas(inventory.get(1), gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[2]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(2)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemFill(this, fluidTank, 2, 3);
|
||||
}
|
||||
@@ -157,9 +158,9 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
}
|
||||
else if(mode == 1)
|
||||
{
|
||||
if(inventory[0] != null && gasTank.getGas() != null)
|
||||
if(!inventory.get(0).isEmpty() && gasTank.getGas() != null)
|
||||
{
|
||||
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
|
||||
gasTank.draw(GasTransmission.addGas(inventory.get(0), gasTank.getGas()), true);
|
||||
}
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
@@ -168,7 +169,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
gasTank.draw(GasTransmission.emit(toSend, this, ListUtils.asList(MekanismUtils.getLeft(facing))), true);
|
||||
}
|
||||
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[2]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(2)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 2, 3);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import mekanism.common.security.SecurityFrequency;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -35,7 +36,7 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements
|
||||
{
|
||||
super("SecurityDesk");
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,40 +46,40 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements
|
||||
{
|
||||
if(owner != null && frequency != null)
|
||||
{
|
||||
if(inventory[0] != null && inventory[0].getItem() instanceof IOwnerItem)
|
||||
if(!inventory.get(0).isEmpty() && inventory.get(0).getItem() instanceof IOwnerItem)
|
||||
{
|
||||
IOwnerItem item = (IOwnerItem)inventory[0].getItem();
|
||||
IOwnerItem item = (IOwnerItem)inventory.get(0).getItem();
|
||||
|
||||
if(item.hasOwner(inventory[0]) && item.getOwner(inventory[0]) != null)
|
||||
if(item.hasOwner(inventory.get(0)) && item.getOwner(inventory.get(0)) != null)
|
||||
{
|
||||
if(item.getOwner(inventory[0]).equals(owner))
|
||||
if(item.getOwner(inventory.get(0)).equals(owner))
|
||||
{
|
||||
item.setOwner(inventory[0], null);
|
||||
item.setOwner(inventory.get(0), null);
|
||||
|
||||
if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory[0]))
|
||||
if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory.get(0)))
|
||||
{
|
||||
((ISecurityItem)item).setSecurity(inventory[0], SecurityMode.PUBLIC);
|
||||
((ISecurityItem)item).setSecurity(inventory.get(0), SecurityMode.PUBLIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(inventory[1] != null && inventory[1].getItem() instanceof IOwnerItem)
|
||||
if(!inventory.get(1).isEmpty() && inventory.get(1).getItem() instanceof IOwnerItem)
|
||||
{
|
||||
IOwnerItem item = (IOwnerItem)inventory[1].getItem();
|
||||
IOwnerItem item = (IOwnerItem)inventory.get(1).getItem();
|
||||
|
||||
if(item.hasOwner(inventory[1]))
|
||||
if(item.hasOwner(inventory.get(1)))
|
||||
{
|
||||
if(item.getOwner(inventory[1]) == null)
|
||||
if(item.getOwner(inventory.get(1)) == null)
|
||||
{
|
||||
item.setOwner(inventory[1], owner);
|
||||
item.setOwner(inventory.get(1), owner);
|
||||
}
|
||||
|
||||
if(item.getOwner(inventory[1]).equals(owner))
|
||||
if(item.getOwner(inventory.get(1)).equals(owner))
|
||||
{
|
||||
if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory[1]))
|
||||
if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory.get(1)))
|
||||
{
|
||||
((ISecurityItem)item).setSecurity(inventory[1], frequency.securityMode);
|
||||
((ISecurityItem)item).setSecurity(inventory.get(1), frequency.securityMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -45,7 +46,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement
|
||||
{
|
||||
super("SeismicVibrator", BlockStateMachine.MachineType.SEISMIC_VIBRATOR.baseEnergy);
|
||||
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.biome.BiomeDesert;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -73,7 +74,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
{
|
||||
super("SolarNeutronActivator");
|
||||
upgradeComponent.setSupported(Upgrade.ENERGY, false);
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,14 +103,14 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
}
|
||||
}
|
||||
|
||||
if(inventory[0] != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas()))
|
||||
if(inventory.get(0) != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas()))
|
||||
{
|
||||
inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true);
|
||||
inputTank.receive(GasTransmission.removeGas(inventory.get(0), inputTank.getGasType(), inputTank.getNeeded()), true);
|
||||
}
|
||||
|
||||
if(inventory[1] != null && outputTank.getGas() != null)
|
||||
if(inventory.get(1) != null && outputTank.getGas() != null)
|
||||
{
|
||||
outputTank.draw(GasTransmission.addGas(inventory[1], outputTank.getGas()), true);
|
||||
outputTank.draw(GasTransmission.addGas(inventory.get(1), outputTank.getGas()), true);
|
||||
}
|
||||
|
||||
SolarNeutronRecipe recipe = getRecipe();
|
||||
|
||||
@@ -48,6 +48,7 @@ import net.minecraft.network.play.server.SPacketSetExperience;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
@@ -88,7 +89,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
public TileEntityTeleporter()
|
||||
{
|
||||
super("Teleporter", BlockStateMachine.MachineType.TELEPORTER.baseEnergy);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
chunkLoaderComponent = new TileComponentChunkLoader(this);
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock implements IComputerIntegration
|
||||
{
|
||||
@@ -20,14 +21,14 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock
|
||||
{
|
||||
super("ThermalEvaporationBlock");
|
||||
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public TileEntityThermalEvaporationBlock(String fullName)
|
||||
{
|
||||
super(fullName);
|
||||
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -85,7 +86,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva
|
||||
{
|
||||
super("ThermalEvaporationController");
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,7 +233,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva
|
||||
{
|
||||
if(outputTank.getFluid() != null)
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[2]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(2)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemFill(this, outputTank, 2, 3);
|
||||
}
|
||||
@@ -240,7 +241,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva
|
||||
|
||||
if(structured)
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
FluidContainerUtils.handleContainerItemEmpty(this, inputTank, 0, 1, new FluidChecker() {
|
||||
@Override
|
||||
|
||||
@@ -60,9 +60,9 @@ public class TileComponentUpgrade implements ITileComponent
|
||||
{
|
||||
if(!tileEntity.getWorld().isRemote)
|
||||
{
|
||||
if(tileEntity.inventory[upgradeSlot] != null && tileEntity.inventory[upgradeSlot].getItem() instanceof IUpgradeItem)
|
||||
if(!tileEntity.inventory.get(upgradeSlot).isEmpty() && tileEntity.inventory.get(upgradeSlot).getItem() instanceof IUpgradeItem)
|
||||
{
|
||||
Upgrade type = ((IUpgradeItem)tileEntity.inventory[upgradeSlot].getItem()).getUpgradeType(tileEntity.inventory[upgradeSlot]);
|
||||
Upgrade type = ((IUpgradeItem)tileEntity.inventory.get(upgradeSlot).getItem()).getUpgradeType(tileEntity.inventory.get(upgradeSlot));
|
||||
|
||||
if(supports(type) && getUpgrades(type) < type.getMax())
|
||||
{
|
||||
@@ -75,12 +75,7 @@ public class TileComponentUpgrade implements ITileComponent
|
||||
upgradeTicks = 0;
|
||||
addUpgrade(type);
|
||||
|
||||
tileEntity.inventory[upgradeSlot].shrink(1);
|
||||
|
||||
if(tileEntity.inventory[upgradeSlot].getCount() == 0)
|
||||
{
|
||||
tileEntity.inventory[upgradeSlot] = null;
|
||||
}
|
||||
tileEntity.inventory.get(upgradeSlot).shrink(1);
|
||||
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(tileEntity)));
|
||||
tileEntity.markDirty();
|
||||
|
||||
@@ -4,6 +4,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
@@ -16,7 +17,7 @@ public final class FluidContainerUtils
|
||||
{
|
||||
public static boolean isFluidContainer(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
|
||||
return !stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
|
||||
}
|
||||
|
||||
public static FluidStack extractFluid(FluidTank tileTank, ItemStack container)
|
||||
@@ -68,41 +69,31 @@ public final class FluidContainerUtils
|
||||
tank.setFluid(handleContainerItemFill(tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot));
|
||||
}
|
||||
|
||||
public static FluidStack handleContainerItemFill(TileEntity tileEntity, ItemStack[] inventory, FluidStack stack, int inSlot, int outSlot)
|
||||
public static FluidStack handleContainerItemFill(TileEntity tileEntity, NonNullList<ItemStack> inventory, FluidStack stack, int inSlot, int outSlot)
|
||||
{
|
||||
if(stack != null)
|
||||
{
|
||||
ItemStack inputCopy = StackUtils.size(inventory[inSlot].copy(), 1);
|
||||
ItemStack inputCopy = StackUtils.size(inventory.get(inSlot).copy(), 1);
|
||||
|
||||
int drained = insertFluid(stack, inputCopy);
|
||||
|
||||
if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].getCount() == inventory[outSlot].getMaxStackSize()))
|
||||
if(!inventory.get(outSlot).isEmpty() && (!ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) || inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize()))
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
stack.amount -= drained;
|
||||
|
||||
if(inventory[outSlot] == null)
|
||||
if(inventory.get(outSlot).isEmpty())
|
||||
{
|
||||
inventory[outSlot] = inputCopy;
|
||||
inventory.set(outSlot, inputCopy);
|
||||
}
|
||||
else if(ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy))
|
||||
else if(ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy))
|
||||
{
|
||||
inventory[outSlot].grow(1);
|
||||
inventory.get(outSlot).grow(1);
|
||||
}
|
||||
|
||||
inventory[inSlot].shrink(1);
|
||||
|
||||
if(inventory[inSlot].getCount() == 0)
|
||||
{
|
||||
inventory[inSlot] = null;
|
||||
}
|
||||
|
||||
if(stack.amount == 0)
|
||||
{
|
||||
stack = null;
|
||||
}
|
||||
inventory.get(inSlot).shrink(1);
|
||||
|
||||
tileEntity.markDirty();
|
||||
}
|
||||
@@ -120,10 +111,10 @@ public final class FluidContainerUtils
|
||||
tank.setFluid(handleContainerItemEmpty(tileEntity, tileEntity.inventory, tank.getFluid(), tank.getCapacity()-tank.getFluidAmount(), inSlot, outSlot, checker));
|
||||
}
|
||||
|
||||
public static FluidStack handleContainerItemEmpty(TileEntity tileEntity, ItemStack[] inventory, FluidStack stored, int needed, int inSlot, int outSlot, final FluidChecker checker)
|
||||
public static FluidStack handleContainerItemEmpty(TileEntity tileEntity, NonNullList<ItemStack> inventory, FluidStack stored, int needed, int inSlot, int outSlot, final FluidChecker checker)
|
||||
{
|
||||
final Fluid storedFinal = stored != null ? stored.getFluid() : null;
|
||||
final ItemStack input = StackUtils.size(inventory[inSlot].copy(), 1);
|
||||
final ItemStack input = StackUtils.size(inventory.get(inSlot).copy(), 1);
|
||||
|
||||
FluidStack ret = extractFluid(needed, input, new FluidChecker() {
|
||||
@Override
|
||||
@@ -135,14 +126,9 @@ public final class FluidContainerUtils
|
||||
|
||||
ItemStack inputCopy = input.copy();
|
||||
|
||||
if(inputCopy.getCount() == 0)
|
||||
if(FluidUtil.getFluidContained(inputCopy) == null && !inputCopy.isEmpty())
|
||||
{
|
||||
inputCopy = null;
|
||||
}
|
||||
|
||||
if(FluidUtil.getFluidContained(inputCopy) == null && inputCopy != null)
|
||||
{
|
||||
if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].getCount() == inventory[outSlot].getMaxStackSize()))
|
||||
if(!inventory.get(outSlot).isEmpty() && (!ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) || inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize()))
|
||||
{
|
||||
return stored;
|
||||
}
|
||||
@@ -165,29 +151,24 @@ public final class FluidContainerUtils
|
||||
|
||||
if(FluidUtil.getFluidContained(inputCopy) == null || needed == 0)
|
||||
{
|
||||
if(inputCopy != null)
|
||||
if(!inputCopy.isEmpty())
|
||||
{
|
||||
if(inventory[outSlot] == null)
|
||||
if(inventory.get(outSlot).isEmpty())
|
||||
{
|
||||
inventory[outSlot] = inputCopy;
|
||||
inventory.set(outSlot, inputCopy);
|
||||
}
|
||||
else if(ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy))
|
||||
else if(ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy))
|
||||
{
|
||||
inventory[outSlot].grow(1);
|
||||
inventory.get(outSlot).grow(1);
|
||||
}
|
||||
}
|
||||
|
||||
inventory[inSlot].shrink(1);
|
||||
|
||||
if(inventory[inSlot].getCount() == 0)
|
||||
{
|
||||
inventory[inSlot] = null;
|
||||
}
|
||||
inventory.get(inSlot).shrink(1);
|
||||
|
||||
tileEntity.markDirty();
|
||||
}
|
||||
else {
|
||||
inventory[inSlot] = inputCopy;
|
||||
inventory.set(inSlot, inputCopy);
|
||||
}
|
||||
|
||||
return stored;
|
||||
@@ -203,9 +184,9 @@ public final class FluidContainerUtils
|
||||
tank.setFluid(handleContainerItem(tileEntity, tileEntity.inventory, editMode, tank.getFluid(), tank.getCapacity()-tank.getFluidAmount(), inSlot, outSlot, checker));
|
||||
}
|
||||
|
||||
public static FluidStack handleContainerItem(TileEntity tileEntity, ItemStack[] inventory, ContainerEditMode editMode, FluidStack stack, int needed, int inSlot, int outSlot, final FluidChecker checker)
|
||||
public static FluidStack handleContainerItem(TileEntity tileEntity, NonNullList<ItemStack> inventory, ContainerEditMode editMode, FluidStack stack, int needed, int inSlot, int outSlot, final FluidChecker checker)
|
||||
{
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(inventory[inSlot]);
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(inventory.get(inSlot));
|
||||
|
||||
if(editMode == ContainerEditMode.FILL || (editMode == ContainerEditMode.BOTH && fluidStack == null))
|
||||
{
|
||||
|
||||
@@ -232,6 +232,11 @@ public final class InventoryUtils
|
||||
|
||||
public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot)
|
||||
{
|
||||
if(toInsert.isEmpty() || inSlot.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return inSlot.isItemEqual(toInsert) && ItemStack.areItemStackTagsEqual(inSlot, toInsert);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -92,9 +93,9 @@ public class FusionReactor implements IFusionReactor
|
||||
{
|
||||
if(controller != null)
|
||||
{
|
||||
ItemStack hohlraum = controller.inventory[0];
|
||||
ItemStack hohlraum = controller.inventory.get(0);
|
||||
|
||||
if(hohlraum != null && hohlraum.getItem() instanceof ItemHohlraum)
|
||||
if(!hohlraum.isEmpty() && hohlraum.getItem() instanceof ItemHohlraum)
|
||||
{
|
||||
GasStack gasStack = ((ItemHohlraum)hohlraum.getItem()).getGas(hohlraum);
|
||||
return gasStack != null && gasStack.getGas() == GasRegistry.getGas("fusionFuelDT") && gasStack.amount == ItemHohlraum.MAX_GAS;
|
||||
@@ -163,10 +164,10 @@ public class FusionReactor implements IFusionReactor
|
||||
|
||||
public void vaporiseHohlraum()
|
||||
{
|
||||
getFuelTank().receive(((ItemHohlraum)controller.inventory[0].getItem()).getGas(controller.inventory[0]), true);
|
||||
getFuelTank().receive(((ItemHohlraum)controller.inventory.get(0).getItem()).getGas(controller.inventory.get(0)), true);
|
||||
lastPlasmaTemperature = plasmaTemperature;
|
||||
|
||||
controller.inventory[0] = null;
|
||||
controller.inventory.set(0, ItemStack.EMPTY);
|
||||
|
||||
burning = true;
|
||||
}
|
||||
@@ -627,7 +628,7 @@ public class FusionReactor implements IFusionReactor
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return isFormed() ? controller.inventory : null;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -34,7 +35,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
public TileEntityBioGenerator()
|
||||
{
|
||||
super("bio", "BioGenerator", 160000, generators.bioGeneration*2);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,33 +43,28 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(inventory[0] != null)
|
||||
if(!inventory.get(0).isEmpty())
|
||||
{
|
||||
ChargeUtils.charge(1, this);
|
||||
|
||||
FluidStack fluid = FluidUtil.getFluidContained(inventory[0]);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(inventory.get(0));
|
||||
|
||||
if(fluid != null && FluidRegistry.isFluidRegistered("bioethanol"))
|
||||
{
|
||||
if(fluid.getFluid() == FluidRegistry.getFluid("bioethanol"))
|
||||
{
|
||||
IFluidHandler handler = FluidUtil.getFluidHandler(inventory[0]);
|
||||
IFluidHandler handler = FluidUtil.getFluidHandler(inventory.get(0));
|
||||
FluidStack drained = handler.drain(bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored, true);
|
||||
|
||||
if(drained != null)
|
||||
{
|
||||
bioFuelSlot.fluidStored += drained.amount;
|
||||
|
||||
if(inventory[0].getCount() == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int fuel = getFuel(inventory[0]);
|
||||
ItemStack prevStack = inventory[0].copy();
|
||||
int fuel = getFuel(inventory.get(0));
|
||||
ItemStack prevStack = inventory.get(0).copy();
|
||||
|
||||
if(fuel > 0)
|
||||
{
|
||||
@@ -78,17 +74,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
{
|
||||
bioFuelSlot.fluidStored += fuel;
|
||||
|
||||
if(inventory[0].getItem().getContainerItem(inventory[0]) != null)
|
||||
if(inventory.get(0).getItem().getContainerItem(inventory.get(0)) != null)
|
||||
{
|
||||
inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
|
||||
inventory.set(0, inventory.get(0).getItem().getContainerItem(inventory.get(0)));
|
||||
}
|
||||
else {
|
||||
inventory[0].shrink(1);
|
||||
}
|
||||
|
||||
if(inventory[0].getCount() == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
inventory.get(0).shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
public TileEntityGasGenerator()
|
||||
{
|
||||
super("gas", "GasGenerator", general.FROM_H2*100, general.FROM_H2*2);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
fuelTank = new GasTank(MAX_GAS);
|
||||
}
|
||||
|
||||
@@ -56,7 +57,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
{
|
||||
ChargeUtils.charge(1, this);
|
||||
|
||||
if(inventory[0] != null && fuelTank.getStored() < MAX_GAS)
|
||||
if(!inventory.get(0).isEmpty() && fuelTank.getStored() < MAX_GAS)
|
||||
{
|
||||
Gas gasType = null;
|
||||
|
||||
@@ -64,17 +65,17 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
{
|
||||
gasType = fuelTank.getGas().getGas();
|
||||
}
|
||||
else if(inventory[0] != null && inventory[0].getItem() instanceof IGasItem)
|
||||
else if(!inventory.get(0).isEmpty() && inventory.get(0).getItem() instanceof IGasItem)
|
||||
{
|
||||
if(((IGasItem)inventory[0].getItem()).getGas(inventory[0]) != null)
|
||||
if(((IGasItem)inventory.get(0).getItem()).getGas(inventory.get(0)) != null)
|
||||
{
|
||||
gasType = ((IGasItem)inventory[0].getItem()).getGas(inventory[0]).getGas();
|
||||
gasType = ((IGasItem)inventory.get(0).getItem()).getGas(inventory.get(0)).getGas();
|
||||
}
|
||||
}
|
||||
|
||||
if(gasType != null && FuelHandler.getFuel(gasType) != null)
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[0], gasType, fuelTank.getNeeded());
|
||||
GasStack removed = GasTransmission.removeGas(inventory.get(0), gasType, fuelTank.getNeeded());
|
||||
boolean isTankEmpty = (fuelTank.getGas() == null);
|
||||
|
||||
int fuelReceived = fuelTank.receive(removed, true);
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -57,7 +58,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
public TileEntityHeatGenerator()
|
||||
{
|
||||
super("heat", "HeatGenerator", 160000, generators.heatGeneration*2);
|
||||
inventory = new ItemStack[2];
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,14 +70,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
{
|
||||
ChargeUtils.charge(1, this);
|
||||
|
||||
if(inventory[0] != null)
|
||||
if(!inventory.get(0).isEmpty())
|
||||
{
|
||||
if(FluidContainerUtils.isFluidContainer(inventory[0]))
|
||||
if(FluidContainerUtils.isFluidContainer(inventory.get(0)))
|
||||
{
|
||||
lavaTank.fill(FluidContainerUtils.extractFluid(lavaTank, inventory[0], FluidChecker.check(FluidRegistry.LAVA)), true);
|
||||
lavaTank.fill(FluidContainerUtils.extractFluid(lavaTank, inventory.get(0), FluidChecker.check(FluidRegistry.LAVA)), true);
|
||||
}
|
||||
else {
|
||||
int fuel = getFuel(inventory[0]);
|
||||
int fuel = getFuel(inventory.get(0));
|
||||
|
||||
if(fuel > 0)
|
||||
{
|
||||
@@ -86,17 +87,12 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
{
|
||||
lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true);
|
||||
|
||||
if(inventory[0].getItem().getContainerItem(inventory[0]) != null)
|
||||
if(inventory.get(0).getItem().getContainerItem(inventory.get(0)) != null)
|
||||
{
|
||||
inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
|
||||
inventory.set(0, inventory.get(0).getItem().getContainerItem(inventory.get(0)));
|
||||
}
|
||||
else {
|
||||
inventory[0].shrink(1);
|
||||
}
|
||||
|
||||
if(inventory[0].getCount() == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
inventory.get(0).shrink(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import micdoodle8.mods.galacticraft.api.world.ISolarLevel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.biome.BiomeDesert;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -33,7 +34,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
|
||||
public TileEntitySolarGenerator(String name, double maxEnergy, double output)
|
||||
{
|
||||
super("solar", name, maxEnergy, output);
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -27,7 +28,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
public TileEntityWindGenerator()
|
||||
{
|
||||
super("wind", "WindGenerator", 200000, (generators.windGenerationMax)*2);
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.reactor.IReactorBlock;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class TileEntityReactorBlock extends TileEntityElectricBlock implements IReactorBlock
|
||||
{
|
||||
@@ -22,7 +23,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp
|
||||
public TileEntityReactorBlock()
|
||||
{
|
||||
super("ReactorBlock", 0);
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public TileEntityReactorBlock(String name, double maxEnergy)
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import net.minecraft.client.audio.ISound.AttenuationType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -60,7 +61,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
|
||||
public TileEntityReactorController()
|
||||
{
|
||||
super("ReactorController", 1000000000);
|
||||
inventory = new ItemStack[1];
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -54,7 +55,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
|
||||
{
|
||||
super("name", 1);
|
||||
|
||||
inventory = new ItemStack[0];
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -380,7 +381,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
return getReactor() != null && getReactor().isFormed() ? getReactor().getInventory()[slotID] : null;
|
||||
return getReactor() != null && getReactor().isFormed() ? getReactor().getInventory().get(slotID) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -394,7 +395,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
|
||||
{
|
||||
if(getReactor() != null && getReactor().isFormed())
|
||||
{
|
||||
getReactor().getInventory()[slotID] = itemstack;
|
||||
getReactor().getInventory().set(slotID, itemstack);
|
||||
|
||||
if(itemstack != null && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user