Fixed thing not working

This commit is contained in:
Raoul Van den Berge
2016-09-17 19:06:55 +02:00
parent 9b576cd938
commit da186bba5a
3 changed files with 28 additions and 6 deletions

View File

@@ -104,7 +104,9 @@ public class GuiCraftingMonitor extends GuiBase {
itemSelectedY = y;
}
x += 16F / (float) task.getDepth();
if (task.getDepth() > 0) {
x += 16F - ((float) (task.getChildren() - task.getDepth()) / (float) task.getChildren() * 16F);
}
drawItem(x + 2, y + 1, task.getOutput());

View File

@@ -10,17 +10,19 @@ public class ClientCraftingTask {
private int id;
private String status;
private int depth;
private int children;
private int progress;
// Used server-side while sending
private List<ItemStack> outputs;
private ClientCraftingTask child;
public ClientCraftingTask(ItemStack output, int id, String status, int depth, int progress) {
public ClientCraftingTask(ItemStack output, int id, String status, int depth, int children, int progress) {
this.output = output;
this.id = id;
this.status = status;
this.depth = depth;
this.children = children;
this.progress = progress;
}
@@ -55,6 +57,10 @@ public class ClientCraftingTask {
return depth;
}
public int getChildren() {
return children;
}
public int getProgress() {
return progress;
}

View File

@@ -52,13 +52,25 @@ public final class RefinedStorageSerializers {
buf.writeInt(tasks.size());
for (ClientCraftingTask task : tasks) {
writeTask(buf, task);
int children = 0;
ClientCraftingTask child = task.getChild();
while (child != null) {
children++;
child = child.getChild();
}
writeTask(buf, task, children);
}
}
private void writeTask(PacketBuffer buf, ClientCraftingTask task) {
private void writeTask(PacketBuffer buf, ClientCraftingTask task, int children) {
ByteBufUtils.writeUTF8String(buf, task.getStatus());
buf.writeInt(children);
buf.writeInt(task.getProgress());
buf.writeInt(task.getOutputs().size());
@@ -70,7 +82,7 @@ public final class RefinedStorageSerializers {
buf.writeBoolean(task.getChild() != null);
if (task.getChild() != null) {
writeTask(buf, task.getChild());
writeTask(buf, task.getChild(), children);
}
}
@@ -90,12 +102,14 @@ public final class RefinedStorageSerializers {
private void readTask(PacketBuffer buf, int i, int depth, List<ClientCraftingTask> tasks) {
String status = ByteBufUtils.readUTF8String(buf);
int children = buf.readInt();
int progress = buf.readInt();
int outputs = buf.readInt();
for (int j = 0; j < outputs; ++j) {
tasks.add(new ClientCraftingTask(ByteBufUtils.readItemStack(buf), i, status, depth, progress));
tasks.add(new ClientCraftingTask(ByteBufUtils.readItemStack(buf), i, status, depth, children, progress));
}
if (buf.readBoolean()) {