Crafting monitor improvements WIP
This commit is contained in:
@@ -3,7 +3,6 @@ package refinedstorage.autocrafting.task;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.autocrafting.CraftingPattern;
|
import refinedstorage.autocrafting.CraftingPattern;
|
||||||
@@ -133,49 +132,43 @@ public class BasicCraftingTask implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInfo() {
|
public List<Object> getInfo() {
|
||||||
|
List<Object> items = new ArrayList<Object>();
|
||||||
|
|
||||||
if (!updatedOnce) {
|
if (!updatedOnce) {
|
||||||
return "{not_started_yet}";
|
items.add("T=gui.refinedstorage:crafting_monitor.not_started_yet");
|
||||||
|
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
boolean areItemsCrafting = false;
|
||||||
|
|
||||||
builder.append(TextFormatting.YELLOW).append("{missing_items}").append(TextFormatting.RESET).append("\n");
|
|
||||||
|
|
||||||
int missingItems = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||||
ItemStack input = pattern.getInputs()[i];
|
|
||||||
|
|
||||||
if (checked[i] && !satisfied[i] && !childTasks[i]) {
|
|
||||||
builder.append("- ").append(input.getDisplayName()).append("\n");
|
|
||||||
|
|
||||||
missingItems++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missingItems == 0) {
|
|
||||||
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.append(TextFormatting.YELLOW).append("{items_crafting}").append(TextFormatting.RESET).append("\n");
|
|
||||||
|
|
||||||
int itemsCrafting = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
|
||||||
ItemStack input = pattern.getInputs()[i];
|
|
||||||
|
|
||||||
if (!satisfied[i] && childTasks[i]) {
|
if (!satisfied[i] && childTasks[i]) {
|
||||||
builder.append("- ").append(input.getUnlocalizedName()).append(".name").append("\n");
|
if (!areItemsCrafting) {
|
||||||
|
items.add("T=gui.refinedstorage:crafting_monitor.items_crafting");
|
||||||
|
|
||||||
itemsCrafting++;
|
areItemsCrafting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(pattern.getInputs()[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemsCrafting == 0) {
|
boolean hasItemsInQueue = false;
|
||||||
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
|
||||||
|
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||||
|
if (!satisfied[i] && !childTasks[i]) {
|
||||||
|
if (!hasItemsInQueue) {
|
||||||
|
items.add("T=gui.refinedstorage:crafting_monitor.items_in_queue");
|
||||||
|
|
||||||
|
hasItemsInQueue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(pattern.getInputs()[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import refinedstorage.autocrafting.CraftingPattern;
|
import refinedstorage.autocrafting.CraftingPattern;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ICraftingTask {
|
public interface ICraftingTask {
|
||||||
CraftingPattern getPattern();
|
CraftingPattern getPattern();
|
||||||
|
|
||||||
@@ -15,5 +17,5 @@ public interface ICraftingTask {
|
|||||||
|
|
||||||
void writeToNBT(NBTTagCompound tag);
|
void writeToNBT(NBTTagCompound tag);
|
||||||
|
|
||||||
String getInfo();
|
List<Object> getInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package refinedstorage.autocrafting.task;
|
|||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
@@ -10,6 +9,9 @@ import refinedstorage.autocrafting.CraftingPattern;
|
|||||||
import refinedstorage.tile.TileCrafter;
|
import refinedstorage.tile.TileCrafter;
|
||||||
import refinedstorage.tile.controller.TileController;
|
import refinedstorage.tile.controller.TileController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ProcessingCraftingTask implements ICraftingTask {
|
public class ProcessingCraftingTask implements ICraftingTask {
|
||||||
public static final int ID = 1;
|
public static final int ID = 1;
|
||||||
|
|
||||||
@@ -125,9 +127,13 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInfo() {
|
public List<Object> getInfo() {
|
||||||
if (!updatedOnce) {
|
List<Object> items = new ArrayList<Object>();
|
||||||
return "{not_started_yet}";
|
|
||||||
|
return items;
|
||||||
|
|
||||||
|
/*if (!updatedOnce) {
|
||||||
|
return Arrays.asList("{not_started_yet}");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@@ -186,6 +192,6 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package refinedstorage.gui;
|
|||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.container.ContainerCraftingMonitor;
|
import refinedstorage.container.ContainerCraftingMonitor;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
import refinedstorage.network.MessageCraftingMonitorCancel;
|
import refinedstorage.network.MessageCraftingMonitorCancel;
|
||||||
|
import refinedstorage.network.MessageCraftingMonitorSelect;
|
||||||
import refinedstorage.tile.TileCraftingMonitor;
|
import refinedstorage.tile.TileCraftingMonitor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiCraftingMonitor extends GuiBase {
|
public class GuiCraftingMonitor extends GuiBase {
|
||||||
public static final int VISIBLE_ROWS = 3;
|
public static final int VISIBLE_ROWS = 3;
|
||||||
@@ -25,16 +25,13 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
private GuiButton cancelButton;
|
private GuiButton cancelButton;
|
||||||
private GuiButton cancelAllButton;
|
private GuiButton cancelAllButton;
|
||||||
|
|
||||||
private int itemSelected = -1;
|
private int selectionX = Integer.MAX_VALUE;
|
||||||
|
private int selectionY = Integer.MAX_VALUE;
|
||||||
private boolean renderItemSelection;
|
|
||||||
private int renderItemSelectionX;
|
|
||||||
private int renderItemSelectionY;
|
|
||||||
|
|
||||||
private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 89);
|
private Scrollbar scrollbar = new Scrollbar(157, 20, 12, 89);
|
||||||
|
|
||||||
public GuiCraftingMonitor(ContainerCraftingMonitor container, TileCraftingMonitor craftingMonitor) {
|
public GuiCraftingMonitor(ContainerCraftingMonitor container, TileCraftingMonitor craftingMonitor) {
|
||||||
super(container, 176, 230);
|
super(container, 256, 230);
|
||||||
|
|
||||||
this.craftingMonitor = craftingMonitor;
|
this.craftingMonitor = craftingMonitor;
|
||||||
}
|
}
|
||||||
@@ -65,11 +62,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
|
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
|
||||||
scrollbar.setScrollDelta((float) scrollbar.getScrollbarHeight() / (float) getRows());
|
scrollbar.setScrollDelta((float) scrollbar.getScrollbarHeight() / (float) getRows());
|
||||||
|
|
||||||
if (itemSelected >= craftingMonitor.getTasks().size()) {
|
cancelButton.enabled = craftingMonitor.hasSelection();
|
||||||
itemSelected = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelButton.enabled = itemSelected != -1;
|
|
||||||
cancelAllButton.enabled = craftingMonitor.getTasks().size() > 0;
|
cancelAllButton.enabled = craftingMonitor.getTasks().size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +72,11 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
drawTexture(x, y, 0, 0, width, height);
|
drawTexture(x, y, 0, 0, width, height);
|
||||||
|
|
||||||
if (renderItemSelection) {
|
|
||||||
drawTexture(x + renderItemSelectionX, y + renderItemSelectionY, 178, 0, ITEM_WIDTH, ITEM_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollbar.draw(this);
|
scrollbar.draw(this);
|
||||||
|
|
||||||
|
if (craftingMonitor.hasSelection()) {
|
||||||
|
drawRect(x + selectionX, y + selectionY, x + selectionX + ITEM_WIDTH - 1, y + selectionY + ITEM_HEIGHT - 1, 0xFFCCCCCC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,20 +87,15 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
int x = 8;
|
int x = 8;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
int item = getOffset() * 2;
|
int id = getOffset() * 2;
|
||||||
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
|
||||||
List<String> infoLines = null;
|
|
||||||
|
|
||||||
renderItemSelection = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
if (item < craftingMonitor.getTasks().size()) {
|
if (id < craftingMonitor.getTasks().size()) {
|
||||||
if (item == itemSelected) {
|
if (id == craftingMonitor.getSelected()) {
|
||||||
renderItemSelection = true;
|
selectionX = x;
|
||||||
renderItemSelectionX = x;
|
selectionY = y;
|
||||||
renderItemSelectionY = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TileCraftingMonitor.ClientSideCraftingTask task = craftingMonitor.getTasks().get(i);
|
TileCraftingMonitor.ClientSideCraftingTask task = craftingMonitor.getTasks().get(i);
|
||||||
@@ -119,29 +107,13 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.scale(scale, scale, 1);
|
GlStateManager.scale(scale, scale, 1);
|
||||||
|
|
||||||
drawString(RefinedStorageUtils.calculateOffsetOnScale(x + 5, scale), RefinedStorageUtils.calculateOffsetOnScale(y + 4, scale), task.output.getDisplayName());
|
drawString(
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(x + 5, scale),
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(y + 4, scale),
|
||||||
|
task.output.getDisplayName()
|
||||||
|
);
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
if (inBounds(x + 5, y + 10, 16, 16, mouseX, mouseY)) {
|
|
||||||
infoLines = Arrays.asList(task.info.split("\n"));
|
|
||||||
|
|
||||||
// @todo use utils method for this
|
|
||||||
for (int j = 0; j < infoLines.size(); ++j) {
|
|
||||||
String line = infoLines.get(j);
|
|
||||||
|
|
||||||
if (line.startsWith("- ")) {
|
|
||||||
infoLines.set(j, "- " + t(line.substring(2)));
|
|
||||||
} else {
|
|
||||||
infoLines.set(j, line
|
|
||||||
.replace("{missing_items}", t("gui.refinedstorage:crafting_monitor.missing_items"))
|
|
||||||
.replace("{items_crafting}", t("gui.refinedstorage:crafting_monitor.items_crafting"))
|
|
||||||
.replace("{items_processing}", t("gui.refinedstorage:crafting_monitor.items_processing"))
|
|
||||||
.replace("{not_started_yet}", t("gui.refinedstorage:crafting_monitor.not_started_yet"))
|
|
||||||
.replace("{none}", t("gui.none")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 1 || i == 3) {
|
if (i == 1 || i == 3) {
|
||||||
@@ -151,11 +123,46 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
x += ITEM_WIDTH;
|
x += ITEM_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
item++;
|
id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infoLines != null) {
|
if (craftingMonitor.hasSelection()) {
|
||||||
drawTooltip(mouseX, mouseY, infoLines);
|
float scale = 0.5f;
|
||||||
|
|
||||||
|
x = 179;
|
||||||
|
y = 24;
|
||||||
|
|
||||||
|
for (Object item : craftingMonitor.getInfo()) {
|
||||||
|
if (item instanceof String) {
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scale, scale, 1);
|
||||||
|
|
||||||
|
String text = (String) item;
|
||||||
|
|
||||||
|
drawString(
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(x, scale),
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(y, scale),
|
||||||
|
text.startsWith("T=") ? t(text.substring(2)) : text
|
||||||
|
);
|
||||||
|
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
} else if (item instanceof ItemStack) {
|
||||||
|
drawItem(x, y, (ItemStack) item);
|
||||||
|
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.scale(scale, scale, 1);
|
||||||
|
|
||||||
|
drawString(
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(x + 20, scale),
|
||||||
|
RefinedStorageUtils.calculateOffsetOnScale(y + 6, scale),
|
||||||
|
((ItemStack) item).getDisplayName()
|
||||||
|
);
|
||||||
|
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
y += item instanceof String ? 7 : 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +180,8 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
super.actionPerformed(button);
|
super.actionPerformed(button);
|
||||||
|
|
||||||
if (button == cancelButton && itemSelected != -1) {
|
if (button == cancelButton && craftingMonitor.hasSelection()) {
|
||||||
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, craftingMonitor.getTasks().get(itemSelected).id));
|
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, craftingMonitor.getTasks().get(craftingMonitor.getSelected()).id));
|
||||||
} else if (button == cancelAllButton && craftingMonitor.getTasks().size() > 0) {
|
} else if (button == cancelAllButton && craftingMonitor.getTasks().size() > 0) {
|
||||||
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, -1));
|
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, -1));
|
||||||
}
|
}
|
||||||
@@ -184,23 +191,33 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
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);
|
||||||
|
|
||||||
if (mouseButton == 0 && inBounds(8, 20, 144, 90, mouseX - guiLeft, mouseY - guiTop)) {
|
boolean resetSelection = !inBounds(174, 19, 77, 91, mouseX - guiLeft, mouseY - guiTop);
|
||||||
itemSelected = -1;
|
|
||||||
|
|
||||||
int item = getOffset() * 2;
|
if (mouseButton == 0 && inBounds(8, 20, 144, 90, mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
|
int id = getOffset() * 2;
|
||||||
|
|
||||||
for (int y = 0; y < 3; ++y) {
|
for (int y = 0; y < 3; ++y) {
|
||||||
for (int x = 0; x < 2; ++x) {
|
for (int x = 0; x < 2; ++x) {
|
||||||
int ix = 8 + (x * ITEM_WIDTH);
|
int ix = 8 + (x * ITEM_WIDTH);
|
||||||
int iy = 20 + (y * ITEM_HEIGHT);
|
int iy = 20 + (y * ITEM_HEIGHT);
|
||||||
|
|
||||||
if (inBounds(ix, iy, ITEM_WIDTH, ITEM_HEIGHT, mouseX - guiLeft, mouseY - guiTop) && item < craftingMonitor.getTasks().size()) {
|
if (inBounds(ix, iy, ITEM_WIDTH, ITEM_HEIGHT, mouseX - guiLeft, mouseY - guiTop) && id < craftingMonitor.getTasks().size()) {
|
||||||
itemSelected = item;
|
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorSelect(craftingMonitor, craftingMonitor.getTasks().get(id).id));
|
||||||
|
|
||||||
|
craftingMonitor.setSelected(id);
|
||||||
|
|
||||||
|
resetSelection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
item++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resetSelection) {
|
||||||
|
RefinedStorage.NETWORK.sendToServer(new MessageCraftingMonitorSelect(craftingMonitor, -1));
|
||||||
|
|
||||||
|
craftingMonitor.setSelected(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/main/java/refinedstorage/network/MessageCraftingMonitorSelect.java
Executable file
50
src/main/java/refinedstorage/network/MessageCraftingMonitorSelect.java
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
package refinedstorage.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import refinedstorage.tile.TileCraftingMonitor;
|
||||||
|
|
||||||
|
public class MessageCraftingMonitorSelect extends MessageHandlerPlayerToServer<MessageCraftingMonitorSelect> implements IMessage {
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
public MessageCraftingMonitorSelect() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageCraftingMonitorSelect(TileCraftingMonitor craftingMonitor, int id) {
|
||||||
|
this.x = craftingMonitor.getPos().getX();
|
||||||
|
this.y = craftingMonitor.getPos().getY();
|
||||||
|
this.z = craftingMonitor.getPos().getZ();
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
x = buf.readInt();
|
||||||
|
y = buf.readInt();
|
||||||
|
z = buf.readInt();
|
||||||
|
id = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(x);
|
||||||
|
buf.writeInt(y);
|
||||||
|
buf.writeInt(z);
|
||||||
|
buf.writeInt(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(MessageCraftingMonitorSelect message, EntityPlayerMP player) {
|
||||||
|
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||||
|
|
||||||
|
if (tile instanceof TileCraftingMonitor) {
|
||||||
|
((TileCraftingMonitor) tile).setSelected(message.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,7 @@ public class CommonProxy {
|
|||||||
RefinedStorage.NETWORK.registerMessage(MessageGridPatternCreate.class, MessageGridPatternCreate.class, id++, Side.SERVER);
|
RefinedStorage.NETWORK.registerMessage(MessageGridPatternCreate.class, MessageGridPatternCreate.class, id++, Side.SERVER);
|
||||||
RefinedStorage.NETWORK.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
RefinedStorage.NETWORK.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
||||||
RefinedStorage.NETWORK.registerMessage(MessageGridItems.class, MessageGridItems.class, id++, Side.CLIENT);
|
RefinedStorage.NETWORK.registerMessage(MessageGridItems.class, MessageGridItems.class, id++, Side.CLIENT);
|
||||||
|
RefinedStorage.NETWORK.registerMessage(MessageCraftingMonitorSelect.class, MessageCraftingMonitorSelect.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TileCraftingMonitor extends TileMachine {
|
public class TileCraftingMonitor extends TileMachine {
|
||||||
private List<ClientSideCraftingTask> tasks = new ArrayList<ClientSideCraftingTask>();
|
private List<ClientSideCraftingTask> tasks = new ArrayList<ClientSideCraftingTask>();
|
||||||
|
private int selected = -1;
|
||||||
|
private List<Object> info = new ArrayList<Object>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
@@ -31,8 +33,6 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
buf.writeInt(controller.getCraftingTasks().size());
|
buf.writeInt(controller.getCraftingTasks().size());
|
||||||
|
|
||||||
for (ICraftingTask task : controller.getCraftingTasks()) {
|
for (ICraftingTask task : controller.getCraftingTasks()) {
|
||||||
ByteBufUtils.writeUTF8String(buf, task.getInfo());
|
|
||||||
|
|
||||||
buf.writeInt(task.getPattern().getOutputs().length);
|
buf.writeInt(task.getPattern().getOutputs().length);
|
||||||
|
|
||||||
for (ItemStack output : task.getPattern().getOutputs()) {
|
for (ItemStack output : task.getPattern().getOutputs()) {
|
||||||
@@ -42,6 +42,18 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
} else {
|
} else {
|
||||||
buf.writeInt(0);
|
buf.writeInt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.writeInt(info.size());
|
||||||
|
|
||||||
|
for (Object item : info) {
|
||||||
|
if (item instanceof String) {
|
||||||
|
buf.writeInt(0);
|
||||||
|
ByteBufUtils.writeUTF8String(buf, (String) item);
|
||||||
|
} else if (item instanceof ItemStack) {
|
||||||
|
buf.writeInt(1);
|
||||||
|
ByteBufUtils.writeItemStack(buf, (ItemStack) item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,24 +65,62 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
List<ClientSideCraftingTask> newTasks = new ArrayList<ClientSideCraftingTask>();
|
List<ClientSideCraftingTask> newTasks = new ArrayList<ClientSideCraftingTask>();
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
String info = ByteBufUtils.readUTF8String(buf);
|
|
||||||
|
|
||||||
int outputs = buf.readInt();
|
int outputs = buf.readInt();
|
||||||
|
|
||||||
for (int j = 0; j < outputs; ++j) {
|
for (int j = 0; j < outputs; ++j) {
|
||||||
newTasks.add(new ClientSideCraftingTask(ByteBufUtils.readItemStack(buf), i, info));
|
newTasks.add(new ClientSideCraftingTask(ByteBufUtils.readItemStack(buf), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.reverse(newTasks);
|
Collections.reverse(newTasks);
|
||||||
|
|
||||||
tasks = newTasks;
|
tasks = newTasks;
|
||||||
|
|
||||||
|
List<Object> newInfo = new ArrayList<Object>();
|
||||||
|
|
||||||
|
size = buf.readInt();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
int type = buf.readInt();
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
newInfo.add(ByteBufUtils.readUTF8String(buf));
|
||||||
|
} else if (type == 1) {
|
||||||
|
newInfo.add(ByteBufUtils.readItemStack(buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
info = newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientSideCraftingTask> getTasks() {
|
public List<ClientSideCraftingTask> getTasks() {
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSelected() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(int selected) {
|
||||||
|
this.selected = selected;
|
||||||
|
|
||||||
|
if (!worldObj.isRemote) {
|
||||||
|
if (selected != -1) {
|
||||||
|
info = controller.getCraftingTasks().get(selected).getInfo();
|
||||||
|
} else {
|
||||||
|
info.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSelection() {
|
||||||
|
return selected != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object> getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Container> getContainer() {
|
public Class<? extends Container> getContainer() {
|
||||||
return ContainerCraftingMonitor.class;
|
return ContainerCraftingMonitor.class;
|
||||||
@@ -79,12 +129,10 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
public class ClientSideCraftingTask {
|
public class ClientSideCraftingTask {
|
||||||
public ItemStack output;
|
public ItemStack output;
|
||||||
public int id;
|
public int id;
|
||||||
public String info;
|
|
||||||
|
|
||||||
public ClientSideCraftingTask(ItemStack output, int id, String info) {
|
public ClientSideCraftingTask(ItemStack output, int id) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.info = info;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ gui.refinedstorage:relay=Relay
|
|||||||
gui.refinedstorage:interface.import=Interface Import
|
gui.refinedstorage:interface.import=Interface Import
|
||||||
gui.refinedstorage:interface.export=Interface Export
|
gui.refinedstorage:interface.export=Interface Export
|
||||||
gui.refinedstorage:crafting_monitor=Crafting Monitor
|
gui.refinedstorage:crafting_monitor=Crafting Monitor
|
||||||
gui.refinedstorage:crafting_monitor.missing_items=Missing items:
|
gui.refinedstorage:crafting_monitor.items_in_queue=Items in queue
|
||||||
gui.refinedstorage:crafting_monitor.items_crafting=Items crafting:
|
gui.refinedstorage:crafting_monitor.items_crafting=Items crafting
|
||||||
gui.refinedstorage:crafting_monitor.items_processing=Items processing:
|
gui.refinedstorage:crafting_monitor.items_processing=Items processing
|
||||||
gui.refinedstorage:crafting_monitor.not_started_yet=Crafting task not started yet.
|
gui.refinedstorage:crafting_monitor.not_started_yet=Not started yet
|
||||||
gui.refinedstorage:wireless_transmitter=Wireless Transmitter
|
gui.refinedstorage:wireless_transmitter=Wireless Transmitter
|
||||||
gui.refinedstorage:wireless_transmitter.distance=%d blocks
|
gui.refinedstorage:wireless_transmitter.distance=%d blocks
|
||||||
gui.refinedstorage:crafter=Crafter
|
gui.refinedstorage:crafter=Crafter
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ gui.refinedstorage:relay=Relais
|
|||||||
gui.refinedstorage:interface.import=Interface d'Import
|
gui.refinedstorage:interface.import=Interface d'Import
|
||||||
gui.refinedstorage:interface.export=Interface d'Export
|
gui.refinedstorage:interface.export=Interface d'Export
|
||||||
gui.refinedstorage:crafting_monitor=Moniteur de Craft
|
gui.refinedstorage:crafting_monitor=Moniteur de Craft
|
||||||
gui.refinedstorage:crafting_monitor.missing_items=Items manquant:
|
gui.refinedstorage:crafting_monitor.missing_items=Items manquant
|
||||||
gui.refinedstorage:crafting_monitor.items_crafting=Items en craft:
|
gui.refinedstorage:crafting_monitor.items_crafting=Items en craft
|
||||||
gui.refinedstorage:crafting_monitor.items_processing=Items en traitement:
|
gui.refinedstorage:crafting_monitor.items_processing=Items en traitement
|
||||||
gui.refinedstorage:crafting_monitor.not_started_yet=Tâche crafting pas encore commencé.
|
gui.refinedstorage:crafting_monitor.not_started_yet=Pas encore commencé
|
||||||
gui.refinedstorage:wireless_transmitter=Émetteur sans Fil
|
gui.refinedstorage:wireless_transmitter=Émetteur sans Fil
|
||||||
gui.refinedstorage:wireless_transmitter.distance=%d blocks
|
gui.refinedstorage:wireless_transmitter.distance=%d blocks
|
||||||
gui.refinedstorage:crafter=Crafteur
|
gui.refinedstorage:crafter=Crafteur
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ gui.refinedstorage:relay=Relais
|
|||||||
gui.refinedstorage:interface.import=Interface Import
|
gui.refinedstorage:interface.import=Interface Import
|
||||||
gui.refinedstorage:interface.export=Interface Export
|
gui.refinedstorage:interface.export=Interface Export
|
||||||
gui.refinedstorage:crafting_monitor=Crafting Monitor
|
gui.refinedstorage:crafting_monitor=Crafting Monitor
|
||||||
gui.refinedstorage:crafting_monitor.missing_items=Ontbrekende items:
|
gui.refinedstorage:crafting_monitor.missing_items=Ontbrekende items
|
||||||
gui.refinedstorage:crafting_monitor.items_crafting=Items aan het craften:
|
gui.refinedstorage:crafting_monitor.items_crafting=Items aan het craften
|
||||||
gui.refinedstorage:crafting_monitor.items_processing=Items aan het verwerken:
|
gui.refinedstorage:crafting_monitor.items_processing=Items aan het verwerken
|
||||||
gui.refinedstorage:crafting_monitor.not_started_yet=Crafting opdracht nog niet begonnen.
|
gui.refinedstorage:crafting_monitor.not_started_yet=Nog niet begonnen
|
||||||
gui.refinedstorage:wireless_transmitter=Draadloze Zender
|
gui.refinedstorage:wireless_transmitter=Draadloze Zender
|
||||||
gui.refinedstorage:wireless_transmitter.distance=%d blokken
|
gui.refinedstorage:wireless_transmitter.distance=%d blokken
|
||||||
gui.refinedstorage:crafter=Crafter
|
gui.refinedstorage:crafter=Crafter
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user