Fixed crafting tasks not saving properly, fixes #171
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Fixed External Storage not updating correctly
|
- Fixed External Storage not updating correctly
|
||||||
- Fixed wireless signal starting from Controller instead of per Wireless Transmitter individually
|
- Fixed wireless signal starting from Controller instead of per Wireless Transmitter individually
|
||||||
- Fixed Controller's redstone state not saving
|
- Fixed Controller's redstone state not saving
|
||||||
|
- Fixed crafting tasks not saving properly
|
||||||
- Huge performance improvements to large storage networks
|
- Huge performance improvements to large storage networks
|
||||||
|
|
||||||
**Features**
|
**Features**
|
||||||
|
@@ -2,6 +2,7 @@ package refinedstorage.api.autocrafting;
|
|||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +15,11 @@ public interface ICraftingPattern {
|
|||||||
*/
|
*/
|
||||||
ICraftingPatternContainer getContainer(World world);
|
ICraftingPatternContainer getContainer(World world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The position of the container where the pattern is in
|
||||||
|
*/
|
||||||
|
BlockPos getContainerPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If this pattern is a processing pattern
|
* @return If this pattern is a processing pattern
|
||||||
*/
|
*/
|
||||||
|
@@ -17,19 +17,15 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
private static final String NBT_CRAFTER_Y = "CrafterY";
|
private static final String NBT_CRAFTER_Y = "CrafterY";
|
||||||
private static final String NBT_CRAFTER_Z = "CrafterZ";
|
private static final String NBT_CRAFTER_Z = "CrafterZ";
|
||||||
|
|
||||||
private int crafterX;
|
private BlockPos crafterPos;
|
||||||
private int crafterY;
|
|
||||||
private int crafterZ;
|
|
||||||
private TileCrafter crafter;
|
private TileCrafter crafter;
|
||||||
private boolean processing;
|
private boolean processing;
|
||||||
private ItemStack[] inputs;
|
private ItemStack[] inputs;
|
||||||
private ItemStack[] outputs;
|
private ItemStack[] outputs;
|
||||||
private ItemStack[] byproducts;
|
private ItemStack[] byproducts;
|
||||||
|
|
||||||
public CraftingPattern(int crafterX, int crafterY, int crafterZ, boolean processing, ItemStack[] inputs, ItemStack[] outputs, ItemStack[] byproducts) {
|
public CraftingPattern(BlockPos crafterPos, boolean processing, ItemStack[] inputs, ItemStack[] outputs, ItemStack[] byproducts) {
|
||||||
this.crafterX = crafterX;
|
this.crafterPos = crafterPos;
|
||||||
this.crafterY = crafterY;
|
|
||||||
this.crafterZ = crafterZ;
|
|
||||||
this.processing = processing;
|
this.processing = processing;
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
@@ -39,12 +35,17 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
@Override
|
@Override
|
||||||
public ICraftingPatternContainer getContainer(World world) {
|
public ICraftingPatternContainer getContainer(World world) {
|
||||||
if (crafter == null) {
|
if (crafter == null) {
|
||||||
crafter = (TileCrafter) world.getTileEntity(new BlockPos(crafterX, crafterY, crafterZ));
|
crafter = (TileCrafter) world.getTileEntity(crafterPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
return crafter;
|
return crafter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos getContainerPosition() {
|
||||||
|
return crafterPos;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isProcessing() {
|
public boolean isProcessing() {
|
||||||
return processing;
|
return processing;
|
||||||
@@ -88,17 +89,15 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
tag.setTag(ItemPattern.NBT_BYPRODUCTS, byproductsTag);
|
tag.setTag(ItemPattern.NBT_BYPRODUCTS, byproductsTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setInteger(NBT_CRAFTER_X, crafter.getPos().getX());
|
tag.setInteger(NBT_CRAFTER_X, crafterPos.getX());
|
||||||
tag.setInteger(NBT_CRAFTER_Y, crafter.getPos().getY());
|
tag.setInteger(NBT_CRAFTER_Y, crafterPos.getY());
|
||||||
tag.setInteger(NBT_CRAFTER_Z, crafter.getPos().getZ());
|
tag.setInteger(NBT_CRAFTER_Z, crafterPos.getZ());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CraftingPattern readFromNBT(NBTTagCompound tag) {
|
public static CraftingPattern readFromNBT(NBTTagCompound tag) {
|
||||||
int cx = tag.getInteger(NBT_CRAFTER_X);
|
BlockPos crafterPos = new BlockPos(tag.getInteger(NBT_CRAFTER_X), tag.getInteger(NBT_CRAFTER_Y), tag.getInteger(NBT_CRAFTER_Z));
|
||||||
int cy = tag.getInteger(NBT_CRAFTER_Y);
|
|
||||||
int cz = tag.getInteger(NBT_CRAFTER_Z);
|
|
||||||
|
|
||||||
boolean processing = tag.getBoolean(ItemPattern.NBT_PROCESSING);
|
boolean processing = tag.getBoolean(ItemPattern.NBT_PROCESSING);
|
||||||
|
|
||||||
@@ -139,6 +138,6 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CraftingPattern(cx, cy, cz, processing, inputs, outputs, byproducts);
|
return new CraftingPattern(crafterPos, processing, inputs, outputs, byproducts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ public class TileCrafter extends TileNode implements ICraftingPatternContainer {
|
|||||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
for (ICraftingTask task : network.getCraftingTasks()) {
|
||||||
if (task.getPattern().getContainer(worldObj) == this) {
|
if (task.getPattern().getContainerPosition().equals(pos)) {
|
||||||
network.cancelCraftingTask(task);
|
network.cancelCraftingTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ import refinedstorage.RefinedStorage;
|
|||||||
import refinedstorage.RefinedStorageBlocks;
|
import refinedstorage.RefinedStorageBlocks;
|
||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
import refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||||
import refinedstorage.api.network.IGridHandler;
|
import refinedstorage.api.network.IGridHandler;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
@@ -172,7 +173,9 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
ICraftingTask top = craftingTasks.peek();
|
ICraftingTask top = craftingTasks.peek();
|
||||||
|
|
||||||
if (ticks % top.getPattern().getContainer(worldObj).getSpeed() == 0 && top.update(worldObj, this)) {
|
ICraftingPatternContainer container = top.getPattern().getContainer(worldObj);
|
||||||
|
|
||||||
|
if (container != null && (ticks % container.getSpeed()) == 0 && top.update(worldObj, this)) {
|
||||||
top.onDone(this);
|
top.onDone(this);
|
||||||
|
|
||||||
craftingTasks.pop();
|
craftingTasks.pop();
|
||||||
@@ -365,9 +368,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
if (pattern != null && ItemPattern.isValid(pattern)) {
|
if (pattern != null && ItemPattern.isValid(pattern)) {
|
||||||
patterns.add(new CraftingPattern(
|
patterns.add(new CraftingPattern(
|
||||||
crafter.getPos().getX(),
|
crafter.getPos(),
|
||||||
crafter.getPos().getY(),
|
|
||||||
crafter.getPos().getZ(),
|
|
||||||
ItemPattern.isProcessing(pattern),
|
ItemPattern.isProcessing(pattern),
|
||||||
ItemPattern.getInputs(pattern),
|
ItemPattern.getInputs(pattern),
|
||||||
ItemPattern.getOutputs(pattern),
|
ItemPattern.getOutputs(pattern),
|
||||||
|
Reference in New Issue
Block a user