Work the new crafting system in the code. Messy, unfinished and untested
This commit is contained in:
@@ -23,6 +23,11 @@ public interface ICraftingPattern {
|
|||||||
*/
|
*/
|
||||||
boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the crafting pattern can be treated as a processing pattern, false otherwise
|
||||||
|
*/
|
||||||
|
boolean isProcessing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the inputs
|
* @return the inputs
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package refinedstorage.api.autocrafting;
|
package refinedstorage.api.autocrafting;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
@@ -17,11 +16,6 @@ public interface ICraftingPatternContainer {
|
|||||||
*/
|
*/
|
||||||
int getSpeed();
|
int getSpeed();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the tile that this container is facing
|
|
||||||
*/
|
|
||||||
TileEntity getFacingTile();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the inventory that this container is facing
|
* @return the inventory that this container is facing
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -16,12 +17,13 @@ public interface ICraftingTaskFactory {
|
|||||||
/**
|
/**
|
||||||
* Returns a crafting task for a given NBT tag and pattern.
|
* Returns a crafting task for a given NBT tag and pattern.
|
||||||
*
|
*
|
||||||
* @param world the world
|
* @param world the world
|
||||||
* @param depth the depth of the crafting task to create
|
* @param network the network
|
||||||
* @param tag the NBT tag, if this is null it isn't reading from disk but is used for making a task on demand
|
* @param pattern the pattern
|
||||||
* @param pattern the pattern
|
* @param quantity the quantity
|
||||||
|
* @param tag the NBT tag, if this is null it isn't reading from disk but is used for making a task on demand
|
||||||
* @return the crafting task
|
* @return the crafting task
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ICraftingTask create(World world, int depth, @Nullable NBTTagCompound tag, ICraftingPattern pattern);
|
ICraftingTask create(World world, INetworkMaster network, ICraftingPattern pattern, int quantity, @Nullable NBTTagCompound tag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
package refinedstorage.api.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 refinedstorage.tile.TileController;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A default implementation for crafting tasks.
|
|
||||||
*/
|
|
||||||
public abstract class CraftingTask implements ICraftingTask {
|
|
||||||
public static final int MAX_DEPTH = 100;
|
|
||||||
|
|
||||||
public static final String NBT_CHILDREN_CREATED = "ChildrenCreated";
|
|
||||||
public static final String NBT_SATISFIED = "Satisfied";
|
|
||||||
public static final String NBT_CHECKED = "Checked";
|
|
||||||
public static final String NBT_TOOK = "Took";
|
|
||||||
public static final String NBT_PATTERN_STACK = "Pattern";
|
|
||||||
public static final String NBT_PATTERN_TYPE = "Type";
|
|
||||||
public static final String NBT_PATTERN_CONTAINER = "Container";
|
|
||||||
|
|
||||||
private static final String NBT_CHILD = "Child";
|
|
||||||
|
|
||||||
protected int depth;
|
|
||||||
|
|
||||||
protected ICraftingPattern pattern;
|
|
||||||
protected ICraftingTask child;
|
|
||||||
|
|
||||||
protected List<ItemStack> took = new ArrayList<>();
|
|
||||||
|
|
||||||
protected boolean childrenCreated[];
|
|
||||||
protected boolean satisfied[];
|
|
||||||
protected boolean checked[];
|
|
||||||
|
|
||||||
public CraftingTask(ICraftingPattern pattern, int depth) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
this.childrenCreated = new boolean[pattern.getInputs().size()];
|
|
||||||
this.satisfied = new boolean[pattern.getInputs().size()];
|
|
||||||
this.checked = new boolean[pattern.getInputs().size()];
|
|
||||||
this.depth = depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICraftingPattern getPattern() {
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTook(List<ItemStack> took) {
|
|
||||||
this.took = took;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ItemStack> getTook() {
|
|
||||||
return took;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean[] getChildrenCreated() {
|
|
||||||
return childrenCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChildrenCreated(boolean[] childrenCreated) {
|
|
||||||
this.childrenCreated = childrenCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean[] getSatisfied() {
|
|
||||||
return satisfied;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean hasReceivedInputs() {
|
|
||||||
for (boolean item : satisfied) {
|
|
||||||
if (!item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatisfied(boolean[] satisfied) {
|
|
||||||
this.satisfied = satisfied;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean[] getChecked() {
|
|
||||||
return checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChecked(boolean[] checked) {
|
|
||||||
this.checked = checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void tryCreateChild(INetworkMaster network, int i) {
|
|
||||||
if (!childrenCreated[i] && depth + 1 < MAX_DEPTH) {
|
|
||||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, this.pattern.getInputs().get(i));
|
|
||||||
|
|
||||||
if (pattern != null) {
|
|
||||||
child = NetworkUtils.createCraftingTask(network, depth + 1, pattern);
|
|
||||||
|
|
||||||
childrenCreated[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public ICraftingTask getChild() {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setChild(@Nullable ICraftingTask child) {
|
|
||||||
this.child = child;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancelled(INetworkMaster network) {
|
|
||||||
for (ItemStack stack : took) {
|
|
||||||
// @TODO: Handle remainder
|
|
||||||
network.insertItem(stack, stack.stackSize, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (child != null) {
|
|
||||||
child.onCancelled(network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
|
||||||
if (child != null) {
|
|
||||||
tag.setTag(NBT_CHILD, child.writeToNBT(new NBTTagCompound()));
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.setString(NBT_PATTERN_TYPE, pattern.getId());
|
|
||||||
tag.setTag(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
|
|
||||||
tag.setLong(NBT_PATTERN_CONTAINER, pattern.getContainer().getPosition().toLong());
|
|
||||||
|
|
||||||
writeBooleanArray(tag, NBT_CHILDREN_CREATED, childrenCreated);
|
|
||||||
writeBooleanArray(tag, NBT_SATISFIED, satisfied);
|
|
||||||
writeBooleanArray(tag, NBT_CHECKED, checked);
|
|
||||||
|
|
||||||
NBTTagList took = new NBTTagList();
|
|
||||||
|
|
||||||
for (ItemStack stack : this.took) {
|
|
||||||
took.appendTag(stack.serializeNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.setTag(NBT_TOOK, took);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readChildNBT(World world, NBTTagCompound tag) {
|
|
||||||
if (tag.hasKey(NBT_CHILD)) {
|
|
||||||
child = TileController.readCraftingTask(world, depth + 1, tag.getCompoundTag(NBT_CHILD));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +1,37 @@
|
|||||||
package refinedstorage.api.autocrafting.task;
|
package refinedstorage.api.autocrafting.task;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import java.util.Deque;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a crafting task.
|
|
||||||
*/
|
|
||||||
public interface ICraftingTask {
|
public interface ICraftingTask {
|
||||||
/**
|
String NBT_QUANTITY = "Quantity";
|
||||||
* @return the pattern
|
String NBT_PATTERN_ID = "PatternID";
|
||||||
*/
|
String NBT_PATTERN_STACK = "PatternStack";
|
||||||
ICraftingPattern getPattern();
|
String NBT_PATTERN_CONTAINER = "PatternContainer";
|
||||||
|
|
||||||
/**
|
void calculate();
|
||||||
* @return the child task
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
ICraftingTask getChild();
|
|
||||||
|
|
||||||
/**
|
void onCancelled();
|
||||||
* @param child the child task
|
|
||||||
*/
|
|
||||||
void setChild(@Nullable ICraftingTask child);
|
|
||||||
|
|
||||||
/**
|
boolean update();
|
||||||
* @param world the world
|
|
||||||
* @param network the network
|
|
||||||
* @return true if the crafting task is done, false otherwise
|
|
||||||
*/
|
|
||||||
boolean update(World world, INetworkMaster network);
|
|
||||||
|
|
||||||
/**
|
int getQuantity();
|
||||||
* Gets called when the crafting task is cancelled.
|
|
||||||
*
|
|
||||||
* @param network the network
|
|
||||||
*/
|
|
||||||
void onCancelled(INetworkMaster network);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes this crafting task to NBT.
|
|
||||||
*
|
|
||||||
* @param tag the NBT tag to write to
|
|
||||||
* @return the written NBT tag
|
|
||||||
*/
|
|
||||||
NBTTagCompound writeToNBT(NBTTagCompound tag);
|
NBTTagCompound writeToNBT(NBTTagCompound tag);
|
||||||
|
|
||||||
/**
|
ICraftingPattern getPattern();
|
||||||
* Returns the status of this crafting task that is used for the tooltip in the crafting monitor.
|
|
||||||
*
|
|
||||||
* @param network the network
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
String getStatus(INetworkMaster network);
|
|
||||||
|
|
||||||
/**
|
Deque<ItemStack> getToTake();
|
||||||
* @return the progress for display in the crafting monitor, or -1 to not display any progress
|
|
||||||
*/
|
Multimap<Item, ItemStack> getToCraft();
|
||||||
int getProgress();
|
|
||||||
|
Multimap<Item, ItemStack> getMissing();
|
||||||
|
|
||||||
|
List<IProcessable> getToProcess();
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/main/java/refinedstorage/api/autocrafting/task/IProcessable.java
Executable file
12
src/main/java/refinedstorage/api/autocrafting/task/IProcessable.java
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
package refinedstorage.api.autocrafting.task;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
|
||||||
|
import java.util.Deque;
|
||||||
|
|
||||||
|
public interface IProcessable {
|
||||||
|
ICraftingPattern getPattern();
|
||||||
|
|
||||||
|
Deque<ItemStack> getToInsert();
|
||||||
|
}
|
||||||
@@ -3,11 +3,18 @@ package refinedstorage.api.network;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
import refinedstorage.api.RefinedStorageAPI;
|
import refinedstorage.api.RefinedStorageAPI;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||||
|
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
|
|
||||||
@@ -27,8 +34,8 @@ public final class NetworkUtils {
|
|||||||
return network.getPattern(stack, CompareUtils.COMPARE_DAMAGE | CompareUtils.COMPARE_NBT);
|
return network.getPattern(stack, CompareUtils.COMPARE_DAMAGE | CompareUtils.COMPARE_NBT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICraftingTask createCraftingTask(INetworkMaster network, int depth, ICraftingPattern pattern) {
|
public static ICraftingTask createCraftingTask(INetworkMaster network, ICraftingPattern pattern, int quantity) {
|
||||||
return RefinedStorageAPI.instance().getCraftingTaskRegistry().getFactory(pattern.getId()).create(network.getNetworkWorld(), depth, null, pattern);
|
return RefinedStorageAPI.instance().getCraftingTaskRegistry().getFactory(pattern.getId()).create(network.getNetworkWorld(), network, pattern, quantity, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
|
||||||
@@ -62,11 +69,31 @@ public final class NetworkUtils {
|
|||||||
ICraftingPattern pattern = network.getPattern(stack, compare);
|
ICraftingPattern pattern = network.getPattern(stack, compare);
|
||||||
|
|
||||||
if (pattern != null) {
|
if (pattern != null) {
|
||||||
network.addCraftingTask(createCraftingTask(network, 0, pattern));
|
network.addCraftingTask(createCraftingTask(network, pattern, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ICraftingTask readCraftingTask(World world, INetworkMaster network, NBTTagCompound tag) {
|
||||||
|
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(ICraftingTask.NBT_PATTERN_STACK));
|
||||||
|
|
||||||
|
if (stack != null && stack.getItem() instanceof ICraftingPatternProvider) {
|
||||||
|
TileEntity container = world.getTileEntity(BlockPos.fromLong(tag.getLong(ICraftingTask.NBT_PATTERN_CONTAINER)));
|
||||||
|
|
||||||
|
if (container instanceof ICraftingPatternContainer) {
|
||||||
|
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
||||||
|
|
||||||
|
ICraftingTaskFactory factory = RefinedStorageAPI.instance().getCraftingTaskRegistry().getFactory(tag.getString(ICraftingTask.NBT_PATTERN_ID));
|
||||||
|
|
||||||
|
if (factory != null) {
|
||||||
|
return factory.create(world, network, pattern, tag.getInteger(ICraftingTask.NBT_QUANTITY), tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) {
|
public static void writeItemStack(ByteBuf buf, INetworkMaster network, ItemStack stack) {
|
||||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||||
buf.writeInt(stack.stackSize);
|
buf.writeInt(stack.stackSize);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import refinedstorage.api.autocrafting.ICraftingPattern;
|
|||||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
||||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryProcessing;
|
|
||||||
import refinedstorage.item.ItemPattern;
|
import refinedstorage.item.ItemPattern;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -79,6 +78,11 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
return !inputs.isEmpty() && !outputs.isEmpty();
|
return !inputs.isEmpty() && !outputs.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProcessing() {
|
||||||
|
return ItemPattern.isProcessing(stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getInputs() {
|
public List<ItemStack> getInputs() {
|
||||||
return inputs;
|
return inputs;
|
||||||
@@ -96,7 +100,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ItemPattern.isProcessing(stack) ? CraftingTaskFactoryProcessing.ID : CraftingTaskFactoryNormal.ID;
|
return CraftingTaskFactoryNormal.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.preview;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.autocrafting.task.CraftingTask;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
|
||||||
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class CraftingPreviewData {
|
|
||||||
private HashMap<Integer, CraftingPreviewStack> data = new HashMap<>();
|
|
||||||
private INetworkMaster network;
|
|
||||||
private boolean depthCheck = false;
|
|
||||||
|
|
||||||
public CraftingPreviewData(INetworkMaster network) {
|
|
||||||
this.network = network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void calculate(ItemStack stack, int quantity) {
|
|
||||||
calculate(stack, quantity, true, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculate(ItemStack stack, int quantity, boolean baseStack, int depth) {
|
|
||||||
if (!this.depthCheck) {
|
|
||||||
quantity = -add(stack, quantity, baseStack);
|
|
||||||
|
|
||||||
if (quantity > 0 && !get(stack).cantCraft()) {
|
|
||||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, stack);
|
|
||||||
|
|
||||||
if (pattern != null && depth < CraftingTask.MAX_DEPTH) {
|
|
||||||
int quantityPerRequest = pattern.getQuantityPerRequest(stack);
|
|
||||||
|
|
||||||
while (quantity > 0) {
|
|
||||||
for (ItemStack ingredient : pattern.getInputs()) {
|
|
||||||
calculate(ingredient, ingredient.stackSize, false, depth + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
get(stack).addExtras(quantityPerRequest);
|
|
||||||
|
|
||||||
quantity -= quantityPerRequest;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (depth >= CraftingTask.MAX_DEPTH) {
|
|
||||||
this.depthCheck = true;
|
|
||||||
}
|
|
||||||
get(stack).setCantCraft(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int add(ItemStack stack, int quantity, boolean baseStack) {
|
|
||||||
int hash = NetworkUtils.getItemStackHashCode(stack);
|
|
||||||
|
|
||||||
CraftingPreviewStack previewStack;
|
|
||||||
if (data.containsKey(hash)) {
|
|
||||||
previewStack = data.get(hash);
|
|
||||||
|
|
||||||
previewStack.addNeeded(quantity);
|
|
||||||
} else {
|
|
||||||
ItemStack networkStack = network.getItemStorage().get(stack, CompareUtils.COMPARE_DAMAGE | CompareUtils.COMPARE_NBT);
|
|
||||||
|
|
||||||
previewStack = new CraftingPreviewStack(stack, quantity, networkStack == null || baseStack ? 0 : networkStack.stackSize);
|
|
||||||
|
|
||||||
data.put(hash, previewStack);
|
|
||||||
}
|
|
||||||
return baseStack ? -quantity : previewStack.getAvailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftingPreviewStack get(ItemStack stack) {
|
|
||||||
return data.get(NetworkUtils.getItemStackHashCode(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<CraftingPreviewStack> values() {
|
|
||||||
return this.depthCheck ? Collections.emptyList() : this.data.values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.preview;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public class CraftingPreviewStack {
|
|
||||||
private ItemStack stack;
|
|
||||||
private int needed;
|
|
||||||
private int stock;
|
|
||||||
private int extras;
|
|
||||||
private boolean cantCraft;
|
|
||||||
|
|
||||||
public CraftingPreviewStack(ItemStack stack, int needed, int stock) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.needed = needed;
|
|
||||||
this.stock = stock;
|
|
||||||
this.extras = 0;
|
|
||||||
this.cantCraft = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToByteBuf(ByteBuf buf) {
|
|
||||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
|
||||||
buf.writeInt(stack.getMetadata());
|
|
||||||
buf.writeInt(needed);
|
|
||||||
buf.writeInt(stock);
|
|
||||||
buf.writeInt(extras);
|
|
||||||
buf.writeBoolean(cantCraft);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CraftingPreviewStack fromByteBuf(ByteBuf buf) {
|
|
||||||
Item item = Item.getItemById(buf.readInt());
|
|
||||||
int meta = buf.readInt();
|
|
||||||
int toCraft = buf.readInt();
|
|
||||||
int available = buf.readInt();
|
|
||||||
|
|
||||||
CraftingPreviewStack stack = new CraftingPreviewStack(new ItemStack(item, 1, meta), toCraft, available);
|
|
||||||
|
|
||||||
stack.extras = buf.readInt();
|
|
||||||
stack.cantCraft = buf.readBoolean();
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNeeded(int quantity) {
|
|
||||||
this.needed += quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addExtras(int quantity) {
|
|
||||||
this.extras += quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAvailable() {
|
|
||||||
return this.stock + this.extras - this.needed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStack() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStock() {
|
|
||||||
return stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNeeded() {
|
|
||||||
return needed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean needsCrafting() {
|
|
||||||
return this.needed > this.stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean cantCraft() {
|
|
||||||
return this.cantCraft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getToCraft() {
|
|
||||||
return this.needed - this.stock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCantCraft(boolean cantCraft) {
|
|
||||||
this.cantCraft = cantCraft;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +1,22 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.registry;
|
package refinedstorage.apiimpl.autocrafting.registry;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.Constants;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
||||||
import refinedstorage.api.autocrafting.task.CraftingTask;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CraftingTaskFactoryNormal implements ICraftingTaskFactory {
|
public class CraftingTaskFactoryNormal implements ICraftingTaskFactory {
|
||||||
public static final String ID = "normal";
|
public static final String ID = "normal";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ICraftingTask create(World world, int depth, @Nullable NBTTagCompound tag, ICraftingPattern pattern) {
|
public ICraftingTask create(World world, INetworkMaster network, ICraftingPattern pattern, int quantity, @Nullable NBTTagCompound tag) {
|
||||||
CraftingTaskNormal task = new CraftingTaskNormal(pattern, depth);
|
return new CraftingTaskNormal(network, pattern, quantity);
|
||||||
|
|
||||||
if (tag != null) {
|
|
||||||
task.setChildrenCreated(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_CHILDREN_CREATED));
|
|
||||||
task.setSatisfied(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_SATISFIED));
|
|
||||||
task.setChecked(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_CHECKED));
|
|
||||||
|
|
||||||
List<ItemStack> took = new ArrayList<>();
|
|
||||||
|
|
||||||
NBTTagList tookTag = tag.getTagList(CraftingTask.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);
|
|
||||||
|
|
||||||
task.readChildNBT(world, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
return task;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.registry;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.util.Constants;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.autocrafting.registry.ICraftingTaskFactory;
|
|
||||||
import refinedstorage.api.autocrafting.task.CraftingTask;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskProcessing;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CraftingTaskFactoryProcessing implements ICraftingTaskFactory {
|
|
||||||
public static final String ID = "processing";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
|
||||||
public ICraftingTask create(World world, int depth, @Nullable NBTTagCompound tag, ICraftingPattern pattern) {
|
|
||||||
CraftingTaskProcessing task = new CraftingTaskProcessing(pattern, depth);
|
|
||||||
|
|
||||||
if (tag != null) {
|
|
||||||
task.setChildrenCreated(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_CHILDREN_CREATED));
|
|
||||||
task.setSatisfied(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_SATISFIED));
|
|
||||||
task.setSatisfiedInsertion(CraftingTask.readBooleanArray(tag, CraftingTaskProcessing.NBT_SATISFIED_INSERTION));
|
|
||||||
task.setChecked(CraftingTask.readBooleanArray(tag, CraftingTask.NBT_CHECKED));
|
|
||||||
|
|
||||||
if (tag.hasKey(CraftingTaskProcessing.NBT_TILE_IN_USE)) {
|
|
||||||
task.setTileInUse(BlockPos.fromLong(tag.getLong(CraftingTaskProcessing.NBT_TILE_IN_USE)));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ItemStack> took = new ArrayList<>();
|
|
||||||
|
|
||||||
NBTTagList tookTag = tag.getTagList(CraftingTask.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);
|
|
||||||
|
|
||||||
task.readChildNBT(world, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +1,233 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.task;
|
package refinedstorage.apiimpl.autocrafting.task;
|
||||||
|
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.task.CraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
|
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
import refinedstorage.api.network.NetworkUtils;
|
||||||
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
|
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
||||||
|
|
||||||
public class CraftingTaskNormal extends CraftingTask {
|
import java.util.ArrayDeque;
|
||||||
public CraftingTaskNormal(ICraftingPattern pattern, int depth) {
|
import java.util.ArrayList;
|
||||||
super(pattern, depth);
|
import java.util.Deque;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CraftingTaskNormal implements ICraftingTask {
|
||||||
|
private INetworkMaster network;
|
||||||
|
private ICraftingPattern pattern;
|
||||||
|
private int quantity;
|
||||||
|
private Deque<ItemStack> toTake = new ArrayDeque<>();
|
||||||
|
private List<IProcessable> toProcess = new ArrayList<>();
|
||||||
|
private Multimap<Item, ItemStack> toCraft = ArrayListMultimap.create();
|
||||||
|
private Multimap<Item, ItemStack> missing = ArrayListMultimap.create();
|
||||||
|
private Multimap<Item, ItemStack> extras = ArrayListMultimap.create();
|
||||||
|
|
||||||
|
public CraftingTaskNormal(INetworkMaster network, ICraftingPattern pattern, int quantity) {
|
||||||
|
this.network = network;
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculate() {
|
||||||
|
calculate(network.getItemStorage().copy(), pattern, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(World world, INetworkMaster network) {
|
public void onCancelled() {
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
|
||||||
checked[i] = true;
|
|
||||||
|
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
}
|
||||||
|
|
||||||
if (!satisfied[i]) {
|
private void calculate(IGroupedItemStorage storage, ICraftingPattern pattern, boolean basePattern) {
|
||||||
ItemStack received = FluidUtils.extractItemOrIfBucketLookInFluids(network, input, input.stackSize);
|
for (int i = 0; i < quantity; ++i) {
|
||||||
|
if (pattern.isProcessing()) {
|
||||||
|
IProcessable processable = new Processable(pattern);
|
||||||
|
|
||||||
if (received != null) {
|
for (int j = pattern.getInputs().size() - 1; j >= 0; --j) {
|
||||||
satisfied[i] = true;
|
processable.getToInsert().push(pattern.getInputs().get(j).copy());
|
||||||
|
}
|
||||||
|
|
||||||
took.add(received);
|
toProcess.add(processable);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack input : pattern.getInputs()) {
|
||||||
|
ItemStack inputInNetwork = storage.get(input, CompareUtils.COMPARE_DAMAGE | CompareUtils.COMPARE_NBT);
|
||||||
|
|
||||||
|
if (inputInNetwork == null || inputInNetwork.stackSize == 0) {
|
||||||
|
if (getExtrasFor(input) != null) {
|
||||||
|
decrOrRemoveExtras(input);
|
||||||
|
} else {
|
||||||
|
ICraftingPattern inputPattern = NetworkUtils.getPattern(network, input);
|
||||||
|
|
||||||
|
if (inputPattern != null) {
|
||||||
|
for (ItemStack output : inputPattern.getOutputs()) {
|
||||||
|
addToCraft(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
calculate(storage, inputPattern, false);
|
||||||
|
} else {
|
||||||
|
addMissing(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tryCreateChild(network, i);
|
if (!pattern.isProcessing()) {
|
||||||
}
|
toTake.push(input);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
storage.remove(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!basePattern) {
|
||||||
|
addExtras(pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasReceivedInputs()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus(INetworkMaster network) {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
return "\nCraftingTask{quantity=" + quantity +
|
||||||
|
"\n, toTake=" + toTake +
|
||||||
|
"\n, toCraft=" + toCraft +
|
||||||
|
"\n, toProcess=" + toProcess +
|
||||||
|
"\n, missing=" + missing +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
boolean missingItems = false;
|
public boolean update() {
|
||||||
|
for (IProcessable processable : toProcess) {
|
||||||
|
if (processable.getPattern().getContainer().getFacingInventory() != null && !processable.getToInsert().isEmpty()) {
|
||||||
|
ItemStack toInsert = NetworkUtils.extractItem(network, processable.getToInsert().peek(), 1);
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
if (ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, true) == null) {
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
ItemHandlerHelper.insertItem(processable.getPattern().getContainer().getFacingInventory(), toInsert, false);
|
||||||
|
|
||||||
if (!satisfied[i] && !childrenCreated[i] && checked[i]) {
|
processable.getToInsert().pop();
|
||||||
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;
|
if (!toTake.isEmpty()) {
|
||||||
|
ItemStack took = NetworkUtils.extractItem(network, toTake.peek(), 1);
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
if (took != null) {
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
toTake.pop();
|
||||||
|
|
||||||
if (!satisfied[i] && childrenCreated[i] && checked[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();
|
if (toTake.isEmpty() && missing.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
|
@Override
|
||||||
public int getProgress() {
|
public int getQuantity() {
|
||||||
int satisfiedAmount = 0;
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
for (boolean item : satisfied) {
|
@Override
|
||||||
if (item) {
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||||
satisfiedAmount++;
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICraftingPattern getPattern() {
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Deque<ItemStack> getToTake() {
|
||||||
|
return toTake;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Multimap<Item, ItemStack> getToCraft() {
|
||||||
|
return toCraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Multimap<Item, ItemStack> getMissing() {
|
||||||
|
return missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IProcessable> getToProcess() {
|
||||||
|
return toProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMissing(ItemStack stack) {
|
||||||
|
for (ItemStack m : missing.get(stack.getItem())) {
|
||||||
|
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
||||||
|
m.stackSize += stack.stackSize;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) ((float) satisfiedAmount / (float) satisfied.length * 100F);
|
missing.put(stack.getItem(), stack.copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExtras(ICraftingPattern pattern) {
|
||||||
|
pattern.getOutputs().stream().filter(o -> o.stackSize > 1).forEach(o -> addExtras(ItemHandlerHelper.copyStackWithSize(o, o.stackSize - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExtras(ItemStack stack) {
|
||||||
|
ItemStack extras = getExtrasFor(stack);
|
||||||
|
|
||||||
|
if (extras != null) {
|
||||||
|
extras.stackSize += stack.stackSize;
|
||||||
|
} else {
|
||||||
|
this.extras.put(stack.getItem(), stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack getExtrasFor(ItemStack stack) {
|
||||||
|
for (ItemStack m : extras.get(stack.getItem())) {
|
||||||
|
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decrOrRemoveExtras(ItemStack stack) {
|
||||||
|
ItemStack extras = getExtrasFor(stack);
|
||||||
|
|
||||||
|
extras.stackSize--;
|
||||||
|
|
||||||
|
if (extras.stackSize == 0) {
|
||||||
|
this.extras.remove(extras.getItem(), extras);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToCraft(ItemStack stack) {
|
||||||
|
for (ItemStack m : toCraft.get(stack.getItem())) {
|
||||||
|
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
||||||
|
m.stackSize += stack.stackSize;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toCraft.put(stack.getItem(), stack.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,226 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.task;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
|
||||||
import refinedstorage.api.autocrafting.task.CraftingTask;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidUtils;
|
|
||||||
|
|
||||||
public class CraftingTaskProcessing extends CraftingTask {
|
|
||||||
public static final String NBT_SATISFIED_INSERTION = "SatisfiedInsertion";
|
|
||||||
public static final String NBT_TILE_IN_USE = "TileInUse";
|
|
||||||
|
|
||||||
private boolean satisfiedInsertion[];
|
|
||||||
private BlockPos tileInUse;
|
|
||||||
|
|
||||||
public CraftingTaskProcessing(ICraftingPattern pattern, int depth) {
|
|
||||||
super(pattern, depth);
|
|
||||||
|
|
||||||
this.satisfiedInsertion = new boolean[pattern.getOutputs().size()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatisfiedInsertion(boolean[] satisfiedInsertion) {
|
|
||||||
this.satisfiedInsertion = satisfiedInsertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTileInUse(BlockPos tileInUse) {
|
|
||||||
this.tileInUse = tileInUse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean update(World world, INetworkMaster network) {
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
|
||||||
checked[i] = true;
|
|
||||||
|
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
|
||||||
|
|
||||||
if (!satisfied[i]) {
|
|
||||||
ItemStack received = FluidUtils.extractItemOrIfBucketLookInFluids(network, input, input.stackSize);
|
|
||||||
|
|
||||||
if (received != null) {
|
|
||||||
satisfied[i] = true;
|
|
||||||
|
|
||||||
took.add(received);
|
|
||||||
} else {
|
|
||||||
tryCreateChild(network, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasReceivedInputs()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ICraftingPatternContainer container = pattern.getContainer();
|
|
||||||
|
|
||||||
if (container.getFacingTile() != null && !isTileInUse(network)) {
|
|
||||||
tileInUse = pattern.getContainer().getFacingTile().getPos();
|
|
||||||
|
|
||||||
if (!took.isEmpty()) {
|
|
||||||
ItemStack toInsert = took.get(0);
|
|
||||||
|
|
||||||
if (ItemHandlerHelper.insertItem(container.getFacingInventory(), toInsert, true) == null) {
|
|
||||||
ItemHandlerHelper.insertItem(container.getFacingInventory(), toInsert, false);
|
|
||||||
|
|
||||||
took.remove(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tileInUse = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasReceivedOutputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasReceivedOutputs() {
|
|
||||||
for (boolean item : satisfiedInsertion) {
|
|
||||||
if (!item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTileInUse(INetworkMaster network) {
|
|
||||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
|
||||||
if (isTileInUse(task)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTileInUse(ICraftingTask task) {
|
|
||||||
if (task == this) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task.getChild() != null) {
|
|
||||||
return isTileInUse(task.getChild());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task instanceof CraftingTaskProcessing) {
|
|
||||||
CraftingTaskProcessing other = (CraftingTaskProcessing) task;
|
|
||||||
|
|
||||||
if (other.tileInUse != null && other.tileInUse.equals(pattern.getContainer().getFacingTile().getPos()) && !other.pattern.equals(pattern)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onInserted(ItemStack stack) {
|
|
||||||
if (!hasReceivedOutputs() && hasReceivedInputs()) {
|
|
||||||
for (int i = 0; i < pattern.getOutputs().size(); ++i) {
|
|
||||||
ItemStack output = pattern.getOutputs().get(i);
|
|
||||||
|
|
||||||
if (!satisfiedInsertion[i]) {
|
|
||||||
if (CompareUtils.compareStackNoQuantity(output, stack)) {
|
|
||||||
satisfiedInsertion[i] = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
|
||||||
super.writeToNBT(tag);
|
|
||||||
|
|
||||||
if (tileInUse != null) {
|
|
||||||
tag.setLong(NBT_TILE_IN_USE, tileInUse.toLong());
|
|
||||||
}
|
|
||||||
|
|
||||||
writeBooleanArray(tag, NBT_SATISFIED_INSERTION, satisfiedInsertion);
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStatus(INetworkMaster network) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
boolean missingItems = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
|
||||||
ItemStack input = pattern.getInputs().get(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().size(); ++i) {
|
|
||||||
ItemStack input = pattern.getInputs().get(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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasReceivedInputs()) {
|
|
||||||
builder.append("I=gui.refinedstorage:crafting_monitor.items_processing\n");
|
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
|
||||||
builder.append("T=").append(pattern.getInputs().get(i).getUnlocalizedName()).append(".name\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pattern.getContainer().getFacingTile() == null) {
|
|
||||||
builder.append("B=gui.refinedstorage:crafting_monitor.machine_none");
|
|
||||||
} else if (isTileInUse(network)) {
|
|
||||||
builder.append("B=gui.refinedstorage:crafting_monitor.machine_in_use");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getProgress() {
|
|
||||||
int satisfiedAmount = 0;
|
|
||||||
|
|
||||||
for (boolean item : satisfied) {
|
|
||||||
if (item) {
|
|
||||||
satisfiedAmount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (boolean item : satisfiedInsertion) {
|
|
||||||
if (item) {
|
|
||||||
satisfiedAmount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) ((float) satisfiedAmount / (float) (satisfied.length + satisfiedInsertion.length) * 100F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
35
src/main/java/refinedstorage/apiimpl/autocrafting/task/Processable.java
Executable file
35
src/main/java/refinedstorage/apiimpl/autocrafting/task/Processable.java
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
package refinedstorage.apiimpl.autocrafting.task;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Deque;
|
||||||
|
|
||||||
|
public class Processable implements IProcessable {
|
||||||
|
private ICraftingPattern pattern;
|
||||||
|
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
||||||
|
|
||||||
|
public Processable(ICraftingPattern pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICraftingPattern getPattern() {
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Deque<ItemStack> getToInsert() {
|
||||||
|
return toInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ProcessablePattern{" +
|
||||||
|
"pattern=" + pattern +
|
||||||
|
", toInsert=" + toInsert +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
package refinedstorage.apiimpl.autocrafting.v2;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
|
||||||
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
|
||||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryProcessing;
|
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CraftingTask {
|
|
||||||
class ProcessablePattern {
|
|
||||||
private ICraftingPattern pattern;
|
|
||||||
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ProcessablePattern{" +
|
|
||||||
"pattern=" + pattern +
|
|
||||||
", toInsert=" + toInsert +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private INetworkMaster network;
|
|
||||||
private ICraftingPattern pattern;
|
|
||||||
private int quantity;
|
|
||||||
private Deque<ItemStack> toTake = new ArrayDeque<>();
|
|
||||||
private List<ProcessablePattern> toProcess = new ArrayList<>();
|
|
||||||
private Multimap<Item, ItemStack> toCraft = ArrayListMultimap.create();
|
|
||||||
private Multimap<Item, ItemStack> missing = ArrayListMultimap.create();
|
|
||||||
private Multimap<Item, ItemStack> extras = ArrayListMultimap.create();
|
|
||||||
|
|
||||||
public CraftingTask(INetworkMaster network, ICraftingPattern pattern, int quantity) {
|
|
||||||
this.network = network;
|
|
||||||
this.pattern = pattern;
|
|
||||||
this.quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void calculate() {
|
|
||||||
calculate(network.getItemStorage().copy(), pattern, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculate(IGroupedItemStorage storage, ICraftingPattern pattern, boolean basePattern) {
|
|
||||||
for (int i = 0; i < quantity; ++i) {
|
|
||||||
boolean isProcessing = pattern.getId().equals(CraftingTaskFactoryProcessing.ID);
|
|
||||||
|
|
||||||
if (isProcessing) {
|
|
||||||
ProcessablePattern processable = new ProcessablePattern();
|
|
||||||
|
|
||||||
processable.pattern = pattern;
|
|
||||||
|
|
||||||
for (int j = pattern.getInputs().size() - 1; j >= 0; --j) {
|
|
||||||
processable.toInsert.push(pattern.getInputs().get(j).copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
toProcess.add(processable);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ItemStack input : pattern.getInputs()) {
|
|
||||||
ItemStack inputInNetwork = storage.get(input, CompareUtils.COMPARE_DAMAGE | CompareUtils.COMPARE_NBT);
|
|
||||||
|
|
||||||
if (inputInNetwork == null || inputInNetwork.stackSize == 0) {
|
|
||||||
if (getExtrasFor(input) != null) {
|
|
||||||
decrOrRemoveExtras(input);
|
|
||||||
} else {
|
|
||||||
ICraftingPattern inputPattern = NetworkUtils.getPattern(network, input);
|
|
||||||
|
|
||||||
if (inputPattern != null) {
|
|
||||||
for (ItemStack output : inputPattern.getOutputs()) {
|
|
||||||
addToCraft(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
calculate(storage, inputPattern, false);
|
|
||||||
} else {
|
|
||||||
addMissing(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!isProcessing) {
|
|
||||||
toTake.push(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.remove(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!basePattern) {
|
|
||||||
addExtras(pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "\nCraftingTask{quantity=" + quantity +
|
|
||||||
"\n, toTake=" + toTake +
|
|
||||||
"\n, toCraft=" + toCraft +
|
|
||||||
"\n, toProcess=" + toProcess +
|
|
||||||
"\n, missing=" + missing +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean update() {
|
|
||||||
for (ProcessablePattern processable : toProcess) {
|
|
||||||
if (processable.pattern.getContainer().getFacingInventory() != null && !processable.toInsert.isEmpty()) {
|
|
||||||
ItemStack toInsert = NetworkUtils.extractItem(network, processable.toInsert.peek(), 1);
|
|
||||||
|
|
||||||
if (ItemHandlerHelper.insertItem(processable.pattern.getContainer().getFacingInventory(), toInsert, true) == null) {
|
|
||||||
ItemHandlerHelper.insertItem(processable.pattern.getContainer().getFacingInventory(), toInsert, false);
|
|
||||||
|
|
||||||
processable.toInsert.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toTake.isEmpty()) {
|
|
||||||
ItemStack took = NetworkUtils.extractItem(network, toTake.peek(), 1);
|
|
||||||
|
|
||||||
if (took != null) {
|
|
||||||
toTake.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toTake.isEmpty() && missing.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMissing(ItemStack stack) {
|
|
||||||
for (ItemStack m : missing.get(stack.getItem())) {
|
|
||||||
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
|
||||||
m.stackSize += stack.stackSize;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
missing.put(stack.getItem(), stack.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addExtras(ICraftingPattern pattern) {
|
|
||||||
pattern.getOutputs().stream().filter(o -> o.stackSize > 1).forEach(o -> addExtras(ItemHandlerHelper.copyStackWithSize(o, o.stackSize - 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addExtras(ItemStack stack) {
|
|
||||||
ItemStack extras = getExtrasFor(stack);
|
|
||||||
|
|
||||||
if (extras != null) {
|
|
||||||
extras.stackSize += stack.stackSize;
|
|
||||||
} else {
|
|
||||||
this.extras.put(stack.getItem(), stack.copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemStack getExtrasFor(ItemStack stack) {
|
|
||||||
for (ItemStack m : extras.get(stack.getItem())) {
|
|
||||||
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void decrOrRemoveExtras(ItemStack stack) {
|
|
||||||
ItemStack extras = getExtrasFor(stack);
|
|
||||||
|
|
||||||
extras.stackSize--;
|
|
||||||
|
|
||||||
if (extras.stackSize == 0) {
|
|
||||||
this.extras.remove(extras.getItem(), extras);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addToCraft(ItemStack stack) {
|
|
||||||
for (ItemStack m : toCraft.get(stack.getItem())) {
|
|
||||||
if (CompareUtils.compareStackNoQuantity(m, stack)) {
|
|
||||||
m.stackSize += stack.stackSize;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toCraft.put(stack.getItem(), stack.copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,14 +6,11 @@ import net.minecraft.util.EnumFacing;
|
|||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
import refinedstorage.api.network.NetworkUtils;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
import refinedstorage.apiimpl.autocrafting.v2.CraftingTask;
|
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskNormal;
|
||||||
import refinedstorage.tile.TileController;
|
|
||||||
|
|
||||||
public class ItemGridHandler implements IItemGridHandler {
|
public class ItemGridHandler implements IItemGridHandler {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
@@ -125,10 +122,11 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
ItemStack stack = network.getItemStorage().get(hash);
|
ItemStack stack = network.getItemStorage().get(hash);
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
CraftingTask t = new CraftingTask(network, NetworkUtils.getPattern(network, stack), quantity);
|
CraftingTaskNormal task = new CraftingTaskNormal(network, NetworkUtils.getPattern(network, stack), quantity);
|
||||||
t.calculate();
|
|
||||||
System.out.println(t.toString());
|
task.calculate();
|
||||||
((TileController) network).craftingTasksV2.add(t);
|
|
||||||
|
network.addCraftingTask(task);
|
||||||
|
|
||||||
/*CraftingPreviewData previewData = new CraftingPreviewData(network);
|
/*CraftingPreviewData previewData = new CraftingPreviewData(network);
|
||||||
|
|
||||||
@@ -140,7 +138,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftingRequested(int hash, int quantity) {
|
public void onCraftingRequested(int hash, int quantity) {
|
||||||
if (quantity <= 0) {
|
/*if (quantity <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +158,12 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
|
|
||||||
quantity -= quantityPerRequest;
|
quantity -= quantityPerRequest;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftingCancelRequested(int id, int depth) {
|
public void onCraftingCancelRequested(int id, int depth) {
|
||||||
if (id >= 0 && id < network.getCraftingTasks().size()) {
|
/*if (id >= 0 && id < network.getCraftingTasks().size()) {
|
||||||
ICraftingTask task = network.getCraftingTasks().get(id);
|
ICraftingTask task = network.getCraftingTasks().get(id);
|
||||||
|
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
@@ -188,6 +186,6 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
for (ICraftingTask task : network.getCraftingTasks()) {
|
||||||
network.cancelCraftingTask(task);
|
network.cancelCraftingTask(task);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
package refinedstorage.gui;
|
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.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
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.tile.ClientCraftingTask;
|
|
||||||
import refinedstorage.tile.TileCraftingMonitor;
|
import refinedstorage.tile.TileCraftingMonitor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiCraftingMonitor extends GuiBase {
|
public class GuiCraftingMonitor extends GuiBase {
|
||||||
@@ -95,7 +92,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
itemSelectedX = -1;
|
itemSelectedX = -1;
|
||||||
itemSelectedY = -1;
|
itemSelectedY = -1;
|
||||||
|
|
||||||
for (int i = 0; i < VISIBLE_ROWS; ++i) {
|
/*for (int i = 0; i < VISIBLE_ROWS; ++i) {
|
||||||
if (item < getTasks().size()) {
|
if (item < getTasks().size()) {
|
||||||
ClientCraftingTask task = getTasks().get(item);
|
ClientCraftingTask task = getTasks().get(item);
|
||||||
|
|
||||||
@@ -150,7 +147,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
|
|
||||||
if (lines != null) {
|
if (lines != null) {
|
||||||
drawTooltip(mouseX, mouseY, Arrays.asList(lines));
|
drawTooltip(mouseX, mouseY, Arrays.asList(lines));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRows() {
|
private int getRows() {
|
||||||
@@ -162,9 +159,9 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
super.actionPerformed(button);
|
super.actionPerformed(button);
|
||||||
|
|
||||||
if (button == cancelButton && itemSelected != -1) {
|
if (button == cancelButton && itemSelected != -1) {
|
||||||
ClientCraftingTask task = getTasks().get(itemSelected);
|
/*ClientCraftingTask task = getTasks().get(itemSelected);
|
||||||
|
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, task.getId(), task.getDepth()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, task.getId(), task.getDepth()));*/
|
||||||
} else if (button == cancelAllButton && getTasks().size() > 0) {
|
} else if (button == cancelAllButton && getTasks().size() > 0) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, -1, 0));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageCraftingMonitorCancel(craftingMonitor, -1, 0));
|
||||||
}
|
}
|
||||||
@@ -190,7 +187,7 @@ public class GuiCraftingMonitor extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ClientCraftingTask> getTasks() {
|
private List<Integer> getTasks() {
|
||||||
return TileCraftingMonitor.TASKS.getValue();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
package refinedstorage.gui;
|
package refinedstorage.gui;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewStack;
|
|
||||||
import refinedstorage.network.MessageGridCraftingStart;
|
import refinedstorage.network.MessageGridCraftingStart;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiCraftingPreview extends GuiBase {
|
public class GuiCraftingPreview extends GuiBase {
|
||||||
private static final int VISIBLE_ROWS = 4;
|
private static final int VISIBLE_ROWS = 4;
|
||||||
|
|
||||||
private List<CraftingPreviewStack> stacks;
|
//private List<CraftingPreviewStack> stacks;
|
||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
|
|
||||||
private int hash;
|
private int hash;
|
||||||
@@ -31,7 +23,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
private GuiButton startButton;
|
private GuiButton startButton;
|
||||||
private GuiButton cancelButton;
|
private GuiButton cancelButton;
|
||||||
|
|
||||||
public GuiCraftingPreview(GuiScreen parent, Collection<CraftingPreviewStack> stacks, int hash, int quantity) {
|
public GuiCraftingPreview(GuiScreen parent, /*Collection<CraftingPreviewStack> stacks, */int hash, int quantity) {
|
||||||
super(new Container() {
|
super(new Container() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
@@ -39,7 +31,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
}
|
}
|
||||||
}, 168, 171);
|
}, 168, 171);
|
||||||
|
|
||||||
this.stacks = new ArrayList<>(stacks);
|
//this.stacks = new ArrayList<>(stacks);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
@@ -52,7 +44,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
public void init(int x, int y) {
|
public void init(int x, int y) {
|
||||||
cancelButton = addButton(x + 16, y + 144, 50, 20, t("gui.cancel"));
|
cancelButton = addButton(x + 16, y + 144, 50, 20, t("gui.cancel"));
|
||||||
startButton = addButton(x + 85, y + 144, 50, 20, t("misc.refinedstorage:start"));
|
startButton = addButton(x + 85, y + 144, 50, 20, t("misc.refinedstorage:start"));
|
||||||
startButton.enabled = !stacks.isEmpty();
|
//startButton.enabled = !stacks.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,7 +59,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
drawTexture(x, y, 0, 0, width, height);
|
drawTexture(x, y, 0, 0, width, height);
|
||||||
|
|
||||||
if (stacks.isEmpty()) {
|
/*if (stacks.isEmpty()) {
|
||||||
drawRect(x + 7, y + 20, x + 142, y + 139, 0xFFDBDBDB);
|
drawRect(x + 7, y + 20, x + 142, y + 139, 0xFFDBDBDB);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -94,7 +86,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,7 +97,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
int y = 22;
|
int y = 22;
|
||||||
float scale = 0.5f;
|
float scale = 0.5f;
|
||||||
|
|
||||||
if (stacks.isEmpty()) {
|
/*if (stacks.isEmpty()) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.scale(scale, scale, 1);
|
GlStateManager.scale(scale, scale, 1);
|
||||||
|
|
||||||
@@ -163,7 +155,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
if (hoveringStack != null) {
|
if (hoveringStack != null) {
|
||||||
drawTooltip(mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
|
drawTooltip(mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -195,7 +187,8 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getRows() {
|
private int getRows() {
|
||||||
return Math.max(0, (int) Math.ceil((float) stacks.size() / 2F));
|
/*return Math.max(0, (int) Math.ceil((float) stacks.size() / 2F));*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close() {
|
private void close() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package refinedstorage.network;
|
package refinedstorage.network;
|
||||||
|
|
||||||
|
/*
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
@@ -57,3 +58,4 @@ public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHan
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -4,8 +4,6 @@ import mcmultipart.client.multipart.ModelMultipartContainer;
|
|||||||
import mcmultipart.raytrace.PartMOP;
|
import mcmultipart.raytrace.PartMOP;
|
||||||
import mcmultipart.raytrace.RayTraceUtils;
|
import mcmultipart.raytrace.RayTraceUtils;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.VertexBuffer;
|
import net.minecraft.client.renderer.VertexBuffer;
|
||||||
@@ -22,7 +20,6 @@ import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
|||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -31,10 +28,7 @@ import refinedstorage.RefinedStorage;
|
|||||||
import refinedstorage.RefinedStorageBlocks;
|
import refinedstorage.RefinedStorageBlocks;
|
||||||
import refinedstorage.RefinedStorageItems;
|
import refinedstorage.RefinedStorageItems;
|
||||||
import refinedstorage.block.*;
|
import refinedstorage.block.*;
|
||||||
import refinedstorage.gui.GuiCraftingPreview;
|
|
||||||
import refinedstorage.gui.grid.GuiCraftingStart;
|
|
||||||
import refinedstorage.item.*;
|
import refinedstorage.item.*;
|
||||||
import refinedstorage.network.MessageGridCraftingPreviewResponse;
|
|
||||||
import refinedstorage.tile.TileController;
|
import refinedstorage.tile.TileController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -154,56 +148,56 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
// Item Variants
|
// Item Variants
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_DISK,
|
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_DISK,
|
||||||
new ResourceLocation("refinedstorage:1k_storage_disk"),
|
new ResourceLocation("refinedstorage:1k_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:4k_storage_disk"),
|
new ResourceLocation("refinedstorage:4k_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:16k_storage_disk"),
|
new ResourceLocation("refinedstorage:16k_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:64k_storage_disk"),
|
new ResourceLocation("refinedstorage:64k_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:creative_storage_disk")
|
new ResourceLocation("refinedstorage:creative_storage_disk")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_PART,
|
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_PART,
|
||||||
new ResourceLocation("refinedstorage:1k_storage_part"),
|
new ResourceLocation("refinedstorage:1k_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:4k_storage_part"),
|
new ResourceLocation("refinedstorage:4k_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:16k_storage_part"),
|
new ResourceLocation("refinedstorage:16k_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:64k_storage_part")
|
new ResourceLocation("refinedstorage:64k_storage_part")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.FLUID_STORAGE_DISK,
|
ModelBakery.registerItemVariants(RefinedStorageItems.FLUID_STORAGE_DISK,
|
||||||
new ResourceLocation("refinedstorage:64k_fluid_storage_disk"),
|
new ResourceLocation("refinedstorage:64k_fluid_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:128k_fluid_storage_disk"),
|
new ResourceLocation("refinedstorage:128k_fluid_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:256k_fluid_storage_disk"),
|
new ResourceLocation("refinedstorage:256k_fluid_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:512k_fluid_storage_disk"),
|
new ResourceLocation("refinedstorage:512k_fluid_storage_disk"),
|
||||||
new ResourceLocation("refinedstorage:creative_fluid_storage_disk")
|
new ResourceLocation("refinedstorage:creative_fluid_storage_disk")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.FLUID_STORAGE_PART,
|
ModelBakery.registerItemVariants(RefinedStorageItems.FLUID_STORAGE_PART,
|
||||||
new ResourceLocation("refinedstorage:64k_fluid_storage_part"),
|
new ResourceLocation("refinedstorage:64k_fluid_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:128k_fluid_storage_part"),
|
new ResourceLocation("refinedstorage:128k_fluid_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:256k_fluid_storage_part"),
|
new ResourceLocation("refinedstorage:256k_fluid_storage_part"),
|
||||||
new ResourceLocation("refinedstorage:512k_fluid_storage_part")
|
new ResourceLocation("refinedstorage:512k_fluid_storage_part")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.PROCESSOR,
|
ModelBakery.registerItemVariants(RefinedStorageItems.PROCESSOR,
|
||||||
new ResourceLocation("refinedstorage:basic_printed_processor"),
|
new ResourceLocation("refinedstorage:basic_printed_processor"),
|
||||||
new ResourceLocation("refinedstorage:improved_printed_processor"),
|
new ResourceLocation("refinedstorage:improved_printed_processor"),
|
||||||
new ResourceLocation("refinedstorage:advanced_printed_processor"),
|
new ResourceLocation("refinedstorage:advanced_printed_processor"),
|
||||||
new ResourceLocation("refinedstorage:basic_processor"),
|
new ResourceLocation("refinedstorage:basic_processor"),
|
||||||
new ResourceLocation("refinedstorage:improved_processor"),
|
new ResourceLocation("refinedstorage:improved_processor"),
|
||||||
new ResourceLocation("refinedstorage:advanced_processor"),
|
new ResourceLocation("refinedstorage:advanced_processor"),
|
||||||
new ResourceLocation("refinedstorage:printed_silicon")
|
new ResourceLocation("refinedstorage:printed_silicon")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.CORE,
|
ModelBakery.registerItemVariants(RefinedStorageItems.CORE,
|
||||||
new ResourceLocation("refinedstorage:construction_core"),
|
new ResourceLocation("refinedstorage:construction_core"),
|
||||||
new ResourceLocation("refinedstorage:destruction_core")
|
new ResourceLocation("refinedstorage:destruction_core")
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.UPGRADE,
|
ModelBakery.registerItemVariants(RefinedStorageItems.UPGRADE,
|
||||||
new ResourceLocation("refinedstorage:upgrade"),
|
new ResourceLocation("refinedstorage:upgrade"),
|
||||||
new ResourceLocation("refinedstorage:range_upgrade"),
|
new ResourceLocation("refinedstorage:range_upgrade"),
|
||||||
new ResourceLocation("refinedstorage:speed_upgrade"),
|
new ResourceLocation("refinedstorage:speed_upgrade"),
|
||||||
new ResourceLocation("refinedstorage:stack_upgrade"),
|
new ResourceLocation("refinedstorage:stack_upgrade"),
|
||||||
new ResourceLocation("refinedstorage:interdimensional_upgrade")
|
new ResourceLocation("refinedstorage:interdimensional_upgrade")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
@@ -301,7 +295,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onReceiveCraftingPreviewResponse(MessageGridCraftingPreviewResponse message) {
|
/*public static void onReceiveCraftingPreviewResponse(MessageGridCraftingPreviewResponse message) {
|
||||||
Minecraft.getMinecraft().addScheduledTask(() -> {
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
||||||
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||||
|
|
||||||
@@ -311,5 +305,5 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.hash, message.quantity));
|
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.hash, message.quantity));
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import refinedstorage.RefinedStorageItems;
|
|||||||
import refinedstorage.api.RefinedStorageAPI;
|
import refinedstorage.api.RefinedStorageAPI;
|
||||||
import refinedstorage.api.solderer.SoldererRecipe;
|
import refinedstorage.api.solderer.SoldererRecipe;
|
||||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal;
|
||||||
import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryProcessing;
|
|
||||||
import refinedstorage.apiimpl.solderer.*;
|
import refinedstorage.apiimpl.solderer.*;
|
||||||
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
import refinedstorage.apiimpl.storage.fluid.FluidStorageNBT;
|
||||||
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
import refinedstorage.apiimpl.storage.item.ItemStorageNBT;
|
||||||
@@ -47,7 +46,6 @@ public class CommonProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RefinedStorageAPI.instance().getCraftingTaskRegistry().addFactory(CraftingTaskFactoryNormal.ID, new CraftingTaskFactoryNormal());
|
RefinedStorageAPI.instance().getCraftingTaskRegistry().addFactory(CraftingTaskFactoryNormal.ID, new CraftingTaskFactoryNormal());
|
||||||
RefinedStorageAPI.instance().getCraftingTaskRegistry().addFactory(CraftingTaskFactoryProcessing.ID, new CraftingTaskFactoryProcessing());
|
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ public class CommonProxy {
|
|||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingPreview.class, MessageGridCraftingPreview.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingPreview.class, MessageGridCraftingPreview.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingPreviewResponse.class, MessageGridCraftingPreviewResponse.class, id++, Side.CLIENT);
|
//RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingPreviewResponse.class, MessageGridCraftingPreviewResponse.class, id++, Side.CLIENT);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderTransfer.class, MessageProcessingPatternEncoderTransfer.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderTransfer.class, MessageProcessingPatternEncoderTransfer.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
||||||
@@ -158,315 +156,315 @@ public class CommonProxy {
|
|||||||
|
|
||||||
// Quartz Enriched Iron
|
// Quartz Enriched Iron
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON, 4),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON, 4),
|
||||||
"II",
|
"II",
|
||||||
"IQ",
|
"IQ",
|
||||||
'I', new ItemStack(Items.IRON_INGOT),
|
'I', new ItemStack(Items.IRON_INGOT),
|
||||||
'Q', new ItemStack(Items.QUARTZ)
|
'Q', new ItemStack(Items.QUARTZ)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Machine Casing
|
// Machine Casing
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
"EEE",
|
"EEE",
|
||||||
"E E",
|
"E E",
|
||||||
"EEE",
|
"EEE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Construction Core
|
// Construction Core
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
||||||
new ItemStack(Items.GLOWSTONE_DUST)
|
new ItemStack(Items.GLOWSTONE_DUST)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Destruction Core
|
// Destruction Core
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
||||||
new ItemStack(Items.QUARTZ)
|
new ItemStack(Items.QUARTZ)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relay
|
// Relay
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.RELAY),
|
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.RELAY),
|
||||||
new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
new ItemStack(RefinedStorageBlocks.CABLE),
|
new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
new ItemStack(Blocks.REDSTONE_TORCH)
|
new ItemStack(Blocks.REDSTONE_TORCH)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Controller
|
// Controller
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CONTROLLER, 1, EnumControllerType.NORMAL.getId()),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CONTROLLER, 1, EnumControllerType.NORMAL.getId()),
|
||||||
"EDE",
|
"EDE",
|
||||||
"SMS",
|
"SMS",
|
||||||
"ESE",
|
"ESE",
|
||||||
'D', new ItemStack(Items.DIAMOND),
|
'D', new ItemStack(Items.DIAMOND),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'S', "itemSilicon"
|
'S', "itemSilicon"
|
||||||
));
|
));
|
||||||
|
|
||||||
// Solderer
|
// Solderer
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.SOLDERER),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.SOLDERER),
|
||||||
"ESE",
|
"ESE",
|
||||||
"E E",
|
"E E",
|
||||||
"ESE",
|
"ESE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'S', new ItemStack(Blocks.STICKY_PISTON)
|
'S', new ItemStack(Blocks.STICKY_PISTON)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Disk Drive
|
// Disk Drive
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.DISK_DRIVE),
|
new ItemStack(RefinedStorageBlocks.DISK_DRIVE),
|
||||||
500,
|
500,
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
new ItemStack(Blocks.CHEST)
|
new ItemStack(Blocks.CHEST)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Cable
|
// Cable
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CABLE, 12),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CABLE, 12),
|
||||||
"EEE",
|
"EEE",
|
||||||
"GRG",
|
"GRG",
|
||||||
"EEE",
|
"EEE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'R', new ItemStack(Items.REDSTONE)
|
'R', new ItemStack(Items.REDSTONE)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Wireless Transmitter
|
// Wireless Transmitter
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.WIRELESS_TRANSMITTER),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.WIRELESS_TRANSMITTER),
|
||||||
"EPE",
|
"EPE",
|
||||||
"EME",
|
"EME",
|
||||||
"EAE",
|
"EAE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
'P', new ItemStack(Items.ENDER_PEARL),
|
'P', new ItemStack(Items.ENDER_PEARL),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Grid
|
// Grid
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
||||||
"ECE",
|
"ECE",
|
||||||
"PMP",
|
"PMP",
|
||||||
"EDE",
|
"EDE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Crafting Grid
|
// Crafting Grid
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.CRAFTING.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.CRAFTING.getId()),
|
||||||
500,
|
500,
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
||||||
new ItemStack(Blocks.CRAFTING_TABLE)
|
new ItemStack(Blocks.CRAFTING_TABLE)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Pattern Grid
|
// Pattern Grid
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.PATTERN.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.PATTERN.getId()),
|
||||||
500,
|
500,
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
||||||
new ItemStack(RefinedStorageItems.PATTERN)
|
new ItemStack(RefinedStorageItems.PATTERN)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Fluid Grid
|
// Fluid Grid
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.FLUID.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.FLUID.getId()),
|
||||||
500,
|
500,
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
||||||
new ItemStack(Items.BUCKET)
|
new ItemStack(Items.BUCKET)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Wireless Grid
|
// Wireless Grid
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.WIRELESS_GRID, 1, ItemWirelessGrid.TYPE_NORMAL),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.WIRELESS_GRID, 1, ItemWirelessGrid.TYPE_NORMAL),
|
||||||
"EPE",
|
"EPE",
|
||||||
"EAE",
|
"EAE",
|
||||||
"EEE",
|
"EEE",
|
||||||
'P', new ItemStack(Items.ENDER_PEARL),
|
'P', new ItemStack(Items.ENDER_PEARL),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Crafter
|
// Crafter
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.CRAFTER),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.CRAFTER),
|
||||||
"ECE",
|
"ECE",
|
||||||
"AMA",
|
"AMA",
|
||||||
"EDE",
|
"EDE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Processing Pattern Encoder
|
// Processing Pattern Encoder
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.PROCESSING_PATTERN_ENCODER),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.PROCESSING_PATTERN_ENCODER),
|
||||||
"ECE",
|
"ECE",
|
||||||
"PMP",
|
"PMP",
|
||||||
"EFE",
|
"EFE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'P', new ItemStack(RefinedStorageItems.PATTERN),
|
'P', new ItemStack(RefinedStorageItems.PATTERN),
|
||||||
'C', new ItemStack(Blocks.CRAFTING_TABLE),
|
'C', new ItemStack(Blocks.CRAFTING_TABLE),
|
||||||
'F', new ItemStack(Blocks.FURNACE)
|
'F', new ItemStack(Blocks.FURNACE)
|
||||||
);
|
);
|
||||||
|
|
||||||
// External Storage
|
// External Storage
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.EXTERNAL_STORAGE),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.EXTERNAL_STORAGE),
|
||||||
"CED",
|
"CED",
|
||||||
"HMH",
|
"HMH",
|
||||||
"EPE",
|
"EPE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'H', new ItemStack(Blocks.CHEST),
|
'H', new ItemStack(Blocks.CHEST),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Importer
|
// Importer
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.IMPORTER),
|
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.IMPORTER),
|
||||||
new ItemStack(RefinedStorageBlocks.CABLE),
|
new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Exporter
|
// Exporter
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.EXPORTER),
|
GameRegistry.addShapelessRecipe(new ItemStack(RefinedStorageBlocks.EXPORTER),
|
||||||
new ItemStack(RefinedStorageBlocks.CABLE),
|
new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DESTRUCTOR),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DESTRUCTOR),
|
||||||
"EDE",
|
"EDE",
|
||||||
"RMR",
|
"RMR",
|
||||||
"EIE",
|
"EIE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.CONSTRUCTOR),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.CONSTRUCTOR),
|
||||||
"ECE",
|
"ECE",
|
||||||
"RMR",
|
"RMR",
|
||||||
"EIE",
|
"EIE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
||||||
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Detector
|
// Detector
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.DETECTOR),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageBlocks.DETECTOR),
|
||||||
"ECE",
|
"ECE",
|
||||||
"RMR",
|
"RMR",
|
||||||
"EPE",
|
"EPE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'C', new ItemStack(Items.COMPARATOR),
|
'C', new ItemStack(Items.COMPARATOR),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Storage Parts
|
// Storage Parts
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_1K),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_1K),
|
||||||
"SES",
|
"SES",
|
||||||
"GRG",
|
"GRG",
|
||||||
"SGS",
|
"SGS",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'S', "itemSilicon",
|
'S', "itemSilicon",
|
||||||
'G', "blockGlass"
|
'G', "blockGlass"
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_4K),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_4K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
||||||
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_1K)
|
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_1K)
|
||||||
);
|
);
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_16K),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_16K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
||||||
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_4K)
|
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_4K)
|
||||||
);
|
);
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_64K),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_64K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_16K)
|
'S', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, ItemStoragePart.TYPE_16K)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Fluid Storage Parts
|
// Fluid Storage Parts
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_64K),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_64K),
|
||||||
"SES",
|
"SES",
|
||||||
"GRG",
|
"GRG",
|
||||||
"SGS",
|
"SGS",
|
||||||
'R', new ItemStack(Items.BUCKET),
|
'R', new ItemStack(Items.BUCKET),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'S', "itemSilicon",
|
'S', "itemSilicon",
|
||||||
'G', "blockGlass"
|
'G', "blockGlass"
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_128K),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_128K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.BUCKET),
|
'R', new ItemStack(Items.BUCKET),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
||||||
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_64K)
|
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_64K)
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_256K),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_256K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.BUCKET),
|
'R', new ItemStack(Items.BUCKET),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
||||||
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_128K)
|
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_128K)
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_512K),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_512K),
|
||||||
"PEP",
|
"PEP",
|
||||||
"SRS",
|
"SRS",
|
||||||
"PSP",
|
"PSP",
|
||||||
'R', new ItemStack(Items.BUCKET),
|
'R', new ItemStack(Items.BUCKET),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||||
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_256K)
|
'S', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, ItemFluidStoragePart.TYPE_256K)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Storage Housing
|
// Storage Housing
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(ItemStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.STORAGE_HOUSING)),
|
GameRegistry.addRecipe(new ShapedOreRecipe(ItemStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.STORAGE_HOUSING)),
|
||||||
"GRG",
|
"GRG",
|
||||||
"R R",
|
"R R",
|
||||||
"EEE",
|
"EEE",
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Storage Disks
|
// Storage Disks
|
||||||
@@ -474,18 +472,18 @@ public class CommonProxy {
|
|||||||
ItemStack disk = ItemStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.STORAGE_DISK, 1, type));
|
ItemStack disk = ItemStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.STORAGE_DISK, 1, type));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
||||||
"GRG",
|
"GRG",
|
||||||
"RPR",
|
"RPR",
|
||||||
"EEE",
|
"EEE",
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'P', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, type),
|
'P', new ItemStack(RefinedStorageItems.STORAGE_PART, 1, type),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addShapelessRecipe(disk,
|
GameRegistry.addShapelessRecipe(disk,
|
||||||
new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
||||||
new ItemStack(RefinedStorageItems.STORAGE_PART, 1, type)
|
new ItemStack(RefinedStorageItems.STORAGE_PART, 1, type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,39 +492,39 @@ public class CommonProxy {
|
|||||||
ItemStack disk = FluidStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.FLUID_STORAGE_DISK, 1, type));
|
ItemStack disk = FluidStorageNBT.createStackWithNBT(new ItemStack(RefinedStorageItems.FLUID_STORAGE_DISK, 1, type));
|
||||||
|
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
GameRegistry.addRecipe(new ShapedOreRecipe(disk,
|
||||||
"GRG",
|
"GRG",
|
||||||
"RPR",
|
"RPR",
|
||||||
"EEE",
|
"EEE",
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'P', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, type),
|
'P', new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, type),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
));
|
));
|
||||||
|
|
||||||
GameRegistry.addShapelessRecipe(disk,
|
GameRegistry.addShapelessRecipe(disk,
|
||||||
new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
||||||
new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, type)
|
new ItemStack(RefinedStorageItems.FLUID_STORAGE_PART, 1, type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pattern
|
// Pattern
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.PATTERN),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.PATTERN),
|
||||||
"GRG",
|
"GRG",
|
||||||
"RGR",
|
"RGR",
|
||||||
"EEE",
|
"EEE",
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'R', new ItemStack(Items.REDSTONE),
|
'R', new ItemStack(Items.REDSTONE),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Upgrade
|
// Upgrade
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.UPGRADE, 1, 0),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageItems.UPGRADE, 1, 0),
|
||||||
"EGE",
|
"EGE",
|
||||||
"EPE",
|
"EPE",
|
||||||
"EGE",
|
"EGE",
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED),
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON)
|
||||||
));
|
));
|
||||||
|
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE));
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE));
|
||||||
@@ -535,11 +533,11 @@ public class CommonProxy {
|
|||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
|
||||||
|
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.UPGRADE, 1, ItemUpgrade.TYPE_STACK),
|
||||||
"USU",
|
"USU",
|
||||||
"SUS",
|
"SUS",
|
||||||
"USU",
|
"USU",
|
||||||
'U', new ItemStack(Items.SUGAR),
|
'U', new ItemStack(Items.SUGAR),
|
||||||
'S', new ItemStack(RefinedStorageItems.UPGRADE, 1, ItemUpgrade.TYPE_SPEED)
|
'S', new ItemStack(RefinedStorageItems.UPGRADE, 1, ItemUpgrade.TYPE_SPEED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Storage Blocks
|
// Storage Blocks
|
||||||
@@ -556,87 +554,87 @@ public class CommonProxy {
|
|||||||
|
|
||||||
// Crafting Monitor
|
// Crafting Monitor
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CRAFTING_MONITOR),
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RefinedStorageBlocks.CRAFTING_MONITOR),
|
||||||
"EGE",
|
"EGE",
|
||||||
"GMG",
|
"GMG",
|
||||||
"EPE",
|
"EPE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'G', "blockGlass",
|
'G', "blockGlass",
|
||||||
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
'P', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.INTERFACE),
|
new ItemStack(RefinedStorageBlocks.INTERFACE),
|
||||||
200,
|
200,
|
||||||
new ItemStack(RefinedStorageBlocks.IMPORTER),
|
new ItemStack(RefinedStorageBlocks.IMPORTER),
|
||||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC),
|
||||||
new ItemStack(RefinedStorageBlocks.EXPORTER)
|
new ItemStack(RefinedStorageBlocks.EXPORTER)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Fluid Interface
|
// Fluid Interface
|
||||||
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
RefinedStorageAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe(
|
||||||
new ItemStack(RefinedStorageBlocks.FLUID_INTERFACE),
|
new ItemStack(RefinedStorageBlocks.FLUID_INTERFACE),
|
||||||
200,
|
200,
|
||||||
new ItemStack(Items.BUCKET),
|
new ItemStack(Items.BUCKET),
|
||||||
new ItemStack(RefinedStorageBlocks.INTERFACE),
|
new ItemStack(RefinedStorageBlocks.INTERFACE),
|
||||||
new ItemStack(Items.BUCKET)
|
new ItemStack(Items.BUCKET)
|
||||||
));
|
));
|
||||||
|
|
||||||
// Grid Filter
|
// Grid Filter
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.GRID_FILTER),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.GRID_FILTER),
|
||||||
"EPE",
|
"EPE",
|
||||||
"PHP",
|
"PHP",
|
||||||
"EPE",
|
"EPE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(Items.PAPER),
|
'P', new ItemStack(Items.PAPER),
|
||||||
'H', new ItemStack(Blocks.HOPPER)
|
'H', new ItemStack(Blocks.HOPPER)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Network Card
|
// Network Card
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.NETWORK_CARD),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.NETWORK_CARD),
|
||||||
"EEE",
|
"EEE",
|
||||||
"PAP",
|
"PAP",
|
||||||
"EEE",
|
"EEE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'P', new ItemStack(Items.PAPER),
|
'P', new ItemStack(Items.PAPER),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Network Transmitter
|
// Network Transmitter
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.NETWORK_TRANSMITTER),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.NETWORK_TRANSMITTER),
|
||||||
"EEE",
|
"EEE",
|
||||||
"CMD",
|
"CMD",
|
||||||
"AAA",
|
"AAA",
|
||||||
'E', new ItemStack(Items.ENDER_PEARL),
|
'E', new ItemStack(Items.ENDER_PEARL),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Network Receiver
|
// Network Receiver
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.NETWORK_RECEIVER),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.NETWORK_RECEIVER),
|
||||||
"AAA",
|
"AAA",
|
||||||
"CMD",
|
"CMD",
|
||||||
"EEE",
|
"EEE",
|
||||||
'E', new ItemStack(Items.ENDER_PEARL),
|
'E', new ItemStack(Items.ENDER_PEARL),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||||
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
'A', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Disk Manipulator
|
// Disk Manipulator
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DISK_MANIPULATOR),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DISK_MANIPULATOR),
|
||||||
"ESE",
|
"ESE",
|
||||||
"CMD",
|
"CMD",
|
||||||
"ESE",
|
"ESE",
|
||||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||||
'S', new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
'S', new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
|
||||||
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
'C', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_CONSTRUCTION),
|
||||||
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
'M', new ItemStack(RefinedStorageBlocks.MACHINE_CASING),
|
||||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION)
|
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
package refinedstorage.tile;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ClientCraftingTask {
|
|
||||||
private ItemStack output;
|
|
||||||
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 children, int progress) {
|
|
||||||
this.output = output;
|
|
||||||
this.id = id;
|
|
||||||
this.status = status;
|
|
||||||
this.depth = depth;
|
|
||||||
this.children = children;
|
|
||||||
this.progress = progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientCraftingTask(INetworkMaster network, ICraftingTask task) {
|
|
||||||
this.status = task.getStatus(network);
|
|
||||||
this.outputs = task.getPattern().getOutputs();
|
|
||||||
this.progress = task.getProgress();
|
|
||||||
this.child = task.getChild() != null ? new ClientCraftingTask(network, task.getChild()) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getOutput() {
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ItemStack> getOutputs() {
|
|
||||||
return outputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientCraftingTask getChild() {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDepth() {
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChildren() {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProgress() {
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,8 +31,6 @@ import refinedstorage.api.storage.fluid.IFluidStorage;
|
|||||||
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
import refinedstorage.api.storage.fluid.IGroupedFluidStorage;
|
||||||
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
import refinedstorage.api.storage.item.IGroupedItemStorage;
|
||||||
import refinedstorage.api.storage.item.IItemStorage;
|
import refinedstorage.api.storage.item.IItemStorage;
|
||||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTaskProcessing;
|
|
||||||
import refinedstorage.apiimpl.autocrafting.v2.CraftingTask;
|
|
||||||
import refinedstorage.apiimpl.network.NetworkNodeGraph;
|
import refinedstorage.apiimpl.network.NetworkNodeGraph;
|
||||||
import refinedstorage.apiimpl.network.WirelessGridHandler;
|
import refinedstorage.apiimpl.network.WirelessGridHandler;
|
||||||
import refinedstorage.apiimpl.network.grid.FluidGridHandler;
|
import refinedstorage.apiimpl.network.grid.FluidGridHandler;
|
||||||
@@ -176,7 +174,6 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
private List<ICraftingPattern> patterns = new ArrayList<>();
|
private List<ICraftingPattern> patterns = new ArrayList<>();
|
||||||
|
|
||||||
public List<CraftingTask> craftingTasksV2 = new ArrayList<>();
|
|
||||||
private List<ICraftingTask> craftingTasks = new ArrayList<>();
|
private List<ICraftingTask> craftingTasks = new ArrayList<>();
|
||||||
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<>();
|
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<>();
|
||||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<>();
|
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<>();
|
||||||
@@ -240,7 +237,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
if (!craftingTasksToRead.isEmpty()) {
|
if (!craftingTasksToRead.isEmpty()) {
|
||||||
for (NBTTagCompound tag : craftingTasksToRead) {
|
for (NBTTagCompound tag : craftingTasksToRead) {
|
||||||
ICraftingTask task = readCraftingTask(worldObj, 0, tag);
|
ICraftingTask task = NetworkUtils.readCraftingTask(worldObj, this, tag);
|
||||||
|
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
addCraftingTask(task);
|
addCraftingTask(task);
|
||||||
@@ -260,7 +257,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
boolean craftingTasksChanged = !craftingTasksToAdd.isEmpty() || !craftingTasksToCancel.isEmpty();
|
boolean craftingTasksChanged = !craftingTasksToAdd.isEmpty() || !craftingTasksToCancel.isEmpty();
|
||||||
|
|
||||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||||
taskToCancel.onCancelled(this);
|
taskToCancel.onCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
craftingTasks.removeAll(craftingTasksToCancel);
|
craftingTasks.removeAll(craftingTasksToCancel);
|
||||||
@@ -272,12 +269,12 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
craftingTasksToAdd.clear();
|
craftingTasksToAdd.clear();
|
||||||
|
|
||||||
/*Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||||
|
|
||||||
while (craftingTaskIterator.hasNext()) {
|
while (craftingTaskIterator.hasNext()) {
|
||||||
ICraftingTask task = craftingTaskIterator.next();
|
ICraftingTask task = craftingTaskIterator.next();
|
||||||
|
|
||||||
if (updateCraftingTask(task)) {
|
if (task.update()) {
|
||||||
craftingTaskIterator.remove();
|
craftingTaskIterator.remove();
|
||||||
|
|
||||||
craftingTasksChanged = true;
|
craftingTasksChanged = true;
|
||||||
@@ -287,17 +284,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
if (!craftingTasks.isEmpty() || craftingTasksChanged) {
|
if (!craftingTasks.isEmpty() || craftingTasksChanged) {
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
updateCraftingTasks();
|
updateCraftingMonitors();
|
||||||
}*/
|
|
||||||
|
|
||||||
Iterator<CraftingTask> craftingTaskIterator = craftingTasksV2.iterator();
|
|
||||||
|
|
||||||
while (craftingTaskIterator.hasNext()) {
|
|
||||||
CraftingTask task = craftingTaskIterator.next();
|
|
||||||
|
|
||||||
if (task.update()) {
|
|
||||||
craftingTaskIterator.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,24 +318,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateCraftingTask(ICraftingTask task) {
|
public void updateCraftingMonitors() {
|
||||||
if (task.getChild() != null) {
|
|
||||||
if (updateCraftingTask(task.getChild())) {
|
|
||||||
task.setChild(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ICraftingPatternContainer container = task.getPattern().getContainer();
|
|
||||||
|
|
||||||
return container != null && ticks % container.getSpeed() == 0 && task.update(worldObj, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateCraftingTasks() {
|
|
||||||
for (INetworkNode node : nodeGraph.all()) {
|
for (INetworkNode node : nodeGraph.all()) {
|
||||||
if (node instanceof TileCraftingMonitor) {
|
if (node instanceof TileCraftingMonitor) {
|
||||||
((TileCraftingMonitor) node).dataManager.sendParameterToWatchers(TileCraftingMonitor.TASKS);
|
//((TileCraftingMonitor) node).dataManager.sendParameterToWatchers(TileCraftingMonitor.TASKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +530,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
if (!simulate && inserted > 0) {
|
if (!simulate && inserted > 0) {
|
||||||
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);
|
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);
|
||||||
|
|
||||||
for (int i = 0; i < inserted; ++i) {
|
/*for (int i = 0; i < inserted; ++i) {
|
||||||
for (ICraftingTask task : craftingTasks) {
|
for (ICraftingTask task : craftingTasks) {
|
||||||
if (inserted == 0) {
|
if (inserted == 0) {
|
||||||
break;
|
break;
|
||||||
@@ -567,20 +540,12 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
inserted--;
|
inserted--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return remainder;
|
return remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onInserted(ItemStack stack, ICraftingTask task) {
|
|
||||||
if (task.getChild() != null) {
|
|
||||||
return onInserted(stack, task.getChild());
|
|
||||||
}
|
|
||||||
|
|
||||||
return task instanceof CraftingTaskProcessing && ((CraftingTaskProcessing) task).onInserted(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
public ItemStack extractItem(ItemStack stack, int size, int flags) {
|
||||||
int requested = size;
|
int requested = size;
|
||||||
@@ -710,26 +675,6 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICraftingTask readCraftingTask(World world, int depth, NBTTagCompound tag) {
|
|
||||||
/* ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(CraftingTask.NBT_PATTERN_STACK));
|
|
||||||
|
|
||||||
if (stack != null && stack.getItem() instanceof ICraftingPatternProvider) {
|
|
||||||
TileEntity container = world.getTileEntity(BlockPos.fromLong(tag.getLong(CraftingTask.NBT_PATTERN_CONTAINER)));
|
|
||||||
|
|
||||||
if (container instanceof ICraftingPatternContainer) {
|
|
||||||
ICraftingPattern pattern = ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) container);
|
|
||||||
|
|
||||||
ICraftingTaskFactory factory = RefinedStorageAPI.instance().getCraftingTaskRegistry().getFactory(tag.getString(CraftingTask.NBT_PATTERN_TYPE));
|
|
||||||
|
|
||||||
if (factory != null) {
|
|
||||||
return factory.create(world, depth, tag, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
|
|||||||
@@ -1,31 +1,8 @@
|
|||||||
package refinedstorage.tile;
|
package refinedstorage.tile;
|
||||||
|
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.tile.data.ITileDataProducer;
|
|
||||||
import refinedstorage.tile.data.RefinedStorageSerializers;
|
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class TileCraftingMonitor extends TileNode {
|
public class TileCraftingMonitor extends TileNode {
|
||||||
public static final TileDataParameter<List<ClientCraftingTask>> TASKS = new TileDataParameter<>(RefinedStorageSerializers.CLIENT_CRAFTING_TASK_SERIALIZER, new ArrayList<>(), new ITileDataProducer<List<ClientCraftingTask>, TileCraftingMonitor>() {
|
|
||||||
@Override
|
|
||||||
public List<ClientCraftingTask> getValue(TileCraftingMonitor tile) {
|
|
||||||
if (tile.connected) {
|
|
||||||
return tile.network.getCraftingTasks().stream().map(t -> new ClientCraftingTask(tile.network, t)).collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
public TileCraftingMonitor() {
|
|
||||||
dataManager.addParameter(TASKS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return RefinedStorage.INSTANCE.config.craftingMonitorUsage;
|
return RefinedStorage.INSTANCE.config.craftingMonitorUsage;
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package refinedstorage.tile.data;
|
package refinedstorage.tile.data;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.datasync.DataParameter;
|
import net.minecraft.network.datasync.DataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializer;
|
import net.minecraft.network.datasync.DataSerializer;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
import refinedstorage.tile.ClientCraftingTask;
|
|
||||||
import refinedstorage.tile.ClientNode;
|
import refinedstorage.tile.ClientNode;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -46,83 +44,6 @@ public final class RefinedStorageSerializers {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final DataSerializer<List<ClientCraftingTask>> CLIENT_CRAFTING_TASK_SERIALIZER = new DataSerializer<List<ClientCraftingTask>>() {
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buf, List<ClientCraftingTask> tasks) {
|
|
||||||
buf.writeInt(tasks.size());
|
|
||||||
|
|
||||||
for (ClientCraftingTask task : tasks) {
|
|
||||||
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, int children) {
|
|
||||||
ByteBufUtils.writeUTF8String(buf, task.getStatus());
|
|
||||||
|
|
||||||
buf.writeInt(children);
|
|
||||||
|
|
||||||
buf.writeInt(task.getProgress());
|
|
||||||
|
|
||||||
buf.writeInt(task.getOutputs().size());
|
|
||||||
|
|
||||||
for (ItemStack output : task.getOutputs()) {
|
|
||||||
ByteBufUtils.writeItemStack(buf, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.writeBoolean(task.getChild() != null);
|
|
||||||
|
|
||||||
if (task.getChild() != null) {
|
|
||||||
writeTask(buf, task.getChild(), children);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ClientCraftingTask> read(PacketBuffer buf) {
|
|
||||||
int size = buf.readInt();
|
|
||||||
|
|
||||||
List<ClientCraftingTask> tasks = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
readTask(buf, i, 0, tasks);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
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, children, progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf.readBoolean()) {
|
|
||||||
readTask(buf, i, depth + 1, tasks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataParameter<List<ClientCraftingTask>> createKey(int id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final DataSerializer<FluidStack> FLUID_STACK_SERIALIZER = new DataSerializer<FluidStack>() {
|
public static final DataSerializer<FluidStack> FLUID_STACK_SERIALIZER = new DataSerializer<FluidStack>() {
|
||||||
@Override
|
@Override
|
||||||
public void write(PacketBuffer buf, FluidStack value) {
|
public void write(PacketBuffer buf, FluidStack value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user