Add information to crafting monitor about crafting task
This commit is contained in:
@@ -204,8 +204,12 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawTooltip(int x, int y, String message) {
|
public void drawTooltip(int x, int y, String message) {
|
||||||
|
drawTooltip(x, y, Arrays.asList(message.split("\n")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawTooltip(int x, int y, List<String> lines) {
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
drawHoveringText(Arrays.asList(message.split("\n")), x, y);
|
drawHoveringText(lines, x, y);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import refinedstorage.container.ContainerCraftingMonitor;
|
import refinedstorage.container.ContainerCraftingMonitor;
|
||||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
import refinedstorage.tile.autocrafting.TileCraftingMonitor;
|
import refinedstorage.tile.autocrafting.TileCraftingMonitor;
|
||||||
|
import scala.actors.threadpool.Arrays;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -64,8 +65,10 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
List<ItemStack> tasks = craftingMonitor.getTasks();
|
List<ItemStack> tasks = craftingMonitor.getTasks();
|
||||||
|
|
||||||
|
List<String> infoLines = null;
|
||||||
|
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
if (slot < tasks.size()) {
|
if (slot < tasks.size() && slot < craftingMonitor.getInfo().length) {
|
||||||
ItemStack task = tasks.get(slot);
|
ItemStack task = tasks.get(slot);
|
||||||
|
|
||||||
drawItem(x, y + 5, task);
|
drawItem(x, y + 5, task);
|
||||||
@@ -77,6 +80,21 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
drawString(calculateOffsetOnScale(x + 1, scale), calculateOffsetOnScale(y - 3, scale), task.getDisplayName());
|
drawString(calculateOffsetOnScale(x + 1, scale), calculateOffsetOnScale(y - 3, scale), task.getDisplayName());
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
|
if (inBounds(x, y + 5, 16, 16, mouseX, mouseY)) {
|
||||||
|
infoLines = Arrays.asList(craftingMonitor.getInfo()[slot].split("\n"));
|
||||||
|
|
||||||
|
for (int j = 0; j < infoLines.size(); ++j) {
|
||||||
|
String line = infoLines.get(j);
|
||||||
|
|
||||||
|
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("{missing_machine}", t("gui.refinedstorage:crafting_monitor.missing_machine"))
|
||||||
|
.replace("{none}", t("misc.refinedstorage:none")));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 1 || i == 3) {
|
if (i == 1 || i == 3) {
|
||||||
@@ -88,6 +106,10 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (infoLines != null) {
|
||||||
|
drawTooltip(mouseX, mouseY, infoLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TileCraftingMonitor extends TileMachine {
|
public class TileCraftingMonitor extends TileMachine {
|
||||||
private List<ItemStack> tasks = new ArrayList<ItemStack>();
|
private List<ItemStack> tasks = new ArrayList<ItemStack>();
|
||||||
|
private String[] info = new String[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
@@ -31,6 +32,8 @@ 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()) {
|
||||||
@@ -46,11 +49,14 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
public void receiveContainerData(ByteBuf buf) {
|
public void receiveContainerData(ByteBuf buf) {
|
||||||
super.receiveContainerData(buf);
|
super.receiveContainerData(buf);
|
||||||
|
|
||||||
List<ItemStack> newTasks = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
|
|
||||||
|
List<ItemStack> newTasks = new ArrayList<ItemStack>();
|
||||||
|
String[] newInfo = new String[size];
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
|
newInfo[i] = ByteBufUtils.readUTF8String(buf);
|
||||||
|
|
||||||
int outputSize = buf.readInt();
|
int outputSize = buf.readInt();
|
||||||
|
|
||||||
for (int j = 0; j < outputSize; ++j) {
|
for (int j = 0; j < outputSize; ++j) {
|
||||||
@@ -59,12 +65,17 @@ public class TileCraftingMonitor extends TileMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks = newTasks;
|
tasks = newTasks;
|
||||||
|
info = newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> getTasks() {
|
public List<ItemStack> getTasks() {
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Container> getContainer() {
|
public Class<? extends Container> getContainer() {
|
||||||
return ContainerCraftingMonitor.class;
|
return ContainerCraftingMonitor.class;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package refinedstorage.tile.autocrafting.task;
|
package refinedstorage.tile.autocrafting.task;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
import refinedstorage.tile.autocrafting.CraftingPattern;
|
import refinedstorage.tile.autocrafting.CraftingPattern;
|
||||||
|
|
||||||
@@ -57,4 +58,47 @@ public class BasicCraftingTask implements ICraftingTask {
|
|||||||
controller.push(output);
|
controller.push(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfo() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
builder.append(TextFormatting.YELLOW).append("{missing_items}").append(TextFormatting.RESET).append("\n");
|
||||||
|
|
||||||
|
int missingItems = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||||
|
ItemStack input = pattern.getInputs()[i];
|
||||||
|
|
||||||
|
if (!satisfied[i] && !childTasks[i]) {
|
||||||
|
builder.append("- ").append(input.getUnlocalizedName()).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 (childTasks[i]) {
|
||||||
|
builder.append("- ").append(input.getDisplayName()).append("\n");
|
||||||
|
|
||||||
|
itemsCrafting++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemsCrafting == 0) {
|
||||||
|
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ public interface ICraftingTask {
|
|||||||
boolean update(TileController controller);
|
boolean update(TileController controller);
|
||||||
|
|
||||||
void onDone(TileController controller);
|
void onDone(TileController controller);
|
||||||
|
|
||||||
|
String getInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import net.minecraft.inventory.IInventory;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityHopper;
|
import net.minecraft.tileentity.TileEntityHopper;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
import refinedstorage.tile.autocrafting.CraftingPattern;
|
import refinedstorage.tile.autocrafting.CraftingPattern;
|
||||||
import refinedstorage.tile.autocrafting.TileCrafter;
|
import refinedstorage.tile.autocrafting.TileCrafter;
|
||||||
@@ -12,11 +13,14 @@ import refinedstorage.util.InventoryUtils;
|
|||||||
public class ProcessingCraftingTask implements ICraftingTask {
|
public class ProcessingCraftingTask implements ICraftingTask {
|
||||||
private CraftingPattern pattern;
|
private CraftingPattern pattern;
|
||||||
private boolean inserted[];
|
private boolean inserted[];
|
||||||
|
private boolean missing[];
|
||||||
private boolean satisfied[];
|
private boolean satisfied[];
|
||||||
|
private boolean missingMachine;
|
||||||
|
|
||||||
public ProcessingCraftingTask(CraftingPattern pattern) {
|
public ProcessingCraftingTask(CraftingPattern pattern) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.inserted = new boolean[pattern.getInputs().length];
|
this.inserted = new boolean[pattern.getInputs().length];
|
||||||
|
this.missing = new boolean[pattern.getInputs().length];
|
||||||
this.satisfied = new boolean[pattern.getOutputs().length];
|
this.satisfied = new boolean[pattern.getOutputs().length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,12 +35,16 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
TileEntity crafterFacing = crafter.getWorld().getTileEntity(crafter.getPos().offset(crafter.getDirection()));
|
TileEntity crafterFacing = crafter.getWorld().getTileEntity(crafter.getPos().offset(crafter.getDirection()));
|
||||||
|
|
||||||
if (crafterFacing instanceof IInventory) {
|
if (crafterFacing instanceof IInventory) {
|
||||||
|
missingMachine = false;
|
||||||
|
|
||||||
for (int i = 0; i < inserted.length; ++i) {
|
for (int i = 0; i < inserted.length; ++i) {
|
||||||
if (!inserted[i]) {
|
if (!inserted[i]) {
|
||||||
ItemStack input = pattern.getInputs()[i];
|
ItemStack input = pattern.getInputs()[i];
|
||||||
ItemStack took = controller.take(input);
|
ItemStack took = controller.take(input);
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
|
missing[i] = false;
|
||||||
|
|
||||||
ItemStack remaining = TileEntityHopper.putStackInInventoryAllSlots((IInventory) crafterFacing, took, crafter.getDirection().getOpposite());
|
ItemStack remaining = TileEntityHopper.putStackInInventoryAllSlots((IInventory) crafterFacing, took, crafter.getDirection().getOpposite());
|
||||||
|
|
||||||
if (remaining == null) {
|
if (remaining == null) {
|
||||||
@@ -44,9 +52,13 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
} else {
|
} else {
|
||||||
controller.push(input);
|
controller.push(input);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
missing[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
missingMachine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < satisfied.length; ++i) {
|
for (int i = 0; i < satisfied.length; ++i) {
|
||||||
@@ -73,4 +85,51 @@ public class ProcessingCraftingTask implements ICraftingTask {
|
|||||||
public void onDone(TileController controller) {
|
public void onDone(TileController controller) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfo() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (missingMachine) {
|
||||||
|
builder.append(TextFormatting.RED).append("{missing_machine}").append(TextFormatting.RESET).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append(TextFormatting.YELLOW).append("{missing_items}").append(TextFormatting.RESET).append("\n");
|
||||||
|
|
||||||
|
int missingItems = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||||
|
ItemStack input = pattern.getInputs()[i];
|
||||||
|
|
||||||
|
if (missing[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_processing}").append(TextFormatting.RESET).append("\n");
|
||||||
|
|
||||||
|
int itemsProcessing = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||||
|
ItemStack input = pattern.getInputs()[i];
|
||||||
|
|
||||||
|
if (inserted[i] && !satisfied[i]) {
|
||||||
|
builder.append("- ").append(input.getDisplayName()).append("\n");
|
||||||
|
|
||||||
|
itemsProcessing++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemsProcessing == 0) {
|
||||||
|
builder.append(TextFormatting.GRAY).append(TextFormatting.ITALIC).append("{none}").append(TextFormatting.RESET).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,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_crafting=Items crafting:
|
||||||
|
gui.refinedstorage:crafting_monitor.items_processing=Items processing:
|
||||||
|
gui.refinedstorage:crafting_monitor.missing_machine=Missing machine!
|
||||||
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
|
||||||
@@ -47,6 +51,7 @@ misc.refinedstorage:yes=Yes
|
|||||||
misc.refinedstorage:no=No
|
misc.refinedstorage:no=No
|
||||||
misc.refinedstorage:start=Start
|
misc.refinedstorage:start=Start
|
||||||
misc.refinedstorage:clear=Clear
|
misc.refinedstorage:clear=Clear
|
||||||
|
misc.refinedstorage:none=None
|
||||||
misc.refinedstorage:priority=Priority
|
misc.refinedstorage:priority=Priority
|
||||||
misc.refinedstorage:processing=Processing
|
misc.refinedstorage:processing=Processing
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,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.items_crafting=Items aan het craften:
|
||||||
|
gui.refinedstorage:crafting_monitor.items_processing=Items aan het verwerken:
|
||||||
|
gui.refinedstorage:crafting_monitor.missing_machine=Ontbrekende machine!
|
||||||
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
|
||||||
@@ -47,6 +51,7 @@ misc.refinedstorage:yes=Ja
|
|||||||
misc.refinedstorage:no=Nee
|
misc.refinedstorage:no=Nee
|
||||||
misc.refinedstorage:start=Start
|
misc.refinedstorage:start=Start
|
||||||
misc.refinedstorage:clear=Legen
|
misc.refinedstorage:clear=Legen
|
||||||
|
misc.refinedstorage:none=Geen
|
||||||
misc.refinedstorage:priority=Prioriteit
|
misc.refinedstorage:priority=Prioriteit
|
||||||
misc.refinedstorage:processing=Verwerking
|
misc.refinedstorage:processing=Verwerking
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user