Reworked autocrafting, still WIP
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package refinedstorage.api;
|
||||
|
||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
||||
import refinedstorage.api.solderer.ISoldererRegistry;
|
||||
|
||||
public final class RefinedStorageAPI {
|
||||
@@ -7,4 +8,9 @@ public final class RefinedStorageAPI {
|
||||
* The solderer registry, set in pre-initialization
|
||||
*/
|
||||
public static ISoldererRegistry SOLDERER_REGISTRY;
|
||||
|
||||
/**
|
||||
* The crafting task registry, set in pre-initialization
|
||||
*/
|
||||
public static ICraftingTaskRegistry CRAFTING_TASK_REGISTRY;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,6 @@ public interface ICraftingPattern {
|
||||
*/
|
||||
BlockPos getContainerPosition();
|
||||
|
||||
/**
|
||||
* @return If this pattern is a processing pattern
|
||||
*/
|
||||
boolean isProcessing();
|
||||
|
||||
/**
|
||||
* @return The inputs
|
||||
*/
|
||||
@@ -40,6 +35,13 @@ public interface ICraftingPattern {
|
||||
*/
|
||||
ItemStack[] getByproducts();
|
||||
|
||||
/**
|
||||
* @return The id of the crafting task, as defined in the registry
|
||||
*/
|
||||
String getId();
|
||||
|
||||
int getQuantityPerRequest(ItemStack requested);
|
||||
|
||||
/**
|
||||
* Writes this pattern to NBT.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package refinedstorage.api.autocrafting.registry;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface ICraftingTaskFactory {
|
||||
@Nonnull
|
||||
ICraftingTask create(@Nullable NBTTagCompound tag, ICraftingPattern pattern);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package refinedstorage.api.autocrafting.registry;
|
||||
|
||||
public interface ICraftingTaskRegistry {
|
||||
void addFactory(String id, ICraftingTaskFactory factory);
|
||||
|
||||
ICraftingTaskFactory getFactory(String id);
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package refinedstorage.api.autocrafting;
|
||||
package refinedstorage.api.autocrafting.task;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a crafting task.
|
||||
*/
|
||||
@@ -13,6 +16,11 @@ public interface ICraftingTask {
|
||||
*/
|
||||
ICraftingPattern getPattern();
|
||||
|
||||
/**
|
||||
* @return The child tasks
|
||||
*/
|
||||
List<ICraftingTask> getChildren();
|
||||
|
||||
/**
|
||||
* @param world The world
|
||||
* @param network The network
|
||||
@@ -20,13 +28,6 @@ public interface ICraftingTask {
|
||||
*/
|
||||
boolean update(World world, INetworkMaster network);
|
||||
|
||||
/**
|
||||
* Gets called as soon as {@link ICraftingTask#update(World, INetworkMaster)} returns true.
|
||||
*
|
||||
* @param network The network
|
||||
*/
|
||||
void onDone(INetworkMaster network);
|
||||
|
||||
/**
|
||||
* Gets called when this crafting task is cancelled.
|
||||
*
|
||||
@@ -39,15 +40,12 @@ public interface ICraftingTask {
|
||||
*
|
||||
* @param tag The NBT tag to write to
|
||||
*/
|
||||
void writeToNBT(NBTTagCompound tag);
|
||||
NBTTagCompound writeToNBT(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Returns the info string that the crafting monitor uses.
|
||||
* Separate every line by the newline character.
|
||||
* Use T=x where x is the translation key for translating.
|
||||
* Use I=x where x is the translation key for translating and displaying the line in yellow.
|
||||
* Returns status info used in the tooltip of the crafting monitor.
|
||||
*
|
||||
* @return The info string
|
||||
* @return The status
|
||||
*/
|
||||
String getInfo();
|
||||
String getStatus();
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
@@ -83,13 +83,6 @@ public interface INetworkMaster {
|
||||
*/
|
||||
void addCraftingTask(@Nonnull ICraftingTask task);
|
||||
|
||||
/**
|
||||
* Adds a crafting task to the bottom of the crafting task stack.
|
||||
*
|
||||
* @param task The crafting task to add as last
|
||||
*/
|
||||
void addCraftingTaskAsLast(@Nonnull ICraftingTask task);
|
||||
|
||||
/**
|
||||
* Creates a crafting task from a {@link ICraftingPattern}.
|
||||
*
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
package refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.NetworkUtils;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BasicCraftingTask implements ICraftingTask {
|
||||
public static final int ID = 0;
|
||||
|
||||
private static final String NBT_SATISFIED = "Satisfied";
|
||||
private static final String NBT_CHECKED = "Checked";
|
||||
private static final String NBT_CHILD_TASKS = "ChildTasks";
|
||||
private static final String NBT_TOOK = "Took";
|
||||
|
||||
private ICraftingPattern pattern;
|
||||
private boolean satisfied[];
|
||||
private boolean checked[];
|
||||
private boolean childTasks[];
|
||||
private List<ItemStack> itemsTook = new ArrayList<>();
|
||||
private boolean updatedOnce;
|
||||
|
||||
public BasicCraftingTask(ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.satisfied = new boolean[pattern.getInputs().length];
|
||||
this.checked = new boolean[pattern.getInputs().length];
|
||||
this.childTasks = new boolean[pattern.getInputs().length];
|
||||
}
|
||||
|
||||
public BasicCraftingTask(NBTTagCompound tag, ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.satisfied = readBooleanArray(tag, NBT_SATISFIED);
|
||||
this.checked = readBooleanArray(tag, NBT_CHECKED);
|
||||
this.childTasks = readBooleanArray(tag, NBT_CHILD_TASKS);
|
||||
|
||||
NBTTagList tookList = tag.getTagList(NBT_TOOK, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < tookList.tagCount(); ++i) {
|
||||
itemsTook.add(ItemStack.loadItemStackFromNBT(tookList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world, INetworkMaster network) {
|
||||
this.updatedOnce = true;
|
||||
|
||||
boolean done = true;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
checked[i] = true;
|
||||
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!satisfied[i]) {
|
||||
done = false;
|
||||
|
||||
ItemStack took = FluidUtils.extractItemOrIfBucketLookInFluids(network, input, 1);
|
||||
|
||||
if (took != null) {
|
||||
itemsTook.add(took);
|
||||
|
||||
satisfied[i] = true;
|
||||
} else if (!childTasks[i]) {
|
||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, input);
|
||||
|
||||
if (pattern != null) {
|
||||
network.addCraftingTask(network.createCraftingTask(pattern));
|
||||
|
||||
childTasks[i] = true;
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
// @TODO: Handle no space
|
||||
@Override
|
||||
public void onDone(INetworkMaster network) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
network.insertItem(output, output.stackSize, false);
|
||||
}
|
||||
|
||||
if (pattern.getByproducts() != null) {
|
||||
for (ItemStack byproduct : pattern.getByproducts()) {
|
||||
network.insertItem(byproduct, byproduct.stackSize, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO: Handle no space
|
||||
@Override
|
||||
public void onCancelled(INetworkMaster network) {
|
||||
for (ItemStack took : itemsTook) {
|
||||
network.insertItem(took, took.stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound patternTag = new NBTTagCompound();
|
||||
pattern.writeToNBT(patternTag);
|
||||
tag.setTag(CraftingPattern.NBT, patternTag);
|
||||
|
||||
writeBooleanArray(tag, NBT_SATISFIED, satisfied);
|
||||
writeBooleanArray(tag, NBT_CHECKED, checked);
|
||||
writeBooleanArray(tag, NBT_CHILD_TASKS, childTasks);
|
||||
|
||||
NBTTagList tookList = new NBTTagList();
|
||||
|
||||
for (ItemStack took : itemsTook) {
|
||||
tookList.appendTag(took.serializeNBT());
|
||||
}
|
||||
|
||||
tag.setTag(NBT_TOOK, tookList);
|
||||
|
||||
tag.setInteger("Type", ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
if (!updatedOnce) {
|
||||
return "T=gui.refinedstorage:crafting_monitor.not_started_yet";
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
boolean hasMissingItems = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (checked[i] && !satisfied[i] && !childTasks[i]) {
|
||||
if (!hasMissingItems) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.missing_items\n");
|
||||
|
||||
hasMissingItems = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
boolean areItemsCrafting = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!satisfied[i] && childTasks[i]) {
|
||||
if (!areItemsCrafting) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.items_crafting\n");
|
||||
|
||||
areItemsCrafting = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static void writeBooleanArray(NBTTagCompound tag, String name, boolean[] array) {
|
||||
int[] intArray = new int[array.length];
|
||||
|
||||
for (int i = 0; i < intArray.length; ++i) {
|
||||
intArray[i] = array[i] ? 1 : 0;
|
||||
}
|
||||
|
||||
tag.setTag(name, new NBTTagIntArray(intArray));
|
||||
}
|
||||
|
||||
public static boolean[] readBooleanArray(NBTTagCompound tag, String name) {
|
||||
int[] intArray = tag.getIntArray(name);
|
||||
|
||||
boolean array[] = new boolean[intArray.length];
|
||||
|
||||
for (int i = 0; i < intArray.length; ++i) {
|
||||
array[i] = intArray[i] == 1 ? true : false;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.tile.TileCrafter;
|
||||
|
||||
@@ -46,11 +47,6 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
return crafterPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProcessing() {
|
||||
return processing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInputs() {
|
||||
return inputs;
|
||||
@@ -66,26 +62,55 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
return byproducts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return processing ? "processing" : "normal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQuantityPerRequest(ItemStack requested) {
|
||||
int quantity = 0;
|
||||
|
||||
for (ItemStack output : outputs) {
|
||||
if (CompareUtils.compareStackNoQuantity(requested, output)) {
|
||||
quantity += output.stackSize;
|
||||
|
||||
if (!processing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return quantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag.setBoolean(ItemPattern.NBT_PROCESSING, processing);
|
||||
|
||||
NBTTagList inputsTag = new NBTTagList();
|
||||
|
||||
for (ItemStack input : inputs) {
|
||||
inputsTag.appendTag(input.serializeNBT());
|
||||
}
|
||||
|
||||
tag.setTag(ItemPattern.NBT_INPUTS, inputsTag);
|
||||
|
||||
NBTTagList outputsTag = new NBTTagList();
|
||||
|
||||
for (ItemStack output : outputs) {
|
||||
outputsTag.appendTag(output.serializeNBT());
|
||||
}
|
||||
|
||||
tag.setTag(ItemPattern.NBT_OUTPUTS, outputsTag);
|
||||
|
||||
if (byproducts != null) {
|
||||
NBTTagList byproductsTag = new NBTTagList();
|
||||
|
||||
for (ItemStack byproduct : byproducts) {
|
||||
byproductsTag.appendTag(byproduct.serializeNBT());
|
||||
}
|
||||
|
||||
tag.setTag(ItemPattern.NBT_BYPRODUCTS, byproductsTag);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
|
||||
/**
|
||||
* @TODO: Rework this!
|
||||
*/
|
||||
public class CraftingTaskScheduler {
|
||||
private static final String NBT_SCHEDULED = "CraftingTaskScheduled";
|
||||
|
||||
@@ -27,7 +30,7 @@ public class CraftingTaskScheduler {
|
||||
if (pattern != null) {
|
||||
scheduledItem = item;
|
||||
|
||||
network.addCraftingTaskAsLast(network.createCraftingTask(pattern));
|
||||
network.addCraftingTask(network.createCraftingTask(pattern));
|
||||
|
||||
tile.markDirty();
|
||||
}
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
package refinedstorage.apiimpl.autocrafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.NetworkUtils;
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
||||
|
||||
public class ProcessingCraftingTask implements ICraftingTask {
|
||||
public static final int ID = 1;
|
||||
|
||||
private static final String NBT_INSERTED = "Inserted";
|
||||
private static final String NBT_CHILD_TASKS = "ChildTasks";
|
||||
private static final String NBT_SATISFIED = "Satisfied";
|
||||
|
||||
private ICraftingPattern pattern;
|
||||
private boolean inserted[];
|
||||
private boolean childTasks[];
|
||||
private boolean satisfied[];
|
||||
private boolean updatedOnce;
|
||||
|
||||
public ProcessingCraftingTask(ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.inserted = new boolean[pattern.getInputs().length];
|
||||
this.childTasks = new boolean[pattern.getInputs().length];
|
||||
this.satisfied = new boolean[pattern.getOutputs().length];
|
||||
}
|
||||
|
||||
public ProcessingCraftingTask(NBTTagCompound tag, ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.inserted = BasicCraftingTask.readBooleanArray(tag, NBT_INSERTED);
|
||||
this.childTasks = BasicCraftingTask.readBooleanArray(tag, NBT_CHILD_TASKS);
|
||||
this.satisfied = BasicCraftingTask.readBooleanArray(tag, NBT_SATISFIED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world, INetworkMaster network) {
|
||||
this.updatedOnce = true;
|
||||
|
||||
ICraftingPatternContainer container = pattern.getContainer(world);
|
||||
|
||||
if (container.getConnectedItems() != null) {
|
||||
for (int i = 0; i < inserted.length; ++i) {
|
||||
if (!inserted[i]) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
ItemStack took = FluidUtils.extractItemOrIfBucketLookInFluids(network, input, 1);
|
||||
|
||||
if (took != null) {
|
||||
if (ItemHandlerHelper.insertItem(container.getConnectedItems(), took, true) == null) {
|
||||
ItemHandlerHelper.insertItem(container.getConnectedItems(), took, false);
|
||||
|
||||
inserted[i] = true;
|
||||
} else {
|
||||
network.insertItem(took, took.stackSize, false);
|
||||
}
|
||||
} else if (!childTasks[i]) {
|
||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, input);
|
||||
|
||||
if (pattern != null) {
|
||||
childTasks[i] = true;
|
||||
|
||||
network.addCraftingTask(network.createCraftingTask(pattern));
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < satisfied.length; ++i) {
|
||||
if (!satisfied[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onInserted(ItemStack stack) {
|
||||
for (int i = 0; i < pattern.getOutputs().length; ++i) {
|
||||
if (!satisfied[i] && CompareUtils.compareStackNoQuantity(stack, pattern.getOutputs()[i])) {
|
||||
satisfied[i] = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDone(INetworkMaster network) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(INetworkMaster network) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound patternTag = new NBTTagCompound();
|
||||
pattern.writeToNBT(patternTag);
|
||||
tag.setTag(CraftingPattern.NBT, patternTag);
|
||||
|
||||
BasicCraftingTask.writeBooleanArray(tag, NBT_INSERTED, inserted);
|
||||
BasicCraftingTask.writeBooleanArray(tag, NBT_CHILD_TASKS, childTasks);
|
||||
BasicCraftingTask.writeBooleanArray(tag, NBT_SATISFIED, satisfied);
|
||||
|
||||
tag.setInteger("Type", ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
if (!updatedOnce) {
|
||||
return "T=gui.refinedstorage:crafting_monitor.not_started_yet";
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
boolean hasMissingItems = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!inserted[i] && !childTasks[i]) {
|
||||
if (!hasMissingItems) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.missing_items\n");
|
||||
|
||||
hasMissingItems = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
boolean areItemsCrafting = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!inserted[i] && childTasks[i]) {
|
||||
if (!areItemsCrafting) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.items_crafting\n");
|
||||
|
||||
areItemsCrafting = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
boolean areItemsProcessing = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (inserted[i]) {
|
||||
if (!areItemsProcessing) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.items_processing\n");
|
||||
|
||||
areItemsProcessing = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package refinedstorage.apiimpl.autocrafting.registry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CraftingTaskFactoryNormal implements ICraftingTaskFactory {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ICraftingTask create(@Nullable NBTTagCompound tag, ICraftingPattern pattern) {
|
||||
CraftingTaskNormal task = new CraftingTaskNormal(pattern);
|
||||
|
||||
task.setChildrenCreated(CraftingTaskNormal.readBooleanArray(tag, CraftingTaskNormal.NBT_CHILDREN));
|
||||
task.setSatisfied(CraftingTaskNormal.readBooleanArray(tag, CraftingTaskNormal.NBT_SATISFIED));
|
||||
|
||||
List<ItemStack> took = new ArrayList<>();
|
||||
|
||||
NBTTagList tookTag = tag.getTagList(CraftingTaskNormal.NBT_TOOK, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < tookTag.tagCount(); ++i) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tookTag.getCompoundTagAt(i));
|
||||
|
||||
if (stack != null) {
|
||||
took.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
task.setTook(took);
|
||||
|
||||
return task;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package refinedstorage.apiimpl.autocrafting.registry;
|
||||
|
||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskRegistry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CraftingTaskRegistry implements ICraftingTaskRegistry {
|
||||
private Map<String, ICraftingTaskFactory> registry = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void addFactory(String id, ICraftingTaskFactory factory) {
|
||||
registry.put(id, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingTaskFactory getFactory(String id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
}
|
||||
34
src/main/java/refinedstorage/apiimpl/autocrafting/task/CraftingTask.java
Executable file
34
src/main/java/refinedstorage/apiimpl/autocrafting/task/CraftingTask.java
Executable file
@@ -0,0 +1,34 @@
|
||||
package refinedstorage.apiimpl.autocrafting.task;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CraftingTask implements ICraftingTask {
|
||||
protected List<ICraftingTask> children;
|
||||
|
||||
@Override
|
||||
public List<ICraftingTask> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void updateChildren(World world, INetworkMaster network) {
|
||||
Iterator<ICraftingTask> childrenIterator = children.iterator();
|
||||
|
||||
while (childrenIterator.hasNext()) {
|
||||
if (childrenIterator.next().update(world, network)) {
|
||||
childrenIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(INetworkMaster network) {
|
||||
for (ICraftingTask child : children) {
|
||||
child.onCancelled(network);
|
||||
}
|
||||
}
|
||||
}
|
||||
183
src/main/java/refinedstorage/apiimpl/autocrafting/task/CraftingTaskNormal.java
Executable file
183
src/main/java/refinedstorage/apiimpl/autocrafting/task/CraftingTaskNormal.java
Executable file
@@ -0,0 +1,183 @@
|
||||
package refinedstorage.apiimpl.autocrafting.task;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.NetworkUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CraftingTaskNormal extends CraftingTask {
|
||||
public static final String NBT_TOOK = "Took";
|
||||
public static final String NBT_SATISFIED = "Satisfied";
|
||||
public static final String NBT_CHILDREN = "Children";
|
||||
|
||||
private ICraftingPattern pattern;
|
||||
private List<ItemStack> took = new ArrayList<>();
|
||||
private boolean satisfied[];
|
||||
private boolean childrenCreated[];
|
||||
|
||||
public CraftingTaskNormal(ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.satisfied = new boolean[pattern.getInputs().length];
|
||||
this.childrenCreated = new boolean[pattern.getInputs().length];
|
||||
}
|
||||
|
||||
public void setTook(List<ItemStack> took) {
|
||||
this.took = took;
|
||||
}
|
||||
|
||||
public void setSatisfied(boolean[] satisfied) {
|
||||
this.satisfied = satisfied;
|
||||
}
|
||||
|
||||
public void setChildrenCreated(boolean[] childrenCreated) {
|
||||
this.childrenCreated = childrenCreated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(World world, INetworkMaster network) {
|
||||
updateChildren(world, network);
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!satisfied[i]) {
|
||||
ItemStack received = NetworkUtils.extractItem(network, input, input.stackSize);
|
||||
|
||||
if (received != null) {
|
||||
satisfied[i] = true;
|
||||
|
||||
took.add(received);
|
||||
} else if (!childrenCreated[i]) {
|
||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, input);
|
||||
|
||||
if (pattern != null) {
|
||||
children.add(network.createCraftingTask(pattern));
|
||||
|
||||
childrenCreated[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (boolean item : satisfied) {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (children.isEmpty()) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
// @TODO: Handle remainder
|
||||
network.insertItem(output, output.stackSize, false);
|
||||
}
|
||||
|
||||
for (ItemStack byproduct : pattern.getByproducts()) {
|
||||
// @TODO: Handle remainder
|
||||
network.insertItem(byproduct, byproduct.stackSize, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(INetworkMaster network) {
|
||||
super.onCancelled(network);
|
||||
|
||||
for (ItemStack stack : took) {
|
||||
// @TODO: Handle remainder
|
||||
network.insertItem(stack, stack.stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
writeBooleanArray(tag, NBT_SATISFIED, satisfied);
|
||||
writeBooleanArray(tag, NBT_CHILDREN, childrenCreated);
|
||||
|
||||
NBTTagList took = new NBTTagList();
|
||||
|
||||
for (ItemStack stack : this.took) {
|
||||
took.appendTag(stack.serializeNBT());
|
||||
}
|
||||
|
||||
tag.setTag(NBT_TOOK, took);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
boolean missingItems = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!satisfied[i] && !childrenCreated[i]) {
|
||||
if (!missingItems) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.missing_items\n");
|
||||
|
||||
missingItems = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
boolean itemsCrafting = false;
|
||||
|
||||
for (int i = 0; i < pattern.getInputs().length; ++i) {
|
||||
ItemStack input = pattern.getInputs()[i];
|
||||
|
||||
if (!satisfied[i] && childrenCreated[i]) {
|
||||
if (!itemsCrafting) {
|
||||
builder.append("I=gui.refinedstorage:crafting_monitor.items_crafting\n");
|
||||
|
||||
itemsCrafting = true;
|
||||
}
|
||||
|
||||
builder.append("T=").append(input.getUnlocalizedName()).append(".name\n");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static void writeBooleanArray(NBTTagCompound tag, String name, boolean[] array) {
|
||||
int[] intArray = new int[array.length];
|
||||
|
||||
for (int i = 0; i < intArray.length; ++i) {
|
||||
intArray[i] = array[i] ? 1 : 0;
|
||||
}
|
||||
|
||||
tag.setTag(name, new NBTTagIntArray(intArray));
|
||||
}
|
||||
|
||||
public static boolean[] readBooleanArray(NBTTagCompound tag, String name) {
|
||||
int[] intArray = tag.getIntArray(name);
|
||||
|
||||
boolean array[] = new boolean[intArray.length];
|
||||
|
||||
for (int i = 0; i < intArray.length; ++i) {
|
||||
array[i] = intArray[i] == 1 ? true : false;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.NetworkUtils;
|
||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||
@@ -128,23 +128,13 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
int quantityPerRequest = 0;
|
||||
|
||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, stack);
|
||||
|
||||
if (pattern != null) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
if (CompareUtils.compareStackNoQuantity(stack, output)) {
|
||||
quantityPerRequest += output.stackSize;
|
||||
|
||||
if (!pattern.isProcessing()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int quantityPerRequest = pattern.getQuantityPerRequest(stack);
|
||||
|
||||
while (quantity > 0) {
|
||||
network.addCraftingTaskAsLast(network.createCraftingTask(pattern));
|
||||
network.addCraftingTask(network.createCraftingTask(pattern));
|
||||
|
||||
quantity -= quantityPerRequest;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.api.RefinedStorageAPI;
|
||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskRegistry;
|
||||
import refinedstorage.apiimpl.solderer.*;
|
||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||
@@ -45,6 +47,9 @@ public class CommonProxy {
|
||||
|
||||
RefinedStorageAPI.SOLDERER_REGISTRY = new SoldererRegistry();
|
||||
|
||||
RefinedStorageAPI.CRAFTING_TASK_REGISTRY = new CraftingTaskRegistry();
|
||||
RefinedStorageAPI.CRAFTING_TASK_REGISTRY.addFactory("normal", new CraftingTaskFactoryNormal());
|
||||
|
||||
int id = 0;
|
||||
|
||||
RefinedStorage.INSTANCE.network.registerMessage(MessageTileDataParameter.class, MessageTileDataParameter.class, id++, Side.CLIENT);
|
||||
|
||||
@@ -18,9 +18,11 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.api.RefinedStorageAPI;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.api.network.*;
|
||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||
@@ -29,9 +31,7 @@ import refinedstorage.api.storage.fluid.IFluidStorage;
|
||||
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
||||
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
||||
import refinedstorage.api.storage.item.IItemStorage;
|
||||
import refinedstorage.apiimpl.autocrafting.BasicCraftingTask;
|
||||
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||
import refinedstorage.apiimpl.autocrafting.ProcessingCraftingTask;
|
||||
import refinedstorage.apiimpl.network.NetworkNodeGraph;
|
||||
import refinedstorage.apiimpl.network.WirelessGridHandler;
|
||||
import refinedstorage.apiimpl.network.grid.FluidGridHandler;
|
||||
@@ -130,6 +130,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||
|
||||
private static final String NBT_CRAFTING_TASKS = "CraftingTasks";
|
||||
private static final String NBT_CRAFTING_TASK_TYPE = "Type";
|
||||
|
||||
private static final Comparator<IItemStorage> ITEM_SIZE_COMPARATOR = (left, right) -> {
|
||||
if (left.getStored() == right.getStored()) {
|
||||
@@ -175,8 +176,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
private List<ICraftingPattern> patterns = new ArrayList<>();
|
||||
|
||||
private Stack<ICraftingTask> craftingTasks = new Stack<>();
|
||||
private List<ICraftingTask> craftingTasksToAddAsLast = new ArrayList<>();
|
||||
private List<ICraftingTask> craftingTasks = new ArrayList<>();
|
||||
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<>();
|
||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<>();
|
||||
|
||||
@@ -243,7 +243,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
Collections.sort(fluidStorage.getStorages(), FLUID_SIZE_COMPARATOR);
|
||||
Collections.sort(fluidStorage.getStorages(), FLUID_PRIORITY_COMPARATOR);
|
||||
|
||||
boolean craftingTasksChanged = !craftingTasksToAdd.isEmpty() || !craftingTasksToAddAsLast.isEmpty() || !craftingTasksToCancel.isEmpty();
|
||||
boolean craftingTasksChanged = !craftingTasksToAdd.isEmpty() || !craftingTasksToCancel.isEmpty();
|
||||
|
||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||
taskToCancel.onCancelled(this);
|
||||
@@ -253,19 +253,27 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
craftingTasksToCancel.clear();
|
||||
|
||||
for (ICraftingTask task : craftingTasksToAdd) {
|
||||
craftingTasks.push(task);
|
||||
craftingTasks.add(task);
|
||||
}
|
||||
|
||||
craftingTasksToAdd.clear();
|
||||
|
||||
for (ICraftingTask task : craftingTasksToAddAsLast) {
|
||||
craftingTasks.add(0, task);
|
||||
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||
|
||||
while (craftingTaskIterator.hasNext()) {
|
||||
ICraftingTask task = craftingTaskIterator.next();
|
||||
|
||||
markDirty();
|
||||
|
||||
ICraftingPatternContainer container = task.getPattern().getContainer(worldObj);
|
||||
|
||||
if (container != null && ticks % container.getSpeed() == 0 && task.update(worldObj, this)) {
|
||||
craftingTaskIterator.remove();
|
||||
|
||||
craftingTasksChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
craftingTasksToAddAsLast.clear();
|
||||
|
||||
updateTopCraftingTask(true);
|
||||
|
||||
if (craftingTasksChanged) {
|
||||
updateCraftingTasks();
|
||||
}
|
||||
@@ -315,24 +323,6 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTopCraftingTask(boolean withSpeed) {
|
||||
if (!craftingTasks.empty()) {
|
||||
markDirty();
|
||||
|
||||
ICraftingTask top = craftingTasks.peek();
|
||||
|
||||
ICraftingPatternContainer container = top.getPattern().getContainer(worldObj);
|
||||
|
||||
if (container != null && (!withSpeed || (ticks % container.getSpeed()) == 0) && top.update(worldObj, this)) {
|
||||
top.onDone(this);
|
||||
|
||||
craftingTasks.pop();
|
||||
|
||||
updateCraftingTasks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
@@ -387,20 +377,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingTaskAsLast(ICraftingTask task) {
|
||||
craftingTasksToAddAsLast.add(task);
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingTask createCraftingTask(ICraftingPattern pattern) {
|
||||
if (pattern.isProcessing()) {
|
||||
return new ProcessingCraftingTask(pattern);
|
||||
} else {
|
||||
return new BasicCraftingTask(pattern);
|
||||
}
|
||||
return RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(pattern.getId()).create(null, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -562,6 +541,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@TODO: Processing crafting tasks
|
||||
|
||||
int inserted = remainder != null ? (orginalSize - remainder.stackSize) : orginalSize;
|
||||
|
||||
if (!simulate && inserted > 0) {
|
||||
@@ -574,7 +556,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
|
||||
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);
|
||||
}
|
||||
}*/
|
||||
|
||||
return remainder;
|
||||
}
|
||||
@@ -705,13 +687,14 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
CraftingPattern pattern = CraftingPattern.readFromNBT(taskTag.getCompoundTag(CraftingPattern.NBT));
|
||||
|
||||
if (pattern != null) {
|
||||
switch (taskTag.getInteger("Type")) {
|
||||
case BasicCraftingTask.ID:
|
||||
addCraftingTask(new BasicCraftingTask(taskTag, pattern));
|
||||
break;
|
||||
case ProcessingCraftingTask.ID:
|
||||
addCraftingTask(new ProcessingCraftingTask(taskTag, pattern));
|
||||
break;
|
||||
ICraftingTaskFactory factory = RefinedStorageAPI.CRAFTING_TASK_REGISTRY.getFactory(taskTag.getString(NBT_CRAFTING_TASK_TYPE));
|
||||
|
||||
if (factory != null) {
|
||||
ICraftingTask task = factory.create(taskTag, pattern);
|
||||
|
||||
if (task != null) {
|
||||
addCraftingTask(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -730,7 +713,11 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
for (ICraftingTask task : craftingTasks) {
|
||||
NBTTagCompound taskTag = new NBTTagCompound();
|
||||
|
||||
task.writeToNBT(taskTag);
|
||||
|
||||
taskTag.setString(NBT_CRAFTING_TASK_TYPE, task.getPattern().getId());
|
||||
|
||||
list.appendTag(taskTag);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TileCraftingMonitor extends TileNode {
|
||||
public List<ClientCraftingTask> getValue(TileCraftingMonitor tile) {
|
||||
if (tile.connected) {
|
||||
List<ClientCraftingTask> tasks = tile.network.getCraftingTasks().stream().map(t -> new ClientCraftingTask(
|
||||
t.getInfo(),
|
||||
t.getStatus(),
|
||||
t.getPattern().getOutputs()
|
||||
)).collect(Collectors.toList());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user