Get rid of ItemGroup
This commit is contained in:
@@ -5,7 +5,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
|||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.container.ContainerController;
|
import refinedstorage.container.ContainerController;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
import refinedstorage.tile.controller.ClientSideMachine;
|
import refinedstorage.tile.controller.ClientMachine;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -71,13 +71,13 @@ public class GuiController extends GuiBase {
|
|||||||
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
|
||||||
List<ClientSideMachine> machines = controller.getClientSideMachines();
|
List<ClientMachine> machines = controller.getClientMachines();
|
||||||
|
|
||||||
ClientSideMachine machineHovering = null;
|
ClientMachine machineHovering = null;
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
if (slot < machines.size()) {
|
if (slot < machines.size()) {
|
||||||
ClientSideMachine machine = machines.get(slot);
|
ClientMachine machine = machines.get(slot);
|
||||||
|
|
||||||
drawItem(x, y + 5, machine.stack);
|
drawItem(x, y + 5, machine.stack);
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class GuiController extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getRows() {
|
private int getRows() {
|
||||||
int max = (int) Math.ceil((float) controller.getClientSideMachines().size() / (float) 2);
|
int max = (int) Math.ceil((float) controller.getClientMachines().size() / (float) 2);
|
||||||
|
|
||||||
return max < 0 ? 0 : max;
|
return max < 0 ? 0 : max;
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ import refinedstorage.network.GridPullFlags;
|
|||||||
import refinedstorage.network.MessageGridCraftingClear;
|
import refinedstorage.network.MessageGridCraftingClear;
|
||||||
import refinedstorage.network.MessageGridCraftingPush;
|
import refinedstorage.network.MessageGridCraftingPush;
|
||||||
import refinedstorage.network.MessageGridPatternCreate;
|
import refinedstorage.network.MessageGridPatternCreate;
|
||||||
import refinedstorage.storage.ClientItemGroup;
|
import refinedstorage.storage.ClientItem;
|
||||||
import refinedstorage.tile.grid.IGrid;
|
import refinedstorage.tile.grid.IGrid;
|
||||||
import refinedstorage.tile.grid.TileGrid;
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
import refinedstorage.tile.grid.WirelessGrid;
|
import refinedstorage.tile.grid.WirelessGrid;
|
||||||
@@ -31,9 +31,9 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class GuiGrid extends GuiBase {
|
public class GuiGrid extends GuiBase {
|
||||||
private Comparator<ClientItemGroup> quantityComparator = new Comparator<ClientItemGroup>() {
|
private Comparator<ClientItem> quantityComparator = new Comparator<ClientItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ClientItemGroup left, ClientItemGroup right) {
|
public int compare(ClientItem left, ClientItem right) {
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
return Integer.valueOf(left.getStack().stackSize).compareTo(right.getStack().stackSize);
|
return Integer.valueOf(left.getStack().stackSize).compareTo(right.getStack().stackSize);
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
@@ -44,9 +44,9 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Comparator<ClientItemGroup> nameComparator = new Comparator<ClientItemGroup>() {
|
private Comparator<ClientItem> nameComparator = new Comparator<ClientItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ClientItemGroup left, ClientItemGroup right) {
|
public int compare(ClientItem left, ClientItem right) {
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
return left.getStack().getDisplayName().compareTo(right.getStack().getDisplayName());
|
return left.getStack().getDisplayName().compareTo(right.getStack().getDisplayName());
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
@@ -60,7 +60,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
private ContainerGrid container;
|
private ContainerGrid container;
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
|
|
||||||
private List<ClientItemGroup> items = new ArrayList<ClientItemGroup>();
|
private List<ClientItem> items = new ArrayList<ClientItem>();
|
||||||
|
|
||||||
private GuiTextField searchField;
|
private GuiTextField searchField;
|
||||||
|
|
||||||
@@ -119,15 +119,15 @@ public class GuiGrid extends GuiBase {
|
|||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
if (grid.isConnected()) {
|
if (grid.isConnected()) {
|
||||||
items.addAll(grid.getItemGroups());
|
items.addAll(grid.getItems());
|
||||||
|
|
||||||
if (!searchField.getText().trim().isEmpty()) {
|
if (!searchField.getText().trim().isEmpty()) {
|
||||||
Iterator<ClientItemGroup> t = items.iterator();
|
Iterator<ClientItem> t = items.iterator();
|
||||||
|
|
||||||
while (t.hasNext()) {
|
while (t.hasNext()) {
|
||||||
ClientItemGroup group = t.next();
|
ClientItem item = t.next();
|
||||||
|
|
||||||
if (!group.getStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
if (!item.getStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
import refinedstorage.container.ContainerGrid;
|
import refinedstorage.container.ContainerGrid;
|
||||||
import refinedstorage.storage.ClientItemGroup;
|
import refinedstorage.storage.ClientItem;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MessageGridItems implements IMessage, IMessageHandler<MessageGridItems, IMessage> {
|
public class MessageGridItems implements IMessage, IMessageHandler<MessageGridItems, IMessage> {
|
||||||
private TileController controller;
|
private TileController controller;
|
||||||
private List<ClientItemGroup> groups = new ArrayList<ClientItemGroup>();
|
private List<ClientItem> items = new ArrayList<ClientItem>();
|
||||||
|
|
||||||
public MessageGridItems() {
|
public MessageGridItems() {
|
||||||
}
|
}
|
||||||
@@ -28,23 +28,25 @@ public class MessageGridItems implements IMessage, IMessageHandler<MessageGridIt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
int size = buf.readInt();
|
int items = buf.readInt();
|
||||||
|
|
||||||
|
for (int i = 0; i < items; ++i) {
|
||||||
|
int size = buf.readInt();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
int quantity = buf.readInt();
|
|
||||||
ItemStack stack = ByteBufUtils.readItemStack(buf);
|
ItemStack stack = ByteBufUtils.readItemStack(buf);
|
||||||
stack.stackSize = quantity;
|
stack.stackSize = size;
|
||||||
groups.add(new ClientItemGroup(i, stack));
|
|
||||||
|
this.items.add(new ClientItem(i, stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
buf.writeInt(controller.getItemGroups().size());
|
buf.writeInt(controller.getItems().size());
|
||||||
|
|
||||||
for (int i = 0; i < controller.getItemGroups().size(); ++i) {
|
for (ItemStack item : controller.getItems()) {
|
||||||
buf.writeInt(controller.getItemGroups().get(i).getQuantity());
|
buf.writeInt(item.stackSize);
|
||||||
ByteBufUtils.writeItemStack(buf, controller.getItemGroups().get(i).toStack());
|
ByteBufUtils.writeItemStack(buf, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ public class MessageGridItems implements IMessage, IMessageHandler<MessageGridIt
|
|||||||
Container container = Minecraft.getMinecraft().thePlayer.openContainer;
|
Container container = Minecraft.getMinecraft().thePlayer.openContainer;
|
||||||
|
|
||||||
if (container instanceof ContainerGrid) {
|
if (container instanceof ContainerGrid) {
|
||||||
((ContainerGrid) container).getGrid().setItemGroups(message.groups);
|
((ContainerGrid) container).getGrid().setItems(message.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@@ -2,11 +2,11 @@ package refinedstorage.storage;
|
|||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public final class ClientItemGroup {
|
public final class ClientItem {
|
||||||
private int id;
|
private int id;
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
|
|
||||||
public ClientItemGroup(int id, ItemStack stack) {
|
public ClientItem(int id, ItemStack stack) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
}
|
}
|
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface IStorage {
|
public interface IStorage {
|
||||||
void addItems(List<ItemGroup> items);
|
void addItems(List<ItemStack> items);
|
||||||
|
|
||||||
void push(ItemStack stack);
|
void push(ItemStack stack);
|
||||||
|
|
||||||
|
@@ -1,140 +0,0 @@
|
|||||||
package refinedstorage.storage;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import refinedstorage.RefinedStorageUtils;
|
|
||||||
|
|
||||||
public final class ItemGroup {
|
|
||||||
private Item type;
|
|
||||||
private int quantity;
|
|
||||||
private int damage;
|
|
||||||
private NBTTagCompound tag;
|
|
||||||
|
|
||||||
public ItemGroup(Item type, int quantity, int damage, NBTTagCompound tag) {
|
|
||||||
this.type = type;
|
|
||||||
this.quantity = quantity;
|
|
||||||
this.damage = damage;
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemGroup(ItemStack stack) {
|
|
||||||
this(stack.getItem(), stack.stackSize, stack.getItemDamage(), stack.getTagCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getQuantity() {
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuantity(int quantity) {
|
|
||||||
this.quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(Item type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDamage() {
|
|
||||||
return damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDamage(int damage) {
|
|
||||||
this.damage = damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasTag() {
|
|
||||||
return tag != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NBTTagCompound getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTag(NBTTagCompound tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean compare(ItemGroup other, int flags) {
|
|
||||||
if (type != other.getType()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_QUANTITY) == RefinedStorageUtils.COMPARE_QUANTITY && quantity != other.getQuantity()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_DAMAGE) == RefinedStorageUtils.COMPARE_DAMAGE && damage != other.getDamage()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_NBT) == RefinedStorageUtils.COMPARE_NBT) {
|
|
||||||
if ((tag != null && other.getTag() == null) || (tag == null && other.getTag() != null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag != null && other.getTag() != null) {
|
|
||||||
if (!tag.equals(other.getTag())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean compare(ItemStack stack, int flags) {
|
|
||||||
if (type != stack.getItem()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_QUANTITY) == RefinedStorageUtils.COMPARE_QUANTITY && quantity != stack.stackSize) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_DAMAGE) == RefinedStorageUtils.COMPARE_DAMAGE && damage != stack.getItemDamage()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & RefinedStorageUtils.COMPARE_NBT) == RefinedStorageUtils.COMPARE_NBT) {
|
|
||||||
if ((tag != null && stack.getTagCompound() == null) || (tag == null && stack.getTagCompound() != null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag != null && stack.getTagCompound() != null) {
|
|
||||||
if (!tag.equals(stack.getTagCompound())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean compareNoQuantity(ItemGroup other) {
|
|
||||||
return compare(other, RefinedStorageUtils.COMPARE_NBT | RefinedStorageUtils.COMPARE_DAMAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean compareNoQuantity(ItemStack stack) {
|
|
||||||
return compare(stack, RefinedStorageUtils.COMPARE_NBT | RefinedStorageUtils.COMPARE_DAMAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemGroup copy() {
|
|
||||||
return copy(quantity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemGroup copy(int newQuantity) {
|
|
||||||
return new ItemGroup(type, newQuantity, damage, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack toStack() {
|
|
||||||
ItemStack stack = new ItemStack(type, quantity, damage);
|
|
||||||
|
|
||||||
stack.setTagCompound(tag);
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -4,6 +4,8 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
import refinedstorage.RefinedStorageUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,7 +24,7 @@ public abstract class NBTStorage implements IStorage {
|
|||||||
|
|
||||||
private boolean dirty;
|
private boolean dirty;
|
||||||
|
|
||||||
private List<ItemGroup> groups = new ArrayList<ItemGroup>();
|
private List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
public NBTStorage(NBTTagCompound tag, int capacity) {
|
public NBTStorage(NBTTagCompound tag, int capacity) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
@@ -37,29 +39,30 @@ public abstract class NBTStorage implements IStorage {
|
|||||||
for (int i = 0; i < list.tagCount(); ++i) {
|
for (int i = 0; i < list.tagCount(); ++i) {
|
||||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||||
|
|
||||||
ItemGroup group = new ItemGroup(
|
ItemStack stack = new ItemStack(
|
||||||
Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)),
|
Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)),
|
||||||
tag.getInteger(NBT_ITEM_QUANTITY),
|
tag.getInteger(NBT_ITEM_QUANTITY),
|
||||||
tag.getInteger(NBT_ITEM_DAMAGE),
|
tag.getInteger(NBT_ITEM_DAMAGE)
|
||||||
tag.hasKey(NBT_ITEM_NBT) ? ((NBTTagCompound) tag.getTag(NBT_ITEM_NBT)) : null
|
|
||||||
);
|
);
|
||||||
|
|
||||||
groups.add(group);
|
stack.setTagCompound(tag.hasKey(NBT_ITEM_NBT) ? ((NBTTagCompound) tag.getTag(NBT_ITEM_NBT)) : null);
|
||||||
|
|
||||||
|
stacks.add(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag) {
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
for (ItemGroup group : groups) {
|
for (ItemStack stack : stacks) {
|
||||||
NBTTagCompound itemTag = new NBTTagCompound();
|
NBTTagCompound itemTag = new NBTTagCompound();
|
||||||
|
|
||||||
itemTag.setInteger(NBT_ITEM_TYPE, Item.getIdFromItem(group.getType()));
|
itemTag.setInteger(NBT_ITEM_TYPE, Item.getIdFromItem(stack.getItem()));
|
||||||
itemTag.setInteger(NBT_ITEM_QUANTITY, group.getQuantity());
|
itemTag.setInteger(NBT_ITEM_QUANTITY, stack.stackSize);
|
||||||
itemTag.setInteger(NBT_ITEM_DAMAGE, group.getDamage());
|
itemTag.setInteger(NBT_ITEM_DAMAGE, stack.getItemDamage());
|
||||||
|
|
||||||
if (group.hasTag()) {
|
if (stack.hasTagCompound()) {
|
||||||
itemTag.setTag(NBT_ITEM_NBT, group.getTag());
|
itemTag.setTag(NBT_ITEM_NBT, stack.getTagCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
list.appendTag(itemTag);
|
list.appendTag(itemTag);
|
||||||
@@ -69,17 +72,17 @@ public abstract class NBTStorage implements IStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addItems(List<ItemGroup> items) {
|
public void addItems(List<ItemStack> items) {
|
||||||
items.addAll(groups);
|
items.addAll(stacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(ItemStack stack) {
|
public void push(ItemStack stack) {
|
||||||
tag.setInteger(NBT_STORED, getStored(tag) + stack.stackSize);
|
tag.setInteger(NBT_STORED, getStored(tag) + stack.stackSize);
|
||||||
|
|
||||||
for (ItemGroup group : groups) {
|
for (ItemStack s : stacks) {
|
||||||
if (group.compareNoQuantity(stack)) {
|
if (RefinedStorageUtils.compareStackNoQuantity(s, stack)) {
|
||||||
group.setQuantity(group.getQuantity() + stack.stackSize);
|
s.stackSize += stack.stackSize;
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
@@ -87,35 +90,32 @@ public abstract class NBTStorage implements IStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
groups.add(new ItemGroup(stack));
|
stacks.add(stack);
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack take(ItemStack stack, int flags) {
|
public ItemStack take(ItemStack stack, int flags) {
|
||||||
int quantity = stack.stackSize;
|
int size = stack.stackSize;
|
||||||
|
|
||||||
for (ItemGroup group : groups) {
|
for (ItemStack s : stacks) {
|
||||||
if (group.compare(stack, flags)) {
|
if (RefinedStorageUtils.compareStack(s, stack, flags)) {
|
||||||
if (quantity > group.getQuantity()) {
|
if (size > s.stackSize) {
|
||||||
quantity = group.getQuantity();
|
size = s.stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group.getQuantity() - quantity == 0) {
|
if (s.stackSize - size == 0) {
|
||||||
groups.remove(group);
|
stacks.remove(s);
|
||||||
} else {
|
} else {
|
||||||
group.setQuantity(group.getQuantity() - quantity);
|
s.stackSize -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setInteger(NBT_STORED, getStored(tag) - quantity);
|
tag.setInteger(NBT_STORED, getStored(tag) - size);
|
||||||
|
|
||||||
ItemStack result = group.toStack();
|
|
||||||
result.stackSize = quantity;
|
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
return result;
|
return ItemHandlerHelper.copyStackWithSize(s, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,6 @@ import refinedstorage.RefinedStorageBlocks;
|
|||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.container.ContainerDetector;
|
import refinedstorage.container.ContainerDetector;
|
||||||
import refinedstorage.inventory.BasicItemHandler;
|
import refinedstorage.inventory.BasicItemHandler;
|
||||||
import refinedstorage.storage.ItemGroup;
|
|
||||||
import refinedstorage.tile.config.ICompareConfig;
|
import refinedstorage.tile.config.ICompareConfig;
|
||||||
import refinedstorage.tile.config.RedstoneMode;
|
import refinedstorage.tile.config.RedstoneMode;
|
||||||
|
|
||||||
@@ -54,19 +53,19 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
|||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
boolean foundAny = false;
|
boolean foundAny = false;
|
||||||
|
|
||||||
for (ItemGroup group : controller.getItemGroups()) {
|
for (ItemStack stack : controller.getItems()) {
|
||||||
if (group.compare(slot, compare)) {
|
if (RefinedStorageUtils.compareStack(slot, stack, compare)) {
|
||||||
foundAny = true;
|
foundAny = true;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_UNDER:
|
case MODE_UNDER:
|
||||||
powered = group.getQuantity() < amount;
|
powered = stack.stackSize < amount;
|
||||||
break;
|
break;
|
||||||
case MODE_EQUAL:
|
case MODE_EQUAL:
|
||||||
powered = group.getQuantity() == amount;
|
powered = stack.stackSize == amount;
|
||||||
break;
|
break;
|
||||||
case MODE_ABOVE:
|
case MODE_ABOVE:
|
||||||
powered = group.getQuantity() > amount;
|
powered = stack.stackSize > amount;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +98,6 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
|||||||
return powered;
|
return powered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowered(boolean powered) {
|
|
||||||
this.powered = powered;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCompare() {
|
public int getCompare() {
|
||||||
return compare;
|
return compare;
|
||||||
|
@@ -15,7 +15,6 @@ import refinedstorage.network.MessagePriorityUpdate;
|
|||||||
import refinedstorage.storage.IStorage;
|
import refinedstorage.storage.IStorage;
|
||||||
import refinedstorage.storage.IStorageGui;
|
import refinedstorage.storage.IStorageGui;
|
||||||
import refinedstorage.storage.IStorageProvider;
|
import refinedstorage.storage.IStorageProvider;
|
||||||
import refinedstorage.storage.ItemGroup;
|
|
||||||
import refinedstorage.tile.config.*;
|
import refinedstorage.tile.config.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -43,12 +42,12 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addItems(List<ItemGroup> items) {
|
public void addItems(List<ItemStack> items) {
|
||||||
IDeepStorageUnit storageUnit = getStorageUnit();
|
IDeepStorageUnit storageUnit = getStorageUnit();
|
||||||
|
|
||||||
if (storageUnit != null) {
|
if (storageUnit != null) {
|
||||||
if (storageUnit.getStoredItemType() != null) {
|
if (storageUnit.getStoredItemType() != null) {
|
||||||
items.add(new ItemGroup(storageUnit.getStoredItemType().copy()));
|
items.add(storageUnit.getStoredItemType().copy());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IItemHandler handler = getItemHandler();
|
IItemHandler handler = getItemHandler();
|
||||||
@@ -56,7 +55,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
if (handler.getStackInSlot(i) != null) {
|
if (handler.getStackInSlot(i) != null) {
|
||||||
items.add(new ItemGroup(handler.getStackInSlot(i).copy()));
|
items.add(handler.getStackInSlot(i).copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ package refinedstorage.tile.controller;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
|
|
||||||
public class ClientSideMachine {
|
public class ClientMachine {
|
||||||
public ItemStack stack;
|
public ItemStack stack;
|
||||||
public int amount;
|
public int amount;
|
||||||
public int energyUsage;
|
public int energyUsage;
|
||||||
@@ -14,11 +14,11 @@ public class ClientSideMachine {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(other instanceof ClientSideMachine)) {
|
if (!(other instanceof ClientMachine)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return energyUsage == ((ClientSideMachine) other).energyUsage && RefinedStorageUtils.compareStack(stack, ((ClientSideMachine) other).stack);
|
return energyUsage == ((ClientMachine) other).energyUsage && RefinedStorageUtils.compareStack(stack, ((ClientMachine) other).stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@@ -2,10 +2,10 @@ package refinedstorage.tile.controller;
|
|||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.item.ItemWirelessGrid;
|
import refinedstorage.item.ItemWirelessGrid;
|
||||||
import refinedstorage.network.GridPullFlags;
|
import refinedstorage.network.GridPullFlags;
|
||||||
import refinedstorage.storage.ItemGroup;
|
|
||||||
import refinedstorage.tile.autocrafting.CraftingPattern;
|
import refinedstorage.tile.autocrafting.CraftingPattern;
|
||||||
import refinedstorage.tile.autocrafting.task.ICraftingTask;
|
import refinedstorage.tile.autocrafting.task.ICraftingTask;
|
||||||
|
|
||||||
@@ -23,31 +23,31 @@ public class StorageHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id < 0 || id > controller.getItemGroups().size() - 1) {
|
if (id < 0 || id > controller.getItems().size() - 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemGroup group = controller.getItemGroups().get(id);
|
ItemStack stack = controller.getItems().get(id);
|
||||||
|
|
||||||
int quantity = 64;
|
int size = 64;
|
||||||
|
|
||||||
if (GridPullFlags.isPullingHalf(flags) && group.getQuantity() > 1) {
|
if (GridPullFlags.isPullingHalf(flags) && stack.stackSize > 1) {
|
||||||
quantity = group.getQuantity() / 2;
|
size = stack.stackSize / 2;
|
||||||
|
|
||||||
if (quantity > 32) {
|
if (size > 32) {
|
||||||
quantity = 32;
|
size = 32;
|
||||||
}
|
}
|
||||||
} else if (GridPullFlags.isPullingOne(flags)) {
|
} else if (GridPullFlags.isPullingOne(flags)) {
|
||||||
quantity = 1;
|
size = 1;
|
||||||
} else if (GridPullFlags.isPullingWithShift(flags)) {
|
} else if (GridPullFlags.isPullingWithShift(flags)) {
|
||||||
// NO OP, the quantity already set (64) is needed for shift
|
// NO OP, the quantity already set (64) is needed for shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quantity > group.getType().getItemStackLimit(group.toStack())) {
|
if (size > stack.getItem().getItemStackLimit(stack)) {
|
||||||
quantity = group.getType().getItemStackLimit(group.toStack());
|
size = stack.getItem().getItemStackLimit(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack took = controller.take(group.copy(quantity).toStack());
|
ItemStack took = controller.take(ItemHandlerHelper.copyStackWithSize(stack, size));
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
if (GridPullFlags.isPullingWithShift(flags)) {
|
if (GridPullFlags.isPullingWithShift(flags)) {
|
||||||
@@ -102,9 +102,11 @@ public class StorageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleCraftingRequest(int id, int quantity) {
|
public void handleCraftingRequest(int id, int quantity) {
|
||||||
if (id >= 0 && id < controller.getItemGroups().size() && quantity > 0 && quantity <= MAX_CRAFTING_PER_REQUEST) {
|
if (id >= 0 && id < controller.getItems().size() && quantity > 0 && quantity <= MAX_CRAFTING_PER_REQUEST) {
|
||||||
ItemStack requested = controller.getItemGroups().get(id).toStack();
|
ItemStack requested = controller.getItems().get(id);
|
||||||
|
|
||||||
int quantityPerRequest = 0;
|
int quantityPerRequest = 0;
|
||||||
|
|
||||||
CraftingPattern pattern = controller.getPattern(requested);
|
CraftingPattern pattern = controller.getPattern(requested);
|
||||||
|
|
||||||
if (pattern != null) {
|
if (pattern != null) {
|
||||||
|
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagList;
|
|||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.RefinedStorageBlocks;
|
import refinedstorage.RefinedStorageBlocks;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
@@ -24,7 +25,6 @@ import refinedstorage.item.ItemPattern;
|
|||||||
import refinedstorage.network.MessageGridItems;
|
import refinedstorage.network.MessageGridItems;
|
||||||
import refinedstorage.storage.IStorage;
|
import refinedstorage.storage.IStorage;
|
||||||
import refinedstorage.storage.IStorageProvider;
|
import refinedstorage.storage.IStorageProvider;
|
||||||
import refinedstorage.storage.ItemGroup;
|
|
||||||
import refinedstorage.tile.ISynchronizedContainer;
|
import refinedstorage.tile.ISynchronizedContainer;
|
||||||
import refinedstorage.tile.TileBase;
|
import refinedstorage.tile.TileBase;
|
||||||
import refinedstorage.tile.TileMachine;
|
import refinedstorage.tile.TileMachine;
|
||||||
@@ -50,20 +50,19 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
private StorageHandler storageHandler = new StorageHandler(this);
|
private StorageHandler storageHandler = new StorageHandler(this);
|
||||||
private WirelessGridHandler wirelessGridHandler = new WirelessGridHandler(this);
|
private WirelessGridHandler wirelessGridHandler = new WirelessGridHandler(this);
|
||||||
|
|
||||||
private List<ItemGroup> itemGroups = new ArrayList<ItemGroup>();
|
private List<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
|
private List<ItemStack> combinedItems = new ArrayList<ItemStack>();
|
||||||
|
private Set<Integer> combinedItemsIndices = new HashSet<Integer>();
|
||||||
|
|
||||||
private List<IStorage> storages = new ArrayList<IStorage>();
|
private List<IStorage> storages = new ArrayList<IStorage>();
|
||||||
|
|
||||||
private Set<Integer> combinedGroupsIndices = new HashSet<Integer>();
|
|
||||||
private List<ItemGroup> combinedGroups = new ArrayList<ItemGroup>();
|
|
||||||
|
|
||||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||||
|
|
||||||
private List<TileMachine> machines = new ArrayList<TileMachine>();
|
private List<TileMachine> machines = new ArrayList<TileMachine>();
|
||||||
private List<TileMachine> machinesToAdd = new ArrayList<TileMachine>();
|
private List<TileMachine> machinesToAdd = new ArrayList<TileMachine>();
|
||||||
private List<TileMachine> machinesToRemove = new ArrayList<TileMachine>();
|
private List<TileMachine> machinesToRemove = new ArrayList<TileMachine>();
|
||||||
|
|
||||||
private List<ClientSideMachine> clientSideMachines = new ArrayList<ClientSideMachine>();
|
private List<ClientMachine> clientMachines = new ArrayList<ClientMachine>();
|
||||||
|
|
||||||
private List<CraftingPattern> patterns = new ArrayList<CraftingPattern>();
|
private List<CraftingPattern> patterns = new ArrayList<CraftingPattern>();
|
||||||
|
|
||||||
@@ -76,9 +75,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
private int energyUsage;
|
private int energyUsage;
|
||||||
|
|
||||||
private int wirelessGridRange;
|
private int wirelessGridRange;
|
||||||
|
|
||||||
private boolean couldRun;
|
private boolean couldRun;
|
||||||
|
|
||||||
private long lastEnergyUpdate;
|
private long lastEnergyUpdate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -198,8 +195,8 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
machines.clear();
|
machines.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemGroup> getItemGroups() {
|
public List<ItemStack> getItems() {
|
||||||
return itemGroups;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ICraftingTask> getCraftingTasks() {
|
public List<ICraftingTask> getCraftingTasks() {
|
||||||
@@ -302,55 +299,53 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncItems() {
|
private void syncItems() {
|
||||||
itemGroups.clear();
|
items.clear();
|
||||||
|
|
||||||
for (IStorage storage : storages) {
|
for (IStorage storage : storages) {
|
||||||
storage.addItems(itemGroups);
|
storage.addItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CraftingPattern pattern : patterns) {
|
for (CraftingPattern pattern : patterns) {
|
||||||
for (ItemStack output : pattern.getOutputs()) {
|
for (ItemStack output : pattern.getOutputs()) {
|
||||||
ItemGroup patternGroup = new ItemGroup(output);
|
items.add(ItemHandlerHelper.copyStackWithSize(output, 0));
|
||||||
patternGroup.setQuantity(0);
|
|
||||||
itemGroups.add(patternGroup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
combinedGroups.clear();
|
combinedItems.clear();
|
||||||
combinedGroupsIndices.clear();
|
combinedItemsIndices.clear();
|
||||||
|
|
||||||
for (int i = 0; i < itemGroups.size(); ++i) {
|
for (int i = 0; i < items.size(); ++i) {
|
||||||
if (combinedGroupsIndices.contains(i)) {
|
if (combinedItemsIndices.contains(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemGroup group = itemGroups.get(i);
|
ItemStack stack = items.get(i);
|
||||||
|
|
||||||
// If the item doesn't exist anymore, remove it from storage to avoid crashes
|
// If the item doesn't exist anymore, remove it from storage to avoid crashes
|
||||||
if (group.getType() == null) {
|
if (stack.getItem() == null) {
|
||||||
combinedGroups.add(group);
|
combinedItems.add(stack);
|
||||||
combinedGroupsIndices.add(i);
|
combinedItemsIndices.add(i);
|
||||||
} else {
|
} else {
|
||||||
for (int j = i + 1; j < itemGroups.size(); ++j) {
|
for (int j = i + 1; j < items.size(); ++j) {
|
||||||
if (combinedGroupsIndices.contains(j)) {
|
if (combinedItemsIndices.contains(j)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemGroup otherGroup = itemGroups.get(j);
|
ItemStack otherStack = items.get(j);
|
||||||
|
|
||||||
if (group.compareNoQuantity(otherGroup)) {
|
if (RefinedStorageUtils.compareStackNoQuantity(stack, otherStack)) {
|
||||||
// We copy here so we don't modify the quantity of the item group IStorage uses.
|
// We copy here so we don't modify the quantity of the ItemStack IStorage uses.
|
||||||
// We re-get the itemgroup with .get(i) because the group may change from a previous iteration in this for loop.
|
// We re-get the ItemStack because the stack may change from a previous iteration in this loop
|
||||||
itemGroups.set(i, itemGroups.get(i).copy(itemGroups.get(i).getQuantity() + otherGroup.getQuantity()));
|
items.set(i, ItemHandlerHelper.copyStackWithSize(items.get(i), items.get(i).stackSize + otherStack.stackSize));
|
||||||
|
|
||||||
combinedGroups.add(otherGroup);
|
combinedItems.add(otherStack);
|
||||||
combinedGroupsIndices.add(j);
|
combinedItemsIndices.add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemGroups.removeAll(combinedGroups);
|
items.removeAll(combinedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncItemsWithClients() {
|
public void syncItemsWithClients() {
|
||||||
@@ -544,8 +539,8 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientSideMachine> getClientSideMachines() {
|
public List<ClientMachine> getClientMachines() {
|
||||||
return clientSideMachines;
|
return clientMachines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -557,12 +552,12 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
|
|
||||||
machines.clear();
|
machines.clear();
|
||||||
|
|
||||||
List<ClientSideMachine> machines = new ArrayList<ClientSideMachine>();
|
List<ClientMachine> machines = new ArrayList<ClientMachine>();
|
||||||
|
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
ClientSideMachine machine = new ClientSideMachine();
|
ClientMachine machine = new ClientMachine();
|
||||||
machine.energyUsage = buf.readInt();
|
machine.energyUsage = buf.readInt();
|
||||||
machine.amount = buf.readInt();
|
machine.amount = buf.readInt();
|
||||||
machine.stack = ByteBufUtils.readItemStack(buf);
|
machine.stack = ByteBufUtils.readItemStack(buf);
|
||||||
@@ -570,7 +565,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
machines.add(machine);
|
machines.add(machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
clientSideMachines = machines;
|
clientMachines = machines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -580,20 +575,20 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
|
|
||||||
buf.writeInt(redstoneMode.id);
|
buf.writeInt(redstoneMode.id);
|
||||||
|
|
||||||
List<ClientSideMachine> m = new ArrayList<ClientSideMachine>();
|
List<ClientMachine> m = new ArrayList<ClientMachine>();
|
||||||
|
|
||||||
for (TileMachine machine : machines) {
|
for (TileMachine machine : machines) {
|
||||||
if (machine.mayUpdate()) {
|
if (machine.mayUpdate()) {
|
||||||
IBlockState state = worldObj.getBlockState(machine.getPos());
|
IBlockState state = worldObj.getBlockState(machine.getPos());
|
||||||
|
|
||||||
ClientSideMachine clientMachine = new ClientSideMachine();
|
ClientMachine clientMachine = new ClientMachine();
|
||||||
|
|
||||||
clientMachine.energyUsage = machine.getEnergyUsage();
|
clientMachine.energyUsage = machine.getEnergyUsage();
|
||||||
clientMachine.amount = 1;
|
clientMachine.amount = 1;
|
||||||
clientMachine.stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
|
clientMachine.stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
|
||||||
|
|
||||||
if (m.contains(clientMachine)) {
|
if (m.contains(clientMachine)) {
|
||||||
for (ClientSideMachine other : m) {
|
for (ClientMachine other : m) {
|
||||||
if (other.equals(clientMachine)) {
|
if (other.equals(clientMachine)) {
|
||||||
other.amount++;
|
other.amount++;
|
||||||
break;
|
break;
|
||||||
@@ -607,7 +602,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
|
|
||||||
buf.writeInt(m.size());
|
buf.writeInt(m.size());
|
||||||
|
|
||||||
for (ClientSideMachine machine : m) {
|
for (ClientMachine machine : m) {
|
||||||
buf.writeInt(machine.energyUsage);
|
buf.writeInt(machine.energyUsage);
|
||||||
buf.writeInt(machine.amount);
|
buf.writeInt(machine.amount);
|
||||||
ByteBufUtils.writeItemStack(buf, machine.stack);
|
ByteBufUtils.writeItemStack(buf, machine.stack);
|
||||||
|
@@ -2,7 +2,7 @@ package refinedstorage.tile.grid;
|
|||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import refinedstorage.block.EnumGridType;
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.storage.ClientItemGroup;
|
import refinedstorage.storage.ClientItem;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -10,9 +10,9 @@ import java.util.List;
|
|||||||
public interface IGrid {
|
public interface IGrid {
|
||||||
EnumGridType getType();
|
EnumGridType getType();
|
||||||
|
|
||||||
List<ClientItemGroup> getItemGroups();
|
List<ClientItem> getItems();
|
||||||
|
|
||||||
void setItemGroups(List<ClientItemGroup> groups);
|
void setItems(List<ClientItem> items);
|
||||||
|
|
||||||
BlockPos getControllerPos();
|
BlockPos getControllerPos();
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import refinedstorage.network.MessageGridCraftingStart;
|
|||||||
import refinedstorage.network.MessageGridSettingsUpdate;
|
import refinedstorage.network.MessageGridSettingsUpdate;
|
||||||
import refinedstorage.network.MessageGridStoragePull;
|
import refinedstorage.network.MessageGridStoragePull;
|
||||||
import refinedstorage.network.MessageGridStoragePush;
|
import refinedstorage.network.MessageGridStoragePush;
|
||||||
import refinedstorage.storage.ClientItemGroup;
|
import refinedstorage.storage.ClientItem;
|
||||||
import refinedstorage.tile.TileMachine;
|
import refinedstorage.tile.TileMachine;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
|||||||
private int sortingType = SORTING_TYPE_NAME;
|
private int sortingType = SORTING_TYPE_NAME;
|
||||||
private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
|
private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
|
||||||
|
|
||||||
private List<ClientItemGroup> itemGroups = new ArrayList<ClientItemGroup>();
|
private List<ClientItem> items = new ArrayList<ClientItem>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
@@ -89,13 +89,13 @@ public class TileGrid extends TileMachine implements IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientItemGroup> getItemGroups() {
|
public List<ClientItem> getItems() {
|
||||||
return itemGroups;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemGroups(List<ClientItemGroup> itemGroups) {
|
public void setItems(List<ClientItem> items) {
|
||||||
this.itemGroups = itemGroups;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -13,7 +13,7 @@ import refinedstorage.network.MessageWirelessGridCraftingStart;
|
|||||||
import refinedstorage.network.MessageWirelessGridSettingsUpdate;
|
import refinedstorage.network.MessageWirelessGridSettingsUpdate;
|
||||||
import refinedstorage.network.MessageWirelessGridStoragePull;
|
import refinedstorage.network.MessageWirelessGridStoragePull;
|
||||||
import refinedstorage.network.MessageWirelessGridStoragePush;
|
import refinedstorage.network.MessageWirelessGridStoragePush;
|
||||||
import refinedstorage.storage.ClientItemGroup;
|
import refinedstorage.storage.ClientItem;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
private int sortingType;
|
private int sortingType;
|
||||||
private int sortingDirection;
|
private int sortingDirection;
|
||||||
private int searchBoxMode;
|
private int searchBoxMode;
|
||||||
private List<ClientItemGroup> itemGroups = new ArrayList<ClientItemGroup>();
|
private static List<ClientItem> items = new ArrayList<ClientItem>();
|
||||||
private long lastUpdate;
|
private long lastUpdate;
|
||||||
|
|
||||||
public WirelessGrid(ItemStack stack, EnumHand hand) {
|
public WirelessGrid(ItemStack stack, EnumHand hand) {
|
||||||
@@ -43,13 +43,13 @@ public class WirelessGrid implements IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientItemGroup> getItemGroups() {
|
public List<ClientItem> getItems() {
|
||||||
return itemGroups;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemGroups(List<ClientItemGroup> groups) {
|
public void setItems(List<ClientItem> items) {
|
||||||
this.itemGroups = groups;
|
this.items = items;
|
||||||
this.lastUpdate = System.currentTimeMillis();
|
this.lastUpdate = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user