GUI processing stuff
This commit is contained in:
@@ -7,6 +7,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.sidebutton.SideButton;
|
||||
@@ -112,8 +113,14 @@ public abstract class GuiBase extends GuiContainer {
|
||||
}
|
||||
|
||||
public GuiButton addButton(int x, int y, int w, int h, String text) {
|
||||
GuiButton button = new GuiButton(lastButtonId++, x, y, w, h, text);
|
||||
return addButton(new GuiButton(lastButtonId++, x, y, w, h, text));
|
||||
}
|
||||
|
||||
public GuiButton addCheckBox(int x, int y, String text) {
|
||||
return addButton(new GuiCheckBox(lastButtonId++, x, y, text, false));
|
||||
}
|
||||
|
||||
public GuiButton addButton(GuiButton button) {
|
||||
buttonList.add(button);
|
||||
|
||||
return button;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GuiCrafter extends GuiBase {
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
|
||||
int x = 27;
|
||||
int y = 19 + (i * 18);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
@@ -35,6 +36,7 @@ public class GuiGrid extends GuiBase {
|
||||
private List<ItemGroup> items = new ArrayList<ItemGroup>();
|
||||
|
||||
private GuiTextField searchField;
|
||||
private GuiCheckBox processingCheckbox;
|
||||
|
||||
private int hoveringSlot;
|
||||
private int hoveringItemId;
|
||||
@@ -65,6 +67,10 @@ public class GuiGrid extends GuiBase {
|
||||
addSideButton(new SideButtonGridSortingDirection(grid));
|
||||
addSideButton(new SideButtonGridSortingType(grid));
|
||||
addSideButton(new SideButtonGridSearchBoxMode(grid));
|
||||
|
||||
if (grid.getType() == EnumGridType.PATTERN) {
|
||||
processingCheckbox = (GuiCheckBox) addCheckBox(x + 65, y + 148, t("misc.refinedstorage:processing"));
|
||||
}
|
||||
}
|
||||
|
||||
public IGrid getGrid() {
|
||||
@@ -302,7 +308,7 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
if (grid.isConnected()) {
|
||||
if (clickedCreatePattern) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridPatternCreate((TileGrid) grid));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridPatternCreate((TileGrid) grid, processingCheckbox.isChecked()));
|
||||
} else if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
|
||||
grid.onItemPush(-1, clickedButton == 1);
|
||||
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,6 +13,7 @@ import java.util.List;
|
||||
public class ItemPattern extends ItemBase {
|
||||
public static final String NBT_RESULT = "Result";
|
||||
public static final String NBT_INGREDIENTS = "Ingredients";
|
||||
public static final String NBT_PROCESSING = "Processing";
|
||||
|
||||
public ItemPattern() {
|
||||
super("pattern");
|
||||
@@ -20,6 +23,10 @@ public class ItemPattern extends ItemBase {
|
||||
public void addInformation(ItemStack pattern, EntityPlayer player, List list, boolean b) {
|
||||
if (hasResult(pattern)) {
|
||||
list.add(getResult(pattern).getDisplayName());
|
||||
|
||||
if (isProcessing(pattern)) {
|
||||
list.add(TextFormatting.ITALIC + I18n.translateToLocal("misc.refinedstorage:processing") + TextFormatting.RESET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +73,22 @@ public class ItemPattern extends ItemBase {
|
||||
pattern.getTagCompound().setTag(NBT_RESULT, stackTag);
|
||||
}
|
||||
|
||||
public static void setProcessing(ItemStack pattern, boolean processing) {
|
||||
if (pattern.getTagCompound() == null) {
|
||||
pattern.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
pattern.getTagCompound().setBoolean(NBT_PROCESSING, processing);
|
||||
}
|
||||
|
||||
public static boolean isProcessing(ItemStack pattern) {
|
||||
if (pattern.getTagCompound() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return pattern.getTagCompound().getBoolean(NBT_PROCESSING);
|
||||
}
|
||||
|
||||
public static boolean hasResult(ItemStack pattern) {
|
||||
if (pattern.getTagCompound() == null) {
|
||||
return false;
|
||||
|
||||
@@ -12,14 +12,16 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private boolean processing;
|
||||
|
||||
public MessageGridPatternCreate() {
|
||||
}
|
||||
|
||||
public MessageGridPatternCreate(TileGrid grid) {
|
||||
public MessageGridPatternCreate(TileGrid grid, boolean processing) {
|
||||
this.x = grid.getPos().getX();
|
||||
this.y = grid.getPos().getY();
|
||||
this.z = grid.getPos().getZ();
|
||||
this.processing = processing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,6 +29,7 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
processing = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,6 +37,7 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeBoolean(processing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +45,7 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileGrid && ((TileGrid) tile).getType() == EnumGridType.PATTERN) {
|
||||
((TileGrid) tile).onCreatePattern();
|
||||
((TileGrid) tile).onCreatePattern(message.processing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageProvider;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.autocrafting.CraftingPattern;
|
||||
import refinedstorage.tile.autocrafting.CraftingTask;
|
||||
import refinedstorage.tile.autocrafting.BasicCraftingTask;
|
||||
import refinedstorage.tile.autocrafting.ICraftingTask;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
import refinedstorage.tile.grid.WirelessGridConsumer;
|
||||
@@ -60,8 +61,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
private List<ClientSideMachine> clientSideMachines = new ArrayList<ClientSideMachine>();
|
||||
|
||||
private List<CraftingPattern> patterns = new ArrayList<CraftingPattern>();
|
||||
private List<CraftingTask> craftingTasks = new ArrayList<CraftingTask>();
|
||||
private List<CraftingTask> craftingTasksToAdd = new ArrayList<CraftingTask>();
|
||||
private List<ICraftingTask> craftingTasks = new ArrayList<ICraftingTask>();
|
||||
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<ICraftingTask>();
|
||||
|
||||
private Set<String> visited = new HashSet<String>();
|
||||
|
||||
@@ -174,10 +175,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
craftingTasks.addAll(craftingTasksToAdd);
|
||||
craftingTasksToAdd.clear();
|
||||
|
||||
Iterator<CraftingTask> crIt = craftingTasks.iterator();
|
||||
Iterator<ICraftingTask> crIt = craftingTasks.iterator();
|
||||
|
||||
while (crIt.hasNext()) {
|
||||
CraftingTask task = crIt.next();
|
||||
ICraftingTask task = crIt.next();
|
||||
|
||||
if (ticks % task.getPattern().getSpeed() == 0 && task.update(this)) {
|
||||
crIt.remove();
|
||||
@@ -250,11 +251,11 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
return itemGroups;
|
||||
}
|
||||
|
||||
public List<CraftingTask> getCraftingTasks() {
|
||||
public List<ICraftingTask> getCraftingTasks() {
|
||||
return craftingTasks;
|
||||
}
|
||||
|
||||
public void addCraftingTask(CraftingTask task) {
|
||||
public void addCraftingTask(ICraftingTask task) {
|
||||
craftingTasksToAdd.add(task);
|
||||
}
|
||||
|
||||
@@ -682,7 +683,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
CraftingPattern pattern = getPatternForItem(itemGroups.get(id).toItemStack());
|
||||
|
||||
if (pattern != null) {
|
||||
addCraftingTask(new CraftingTask(pattern));
|
||||
addCraftingTask(new BasicCraftingTask(pattern));
|
||||
|
||||
quantity -= pattern.getResult().stackSize;
|
||||
} else {
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package refinedstorage.tile.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CraftingTask {
|
||||
public class BasicCraftingTask implements ICraftingTask {
|
||||
private CraftingPattern pattern;
|
||||
private boolean satisfied[];
|
||||
private boolean childTasks[];
|
||||
|
||||
public CraftingTask(CraftingPattern pattern) {
|
||||
public BasicCraftingTask(CraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.satisfied = new boolean[pattern.getIngredients().length];
|
||||
this.childTasks = new boolean[pattern.getIngredients().length];
|
||||
@@ -39,7 +35,7 @@ public class CraftingTask {
|
||||
CraftingPattern pattern = controller.getPatternForItem(ingredient);
|
||||
|
||||
if (pattern != null) {
|
||||
controller.addCraftingTask(new CraftingTask(pattern));
|
||||
controller.addCraftingTask(new BasicCraftingTask(pattern));
|
||||
|
||||
childTasks[i] = true;
|
||||
|
||||
9
src/main/java/refinedstorage/tile/autocrafting/ICraftingTask.java
Executable file
9
src/main/java/refinedstorage/tile/autocrafting/ICraftingTask.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package refinedstorage.tile.autocrafting;
|
||||
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public interface ICraftingTask {
|
||||
CraftingPattern getPattern();
|
||||
|
||||
boolean update(TileController controller);
|
||||
}
|
||||
21
src/main/java/refinedstorage/tile/autocrafting/ProcessingCraftingTask.java
Executable file
21
src/main/java/refinedstorage/tile/autocrafting/ProcessingCraftingTask.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package refinedstorage.tile.autocrafting;
|
||||
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class ProcessingCraftingTask implements ICraftingTask {
|
||||
private CraftingPattern pattern;
|
||||
|
||||
public ProcessingCraftingTask(CraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftingPattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileController controller) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class TileCraftingMonitor extends TileMachine {
|
||||
if (connected) {
|
||||
buf.writeInt(controller.getCraftingTasks().size());
|
||||
|
||||
for (CraftingTask task : controller.getCraftingTasks()) {
|
||||
for (ICraftingTask task : controller.getCraftingTasks()) {
|
||||
ByteBufUtils.writeItemStack(buf, task.getPattern().getResult());
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -165,7 +165,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreatePattern() {
|
||||
public void onCreatePattern(boolean processing) {
|
||||
ItemStack crafted = craftingResultInventory.getStackInSlot(0);
|
||||
|
||||
if (patternsInventory.getStackInSlot(1) == null && patternsInventory.getStackInSlot(0) != null && patternsInventory.getStackInSlot(0).stackSize > 0) {
|
||||
@@ -174,6 +174,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
ItemStack pattern = new ItemStack(RefinedStorageItems.PATTERN);
|
||||
|
||||
ItemPattern.setResult(pattern, crafted);
|
||||
ItemPattern.setProcessing(pattern, processing);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack ingredient = craftingInventory.getStackInSlot(i);
|
||||
|
||||
Reference in New Issue
Block a user