Buggy view type toggle
This commit is contained in:
@@ -16,10 +16,7 @@ import refinedstorage.api.network.GridExtractFlags;
|
|||||||
import refinedstorage.apiimpl.storage.ClientStack;
|
import refinedstorage.apiimpl.storage.ClientStack;
|
||||||
import refinedstorage.block.EnumGridType;
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.container.ContainerGrid;
|
import refinedstorage.container.ContainerGrid;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode;
|
import refinedstorage.gui.sidebutton.*;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonGridSortingDirection;
|
|
||||||
import refinedstorage.gui.sidebutton.SideButtonGridSortingType;
|
|
||||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
|
||||||
import refinedstorage.jei.RefinedStorageJEIPlugin;
|
import refinedstorage.jei.RefinedStorageJEIPlugin;
|
||||||
import refinedstorage.network.MessageGridCraftingClear;
|
import refinedstorage.network.MessageGridCraftingClear;
|
||||||
import refinedstorage.network.MessageGridInsertHeld;
|
import refinedstorage.network.MessageGridInsertHeld;
|
||||||
@@ -105,6 +102,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
searchField.yPosition = sy;
|
searchField.yPosition = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSideButton(new SideButtonGridViewType(grid));
|
||||||
addSideButton(new SideButtonGridSortingDirection(grid));
|
addSideButton(new SideButtonGridSortingDirection(grid));
|
||||||
addSideButton(new SideButtonGridSortingType(grid));
|
addSideButton(new SideButtonGridSortingType(grid));
|
||||||
addSideButton(new SideButtonGridSearchBoxMode(this));
|
addSideButton(new SideButtonGridSearchBoxMode(this));
|
||||||
@@ -127,13 +125,32 @@ public class GuiGrid extends GuiBase {
|
|||||||
Iterator<ClientStack> t = items.iterator();
|
Iterator<ClientStack> t = items.iterator();
|
||||||
|
|
||||||
while (t.hasNext()) {
|
while (t.hasNext()) {
|
||||||
ItemStack item = t.next().getStack();
|
ClientStack stack = t.next();
|
||||||
|
|
||||||
|
switch (grid.getViewType()) {
|
||||||
|
case TileGrid.VIEW_TYPE_NORMAL:
|
||||||
|
break;
|
||||||
|
case TileGrid.VIEW_TYPE_NON_CRAFTABLES:
|
||||||
|
if (stack.isCraftable()) {
|
||||||
|
t.remove();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TileGrid.VIEW_TYPE_CRAFTABLES:
|
||||||
|
if (!stack.isCraftable()) {
|
||||||
|
t.remove();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (query.startsWith("@")) {
|
if (query.startsWith("@")) {
|
||||||
String[] parts = query.split(" ");
|
String[] parts = query.split(" ");
|
||||||
|
|
||||||
String modId = parts[0].substring(1);
|
String modId = parts[0].substring(1);
|
||||||
String modIdFromItem = Item.REGISTRY.getNameForObject(item.getItem()).getResourceDomain();
|
String modIdFromItem = Item.REGISTRY.getNameForObject(stack.getStack().getItem()).getResourceDomain();
|
||||||
|
|
||||||
if (!modIdFromItem.contains(modId)) {
|
if (!modIdFromItem.contains(modId)) {
|
||||||
t.remove();
|
t.remove();
|
||||||
@@ -148,18 +165,18 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.getDisplayName().toLowerCase().contains(itemFromMod.toString())) {
|
if (!stack.getStack().getDisplayName().toLowerCase().contains(itemFromMod.toString())) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (query.startsWith("#")) {
|
} else if (query.startsWith("#")) {
|
||||||
String tooltip = query.substring(1);
|
String tooltip = query.substring(1);
|
||||||
String tooltipFromItem = StringUtils.join(item.getTooltip(container.getPlayer(), true), "\n");
|
String tooltipFromItem = StringUtils.join(stack.getStack().getTooltip(container.getPlayer(), true), "\n");
|
||||||
|
|
||||||
if (!tooltipFromItem.contains(tooltip)) {
|
if (!tooltipFromItem.contains(tooltip)) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
} else if (!item.getDisplayName().toLowerCase().contains(query)) {
|
} else if (!stack.getStack().getDisplayName().toLowerCase().contains(query)) {
|
||||||
t.remove();
|
t.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
src/main/java/refinedstorage/gui/sidebutton/SideButtonGridViewType.java
Executable file
40
src/main/java/refinedstorage/gui/sidebutton/SideButtonGridViewType.java
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
package refinedstorage.gui.sidebutton;
|
||||||
|
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import refinedstorage.gui.GuiBase;
|
||||||
|
import refinedstorage.tile.grid.IGrid;
|
||||||
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
|
|
||||||
|
public class SideButtonGridViewType extends SideButton {
|
||||||
|
private IGrid grid;
|
||||||
|
|
||||||
|
public SideButtonGridViewType(IGrid grid) {
|
||||||
|
this.grid = grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTooltip(GuiBase gui) {
|
||||||
|
return TextFormatting.YELLOW + gui.t("sidebutton.refinedstorage:grid.view_type") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:grid.view_type." + grid.getViewType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GuiBase gui, int x, int y) {
|
||||||
|
gui.bindTexture("icons.png");
|
||||||
|
gui.drawTexture(x, y + 2 - 1, grid.getViewType() * 16, 112, 16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed() {
|
||||||
|
int type = grid.getViewType();
|
||||||
|
|
||||||
|
if (type == TileGrid.VIEW_TYPE_NORMAL) {
|
||||||
|
type = TileGrid.VIEW_TYPE_NON_CRAFTABLES;
|
||||||
|
} else if (type == TileGrid.VIEW_TYPE_NON_CRAFTABLES) {
|
||||||
|
type = TileGrid.VIEW_TYPE_CRAFTABLES;
|
||||||
|
} else if (type == TileGrid.VIEW_TYPE_CRAFTABLES) {
|
||||||
|
type = TileGrid.VIEW_TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.onViewTypeChanged(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,10 +42,6 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
|||||||
public static final int TYPE_NORMAL = 0;
|
public static final int TYPE_NORMAL = 0;
|
||||||
public static final int TYPE_CREATIVE = 1;
|
public static final int TYPE_CREATIVE = 1;
|
||||||
|
|
||||||
public static final String NBT_SORTING_TYPE = "SortingType";
|
|
||||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
|
||||||
public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
|
||||||
|
|
||||||
private static final String NBT_CONTROLLER_X = "ControllerX";
|
private static final String NBT_CONTROLLER_X = "ControllerX";
|
||||||
private static final String NBT_CONTROLLER_Y = "ControllerY";
|
private static final String NBT_CONTROLLER_Y = "ControllerY";
|
||||||
private static final String NBT_CONTROLLER_Z = "ControllerZ";
|
private static final String NBT_CONTROLLER_Z = "ControllerZ";
|
||||||
@@ -137,9 +133,10 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
|||||||
tag.setInteger(NBT_CONTROLLER_Y, pos.getY());
|
tag.setInteger(NBT_CONTROLLER_Y, pos.getY());
|
||||||
tag.setInteger(NBT_CONTROLLER_Z, pos.getZ());
|
tag.setInteger(NBT_CONTROLLER_Z, pos.getZ());
|
||||||
tag.setInteger(NBT_DIMENSION_ID, player.dimension);
|
tag.setInteger(NBT_DIMENSION_ID, player.dimension);
|
||||||
tag.setInteger(NBT_SORTING_DIRECTION, TileGrid.SORTING_DIRECTION_DESCENDING);
|
tag.setInteger(TileGrid.NBT_VIEW_TYPE, TileGrid.VIEW_TYPE_NORMAL);
|
||||||
tag.setInteger(NBT_SORTING_TYPE, TileGrid.SORTING_TYPE_NAME);
|
tag.setInteger(TileGrid.NBT_SORTING_DIRECTION, TileGrid.SORTING_DIRECTION_DESCENDING);
|
||||||
tag.setInteger(NBT_SEARCH_BOX_MODE, TileGrid.SEARCH_BOX_MODE_NORMAL);
|
tag.setInteger(TileGrid.NBT_SORTING_TYPE, TileGrid.SORTING_TYPE_NAME);
|
||||||
|
tag.setInteger(TileGrid.NBT_SEARCH_BOX_MODE, TileGrid.SEARCH_BOX_MODE_NORMAL);
|
||||||
|
|
||||||
stack.setTagCompound(tag);
|
stack.setTagCompound(tag);
|
||||||
|
|
||||||
@@ -184,16 +181,20 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
|||||||
return stack.getTagCompound().getInteger(NBT_CONTROLLER_Z);
|
return stack.getTagCompound().getInteger(NBT_CONTROLLER_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getViewType(ItemStack stack) {
|
||||||
|
return stack.getTagCompound().getInteger(TileGrid.NBT_VIEW_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getSortingType(ItemStack stack) {
|
public static int getSortingType(ItemStack stack) {
|
||||||
return stack.getTagCompound().getInteger(NBT_SORTING_TYPE);
|
return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSortingDirection(ItemStack stack) {
|
public static int getSortingDirection(ItemStack stack) {
|
||||||
return stack.getTagCompound().getInteger(NBT_SORTING_DIRECTION);
|
return stack.getTagCompound().getInteger(TileGrid.NBT_SORTING_DIRECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSearchBoxMode(ItemStack stack) {
|
public static int getSearchBoxMode(ItemStack stack) {
|
||||||
return stack.getTagCompound().getInteger(NBT_SEARCH_BOX_MODE);
|
return stack.getTagCompound().getInteger(TileGrid.NBT_SEARCH_BOX_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasValidNBT(ItemStack stack) {
|
private static boolean hasValidNBT(ItemStack stack) {
|
||||||
@@ -202,9 +203,10 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
|||||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
|
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
|
||||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Z)
|
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Z)
|
||||||
&& stack.getTagCompound().hasKey(NBT_DIMENSION_ID)
|
&& stack.getTagCompound().hasKey(NBT_DIMENSION_ID)
|
||||||
&& stack.getTagCompound().hasKey(NBT_SORTING_DIRECTION)
|
&& stack.getTagCompound().hasKey(TileGrid.NBT_VIEW_TYPE)
|
||||||
&& stack.getTagCompound().hasKey(NBT_SORTING_TYPE)
|
&& stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_DIRECTION)
|
||||||
&& stack.getTagCompound().hasKey(NBT_SEARCH_BOX_MODE);
|
&& stack.getTagCompound().hasKey(TileGrid.NBT_SORTING_TYPE)
|
||||||
|
&& stack.getTagCompound().hasKey(TileGrid.NBT_SEARCH_BOX_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
|
private int viewType;
|
||||||
private int sortingDirection;
|
private int sortingDirection;
|
||||||
private int sortingType;
|
private int sortingType;
|
||||||
private int searchBoxMode;
|
private int searchBoxMode;
|
||||||
@@ -18,10 +19,11 @@ public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
public MessageGridSettingsUpdate() {
|
public MessageGridSettingsUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageGridSettingsUpdate(TileGrid grid, int sortingDirection, int sortingType, int searchBoxMode) {
|
public MessageGridSettingsUpdate(TileGrid grid, int viewType, int sortingDirection, int sortingType, int searchBoxMode) {
|
||||||
this.x = grid.getPos().getX();
|
this.x = grid.getPos().getX();
|
||||||
this.y = grid.getPos().getY();
|
this.y = grid.getPos().getY();
|
||||||
this.z = grid.getPos().getZ();
|
this.z = grid.getPos().getZ();
|
||||||
|
this.viewType = viewType;
|
||||||
this.sortingDirection = sortingDirection;
|
this.sortingDirection = sortingDirection;
|
||||||
this.sortingType = sortingType;
|
this.sortingType = sortingType;
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
@@ -32,6 +34,7 @@ public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
x = buf.readInt();
|
x = buf.readInt();
|
||||||
y = buf.readInt();
|
y = buf.readInt();
|
||||||
z = buf.readInt();
|
z = buf.readInt();
|
||||||
|
viewType = buf.readInt();
|
||||||
sortingDirection = buf.readInt();
|
sortingDirection = buf.readInt();
|
||||||
sortingType = buf.readInt();
|
sortingType = buf.readInt();
|
||||||
searchBoxMode = buf.readInt();
|
searchBoxMode = buf.readInt();
|
||||||
@@ -42,6 +45,7 @@ public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
buf.writeInt(x);
|
buf.writeInt(x);
|
||||||
buf.writeInt(y);
|
buf.writeInt(y);
|
||||||
buf.writeInt(z);
|
buf.writeInt(z);
|
||||||
|
buf.writeInt(viewType);
|
||||||
buf.writeInt(sortingDirection);
|
buf.writeInt(sortingDirection);
|
||||||
buf.writeInt(sortingType);
|
buf.writeInt(sortingType);
|
||||||
buf.writeInt(searchBoxMode);
|
buf.writeInt(searchBoxMode);
|
||||||
@@ -52,6 +56,10 @@ public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<Mess
|
|||||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||||
|
|
||||||
if (tile instanceof TileGrid) {
|
if (tile instanceof TileGrid) {
|
||||||
|
if (TileGrid.isValidViewType(message.viewType)) {
|
||||||
|
((TileGrid) tile).setViewType(message.viewType);
|
||||||
|
}
|
||||||
|
|
||||||
if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
|
if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
|
||||||
((TileGrid) tile).setSortingDirection(message.sortingDirection);
|
((TileGrid) tile).setSortingDirection(message.sortingDirection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import refinedstorage.RefinedStorageItems;
|
import refinedstorage.RefinedStorageItems;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.item.ItemWirelessGrid;
|
|
||||||
import refinedstorage.tile.grid.TileGrid;
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
|
|
||||||
public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToServer<MessageWirelessGridSettingsUpdate> implements IMessage {
|
public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToServer<MessageWirelessGridSettingsUpdate> implements IMessage {
|
||||||
private int hand;
|
private int hand;
|
||||||
|
private int viewType;
|
||||||
private int sortingDirection;
|
private int sortingDirection;
|
||||||
private int sortingType;
|
private int sortingType;
|
||||||
private int searchBoxMode;
|
private int searchBoxMode;
|
||||||
@@ -18,8 +18,9 @@ public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToSer
|
|||||||
public MessageWirelessGridSettingsUpdate() {
|
public MessageWirelessGridSettingsUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageWirelessGridSettingsUpdate(int hand, int sortingDirection, int sortingType, int searchBoxMode) {
|
public MessageWirelessGridSettingsUpdate(int hand, int viewType, int sortingDirection, int sortingType, int searchBoxMode) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
|
this.viewType = viewType;
|
||||||
this.sortingDirection = sortingDirection;
|
this.sortingDirection = sortingDirection;
|
||||||
this.sortingType = sortingType;
|
this.sortingType = sortingType;
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
@@ -28,6 +29,7 @@ public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToSer
|
|||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
hand = buf.readInt();
|
hand = buf.readInt();
|
||||||
|
viewType = buf.readInt();
|
||||||
sortingDirection = buf.readInt();
|
sortingDirection = buf.readInt();
|
||||||
sortingType = buf.readInt();
|
sortingType = buf.readInt();
|
||||||
searchBoxMode = buf.readInt();
|
searchBoxMode = buf.readInt();
|
||||||
@@ -36,6 +38,7 @@ public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToSer
|
|||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
buf.writeInt(hand);
|
buf.writeInt(hand);
|
||||||
|
buf.writeInt(viewType);
|
||||||
buf.writeInt(sortingDirection);
|
buf.writeInt(sortingDirection);
|
||||||
buf.writeInt(sortingType);
|
buf.writeInt(sortingType);
|
||||||
buf.writeInt(searchBoxMode);
|
buf.writeInt(searchBoxMode);
|
||||||
@@ -46,16 +49,20 @@ public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToSer
|
|||||||
ItemStack held = player.getHeldItem(RefinedStorageUtils.getHandById(message.hand));
|
ItemStack held = player.getHeldItem(RefinedStorageUtils.getHandById(message.hand));
|
||||||
|
|
||||||
if (held != null && held.getItem() == RefinedStorageItems.WIRELESS_GRID && held.getTagCompound() != null) {
|
if (held != null && held.getItem() == RefinedStorageItems.WIRELESS_GRID && held.getTagCompound() != null) {
|
||||||
|
if (TileGrid.isValidViewType(message.viewType)) {
|
||||||
|
held.getTagCompound().setInteger(TileGrid.NBT_VIEW_TYPE, message.viewType);
|
||||||
|
}
|
||||||
|
|
||||||
if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
|
if (TileGrid.isValidSortingDirection(message.sortingDirection)) {
|
||||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
|
held.getTagCompound().setInteger(TileGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TileGrid.isValidSortingType(message.sortingType)) {
|
if (TileGrid.isValidSortingType(message.sortingType)) {
|
||||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SORTING_TYPE, message.sortingType);
|
held.getTagCompound().setInteger(TileGrid.NBT_SORTING_TYPE, message.sortingType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TileGrid.isValidSearchBoxMode(message.searchBoxMode)) {
|
if (TileGrid.isValidSearchBoxMode(message.searchBoxMode)) {
|
||||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
|
held.getTagCompound().setInteger(TileGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ public interface IGrid {
|
|||||||
|
|
||||||
IGridHandler getGridHandler();
|
IGridHandler getGridHandler();
|
||||||
|
|
||||||
|
int getViewType();
|
||||||
|
|
||||||
int getSortingType();
|
int getSortingType();
|
||||||
|
|
||||||
int getSortingDirection();
|
int getSortingDirection();
|
||||||
|
|
||||||
int getSearchBoxMode();
|
int getSearchBoxMode();
|
||||||
|
|
||||||
|
void onViewTypeChanged(int type);
|
||||||
|
|
||||||
void onSortingTypeChanged(int type);
|
void onSortingTypeChanged(int type);
|
||||||
|
|
||||||
void onSortingDirectionChanged(int direction);
|
void onSortingDirectionChanged(int direction);
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileGrid extends TileNode implements IGrid {
|
public class TileGrid extends TileNode implements IGrid {
|
||||||
private static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
public static final String NBT_VIEW_TYPE = "ViewType";
|
||||||
private static final String NBT_SORTING_TYPE = "SortingType";
|
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||||
private static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
public static final String NBT_SORTING_TYPE = "SortingType";
|
||||||
|
public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
||||||
|
|
||||||
public static final int SORTING_DIRECTION_ASCENDING = 0;
|
public static final int SORTING_DIRECTION_ASCENDING = 0;
|
||||||
public static final int SORTING_DIRECTION_DESCENDING = 1;
|
public static final int SORTING_DIRECTION_DESCENDING = 1;
|
||||||
@@ -44,6 +45,10 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED = 2;
|
public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED = 2;
|
||||||
public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED = 3;
|
public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED = 3;
|
||||||
|
|
||||||
|
public static final int VIEW_TYPE_NORMAL = 0;
|
||||||
|
public static final int VIEW_TYPE_NON_CRAFTABLES = 1;
|
||||||
|
public static final int VIEW_TYPE_CRAFTABLES = 2;
|
||||||
|
|
||||||
private Container craftingContainer = new Container() {
|
private Container craftingContainer = new Container() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
@@ -62,6 +67,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
|
|
||||||
private EnumGridType type;
|
private EnumGridType type;
|
||||||
|
|
||||||
|
private int viewType = VIEW_TYPE_NORMAL;
|
||||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
||||||
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;
|
||||||
@@ -255,6 +261,17 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getViewType() {
|
||||||
|
return viewType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewType(int type) {
|
||||||
|
this.viewType = type;
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
public int getSortingDirection() {
|
public int getSortingDirection() {
|
||||||
return sortingDirection;
|
return sortingDirection;
|
||||||
}
|
}
|
||||||
@@ -285,19 +302,24 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewTypeChanged(int type) {
|
||||||
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, sortingType, searchBoxMode, type));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingTypeChanged(int type) {
|
public void onSortingTypeChanged(int type) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, type, searchBoxMode));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, type, searchBoxMode, viewType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingDirectionChanged(int direction) {
|
public void onSortingDirectionChanged(int direction) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, direction, sortingType, searchBoxMode));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, direction, sortingType, searchBoxMode, viewType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, sortingType, searchBoxMode));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, sortingType, searchBoxMode, viewType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -306,22 +328,26 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(NBTTagCompound nbt) {
|
public void read(NBTTagCompound tag) {
|
||||||
super.read(nbt);
|
super.read(tag);
|
||||||
|
|
||||||
RefinedStorageUtils.readItemsLegacy(matrix, 0, nbt);
|
RefinedStorageUtils.readItemsLegacy(matrix, 0, tag);
|
||||||
RefinedStorageUtils.readItems(patterns, 1, nbt);
|
RefinedStorageUtils.readItems(patterns, 1, tag);
|
||||||
|
|
||||||
if (nbt.hasKey(NBT_SORTING_DIRECTION)) {
|
if (tag.hasKey(NBT_VIEW_TYPE)) {
|
||||||
sortingDirection = nbt.getInteger(NBT_SORTING_DIRECTION);
|
viewType = tag.getInteger(NBT_VIEW_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.hasKey(NBT_SORTING_TYPE)) {
|
if (tag.hasKey(NBT_SORTING_DIRECTION)) {
|
||||||
sortingType = nbt.getInteger(NBT_SORTING_TYPE);
|
sortingDirection = tag.getInteger(NBT_SORTING_DIRECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.hasKey(NBT_SEARCH_BOX_MODE)) {
|
if (tag.hasKey(NBT_SORTING_TYPE)) {
|
||||||
searchBoxMode = nbt.getInteger(NBT_SEARCH_BOX_MODE);
|
sortingType = tag.getInteger(NBT_SORTING_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
|
||||||
|
searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,6 +358,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
RefinedStorageUtils.writeItemsLegacy(matrix, 0, tag);
|
RefinedStorageUtils.writeItemsLegacy(matrix, 0, tag);
|
||||||
RefinedStorageUtils.writeItems(patterns, 1, tag);
|
RefinedStorageUtils.writeItems(patterns, 1, tag);
|
||||||
|
|
||||||
|
tag.setInteger(NBT_VIEW_TYPE, viewType);
|
||||||
tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
||||||
tag.setInteger(NBT_SORTING_TYPE, sortingType);
|
tag.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||||
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||||
@@ -344,6 +371,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
super.writeContainerData(buf);
|
super.writeContainerData(buf);
|
||||||
|
|
||||||
buf.writeBoolean(isConnected());
|
buf.writeBoolean(isConnected());
|
||||||
|
buf.writeInt(viewType);
|
||||||
buf.writeInt(sortingDirection);
|
buf.writeInt(sortingDirection);
|
||||||
buf.writeInt(sortingType);
|
buf.writeInt(sortingType);
|
||||||
buf.writeInt(searchBoxMode);
|
buf.writeInt(searchBoxMode);
|
||||||
@@ -354,6 +382,7 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
super.readContainerData(buf);
|
super.readContainerData(buf);
|
||||||
|
|
||||||
connected = buf.readBoolean();
|
connected = buf.readBoolean();
|
||||||
|
viewType = buf.readInt();
|
||||||
sortingDirection = buf.readInt();
|
sortingDirection = buf.readInt();
|
||||||
sortingType = buf.readInt();
|
sortingType = buf.readInt();
|
||||||
searchBoxMode = buf.readInt();
|
searchBoxMode = buf.readInt();
|
||||||
@@ -376,6 +405,12 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidViewType(int type) {
|
||||||
|
return type == VIEW_TYPE_NORMAL ||
|
||||||
|
type == VIEW_TYPE_CRAFTABLES ||
|
||||||
|
type == VIEW_TYPE_NON_CRAFTABLES;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isValidSearchBoxMode(int mode) {
|
public static boolean isValidSearchBoxMode(int mode) {
|
||||||
return mode == SEARCH_BOX_MODE_NORMAL ||
|
return mode == SEARCH_BOX_MODE_NORMAL ||
|
||||||
mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
|
mode == SEARCH_BOX_MODE_NORMAL_AUTOSELECTED ||
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
private EnumHand hand;
|
private EnumHand hand;
|
||||||
private World world;
|
private World world;
|
||||||
private BlockPos controllerPos;
|
private BlockPos controllerPos;
|
||||||
|
private int viewType;
|
||||||
private int sortingType;
|
private int sortingType;
|
||||||
private int sortingDirection;
|
private int sortingDirection;
|
||||||
private int searchBoxMode;
|
private int searchBoxMode;
|
||||||
@@ -27,6 +28,7 @@ public class WirelessGrid implements IGrid {
|
|||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.controllerPos = new BlockPos(ItemWirelessGrid.getX(stack), ItemWirelessGrid.getY(stack), ItemWirelessGrid.getZ(stack));
|
this.controllerPos = new BlockPos(ItemWirelessGrid.getX(stack), ItemWirelessGrid.getY(stack), ItemWirelessGrid.getZ(stack));
|
||||||
|
this.viewType = ItemWirelessGrid.getViewType(stack);
|
||||||
this.sortingType = ItemWirelessGrid.getSortingType(stack);
|
this.sortingType = ItemWirelessGrid.getSortingType(stack);
|
||||||
this.sortingDirection = ItemWirelessGrid.getSortingDirection(stack);
|
this.sortingDirection = ItemWirelessGrid.getSortingDirection(stack);
|
||||||
this.searchBoxMode = ItemWirelessGrid.getSearchBoxMode(stack);
|
this.searchBoxMode = ItemWirelessGrid.getSearchBoxMode(stack);
|
||||||
@@ -49,18 +51,9 @@ public class WirelessGrid implements IGrid {
|
|||||||
return controller != null ? controller.getGridHandler() : null;
|
return controller != null ? controller.getGridHandler() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClose(EntityPlayer player) {
|
@Override
|
||||||
TileController controller = getController();
|
public int getViewType() {
|
||||||
|
return viewType;
|
||||||
if (controller != null) {
|
|
||||||
controller.getWirelessGridHandler().onClose(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TileController getController() {
|
|
||||||
TileEntity tile = world.getTileEntity(controllerPos);
|
|
||||||
|
|
||||||
return tile instanceof TileController ? (TileController) tile : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,23 +71,30 @@ public class WirelessGrid implements IGrid {
|
|||||||
return searchBoxMode;
|
return searchBoxMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewTypeChanged(int type) {
|
||||||
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), getSortingDirection(), getSortingType(), getSearchBoxMode(), type));
|
||||||
|
|
||||||
|
this.viewType = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingTypeChanged(int type) {
|
public void onSortingTypeChanged(int type) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), getSortingDirection(), type, getSearchBoxMode()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), getSortingDirection(), type, getSearchBoxMode(), getViewType()));
|
||||||
|
|
||||||
this.sortingType = type;
|
this.sortingType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingDirectionChanged(int direction) {
|
public void onSortingDirectionChanged(int direction) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), direction, getSortingType(), getSearchBoxMode()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), direction, getSortingType(), getSearchBoxMode(), getViewType()));
|
||||||
|
|
||||||
this.sortingDirection = direction;
|
this.sortingDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), getSortingDirection(), getSortingType(), searchBoxMode));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageWirelessGridSettingsUpdate(RefinedStorageUtils.getIdFromHand(hand), getSortingDirection(), getSortingType(), searchBoxMode, getViewType()));
|
||||||
|
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
}
|
}
|
||||||
@@ -108,4 +108,18 @@ public class WirelessGrid implements IGrid {
|
|||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClose(EntityPlayer player) {
|
||||||
|
TileController controller = getController();
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
controller.getWirelessGridHandler().onClose(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TileController getController() {
|
||||||
|
TileEntity tile = world.getTileEntity(controllerPos);
|
||||||
|
|
||||||
|
return tile instanceof TileController ? (TileController) tile : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ sidebutton.refinedstorage:redstone_mode.0=Ignore redstone signal
|
|||||||
sidebutton.refinedstorage:redstone_mode.1=Only work with redstone signal
|
sidebutton.refinedstorage:redstone_mode.1=Only work with redstone signal
|
||||||
sidebutton.refinedstorage:redstone_mode.2=Only work without redstone signal
|
sidebutton.refinedstorage:redstone_mode.2=Only work without redstone signal
|
||||||
|
|
||||||
|
sidebutton.refinedstorage:grid.view_type=Display
|
||||||
|
sidebutton.refinedstorage:grid.view_type.0=Normal
|
||||||
|
sidebutton.refinedstorage:grid.view_type.1=No craftables
|
||||||
|
sidebutton.refinedstorage:grid.view_type.2=Only craftables
|
||||||
sidebutton.refinedstorage:grid.sorting.direction=Sorting Direction
|
sidebutton.refinedstorage:grid.sorting.direction=Sorting Direction
|
||||||
sidebutton.refinedstorage:grid.sorting.direction.0=Ascending
|
sidebutton.refinedstorage:grid.sorting.direction.0=Ascending
|
||||||
sidebutton.refinedstorage:grid.sorting.direction.1=Descending
|
sidebutton.refinedstorage:grid.sorting.direction.1=Descending
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ sidebutton.refinedstorage:redstone_mode.0=Redstone negeren
|
|||||||
sidebutton.refinedstorage:redstone_mode.1=Alleen werken met redstone signaal
|
sidebutton.refinedstorage:redstone_mode.1=Alleen werken met redstone signaal
|
||||||
sidebutton.refinedstorage:redstone_mode.2=Alleen werken zonder redstone signaal
|
sidebutton.refinedstorage:redstone_mode.2=Alleen werken zonder redstone signaal
|
||||||
|
|
||||||
|
sidebutton.refinedstorage:grid.view_type=Weergave
|
||||||
|
sidebutton.refinedstorage:grid.view_type.0=Normaal
|
||||||
|
sidebutton.refinedstorage:grid.view_type.1=Geen craftables
|
||||||
|
sidebutton.refinedstorage:grid.view_type.2=Alleen craftables
|
||||||
sidebutton.refinedstorage:grid.sorting.direction=Sorteer Richting
|
sidebutton.refinedstorage:grid.sorting.direction=Sorteer Richting
|
||||||
sidebutton.refinedstorage:grid.sorting.direction.0=Oplopend
|
sidebutton.refinedstorage:grid.sorting.direction.0=Oplopend
|
||||||
sidebutton.refinedstorage:grid.sorting.direction.1=Aflopend
|
sidebutton.refinedstorage:grid.sorting.direction.1=Aflopend
|
||||||
|
|||||||
Reference in New Issue
Block a user