Oredict toggle on grids
This commit is contained in:
@@ -19,18 +19,22 @@ import com.raoulvdberge.refinedstorage.gui.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.RSJEIPlugin;
|
||||
import com.raoulvdberge.refinedstorage.network.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -52,6 +56,7 @@ public class GuiGrid extends GuiBase {
|
||||
private boolean wasConnected;
|
||||
|
||||
private GuiTextField searchField;
|
||||
private GuiCheckBox oredictPattern;
|
||||
|
||||
private ContainerGrid container;
|
||||
private IGrid grid;
|
||||
@@ -100,6 +105,9 @@ public class GuiGrid extends GuiBase {
|
||||
int sx = x + 80 + 1;
|
||||
int sy = y + 6 + 1;
|
||||
|
||||
int ox = x + 64;
|
||||
int oy = y + 138;
|
||||
|
||||
if (searchField == null) {
|
||||
searchField = new GuiTextField(0, fontRendererObj, sx, sy, 88 - 6, fontRendererObj.FONT_HEIGHT);
|
||||
searchField.setEnableBackgroundDrawing(false);
|
||||
@@ -112,6 +120,13 @@ public class GuiGrid extends GuiBase {
|
||||
searchField.yPosition = sy;
|
||||
}
|
||||
|
||||
if (oredictPattern == null) {
|
||||
oredictPattern = addCheckBox(ox, oy, I18n.format("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
||||
} else {
|
||||
oredictPattern.xPosition = ox;
|
||||
oredictPattern.yPosition = oy;
|
||||
}
|
||||
|
||||
if (grid.getType() != EnumGridType.FLUID) {
|
||||
addSideButton(new SideButtonGridViewType(this, grid));
|
||||
}
|
||||
@@ -363,6 +378,15 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
|
||||
if (button == oredictPattern) {
|
||||
TileDataManager.setParameter(TileGrid.OREDICT_PATTERN, oredictPattern.isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
@@ -459,4 +483,10 @@ public class GuiGrid extends GuiBase {
|
||||
searchField.setFocused(TileGrid.isSearchBoxModeWithAutoselection(mode));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOredictPattern(boolean checked) {
|
||||
if (oredictPattern != null) {
|
||||
oredictPattern.setIsChecked(checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ public class SideButtonCompare extends SideButton {
|
||||
ty = 80;
|
||||
} else if (mask == IComparer.COMPARE_NBT) {
|
||||
ty = 48;
|
||||
} else if (mask == IComparer.COMPARE_OREDICT) {
|
||||
ty = -100; // Temporary
|
||||
}
|
||||
|
||||
int tx = (parameter.getValue() & mask) == mask ? 0 : 16;
|
||||
|
||||
@@ -107,10 +107,29 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
}
|
||||
});
|
||||
|
||||
public static final TileDataParameter<Boolean> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileGrid>() {
|
||||
@Override
|
||||
public Boolean getValue(TileGrid tile) {
|
||||
return tile.oredictPattern;
|
||||
}
|
||||
}, new ITileDataConsumer<Boolean, TileGrid>() {
|
||||
@Override
|
||||
public void setValue(TileGrid tile, Boolean value) {
|
||||
tile.oredictPattern = value;
|
||||
|
||||
tile.markDirty();
|
||||
}
|
||||
}, parameter -> {
|
||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiGrid) {
|
||||
((GuiGrid) Minecraft.getMinecraft().currentScreen).updateOredictPattern(parameter.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
public static final String NBT_VIEW_TYPE = "ViewType";
|
||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||
public static final String NBT_SORTING_TYPE = "SortingType";
|
||||
public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
||||
public static final String NBT_OREDICT_PATTERN = "OredictPattern";
|
||||
|
||||
public static final int SORTING_DIRECTION_ASCENDING = 0;
|
||||
public static final int SORTING_DIRECTION_DESCENDING = 1;
|
||||
@@ -152,11 +171,14 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
private int sortingType = SORTING_TYPE_QUANTITY;
|
||||
private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
|
||||
|
||||
private boolean oredictPattern = false;
|
||||
|
||||
public TileGrid() {
|
||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||
dataManager.addWatchedParameter(SORTING_TYPE);
|
||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||
dataManager.addWatchedParameter(OREDICT_PATTERN);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,6 +336,8 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
|
||||
ItemStack pattern = new ItemStack(RSItems.PATTERN);
|
||||
|
||||
ItemPattern.setOredict(pattern, oredictPattern);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack ingredient = matrix.getStackInSlot(i);
|
||||
|
||||
@@ -467,6 +491,10 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
|
||||
searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_OREDICT_PATTERN)) {
|
||||
oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -482,6 +510,8 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
tag.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
|
||||
tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user