mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
The Great Reformat; moving to google-java-style w/ 4 space indent and 120 column line wrap
This commit is contained in:
1 parent
c632cc6af9
commit
e0b7ea62a4
933 files changed
+95734
-108818
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package mekanism.common.content.transporter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -9,106 +8,90 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public final class InvStack
|
||||
{
|
||||
public TileEntity tileEntity;
|
||||
public ArrayList<ItemStack> itemStacks;
|
||||
public ArrayList<Integer> slotIDs;
|
||||
public EnumFacing side;
|
||||
public final class InvStack {
|
||||
|
||||
public InvStack(TileEntity inv, EnumFacing facing)
|
||||
{
|
||||
tileEntity = inv;
|
||||
itemStacks = new ArrayList<>();
|
||||
slotIDs = new ArrayList<>();
|
||||
side = facing;
|
||||
}
|
||||
public TileEntity tileEntity;
|
||||
public ArrayList<ItemStack> itemStacks;
|
||||
public ArrayList<Integer> slotIDs;
|
||||
public EnumFacing side;
|
||||
|
||||
public InvStack(TileEntity inv, int id, ItemStack stack, EnumFacing facing)
|
||||
{
|
||||
tileEntity = inv;
|
||||
itemStacks = new ArrayList<>();
|
||||
slotIDs = new ArrayList<>();
|
||||
side = facing;
|
||||
public InvStack(TileEntity inv, EnumFacing facing) {
|
||||
tileEntity = inv;
|
||||
itemStacks = new ArrayList<>();
|
||||
slotIDs = new ArrayList<>();
|
||||
side = facing;
|
||||
}
|
||||
|
||||
appendStack(id, stack);
|
||||
}
|
||||
public InvStack(TileEntity inv, int id, ItemStack stack, EnumFacing facing) {
|
||||
tileEntity = inv;
|
||||
itemStacks = new ArrayList<>();
|
||||
slotIDs = new ArrayList<>();
|
||||
side = facing;
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
int size = 0;
|
||||
appendStack(id, stack);
|
||||
}
|
||||
|
||||
for(ItemStack stack : itemStacks)
|
||||
{
|
||||
size += stack.getCount();
|
||||
}
|
||||
public ItemStack getStack() {
|
||||
int size = 0;
|
||||
|
||||
if(!itemStacks.isEmpty())
|
||||
{
|
||||
ItemStack ret = itemStacks.get(0).copy();
|
||||
ret.setCount(size);
|
||||
for (ItemStack stack : itemStacks) {
|
||||
size += stack.getCount();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
if (!itemStacks.isEmpty()) {
|
||||
ItemStack ret = itemStacks.get(0).copy();
|
||||
ret.setCount(size);
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void appendStack(int id, ItemStack stack)
|
||||
{
|
||||
slotIDs.add(id);
|
||||
itemStacks.add(stack);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void use(int amount)
|
||||
{
|
||||
if(tileEntity instanceof IInventory)
|
||||
{
|
||||
IInventory inventory = InventoryUtils.checkChestInv((IInventory)tileEntity);
|
||||
|
||||
for(int i = 0; i < slotIDs.size(); i++)
|
||||
{
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
|
||||
if(inventory.getStackInSlot(slotIDs.get(i)).getCount() == stack.getCount() && stack.getCount() <= amount)
|
||||
{
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), ItemStack.EMPTY);
|
||||
amount -= stack.getCount();
|
||||
}
|
||||
else {
|
||||
ItemStack ret = stack.copy();
|
||||
ret.setCount(inventory.getStackInSlot(slotIDs.get(i)).getCount() - amount);
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), ret);
|
||||
amount -= stack.getCount();
|
||||
}
|
||||
|
||||
if(amount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(InventoryUtils.isItemHandler(tileEntity, side))
|
||||
{
|
||||
IItemHandler handler = InventoryUtils.getItemHandler(tileEntity, side);
|
||||
|
||||
for(int i = 0; i < slotIDs.size(); i++)
|
||||
{
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
int toUse = Math.min(amount, stack.getCount());
|
||||
handler.extractItem(slotIDs.get(i), toUse, false);
|
||||
amount -= toUse;
|
||||
|
||||
if(amount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void appendStack(int id, ItemStack stack) {
|
||||
slotIDs.add(id);
|
||||
itemStacks.add(stack);
|
||||
}
|
||||
|
||||
public void use()
|
||||
{
|
||||
use(getStack().getCount());
|
||||
}
|
||||
public void use(int amount) {
|
||||
if (tileEntity instanceof IInventory) {
|
||||
IInventory inventory = InventoryUtils.checkChestInv((IInventory) tileEntity);
|
||||
|
||||
for (int i = 0; i < slotIDs.size(); i++) {
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
|
||||
if (inventory.getStackInSlot(slotIDs.get(i)).getCount() == stack.getCount()
|
||||
&& stack.getCount() <= amount) {
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), ItemStack.EMPTY);
|
||||
amount -= stack.getCount();
|
||||
} else {
|
||||
ItemStack ret = stack.copy();
|
||||
ret.setCount(inventory.getStackInSlot(slotIDs.get(i)).getCount() - amount);
|
||||
inventory.setInventorySlotContents(slotIDs.get(i), ret);
|
||||
amount -= stack.getCount();
|
||||
}
|
||||
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (InventoryUtils.isItemHandler(tileEntity, side)) {
|
||||
IItemHandler handler = InventoryUtils.getItemHandler(tileEntity, side);
|
||||
|
||||
for (int i = 0; i < slotIDs.size(); i++) {
|
||||
ItemStack stack = itemStacks.get(i);
|
||||
int toUse = Math.min(amount, stack.getCount());
|
||||
handler.extractItem(slotIDs.get(i), toUse, false);
|
||||
amount -= toUse;
|
||||
|
||||
if (amount == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void use() {
|
||||
use(getStack().getCount());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user