Grid optimizations
This commit is contained in:
@@ -7,6 +7,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
@@ -21,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.ItemGroup;
|
import refinedstorage.storage.ClientItemGroup;
|
||||||
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;
|
||||||
@@ -30,15 +31,41 @@ 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>() {
|
||||||
|
@Override
|
||||||
|
public int compare(ClientItemGroup left, ClientItemGroup right) {
|
||||||
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
|
return Integer.valueOf(right.getStack().stackSize).compareTo(left.getStack().stackSize);
|
||||||
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
|
return Integer.valueOf(left.getStack().stackSize).compareTo(right.getStack().stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private Comparator<ClientItemGroup> nameComparator = new Comparator<ClientItemGroup>() {
|
||||||
|
@Override
|
||||||
|
public int compare(ClientItemGroup left, ClientItemGroup right) {
|
||||||
|
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||||
|
return right.getStack().getDisplayName().compareTo(left.getStack().getDisplayName());
|
||||||
|
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||||
|
return left.getStack().getDisplayName().compareTo(right.getStack().getDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private ContainerGrid container;
|
private ContainerGrid container;
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
|
|
||||||
private List<ItemGroup> items = new ArrayList<ItemGroup>();
|
private List<ClientItemGroup> items = new ArrayList<ClientItemGroup>();
|
||||||
|
|
||||||
private GuiTextField searchField;
|
private GuiTextField searchField;
|
||||||
|
|
||||||
private int hoveringSlot;
|
private int slotNumber;
|
||||||
private int hoveringItemId;
|
private int slotId;
|
||||||
|
|
||||||
private Scrollbar scrollbar;
|
private Scrollbar scrollbar;
|
||||||
|
|
||||||
@@ -95,43 +122,21 @@ public class GuiGrid extends GuiBase {
|
|||||||
items.addAll(grid.getItemGroups());
|
items.addAll(grid.getItemGroups());
|
||||||
|
|
||||||
if (!searchField.getText().trim().isEmpty()) {
|
if (!searchField.getText().trim().isEmpty()) {
|
||||||
Iterator<ItemGroup> t = items.iterator();
|
Iterator<ClientItemGroup> t = items.iterator();
|
||||||
|
|
||||||
while (t.hasNext()) {
|
while (t.hasNext()) {
|
||||||
ItemGroup group = t.next();
|
ClientItemGroup group = t.next();
|
||||||
|
|
||||||
if (!group.toCachedStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
if (!group.getStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(items, new Comparator<ItemGroup>() {
|
Collections.sort(items, nameComparator);
|
||||||
@Override
|
|
||||||
public int compare(ItemGroup left, ItemGroup right) {
|
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
|
||||||
return right.toCachedStack().getDisplayName().compareTo(left.toCachedStack().getDisplayName());
|
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
|
||||||
return left.toCachedStack().getDisplayName().compareTo(right.toCachedStack().getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
||||||
Collections.sort(items, new Comparator<ItemGroup>() {
|
Collections.sort(items, quantityComparator);
|
||||||
@Override
|
|
||||||
public int compare(ItemGroup left, ItemGroup right) {
|
|
||||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
|
||||||
return Integer.valueOf(right.getQuantity()).compareTo(left.getQuantity());
|
|
||||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
|
||||||
return Integer.valueOf(left.getQuantity()).compareTo(right.getQuantity());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,11 +155,11 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHoveringOverItemInSlot() {
|
private boolean isHoveringOverItemInSlot() {
|
||||||
return grid.isConnected() && isHoveringOverSlot() && hoveringSlot < items.size();
|
return grid.isConnected() && isHoveringOverSlot() && slotNumber < items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHoveringOverSlot() {
|
private boolean isHoveringOverSlot() {
|
||||||
return hoveringSlot >= 0;
|
return slotNumber >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHoveringOverClear(int mouseX, int mouseY) {
|
public boolean isHoveringOverClear(int mouseX, int mouseY) {
|
||||||
@@ -221,7 +226,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
int x = 8;
|
int x = 8;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
this.hoveringSlot = -1;
|
this.slotNumber = -1;
|
||||||
|
|
||||||
int slot = getOffset() * 9;
|
int slot = getOffset() * 9;
|
||||||
|
|
||||||
@@ -229,37 +234,17 @@ public class GuiGrid extends GuiBase {
|
|||||||
|
|
||||||
for (int i = 0; i < 9 * getVisibleRows(); ++i) {
|
for (int i = 0; i < 9 * getVisibleRows(); ++i) {
|
||||||
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
||||||
this.hoveringSlot = slot;
|
this.slotNumber = slot;
|
||||||
|
|
||||||
if (slot < items.size()) {
|
if (slot < items.size()) {
|
||||||
// we need to use the ID, because if we filter, the client-side index will change
|
slotId = items.get(slot).getId();
|
||||||
// while the server-side's index will still be the same.
|
|
||||||
this.hoveringItemId = items.get(slot).getId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot < items.size()) {
|
if (slot < items.size()) {
|
||||||
int qty = items.get(slot).getQuantity();
|
ItemStack stack = items.get(slot).getStack();
|
||||||
|
|
||||||
String text;
|
drawItem(x, y, stack, true, formatQuantity(stack.stackSize));
|
||||||
|
|
||||||
if (qty >= 1000000) {
|
|
||||||
text = String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M";
|
|
||||||
} else if (qty >= 1000) {
|
|
||||||
text = String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K";
|
|
||||||
} else if (qty == 1) {
|
|
||||||
text = null;
|
|
||||||
} else if (qty == 0) {
|
|
||||||
text = t("gui.refinedstorage:grid.craft");
|
|
||||||
} else {
|
|
||||||
text = String.valueOf(qty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hoveringSlot == slot && GuiScreen.isShiftKeyDown() && qty > 1) {
|
|
||||||
text = String.valueOf(qty);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawItem(x, y, items.get(slot).toCachedStack(), true, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
||||||
@@ -287,7 +272,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isHoveringOverItemInSlot()) {
|
if (isHoveringOverItemInSlot()) {
|
||||||
drawTooltip(mouseX, mouseY, items.get(hoveringSlot).toCachedStack());
|
drawTooltip(mouseX, mouseY, items.get(slotNumber).getStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHoveringOverClear(mouseX, mouseY)) {
|
if (isHoveringOverClear(mouseX, mouseY)) {
|
||||||
@@ -299,6 +284,20 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatQuantity(int qty) {
|
||||||
|
if (qty >= 1000000) {
|
||||||
|
return String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M";
|
||||||
|
} else if (qty >= 1000) {
|
||||||
|
return String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K";
|
||||||
|
} else if (qty == 1) {
|
||||||
|
return null;
|
||||||
|
} else if (qty == 0) {
|
||||||
|
return t("gui.refinedstorage:grid.craft");
|
||||||
|
} else {
|
||||||
|
return String.valueOf(qty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
||||||
super.mouseClicked(mouseX, mouseY, clickedButton);
|
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
@@ -316,8 +315,8 @@ public class GuiGrid extends GuiBase {
|
|||||||
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
|
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
|
||||||
grid.onItemPush(-1, clickedButton == 1);
|
grid.onItemPush(-1, clickedButton == 1);
|
||||||
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
||||||
if (items.get(hoveringSlot).getQuantity() == 0 || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown())) {
|
if (items.get(slotNumber).getStack().stackSize == 0 || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown())) {
|
||||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingSettings(this, hoveringItemId));
|
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingSettings(this, slotId));
|
||||||
} else {
|
} else {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
@@ -333,7 +332,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
flags |= GridPullFlags.PULL_ONE;
|
flags |= GridPullFlags.PULL_ONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.onItemPull(hoveringItemId, flags);
|
grid.onItemPull(slotId, flags);
|
||||||
}
|
}
|
||||||
} else if (clickedClear) {
|
} else if (clickedClear) {
|
||||||
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
||||||
|
@@ -17,9 +17,9 @@ public class MessageCompareUpdate extends MessageHandlerPlayerToServer<MessageCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MessageCompareUpdate(ICompareConfig setting, int compare) {
|
public MessageCompareUpdate(ICompareConfig setting, int compare) {
|
||||||
this.x = setting.getMachinePos().getX();
|
this.x = ((TileEntity) setting).getPos().getX();
|
||||||
this.y = setting.getMachinePos().getY();
|
this.y = ((TileEntity) setting).getPos().getY();
|
||||||
this.z = setting.getMachinePos().getZ();
|
this.z = ((TileEntity) setting).getPos().getZ();
|
||||||
this.compare = compare;
|
this.compare = compare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,10 +3,13 @@ package refinedstorage.network;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
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.ItemGroup;
|
import refinedstorage.storage.ItemGroup;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
@@ -15,7 +18,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<ItemGroup> groups = new ArrayList<ItemGroup>();
|
private List<ClientItemGroup> groups = new ArrayList<ClientItemGroup>();
|
||||||
|
|
||||||
public MessageGridItems() {
|
public MessageGridItems() {
|
||||||
}
|
}
|
||||||
@@ -29,7 +32,14 @@ public class MessageGridItems implements IMessage, IMessageHandler<MessageGridIt
|
|||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
groups.add(new ItemGroup(buf));
|
int id = buf.readInt();
|
||||||
|
|
||||||
|
int quantity = buf.readInt();
|
||||||
|
|
||||||
|
ItemStack stack = ByteBufUtils.readItemStack(buf);
|
||||||
|
stack.stackSize = quantity;
|
||||||
|
|
||||||
|
groups.add(new ClientItemGroup(id, stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +48,9 @@ public class MessageGridItems implements IMessage, IMessageHandler<MessageGridIt
|
|||||||
buf.writeInt(controller.getItemGroups().size());
|
buf.writeInt(controller.getItemGroups().size());
|
||||||
|
|
||||||
for (int i = 0; i < controller.getItemGroups().size(); ++i) {
|
for (int i = 0; i < controller.getItemGroups().size(); ++i) {
|
||||||
controller.getItemGroups().get(i).toBytes(buf, i);
|
buf.writeInt(i);
|
||||||
|
buf.writeInt(controller.getItemGroups().get(i).getQuantity());
|
||||||
|
ByteBufUtils.writeItemStack(buf, controller.getItemGroups().get(i).toStack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,9 +17,9 @@ public class MessageModeToggle extends MessageHandlerPlayerToServer<MessageModeT
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MessageModeToggle(IModeConfig mode) {
|
public MessageModeToggle(IModeConfig mode) {
|
||||||
this.x = mode.getMachinePos().getX();
|
this.x = ((TileEntity) mode).getPos().getX();
|
||||||
this.y = mode.getMachinePos().getY();
|
this.y = ((TileEntity) mode).getPos().getY();
|
||||||
this.z = mode.getMachinePos().getZ();
|
this.z = ((TileEntity) mode).getPos().getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,9 +16,9 @@ public class MessageRedstoneModeUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MessageRedstoneModeUpdate(IRedstoneModeConfig setting) {
|
public MessageRedstoneModeUpdate(IRedstoneModeConfig setting) {
|
||||||
this.x = setting.getMachinePos().getX();
|
this.x = ((TileEntity) setting).getPos().getX();
|
||||||
this.y = setting.getMachinePos().getY();
|
this.y = ((TileEntity) setting).getPos().getY();
|
||||||
this.z = setting.getMachinePos().getZ();
|
this.z = ((TileEntity) setting).getPos().getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
21
src/main/java/refinedstorage/storage/ClientItemGroup.java
Executable file
21
src/main/java/refinedstorage/storage/ClientItemGroup.java
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
package refinedstorage.storage;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public final class ClientItemGroup {
|
||||||
|
private int id;
|
||||||
|
private ItemStack stack;
|
||||||
|
|
||||||
|
public ClientItemGroup(int id, ItemStack stack) {
|
||||||
|
this.id = id;
|
||||||
|
this.stack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
@@ -7,22 +7,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
|
|
||||||
public class ItemGroup {
|
public final class ItemGroup {
|
||||||
private Item type;
|
private Item type;
|
||||||
private int quantity;
|
private int quantity;
|
||||||
private int damage;
|
private int damage;
|
||||||
private NBTTagCompound tag;
|
private NBTTagCompound tag;
|
||||||
// Used clientside
|
|
||||||
private int id;
|
|
||||||
private ItemStack cachedStack;
|
|
||||||
|
|
||||||
public ItemGroup(ByteBuf buf) {
|
|
||||||
this.id = buf.readInt();
|
|
||||||
this.type = Item.getItemById(buf.readInt());
|
|
||||||
this.quantity = buf.readInt();
|
|
||||||
this.damage = buf.readInt();
|
|
||||||
this.tag = buf.readBoolean() ? ByteBufUtils.readTag(buf) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemGroup(Item type, int quantity, int damage, NBTTagCompound tag) {
|
public ItemGroup(Item type, int quantity, int damage, NBTTagCompound tag) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -35,18 +24,6 @@ public class ItemGroup {
|
|||||||
this(stack.getItem(), stack.stackSize, stack.getItemDamage(), stack.getTagCompound());
|
this(stack.getItem(), stack.stackSize, stack.getItemDamage(), stack.getTagCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toBytes(ByteBuf buf, int id) {
|
|
||||||
buf.writeInt(id);
|
|
||||||
buf.writeInt(Item.getIdFromItem(type));
|
|
||||||
buf.writeInt(quantity);
|
|
||||||
buf.writeInt(damage);
|
|
||||||
buf.writeBoolean(hasTag());
|
|
||||||
|
|
||||||
if (hasTag()) {
|
|
||||||
ByteBufUtils.writeTag(buf, tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getQuantity() {
|
public int getQuantity() {
|
||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
@@ -147,10 +124,6 @@ public class ItemGroup {
|
|||||||
return compare(stack, RefinedStorageUtils.COMPARE_NBT | RefinedStorageUtils.COMPARE_DAMAGE);
|
return compare(stack, RefinedStorageUtils.COMPARE_NBT | RefinedStorageUtils.COMPARE_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemGroup copy() {
|
public ItemGroup copy() {
|
||||||
return copy(quantity);
|
return copy(quantity);
|
||||||
}
|
}
|
||||||
@@ -166,12 +139,4 @@ public class ItemGroup {
|
|||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack toCachedStack() {
|
|
||||||
if (cachedStack == null) {
|
|
||||||
cachedStack = toStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
return cachedStack;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -131,11 +131,6 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
|||||||
this.redstoneMode = mode;
|
this.redstoneMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockPos getMachinePos() {
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readContainerData(ByteBuf buf) {
|
public void readContainerData(ByteBuf buf) {
|
||||||
redstoneMode = RedstoneMode.getById(buf.readInt());
|
redstoneMode = RedstoneMode.getById(buf.readInt());
|
||||||
|
@@ -6,6 +6,4 @@ public interface ICompareConfig {
|
|||||||
int getCompare();
|
int getCompare();
|
||||||
|
|
||||||
void setCompare(int compare);
|
void setCompare(int compare);
|
||||||
|
|
||||||
BlockPos getMachinePos();
|
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,4 @@ public interface IModeConfig {
|
|||||||
void setMode(int mode);
|
void setMode(int mode);
|
||||||
|
|
||||||
int getMode();
|
int getMode();
|
||||||
|
|
||||||
BlockPos getMachinePos();
|
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,4 @@ public interface IRedstoneModeConfig {
|
|||||||
RedstoneMode getRedstoneMode();
|
RedstoneMode getRedstoneMode();
|
||||||
|
|
||||||
void setRedstoneMode(RedstoneMode mode);
|
void setRedstoneMode(RedstoneMode mode);
|
||||||
|
|
||||||
BlockPos getMachinePos();
|
|
||||||
}
|
}
|
||||||
|
@@ -545,11 +545,6 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockPos getMachinePos() {
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientSideMachine> getClientSideMachines() {
|
public List<ClientSideMachine> getClientSideMachines() {
|
||||||
return clientSideMachines;
|
return clientSideMachines;
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +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.ItemGroup;
|
import refinedstorage.storage.ItemGroup;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
|
|
||||||
@@ -10,9 +11,9 @@ import java.util.List;
|
|||||||
public interface IGrid {
|
public interface IGrid {
|
||||||
EnumGridType getType();
|
EnumGridType getType();
|
||||||
|
|
||||||
List<ItemGroup> getItemGroups();
|
List<ClientItemGroup> getItemGroups();
|
||||||
|
|
||||||
void setItemGroups(List<ItemGroup> groups);
|
void setItemGroups(List<ClientItemGroup> groups);
|
||||||
|
|
||||||
BlockPos getControllerPos();
|
BlockPos getControllerPos();
|
||||||
|
|
||||||
|
@@ -24,6 +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.ItemGroup;
|
import refinedstorage.storage.ItemGroup;
|
||||||
import refinedstorage.tile.TileMachine;
|
import refinedstorage.tile.TileMachine;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
@@ -69,7 +70,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<ItemGroup> itemGroups = new ArrayList<ItemGroup>();
|
private List<ClientItemGroup> itemGroups = new ArrayList<ClientItemGroup>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
@@ -89,12 +90,12 @@ public class TileGrid extends TileMachine implements IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemGroup> getItemGroups() {
|
public List<ClientItemGroup> getItemGroups() {
|
||||||
return itemGroups;
|
return itemGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemGroups(List<ItemGroup> itemGroups) {
|
public void setItemGroups(List<ClientItemGroup> itemGroups) {
|
||||||
this.itemGroups = itemGroups;
|
this.itemGroups = itemGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,6 +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.ItemGroup;
|
import refinedstorage.storage.ItemGroup;
|
||||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
@@ -26,7 +27,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<ItemGroup> itemGroups = new ArrayList<ItemGroup>();
|
private List<ClientItemGroup> itemGroups = new ArrayList<ClientItemGroup>();
|
||||||
private long lastUpdate;
|
private long lastUpdate;
|
||||||
|
|
||||||
public WirelessGrid(ItemStack stack, EnumHand hand) {
|
public WirelessGrid(ItemStack stack, EnumHand hand) {
|
||||||
@@ -43,12 +44,12 @@ public class WirelessGrid implements IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemGroup> getItemGroups() {
|
public List<ClientItemGroup> getItemGroups() {
|
||||||
return itemGroups;
|
return itemGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemGroups(List<ItemGroup> groups) {
|
public void setItemGroups(List<ClientItemGroup> groups) {
|
||||||
this.itemGroups = groups;
|
this.itemGroups = groups;
|
||||||
this.lastUpdate = System.currentTimeMillis();
|
this.lastUpdate = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user