Oredict toggle on processing pattern encoder
This commit is contained in:
@@ -38,7 +38,7 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 90);
|
addPlayerInventory(8, 101);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,22 +5,29 @@ import com.raoulvdberge.refinedstorage.container.ContainerProcessingPatternEncod
|
|||||||
import com.raoulvdberge.refinedstorage.network.MessageGridPatternCreate;
|
import com.raoulvdberge.refinedstorage.network.MessageGridPatternCreate;
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageProcessingPatternEncoderClear;
|
import com.raoulvdberge.refinedstorage.network.MessageProcessingPatternEncoderClear;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
|
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
|
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class GuiProcessingPatternEncoder extends GuiBase {
|
public class GuiProcessingPatternEncoder extends GuiBase {
|
||||||
private TileProcessingPatternEncoder encoder;
|
private TileProcessingPatternEncoder encoder;
|
||||||
|
|
||||||
|
private GuiCheckBox oredictPattern;
|
||||||
|
|
||||||
public GuiProcessingPatternEncoder(ContainerProcessingPatternEncoder container, TileProcessingPatternEncoder encoder) {
|
public GuiProcessingPatternEncoder(ContainerProcessingPatternEncoder container, TileProcessingPatternEncoder encoder) {
|
||||||
super(container, 176, 172);
|
super(container, 176, 183);
|
||||||
|
|
||||||
this.encoder = encoder;
|
this.encoder = encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(int x, int y) {
|
public void init(int x, int y) {
|
||||||
|
oredictPattern = addCheckBox(x + 7, y + 76, I18n.format("misc.refinedstorage:oredict"), TileProcessingPatternEncoder.OREDICT_PATTERN.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -32,7 +39,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverClear(int mouseX, int mouseY) {
|
private boolean isOverClear(int mouseX, int mouseY) {
|
||||||
return inBounds(136, 75, 7, 7, mouseX, mouseY);
|
return inBounds(80, 19, 7, 7, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,7 +64,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void drawForeground(int mouseX, int mouseY) {
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
drawString(7, 7, t("gui.refinedstorage:processing_pattern_encoder"));
|
drawString(7, 7, t("gui.refinedstorage:processing_pattern_encoder"));
|
||||||
drawString(7, 78, t("container.inventory"));
|
drawString(7, 90, t("container.inventory"));
|
||||||
|
|
||||||
if (isOverCreatePattern(mouseX, mouseY)) {
|
if (isOverCreatePattern(mouseX, mouseY)) {
|
||||||
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:processing_pattern_encoder.pattern_create"));
|
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:processing_pattern_encoder.pattern_create"));
|
||||||
@@ -68,6 +75,15 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
|
||||||
|
if (button == oredictPattern) {
|
||||||
|
TileDataManager.setParameter(TileProcessingPatternEncoder.OREDICT_PATTERN, oredictPattern.isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
@@ -82,4 +98,10 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateOredictPattern(boolean checked) {
|
||||||
|
if (oredictPattern != null) {
|
||||||
|
oredictPattern.setIsChecked(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -120,11 +120,13 @@ public class GuiGrid extends GuiBase {
|
|||||||
searchField.yPosition = sy;
|
searchField.yPosition = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oredictPattern == null) {
|
if (grid.getType() == EnumGridType.PATTERN) {
|
||||||
oredictPattern = addCheckBox(ox, oy, I18n.format("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
if (oredictPattern == null) {
|
||||||
} else {
|
oredictPattern = addCheckBox(ox, oy, I18n.format("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
||||||
oredictPattern.xPosition = ox;
|
} else {
|
||||||
oredictPattern.yPosition = oy;
|
oredictPattern.xPosition = ox;
|
||||||
|
oredictPattern.yPosition = oy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grid.getType() != EnumGridType.FLUID) {
|
if (grid.getType() != EnumGridType.FLUID) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class SideButtonCompare extends SideButton {
|
|||||||
} else if (mask == IComparer.COMPARE_NBT) {
|
} else if (mask == IComparer.COMPARE_NBT) {
|
||||||
ty = 48;
|
ty = 48;
|
||||||
} else if (mask == IComparer.COMPARE_OREDICT) {
|
} else if (mask == IComparer.COMPARE_OREDICT) {
|
||||||
ty = -100; // Temporary
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tx = (parameter.getValue() & mask) == mask ? 0 : 16;
|
int tx = (parameter.getValue() & mask) == mask ? 0 : 16;
|
||||||
|
|||||||
@@ -2,11 +2,17 @@ package com.raoulvdberge.refinedstorage.tile;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RSItems;
|
import com.raoulvdberge.refinedstorage.RSItems;
|
||||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiProcessingPatternEncoder;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
|
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
@@ -14,9 +20,35 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
public class TileProcessingPatternEncoder extends TileBase {
|
public class TileProcessingPatternEncoder extends TileBase {
|
||||||
|
private static final String NBT_OREDICT_PATTERN = "OredictPattern";
|
||||||
|
|
||||||
|
public static final TileDataParameter<Boolean> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileProcessingPatternEncoder>() {
|
||||||
|
@Override
|
||||||
|
public Boolean getValue(TileProcessingPatternEncoder tile) {
|
||||||
|
return tile.oredictPattern;
|
||||||
|
}
|
||||||
|
}, new ITileDataConsumer<Boolean, TileProcessingPatternEncoder>() {
|
||||||
|
@Override
|
||||||
|
public void setValue(TileProcessingPatternEncoder tile, Boolean value) {
|
||||||
|
tile.oredictPattern = value;
|
||||||
|
|
||||||
|
tile.markDirty();
|
||||||
|
}
|
||||||
|
}, parameter -> {
|
||||||
|
if (Minecraft.getMinecraft().currentScreen instanceof GuiProcessingPatternEncoder) {
|
||||||
|
((GuiProcessingPatternEncoder) Minecraft.getMinecraft().currentScreen).updateOredictPattern(parameter.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private ItemHandlerBasic patterns = new ItemHandlerBasic(2, this, new ItemValidatorBasic(RSItems.PATTERN));
|
private ItemHandlerBasic patterns = new ItemHandlerBasic(2, this, new ItemValidatorBasic(RSItems.PATTERN));
|
||||||
private ItemHandlerBasic configuration = new ItemHandlerBasic(9 * 2, this);
|
private ItemHandlerBasic configuration = new ItemHandlerBasic(9 * 2, this);
|
||||||
|
|
||||||
|
private boolean oredictPattern;
|
||||||
|
|
||||||
|
public TileProcessingPatternEncoder() {
|
||||||
|
dataManager.addWatchedParameter(OREDICT_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound write(NBTTagCompound tag) {
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
super.write(tag);
|
super.write(tag);
|
||||||
@@ -24,6 +56,8 @@ public class TileProcessingPatternEncoder extends TileBase {
|
|||||||
RSUtils.writeItems(patterns, 0, tag);
|
RSUtils.writeItems(patterns, 0, tag);
|
||||||
RSUtils.writeItems(configuration, 1, tag);
|
RSUtils.writeItems(configuration, 1, tag);
|
||||||
|
|
||||||
|
tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,12 +67,18 @@ public class TileProcessingPatternEncoder extends TileBase {
|
|||||||
|
|
||||||
RSUtils.readItems(patterns, 0, tag);
|
RSUtils.readItems(patterns, 0, tag);
|
||||||
RSUtils.readItems(configuration, 1, tag);
|
RSUtils.readItems(configuration, 1, tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_OREDICT_PATTERN)) {
|
||||||
|
oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreatePattern() {
|
public void onCreatePattern() {
|
||||||
if (canCreatePattern()) {
|
if (canCreatePattern()) {
|
||||||
ItemStack pattern = new ItemStack(RSItems.PATTERN);
|
ItemStack pattern = new ItemStack(RSItems.PATTERN);
|
||||||
|
|
||||||
|
ItemPattern.setOredict(pattern, oredictPattern);
|
||||||
|
|
||||||
for (int i = 0; i < 18; ++i) {
|
for (int i = 0; i < 18; ++i) {
|
||||||
if (configuration.getStackInSlot(i) != null) {
|
if (configuration.getStackInSlot(i) != null) {
|
||||||
if (i >= 9) {
|
if (i >= 9) {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user