rewrite most the autocraft calculations (#472)
* rewrite most the autocraft calculations, mainly to improve the preview generation * fix impl being in the api and general code style * fix code style * remove breakpoint line
This commit is contained in:
@@ -34,7 +34,7 @@ public interface ICraftingPattern {
|
|||||||
boolean isOredict();
|
boolean isOredict();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the inputs
|
* @return the inputs, can contain nulls
|
||||||
*/
|
*/
|
||||||
List<ItemStack> getInputs();
|
List<ItemStack> getInputs();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package refinedstorage.api.autocrafting.preview;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface ICraftingPreviewStack {
|
||||||
|
/**
|
||||||
|
* @return the stack to display
|
||||||
|
*/
|
||||||
|
ItemStack getStack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return available amount of the {@link #getStack()}
|
||||||
|
*/
|
||||||
|
int getAvailable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return toCraft or missing (depends on {@link #hasMissing()} amount of the {@link #getStack()}
|
||||||
|
*/
|
||||||
|
int getToCraft();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When this is true {@link #getToCraft()} will be the missing items
|
||||||
|
*
|
||||||
|
* @return true when items are missing
|
||||||
|
*/
|
||||||
|
boolean hasMissing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param buf byte buf to write to
|
||||||
|
*/
|
||||||
|
void writeToByteBuf(ByteBuf buf);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package refinedstorage.api.autocrafting.task;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||||
|
import refinedstorage.api.autocrafting.preview.ICraftingPreviewStack;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ public interface ICraftingTask {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates this task. Gets called every few ticks, depending on the speed of the pattern container.
|
* Updates this task. Gets called every few ticks, depending on the speed of the pattern container.
|
||||||
|
* {@link ICraftingTask#calculate()} must be run before this
|
||||||
*
|
*
|
||||||
* @return true if this crafting task is finished and can be deleted from the list, false otherwise
|
* @return true if this crafting task is finished and can be deleted from the list, false otherwise
|
||||||
*/
|
*/
|
||||||
@@ -46,6 +48,8 @@ public interface ICraftingTask {
|
|||||||
NBTTagCompound writeToNBT(NBTTagCompound tag);
|
NBTTagCompound writeToNBT(NBTTagCompound tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* {@link ICraftingTask#calculate()} must be run before this
|
||||||
|
*
|
||||||
* @return the elements of this task for display in the crafting monitor
|
* @return the elements of this task for display in the crafting monitor
|
||||||
*/
|
*/
|
||||||
List<ICraftingMonitorElement> getCraftingMonitorElements();
|
List<ICraftingMonitorElement> getCraftingMonitorElements();
|
||||||
@@ -56,7 +60,25 @@ public interface ICraftingTask {
|
|||||||
ICraftingPattern getPattern();
|
ICraftingPattern getPattern();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* {@link ICraftingTask#calculate()} must be run before this
|
||||||
|
*
|
||||||
* @return the processable items in this task
|
* @return the processable items in this task
|
||||||
*/
|
*/
|
||||||
List<IProcessable> getToProcess();
|
List<IProcessable> getToProcess();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to check if the crafting task has recursive elements
|
||||||
|
* (eg. block needs 9 ingots, ingots are crafted by a block)
|
||||||
|
* {@link ICraftingTask#calculate()} must be run before this
|
||||||
|
*
|
||||||
|
* @return true if no recursion was found
|
||||||
|
*/
|
||||||
|
boolean isValid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link ICraftingTask#calculate()} must be run before this
|
||||||
|
*
|
||||||
|
* @return get a list of {@link ICraftingPreviewStack}s
|
||||||
|
*/
|
||||||
|
List<ICraftingPreviewStack> getPreviewStacks();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import refinedstorage.item.ItemPattern;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CraftingPattern implements ICraftingPattern {
|
public class CraftingPattern implements ICraftingPattern {
|
||||||
private World world;
|
private World world;
|
||||||
@@ -38,15 +39,9 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
ItemStack slot = ItemPattern.getSlot(stack, i);
|
ItemStack slot = ItemPattern.getSlot(stack, i);
|
||||||
|
inputs.add(slot);
|
||||||
if (slot != null) {
|
|
||||||
for (int j = 0; j < slot.stackSize; ++j) {
|
|
||||||
inputs.add(ItemHandlerHelper.copyStackWithSize(slot, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
inv.setInventorySlotContents(i, slot);
|
inv.setInventorySlotContents(i, slot);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!ItemPattern.isProcessing(stack)) {
|
if (!ItemPattern.isProcessing(stack)) {
|
||||||
ItemStack output = CraftingManager.getInstance().findMatchingRecipe(inv, world);
|
ItemStack output = CraftingManager.getInstance().findMatchingRecipe(inv, world);
|
||||||
@@ -77,7 +72,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return !inputs.isEmpty() && !outputs.isEmpty();
|
return inputs.stream().filter(Objects::nonNull).count() > 0 && !outputs.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package refinedstorage.apiimpl.autocrafting.preview;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
import refinedstorage.api.autocrafting.preview.ICraftingPreviewStack;
|
||||||
|
|
||||||
|
public class CraftingPreviewStack implements ICraftingPreviewStack {
|
||||||
|
private ItemStack stack;
|
||||||
|
private int available;
|
||||||
|
private boolean missing;
|
||||||
|
private int toCraft;
|
||||||
|
// if missing is true then toCraft is the missing amount
|
||||||
|
|
||||||
|
public CraftingPreviewStack(ItemStack stack) {
|
||||||
|
this.stack = ItemHandlerHelper.copyStackWithSize(stack, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingPreviewStack(ItemStack stack, int available, boolean missing, int toCraft) {
|
||||||
|
this.stack = stack;
|
||||||
|
this.available = available;
|
||||||
|
this.missing = missing;
|
||||||
|
this.toCraft = toCraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToByteBuf(ByteBuf buf) {
|
||||||
|
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||||
|
buf.writeInt(stack.getMetadata());
|
||||||
|
buf.writeInt(available);
|
||||||
|
buf.writeBoolean(missing);
|
||||||
|
buf.writeInt(toCraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CraftingPreviewStack fromByteBuf(ByteBuf buf) {
|
||||||
|
Item item = Item.getItemById(buf.readInt());
|
||||||
|
int meta = buf.readInt();
|
||||||
|
int available = buf.readInt();
|
||||||
|
boolean missing = buf.readBoolean();
|
||||||
|
int toCraft = buf.readInt();
|
||||||
|
|
||||||
|
return new CraftingPreviewStack(new ItemStack(item, 1, meta), available, missing, toCraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAvailable(int amount) {
|
||||||
|
this.available += amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailable() {
|
||||||
|
return available;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToCraft(int amount) {
|
||||||
|
this.toCraft += amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getToCraft() {
|
||||||
|
return this.toCraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMissing(boolean missing) {
|
||||||
|
this.missing = missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMissing() {
|
||||||
|
return missing;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
|||||||
import refinedstorage.RSUtils;
|
import refinedstorage.RSUtils;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
import refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||||
|
import refinedstorage.api.autocrafting.preview.ICraftingPreviewStack;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.autocrafting.task.IProcessable;
|
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
@@ -18,11 +19,9 @@ import refinedstorage.apiimpl.API;
|
|||||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementFluidRender;
|
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementFluidRender;
|
||||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementItemRender;
|
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementItemRender;
|
||||||
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementText;
|
import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementText;
|
||||||
|
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewStack;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CraftingTask implements ICraftingTask {
|
public class CraftingTask implements ICraftingTask {
|
||||||
@@ -32,10 +31,11 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
private int quantity;
|
private int quantity;
|
||||||
private List<IProcessable> toProcess = new ArrayList<>();
|
private List<IProcessable> toProcess = new ArrayList<>();
|
||||||
private IItemStackList toTake = API.instance().createItemStackList();
|
private IItemStackList toTake = API.instance().createItemStackList();
|
||||||
private IFluidStackList toTakeFluids = API.instance().createFluidStackList();
|
|
||||||
private IItemStackList toCraft = API.instance().createItemStackList();
|
private IItemStackList toCraft = API.instance().createItemStackList();
|
||||||
|
private IFluidStackList toTakeFluids = API.instance().createFluidStackList();
|
||||||
private IItemStackList missing = API.instance().createItemStackList();
|
private IItemStackList missing = API.instance().createItemStackList();
|
||||||
private IItemStackList extras = API.instance().createItemStackList();
|
private Set<ICraftingPattern> usedPatterns = new HashSet<>();
|
||||||
|
private boolean recurseFound = false;
|
||||||
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
||||||
private int compare = IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT;
|
private int compare = IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT;
|
||||||
private List<ItemStack> took = new ArrayList<>();
|
private List<ItemStack> took = new ArrayList<>();
|
||||||
@@ -52,65 +52,105 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void calculate() {
|
public void calculate() {
|
||||||
IItemStackList list = network.getItemStorageCache().getList().copy();
|
IItemStackList networkList = network.getItemStorageCache().getList().copy();
|
||||||
|
IItemStackList toInsert = API.instance().createItemStackList();
|
||||||
|
|
||||||
int newQuantity = quantity;
|
toCraft.add(ItemHandlerHelper.copyStackWithSize(requested, quantity));
|
||||||
|
int quantity = this.quantity;
|
||||||
while (newQuantity > 0) {
|
while (quantity > 0 && !recurseFound) {
|
||||||
calculate(list, pattern, true);
|
calculate(networkList, pattern, toInsert);
|
||||||
|
quantity -= pattern.getQuantityPerRequest(requested);
|
||||||
for (ItemStack output : pattern.getOutputs()) {
|
|
||||||
toInsert.add(output.copy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newQuantity -= requested == null ? newQuantity : pattern.getQuantityPerRequest(requested);
|
if (!recurseFound) {
|
||||||
|
this.toInsert.addAll(toInsert.getStacks());
|
||||||
|
}
|
||||||
|
usedPatterns.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack extra : extras.getStacks()) {
|
private void calculate(IItemStackList networkList, ICraftingPattern pattern, IItemStackList toInsert) {
|
||||||
toInsert.add(extra);
|
recurseFound = !usedPatterns.add(pattern);
|
||||||
}
|
if (recurseFound) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculate(IItemStackList list, ICraftingPattern pattern, boolean basePattern) {
|
|
||||||
ItemStack[] took = new ItemStack[9];
|
ItemStack[] took = new ItemStack[9];
|
||||||
|
|
||||||
if (pattern.isProcessing()) {
|
if (pattern.isProcessing()) {
|
||||||
toProcess.add(new Processable(pattern));
|
toProcess.add(new Processable(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!basePattern) {
|
IItemStackList inputs = API.instance().createItemStackList();
|
||||||
pattern.getOutputs().stream()
|
IItemStackList actualInputs = API.instance().createItemStackList();
|
||||||
.filter(o -> o.stackSize > 1)
|
for (ItemStack input : pattern.getInputs()) {
|
||||||
.forEach(o -> extras.add(ItemHandlerHelper.copyStackWithSize(o, o.stackSize - 1)));
|
if (input != null) {
|
||||||
|
inputs.add(input.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getInputs().size(); ++i) {
|
for (ItemStack input : inputs.getStacks()) {
|
||||||
ItemStack input = pattern.getInputs().get(i);
|
ItemStack extraStack = toInsert.get(input, compare);
|
||||||
|
ItemStack networkStack = networkList.get(input, compare);
|
||||||
|
|
||||||
ItemStack inputInNetwork = list.get(input, compare);
|
while (input.stackSize > 0) {
|
||||||
|
if (extraStack != null && extraStack.stackSize > 0) {
|
||||||
if (inputInNetwork == null || inputInNetwork.stackSize == 0) {
|
int takeQuantity = Math.min(extraStack.stackSize, input.stackSize);
|
||||||
ItemStack extra = extras.get(input, compare);
|
ItemStack inputStack = ItemHandlerHelper.copyStackWithSize(extraStack, takeQuantity);
|
||||||
|
actualInputs.add(inputStack.copy());
|
||||||
if (extra != null) {
|
input.stackSize -= takeQuantity;
|
||||||
ItemStack extraToRemove = ItemHandlerHelper.copyStackWithSize(extra, 1);
|
toInsert.remove(inputStack, true);
|
||||||
|
} else if (networkStack != null && networkStack.stackSize > 0) {
|
||||||
if (!pattern.isProcessing()) {
|
int takeQuantity = Math.min(networkStack.stackSize, input.stackSize);
|
||||||
took[i] = extraToRemove;
|
ItemStack inputStack = ItemHandlerHelper.copyStackWithSize(networkStack, takeQuantity);
|
||||||
}
|
toTake.add(inputStack.copy());
|
||||||
|
actualInputs.add(inputStack.copy());
|
||||||
extras.remove(extraToRemove, true);
|
input.stackSize -= takeQuantity;
|
||||||
|
networkList.remove(inputStack, true);
|
||||||
} else {
|
} else {
|
||||||
ICraftingPattern inputPattern = network.getPattern(input, compare);
|
ICraftingPattern inputPattern = network.getPattern(input, compare);
|
||||||
|
|
||||||
if (inputPattern != null) {
|
if (inputPattern != null) {
|
||||||
for (ItemStack output : inputPattern.getOutputs()) {
|
int craftQuantity = Math.min(inputPattern.getQuantityPerRequest(input), input.stackSize);
|
||||||
toCraft.add(output);
|
ItemStack inputCrafted = ItemHandlerHelper.copyStackWithSize(input, craftQuantity);
|
||||||
|
toCraft.add(inputCrafted.copy());
|
||||||
|
actualInputs.add(inputCrafted.copy());
|
||||||
|
calculate(networkList, inputPattern, toInsert);
|
||||||
|
input.stackSize -= craftQuantity;
|
||||||
|
// Calculate added all the crafted outputs toInsert
|
||||||
|
// So we remove the ones we use from toInsert
|
||||||
|
toInsert.remove(inputCrafted, true);
|
||||||
|
} else if (!doFluidCalculation(networkList, input, toInsert)) {
|
||||||
|
missing.add(input.copy());
|
||||||
|
input.stackSize = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calculate(list, inputPattern, false);
|
if (missing.isEmpty()) {
|
||||||
} else {
|
for (int i = 0; i < pattern.getInputs().size(); i++) {
|
||||||
|
ItemStack input = pattern.getInputs().get(i);
|
||||||
|
if (input != null) {
|
||||||
|
ItemStack actualInput = actualInputs.get(input, compare);
|
||||||
|
ItemStack taken = ItemHandlerHelper.copyStackWithSize(actualInput, input.stackSize);
|
||||||
|
took[i] = taken;
|
||||||
|
actualInputs.remove(taken, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack byproduct : (pattern.isOredict() ? pattern.getByproducts(took) : pattern.getByproducts())) {
|
||||||
|
toInsert.add(byproduct.copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack output : pattern.getOutputs()) {
|
||||||
|
toInsert.add(output.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usedPatterns.remove(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean doFluidCalculation(IItemStackList networkList, ItemStack input, IItemStackList toInsert) {
|
||||||
FluidStack fluidInItem = RSUtils.getFluidFromStack(input, true);
|
FluidStack fluidInItem = RSUtils.getFluidFromStack(input, true);
|
||||||
|
|
||||||
if (fluidInItem != null && RSUtils.hasFluidBucket(fluidInItem)) {
|
if (fluidInItem != null && RSUtils.hasFluidBucket(fluidInItem)) {
|
||||||
@@ -119,14 +159,15 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
if (fluidInStorage == null || fluidInStorage.amount < fluidInItem.amount) {
|
if (fluidInStorage == null || fluidInStorage.amount < fluidInItem.amount) {
|
||||||
missing.add(input);
|
missing.add(input);
|
||||||
} else {
|
} else {
|
||||||
boolean hasBucket = network.getItemStorageCache().getList().get(RSUtils.EMPTY_BUCKET) != null;
|
boolean hasBucket = networkList.get(RSUtils.EMPTY_BUCKET) != null;
|
||||||
ICraftingPattern bucketPattern = network.getPattern(RSUtils.EMPTY_BUCKET);
|
ICraftingPattern bucketPattern = network.getPattern(RSUtils.EMPTY_BUCKET);
|
||||||
|
|
||||||
if (!hasBucket) {
|
if (!hasBucket) {
|
||||||
if (bucketPattern == null) {
|
if (bucketPattern == null) {
|
||||||
missing.add(RSUtils.EMPTY_BUCKET.copy());
|
missing.add(RSUtils.EMPTY_BUCKET.copy());
|
||||||
} else {
|
} else {
|
||||||
calculate(list, bucketPattern, false);
|
toCraft.add(RSUtils.EMPTY_BUCKET.copy());
|
||||||
|
calculate(networkList, bucketPattern, toInsert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,27 +175,9 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
toTakeFluids.add(fluidInItem.copy());
|
toTakeFluids.add(fluidInItem.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return true;
|
||||||
missing.add(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!pattern.isProcessing()) {
|
|
||||||
ItemStack take = ItemHandlerHelper.copyStackWithSize(inputInNetwork, 1);
|
|
||||||
|
|
||||||
toTake.add(take);
|
|
||||||
|
|
||||||
took[i] = take;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.remove(inputInNetwork, 1, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ItemStack byproduct : (pattern.isOredict() ? pattern.getByproducts(took) : pattern.getByproducts())) {
|
|
||||||
extras.add(byproduct.copy());
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -173,14 +196,13 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
return "\nCraftingTask{quantity=" + quantity +
|
return "\nCraftingTask{quantity=" + quantity +
|
||||||
"\n, toTake=" + toTake +
|
"\n, toTake=" + toTake +
|
||||||
"\n, toTakeFluids=" + toTakeFluids +
|
"\n, toTakeFluids=" + toTakeFluids +
|
||||||
"\n, toCraft=" + toCraft +
|
|
||||||
"\n, toProcess=" + toProcess +
|
"\n, toProcess=" + toProcess +
|
||||||
"\n, extras=" + extras +
|
"\n, toCraft=" + toProcess +
|
||||||
"\n, toInsert=" + toInsert +
|
"\n, toInsert=" + toInsert +
|
||||||
"\n, missing=" + missing +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean update() {
|
public boolean update() {
|
||||||
for (IProcessable processable : toProcess) {
|
for (IProcessable processable : toProcess) {
|
||||||
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
|
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
|
||||||
@@ -226,7 +248,7 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
if (isFinished()) {
|
if (isFinished()) {
|
||||||
ItemStack insert = toInsert.peek();
|
ItemStack insert = toInsert.peek();
|
||||||
|
|
||||||
if (network.insertItem(insert, insert.stackSize, true) == null) {
|
if (insert != null && network.insertItem(insert, insert.stackSize, true) == null) {
|
||||||
network.insertItem(insert, insert.stackSize, false);
|
network.insertItem(insert, insert.stackSize, false);
|
||||||
|
|
||||||
toInsert.pop();
|
toInsert.pop();
|
||||||
@@ -330,6 +352,53 @@ public class CraftingTask implements ICraftingTask {
|
|||||||
return toProcess;
|
return toProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return !recurseFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ICraftingPreviewStack> getPreviewStacks() {
|
||||||
|
if (!isValid()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, CraftingPreviewStack> map = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (ItemStack stack : toCraft.getStacks()) {
|
||||||
|
int hash = API.instance().getItemStackHashCode(stack);
|
||||||
|
CraftingPreviewStack previewStack = map.get(hash);
|
||||||
|
if (previewStack == null) {
|
||||||
|
previewStack = new CraftingPreviewStack(stack);
|
||||||
|
}
|
||||||
|
previewStack.addToCraft(stack.stackSize);
|
||||||
|
map.put(hash, previewStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack stack : toTake.getStacks()) {
|
||||||
|
int hash = API.instance().getItemStackHashCode(stack);
|
||||||
|
CraftingPreviewStack previewStack = map.get(hash);
|
||||||
|
if (previewStack == null) {
|
||||||
|
previewStack = new CraftingPreviewStack(stack);
|
||||||
|
}
|
||||||
|
previewStack.addAvailable(stack.stackSize);
|
||||||
|
map.put(hash, previewStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack stack : missing.getStacks()) {
|
||||||
|
int hash = API.instance().getItemStackHashCode(stack);
|
||||||
|
CraftingPreviewStack previewStack = map.get(hash);
|
||||||
|
if (previewStack == null) {
|
||||||
|
previewStack = new CraftingPreviewStack(stack);
|
||||||
|
}
|
||||||
|
previewStack.setMissing(true);
|
||||||
|
previewStack.addToCraft(stack.stackSize);
|
||||||
|
map.put(hash, previewStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>(map.values());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isFinished() {
|
private boolean isFinished() {
|
||||||
return toTake.isEmpty() && toTakeFluids.isEmpty() && missing.isEmpty() && hasProcessedItems();
|
return toTake.isEmpty() && toTakeFluids.isEmpty() && missing.isEmpty() && hasProcessedItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ 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.RS;
|
import refinedstorage.RS;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.apiimpl.API;
|
import refinedstorage.apiimpl.API;
|
||||||
import refinedstorage.apiimpl.autocrafting.task.CraftingTask;
|
import refinedstorage.apiimpl.autocrafting.task.CraftingTask;
|
||||||
|
import refinedstorage.network.MessageGridCraftingPreviewResponse;
|
||||||
|
|
||||||
public class ItemGridHandler implements IItemGridHandler {
|
public class ItemGridHandler implements IItemGridHandler {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
@@ -122,45 +124,25 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
CraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
||||||
|
|
||||||
task.calculate();
|
task.calculate();
|
||||||
|
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
|
||||||
System.out.println(task.toString());
|
|
||||||
|
|
||||||
network.addCraftingTask(task);
|
|
||||||
|
|
||||||
/*CraftingPreviewData previewData = new CraftingPreviewData(network);
|
|
||||||
|
|
||||||
previewData.calculate(stack, quantity);
|
|
||||||
|
|
||||||
RefinedStorage.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(previewData.values(), hash, quantity), player);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftingRequested(int hash, int quantity) {
|
public void onCraftingRequested(int hash, int quantity) {
|
||||||
/*if (quantity <= 0) {
|
if (quantity <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = network.getItemStorage().get(hash);
|
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
||||||
|
|
||||||
if (stack == null) {
|
if (stack != null) {
|
||||||
return;
|
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
||||||
|
task.calculate();
|
||||||
|
network.addCraftingTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingPattern pattern = NetworkUtils.getPattern(network, stack);
|
|
||||||
|
|
||||||
if (pattern != null) {
|
|
||||||
int quantityPerRequest = pattern.getQuantityPerRequest(stack);
|
|
||||||
|
|
||||||
while (quantity > 0) {
|
|
||||||
network.addCraftingTask(NetworkUtils.createCraftingTask(network, 0, pattern));
|
|
||||||
|
|
||||||
quantity -= quantityPerRequest;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
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.RS;
|
import refinedstorage.RS;
|
||||||
|
import refinedstorage.api.autocrafting.preview.ICraftingPreviewStack;
|
||||||
import refinedstorage.network.MessageGridCraftingStart;
|
import refinedstorage.network.MessageGridCraftingStart;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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<ICraftingPreviewStack> stacks;
|
||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
|
|
||||||
private int hash;
|
private int hash;
|
||||||
@@ -23,7 +30,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, List<ICraftingPreviewStack> stacks, int hash, int quantity) {
|
||||||
super(new Container() {
|
super(new Container() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
@@ -31,7 +38,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;
|
||||||
@@ -44,7 +51,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
|
||||||
@@ -59,7 +66,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 {
|
||||||
@@ -70,9 +77,9 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
if (slot < stacks.size()) {
|
if (slot < stacks.size()) {
|
||||||
CraftingPreviewStack stack = stacks.get(slot);
|
ICraftingPreviewStack stack = stacks.get(slot);
|
||||||
|
|
||||||
if (stack.cantCraft()) {
|
if (stack.hasMissing()) {
|
||||||
drawTexture(x, y, 189, 0, 67, 29);
|
drawTexture(x, y, 189, 0, 67, 29);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +93,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -97,7 +104,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);
|
||||||
|
|
||||||
@@ -115,7 +122,7 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
if (slot < stacks.size()) {
|
if (slot < stacks.size()) {
|
||||||
CraftingPreviewStack stack = stacks.get(slot);
|
ICraftingPreviewStack stack = stacks.get(slot);
|
||||||
|
|
||||||
drawItem(x, y + 5, stack.getStack());
|
drawItem(x, y + 5, stack.getStack());
|
||||||
|
|
||||||
@@ -124,15 +131,15 @@ public class GuiCraftingPreview extends GuiBase {
|
|||||||
|
|
||||||
int yy = y + 8;
|
int yy = y + 8;
|
||||||
|
|
||||||
if (stack.needsCrafting()) {
|
if (stack.getToCraft() > 0) {
|
||||||
String format = stack.cantCraft() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
String format = stack.hasMissing() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
||||||
drawString(calculateOffsetOnScale(x + 23, scale), calculateOffsetOnScale(yy, scale), t(format, stack.getToCraft()));
|
drawString(calculateOffsetOnScale(x + 23, scale), calculateOffsetOnScale(yy, scale), t(format, stack.getToCraft()));
|
||||||
|
|
||||||
yy += 7;
|
yy += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getStock() > 0) {
|
if (stack.getAvailable() > 0) {
|
||||||
drawString(calculateOffsetOnScale(x + 23, scale), calculateOffsetOnScale(yy, scale), t("gui.refinedstorage:crafting_preview.available", stack.getStock()));
|
drawString(calculateOffsetOnScale(x + 23, scale), calculateOffsetOnScale(yy, scale), t("gui.refinedstorage:crafting_preview.available", stack.getAvailable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
@@ -155,7 +162,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
|
||||||
@@ -187,8 +194,7 @@ 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,25 +1,25 @@
|
|||||||
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;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.api.autocrafting.preview.ICraftingPreviewStack;
|
||||||
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewStack;
|
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewStack;
|
||||||
import refinedstorage.proxy.ClientProxy;
|
import refinedstorage.proxy.ClientProxy;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHandler<MessageGridCraftingPreviewResponse, IMessage> {
|
public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHandler<MessageGridCraftingPreviewResponse, IMessage> {
|
||||||
public Collection<CraftingPreviewStack> stacks;
|
public List<ICraftingPreviewStack> stacks;
|
||||||
public int hash;
|
public int hash;
|
||||||
public int quantity;
|
public int quantity;
|
||||||
|
|
||||||
public MessageGridCraftingPreviewResponse() {
|
public MessageGridCraftingPreviewResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageGridCraftingPreviewResponse(Collection<CraftingPreviewStack> stacks, int hash, int quantity) {
|
public MessageGridCraftingPreviewResponse(List<ICraftingPreviewStack> stacks, int hash, int quantity) {
|
||||||
this.stacks = stacks;
|
this.stacks = stacks;
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
@@ -46,7 +46,7 @@ public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHan
|
|||||||
|
|
||||||
buf.writeInt(stacks.size());
|
buf.writeInt(stacks.size());
|
||||||
|
|
||||||
for (CraftingPreviewStack stack : stacks) {
|
for (ICraftingPreviewStack stack : stacks) {
|
||||||
stack.writeToByteBuf(buf);
|
stack.writeToByteBuf(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,4 +58,3 @@ public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHan
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -4,6 +4,8 @@ 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;
|
||||||
@@ -20,6 +22,7 @@ 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;
|
||||||
@@ -28,7 +31,10 @@ import refinedstorage.RS;
|
|||||||
import refinedstorage.RSBlocks;
|
import refinedstorage.RSBlocks;
|
||||||
import refinedstorage.RSItems;
|
import refinedstorage.RSItems;
|
||||||
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;
|
||||||
@@ -297,7 +303,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;
|
||||||
|
|
||||||
@@ -307,5 +313,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));
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class CommonProxy {
|
|||||||
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
||||||
RS.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
||||||
RS.INSTANCE.network.registerMessage(MessageGridCraftingPreview.class, MessageGridCraftingPreview.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageGridCraftingPreview.class, MessageGridCraftingPreview.class, id++, Side.SERVER);
|
||||||
//RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingPreviewResponse.class, MessageGridCraftingPreviewResponse.class, id++, Side.CLIENT);
|
RS.INSTANCE.network.registerMessage(MessageGridCraftingPreviewResponse.class, MessageGridCraftingPreviewResponse.class, id++, Side.CLIENT);
|
||||||
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderTransfer.class, MessageProcessingPatternEncoderTransfer.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderTransfer.class, MessageProcessingPatternEncoderTransfer.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
||||||
|
|||||||
@@ -273,8 +273,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
craftingTasksToCancel.clear();
|
craftingTasksToCancel.clear();
|
||||||
|
|
||||||
for (ICraftingTask task : craftingTasksToAdd) {
|
for (ICraftingTask task : craftingTasksToAdd) {
|
||||||
|
if (task.isValid()) {
|
||||||
craftingTasks.add(task);
|
craftingTasks.add(task);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
craftingTasksToAdd.clear();
|
craftingTasksToAdd.clear();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user