Further optimize Grid. Should fix #1719
This commit is contained in:
@@ -71,15 +71,17 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
public GuiGrid(ContainerGrid container, IGrid grid) {
|
||||
super(container, grid.getType() == GridType.FLUID ? 193 : 227, 0);
|
||||
|
||||
List<IGridSorter> defaultSorters = new LinkedList<>();
|
||||
defaultSorters.add(new GridSorterName());
|
||||
defaultSorters.add(new GridSorterQuantity());
|
||||
defaultSorters.add(new GridSorterID());
|
||||
defaultSorters.add(new GridSorterInventoryTweaks());
|
||||
defaultSorters.add(new GridSorterLastModified());
|
||||
IGridSorter defaultSorter;
|
||||
|
||||
List<IGridSorter> sorters = new LinkedList<>();
|
||||
sorters.add(defaultSorter = new GridSorterName());
|
||||
sorters.add(new GridSorterQuantity());
|
||||
sorters.add(new GridSorterID());
|
||||
sorters.add(new GridSorterInventoryTweaks());
|
||||
sorters.add(new GridSorterLastModified());
|
||||
|
||||
this.grid = grid;
|
||||
this.view = grid.getType() == GridType.FLUID ? new GridViewFluid(this, defaultSorters) : new GridViewItem(this, defaultSorters);
|
||||
this.view = grid.getType() == GridType.FLUID ? new GridViewFluid(this, defaultSorter, sorters) : new GridViewItem(this, defaultSorter, sorters);
|
||||
this.wasConnected = this.grid.isActive();
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
addSideButton(new SideButtonGridSearchBoxMode(this));
|
||||
addSideButton(new SideButtonGridSize(this, () -> grid.getSize(), size -> grid.onSizeChanged(size)));
|
||||
|
||||
view.sort();
|
||||
updateScrollbarAndTabs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -622,7 +624,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
TileDataManager.setParameter(TileGrid.BLOCKING_PATTERN, blockingPattern.isChecked());
|
||||
} else if (button == processingPattern) {
|
||||
// Rebuild the inventory slots before the slot change packet arrives
|
||||
TileGrid.PROCESSING_PATTERN.setValue(processingPattern.isChecked());
|
||||
TileGrid.PROCESSING_PATTERN.setValue(false, processingPattern.isChecked());
|
||||
((ContainerGrid) this.inventorySlots).initSlots();
|
||||
|
||||
TileDataManager.setParameter(TileGrid.PROCESSING_PATTERN, processingPattern.isChecked());
|
||||
@@ -747,6 +749,21 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScrollbarAndTabs() {
|
||||
if (scrollbar != null) {
|
||||
scrollbar.setEnabled(getRows() > getVisibleRows());
|
||||
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
||||
}
|
||||
|
||||
if (tabPageLeft != null) {
|
||||
tabPageLeft.visible = grid.getTotalTabPages() > 0;
|
||||
}
|
||||
|
||||
if (tabPageRight != null) {
|
||||
tabPageRight.visible = grid.getTotalTabPages() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public GuiButton getTabPageLeft() {
|
||||
return tabPageLeft;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
|
||||
public class GridStackItem implements IGridStack {
|
||||
private int hash;
|
||||
private ItemStack stack;
|
||||
private String cachedName;
|
||||
private boolean craftable;
|
||||
private boolean displayCraftText;
|
||||
private String[] oreIds = null;
|
||||
@@ -72,7 +73,11 @@ public class GridStackItem implements IGridStack {
|
||||
@Override
|
||||
public String getName() {
|
||||
try {
|
||||
return stack.getDisplayName();
|
||||
if (cachedName == null) {
|
||||
cachedName = stack.getDisplayName();
|
||||
}
|
||||
|
||||
return cachedName;
|
||||
} catch (Throwable t) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.filtering.GridFilterParser;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSorterDirection;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.GridSorterName;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.IGridSorter;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
@@ -15,14 +14,15 @@ public abstract class GridViewBase implements IGridView {
|
||||
private GuiGrid gui;
|
||||
private boolean canCraft;
|
||||
|
||||
private IGridSorter defaultSorter;
|
||||
private List<IGridSorter> sorters;
|
||||
private SorterThread sorterThread = new SorterThread();
|
||||
|
||||
private List<IGridStack> stacks;
|
||||
private List<IGridStack> stacks = new ArrayList<>();
|
||||
protected Map<Integer, IGridStack> map = new HashMap<>();
|
||||
|
||||
public GridViewBase(GuiGrid gui, List<IGridSorter> sorters) {
|
||||
public GridViewBase(GuiGrid gui, IGridSorter defaultSorter, List<IGridSorter> sorters) {
|
||||
this.gui = gui;
|
||||
this.defaultSorter = defaultSorter;
|
||||
this.sorters = sorters;
|
||||
}
|
||||
|
||||
@@ -33,43 +33,6 @@ public abstract class GridViewBase implements IGridView {
|
||||
|
||||
@Override
|
||||
public void sort() {
|
||||
if (!sorterThread.sorting) {
|
||||
new Thread(sorterThread, "RS grid sorting").start();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI(GuiGrid gui) {
|
||||
if (gui.getScrollbar() != null) {
|
||||
gui.getScrollbar().setEnabled(gui.getRows() > gui.getVisibleRows());
|
||||
gui.getScrollbar().setMaxOffset(gui.getRows() - gui.getVisibleRows());
|
||||
}
|
||||
|
||||
if (gui.getTabPageLeft() != null) {
|
||||
gui.getTabPageLeft().visible = gui.getGrid().getTotalTabPages() > 0;
|
||||
}
|
||||
|
||||
if (gui.getTabPageRight() != null) {
|
||||
gui.getTabPageRight().visible = gui.getGrid().getTotalTabPages() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanCraft(boolean canCraft) {
|
||||
this.canCraft = canCraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft() {
|
||||
return canCraft;
|
||||
}
|
||||
|
||||
private class SorterThread implements Runnable {
|
||||
private boolean sorting;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.sorting = true;
|
||||
|
||||
List<IGridStack> stacks = new ArrayList<>();
|
||||
|
||||
if (gui.getGrid().isActive()) {
|
||||
@@ -99,20 +62,27 @@ public abstract class GridViewBase implements IGridView {
|
||||
|
||||
GridSorterDirection sortingDirection = grid.getSortingDirection() == IGrid.SORTING_DIRECTION_DESCENDING ? GridSorterDirection.DESCENDING : GridSorterDirection.ASCENDING;
|
||||
|
||||
GridSorterName defaultSorting = new GridSorterName();
|
||||
stacks.sort((left, right) -> defaultSorter.compare(left, right, sortingDirection));
|
||||
|
||||
stacks.sort((left, right) -> defaultSorting.compare(left, right, sortingDirection));
|
||||
|
||||
sorters.stream().filter(s -> s.isApplicable(grid)).forEach(s -> {
|
||||
stacks.sort((left, right) -> s.compare(left, right, sortingDirection));
|
||||
});
|
||||
for (IGridSorter sorter : sorters) {
|
||||
if (sorter.isApplicable(grid)) {
|
||||
stacks.sort((left, right) -> sorter.compare(left, right, sortingDirection));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridViewBase.this.stacks = stacks;
|
||||
this.stacks = stacks;
|
||||
|
||||
updateUI(gui);
|
||||
|
||||
this.sorting = false;
|
||||
this.gui.updateScrollbarAndTabs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanCraft(boolean canCraft) {
|
||||
this.canCraft = canCraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft() {
|
||||
return canCraft;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import java.util.List;
|
||||
|
||||
public class GridViewFluid extends GridViewBase {
|
||||
public GridViewFluid(GuiGrid gui, List<IGridSorter> sorters) {
|
||||
super(gui, sorters);
|
||||
public GridViewFluid(GuiGrid gui, IGridSorter defaultSorter, List<IGridSorter> sorters) {
|
||||
super(gui, defaultSorter, sorters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import java.util.List;
|
||||
|
||||
public class GridViewItem extends GridViewBase {
|
||||
public GridViewItem(GuiGrid gui, List<IGridSorter> sorters) {
|
||||
super(gui, sorters);
|
||||
public GridViewItem(GuiGrid gui, IGridSorter defaultSorter, List<IGridSorter> sorters) {
|
||||
super(gui, defaultSorter, sorters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ItemHandlerFilter extends ItemHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && !filters.isEmpty()) {
|
||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,24 +12,27 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
public class MessageTileDataParameter implements IMessage, IMessageHandler<MessageTileDataParameter, IMessage> {
|
||||
private TileEntity tile;
|
||||
private TileDataParameter parameter;
|
||||
private boolean initial;
|
||||
|
||||
public MessageTileDataParameter() {
|
||||
}
|
||||
|
||||
public MessageTileDataParameter(TileEntity tile, TileDataParameter parameter) {
|
||||
public MessageTileDataParameter(TileEntity tile, TileDataParameter parameter, boolean initial) {
|
||||
this.tile = tile;
|
||||
this.parameter = parameter;
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int id = buf.readInt();
|
||||
boolean initial = buf.readBoolean();
|
||||
|
||||
TileDataParameter parameter = TileDataManager.getParameter(id);
|
||||
|
||||
if (parameter != null) {
|
||||
try {
|
||||
parameter.setValue(parameter.getSerializer().read(new PacketBuffer(buf)));
|
||||
parameter.setValue(initial, parameter.getSerializer().read(new PacketBuffer(buf)));
|
||||
} catch (Exception e) {
|
||||
// NO OP
|
||||
}
|
||||
@@ -39,6 +42,7 @@ public class MessageTileDataParameter implements IMessage, IMessageHandler<Messa
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(parameter.getId());
|
||||
buf.writeBoolean(initial);
|
||||
|
||||
parameter.getSerializer().write((PacketBuffer) buf, parameter.getValueProducer().apply(tile));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
||||
t.getNode().setSize(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::initGui));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::initGui));
|
||||
|
||||
public TileCrafterManager() {
|
||||
dataManager.addWatchedParameter(SIZE);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TileDetector extends TileNode<NetworkNodeDetector> {
|
||||
public static final TileDataParameter<Integer, TileDetector> AMOUNT = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getAmount(), (t, v) -> {
|
||||
t.getNode().setAmount(v);
|
||||
t.getNode().markDirty();
|
||||
}, p -> GuiBase.executeLater(GuiDetector.class, detector -> detector.getAmount().setText(String.valueOf(p))));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiDetector.class, detector -> detector.getAmount().setText(String.valueOf(p))));
|
||||
|
||||
public TileDetector() {
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
|
||||
|
||||
player.openContainer.detectAndSendChanges();
|
||||
});
|
||||
}, p -> {
|
||||
}, (initial, p) -> {
|
||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiExporter) {
|
||||
((ContainerExporter) ((GuiExporter) Minecraft.getMinecraft().currentScreen).inventorySlots).initSlots();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHan
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -27,11 +27,7 @@ public class TileReader extends TileNode<NetworkNodeReader> {
|
||||
((IGuiReaderWriter) t.getNode()).setChannel(v);
|
||||
|
||||
t.getNode().markDirty();
|
||||
}, p -> {
|
||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiReaderWriter) {
|
||||
((GuiReaderWriter) Minecraft.getMinecraft().currentScreen).updateSelection(p);
|
||||
}
|
||||
});
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiReaderWriter.class, readerWriter -> readerWriter.updateSelection(p)));
|
||||
}
|
||||
|
||||
public static final TileDataParameter<String, TileReader> CHANNEL = createChannelParameter();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TileDataManager {
|
||||
}
|
||||
|
||||
public void sendParameterToWatchers(TileDataParameter parameter) {
|
||||
watchers.forEach(l -> l.sendParameter(parameter));
|
||||
watchers.forEach(l -> l.sendParameter(false, parameter));
|
||||
}
|
||||
|
||||
public static void registerParameter(TileDataParameter parameter) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class TileDataParameter<T, E extends TileEntity> {
|
||||
@@ -15,7 +14,7 @@ public class TileDataParameter<T, E extends TileEntity> {
|
||||
@Nullable
|
||||
private BiConsumer<E, T> valueConsumer;
|
||||
@Nullable
|
||||
private Consumer<T> listener;
|
||||
private TileDataParameterClientListener<T> listener;
|
||||
private T value;
|
||||
|
||||
public TileDataParameter(DataSerializer<T> serializer, T defaultValue, Function<E, T> producer) {
|
||||
@@ -26,7 +25,7 @@ public class TileDataParameter<T, E extends TileEntity> {
|
||||
this(serializer, defaultValue, producer, consumer, null);
|
||||
}
|
||||
|
||||
public TileDataParameter(DataSerializer<T> serializer, T defaultValue, Function<E, T> producer, @Nullable BiConsumer<E, T> consumer, @Nullable Consumer<T> listener) {
|
||||
public TileDataParameter(DataSerializer<T> serializer, T defaultValue, Function<E, T> producer, @Nullable BiConsumer<E, T> consumer, @Nullable TileDataParameterClientListener<T> listener) {
|
||||
this.value = defaultValue;
|
||||
this.serializer = serializer;
|
||||
this.valueProducer = producer;
|
||||
@@ -55,11 +54,11 @@ public class TileDataParameter<T, E extends TileEntity> {
|
||||
return valueConsumer;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
public void setValue(boolean initial, T value) {
|
||||
this.value = value;
|
||||
|
||||
if (listener != null) {
|
||||
listener.accept(value);
|
||||
listener.onChanged(initial, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.data;
|
||||
|
||||
public interface TileDataParameterClientListener<T> {
|
||||
void onChanged(boolean initial, T value);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class TileDataWatcher {
|
||||
|
||||
public void detectAndSendChanges() {
|
||||
if (!sentInitial) {
|
||||
manager.getParameters().forEach(this::sendParameter);
|
||||
manager.getParameters().forEach(p -> sendParameter(true, p));
|
||||
|
||||
sentInitial = true;
|
||||
} else {
|
||||
@@ -45,14 +45,14 @@ public class TileDataWatcher {
|
||||
|
||||
// Avoid sending watched parameter twice (after initial packet)
|
||||
if (cached != null) {
|
||||
sendParameter(parameter);
|
||||
sendParameter(false, parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendParameter(TileDataParameter parameter) {
|
||||
RS.INSTANCE.network.sendTo(new MessageTileDataParameter(manager.getTile(), parameter), player);
|
||||
public void sendParameter(boolean initial, TileDataParameter parameter) {
|
||||
RS.INSTANCE.network.sendTo(new MessageTileDataParameter(manager.getTile(), parameter, initial), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,35 +24,39 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
t.getNode().setViewType(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
public static final TileDataParameter<Integer, TileGrid> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSortingDirection(), (t, v) -> {
|
||||
if (IGrid.isValidSortingDirection(v)) {
|
||||
t.getNode().setSortingDirection(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
public static final TileDataParameter<Integer, TileGrid> SORTING_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSortingType(), (t, v) -> {
|
||||
if (IGrid.isValidSortingType(v)) {
|
||||
t.getNode().setSortingType(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> trySortGrid(initial));
|
||||
public static final TileDataParameter<Integer, TileGrid> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
public static final TileDataParameter<Integer, TileGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
public static final TileDataParameter<Integer, TileGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
||||
t.getNode().markDirty();
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> {
|
||||
if (p != -1) {
|
||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||
}
|
||||
});
|
||||
public static final TileDataParameter<Integer, TileGrid> TAB_PAGE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabPage(), (t, v) -> {
|
||||
if (v >= 0 && v <= t.getNode().getTotalTabPages()) {
|
||||
t.getNode().setTabPage(v);
|
||||
@@ -62,7 +66,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
public static final TileDataParameter<Boolean, TileGrid> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isOredictPattern(), (t, v) -> {
|
||||
t.getNode().setOredictPattern(v);
|
||||
t.getNode().markDirty();
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateOredictPattern(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateOredictPattern(p)));
|
||||
public static final TileDataParameter<Boolean, TileGrid> PROCESSING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isProcessingPattern(), (t, v) -> {
|
||||
t.getNode().setProcessingPattern(v);
|
||||
t.getNode().markDirty();
|
||||
@@ -75,11 +79,17 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
((ContainerGrid) player.openContainer).initSlots();
|
||||
((ContainerGrid) player.openContainer).sendAllSlots();
|
||||
});
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
public static final TileDataParameter<Boolean, TileGrid> BLOCKING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isBlockingPattern(), (t, v) -> {
|
||||
t.getNode().setBlockingPattern(v);
|
||||
t.getNode().markDirty();
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateBlockingPattern(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateBlockingPattern(p)));
|
||||
|
||||
public static void trySortGrid(boolean initial) {
|
||||
if (!initial) {
|
||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||
}
|
||||
}
|
||||
|
||||
public TileGrid() {
|
||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||
|
||||
@@ -34,9 +34,9 @@ import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
@@ -66,33 +66,33 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
||||
t.setSortingDirection(v);
|
||||
t.markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> TileGrid.trySortGrid(initial));
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> SORTING_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSortingType, (t, v) -> {
|
||||
if (IGrid.isValidSortingType(v)) {
|
||||
t.setSortingType(v);
|
||||
t.markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> TileGrid.trySortGrid(initial));
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSearchBoxMode, (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.setSearchBoxMode(v);
|
||||
t.markDirty();
|
||||
}
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSize, (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.setSize(v);
|
||||
t.markDirty();
|
||||
}
|
||||
}, p -> {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
||||
Minecraft.getMinecraft().currentScreen.initGui();
|
||||
}
|
||||
});
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getTabSelected, (t, v) -> {
|
||||
t.setTabSelected(v == t.getTabSelected() ? -1 : v);
|
||||
t.markDirty();
|
||||
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort()));
|
||||
}, (initial, p) -> {
|
||||
if (p != -1) {
|
||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||
}
|
||||
});
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> TAB_PAGE = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getTabPage, (t, v) -> {
|
||||
if (v >= 0 && v <= t.getTotalTabPages()) {
|
||||
t.setTabPage(v);
|
||||
|
||||
Reference in New Issue
Block a user