You can now re-insert Processing Patterns in the Pattern Grid and have the inputs and outputs be completed. Fixes #1569
Fixed bug where pattern was recipe pattern was creatable when there was no recipe output.
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
- Removed MCMultiPart integration (raoulvdberge)
|
||||
- Removed Project E integration (raoulvdberge)
|
||||
- Removed Storage Drawers integration (you can still attach an External Storage to drawers, though) (raoulvdberge)
|
||||
- Removed blocking mode in autocrafting (raoulvdberge)
|
||||
- You can no longer put a Filter in filter slots to gain additional filter slots (raoulvdberge)
|
||||
- You can now re-insert Processing Patterns in the Pattern Grid and have the inputs and outputs be completed (raoulvdberge)
|
||||
- Fixed bug where pattern was recipe pattern was creatable when there was no recipe output (raoulvdberge)
|
||||
- If an Interface is configured to expose the entire network storage (by configuring no export slots), it will no longer expose the entire RS storage, due to performance issues (raoulvdberge)
|
||||
- The Portable Grid no longer exposes a inventory for crossmod interaction, due to performance issues (raoulvdberge)
|
||||
- Removed the Wrench (raoulvdberge)
|
||||
|
@@ -34,20 +34,23 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
this.oredict = ItemPattern.isOredict(stack);
|
||||
|
||||
if (processing) {
|
||||
this.valid = false; // TODO
|
||||
this.valid = true;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack input = ItemPattern.getSlot(stack, i);
|
||||
ItemStack input = ItemPattern.getInputSlot(stack, i);
|
||||
|
||||
inputs.add(input == null ? NonNullList.create() : NonNullList.from(ItemStack.EMPTY, input));
|
||||
}
|
||||
|
||||
this.outputs = ItemPattern.getOutputs(stack);
|
||||
ItemStack output = ItemPattern.getOutputSlot(stack, i);
|
||||
if (output != null) {
|
||||
outputs.add(output);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InventoryCrafting inv = new InventoryCraftingDummy();
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack input = ItemPattern.getSlot(stack, i);
|
||||
ItemStack input = ItemPattern.getInputSlot(stack, i);
|
||||
|
||||
inputs.add(input == null ? NonNullList.create() : NonNullList.from(ItemStack.EMPTY, input));
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheListenerGridItem;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockGrid;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -85,10 +86,25 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
if (slot == 1 && !processingPattern && !getStackInSlot(slot).isEmpty()) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(ItemPattern.getSlot(getStackInSlot(slot), i)));
|
||||
ItemStack pattern = getStackInSlot(slot);
|
||||
if (slot == 1 && !pattern.isEmpty()) {
|
||||
boolean isPatternProcessing = ItemPattern.isProcessing(pattern);
|
||||
|
||||
if (isPatternProcessing && processingPattern) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
matrixProcessing.setStackInSlot(i, StackUtils.nullToEmpty(ItemPattern.getInputSlot(pattern, i)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
matrixProcessing.setStackInSlot(9 + i, StackUtils.nullToEmpty(ItemPattern.getOutputSlot(pattern, i)));
|
||||
}
|
||||
} else if (!isPatternProcessing && !processingPattern) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(ItemPattern.getInputSlot(pattern, i)));
|
||||
}
|
||||
}
|
||||
|
||||
sendSlotUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +395,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void onPatternMatrixClear() {
|
||||
public void clearMatrix() {
|
||||
for (int i = 0; i < matrixProcessing.getSlots(); ++i) {
|
||||
matrixProcessing.setStackInSlot(i, ItemStack.EMPTY);
|
||||
}
|
||||
@@ -389,6 +405,23 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSlotUpdate(boolean initSlots) {
|
||||
if (!world.isRemote) {
|
||||
world.getMinecraftServer()
|
||||
.getPlayerList()
|
||||
.getPlayers()
|
||||
.stream()
|
||||
.filter(player -> player.openContainer instanceof ContainerGrid && ((ContainerGrid) player.openContainer).getTile() != null && ((ContainerGrid) player.openContainer).getTile().getPos().equals(pos))
|
||||
.forEach(player -> {
|
||||
if (initSlots) {
|
||||
((ContainerGrid) player.openContainer).initSlots();
|
||||
}
|
||||
|
||||
((ContainerGrid) player.openContainer).sendAllSlots();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(EntityPlayer player) {
|
||||
// NO OP
|
||||
@@ -490,14 +523,15 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
ItemStack pattern = new ItemStack(RSItems.PATTERN);
|
||||
|
||||
ItemPattern.setOredict(pattern, oredictPattern);
|
||||
ItemPattern.setProcessing(pattern, processingPattern);
|
||||
|
||||
if (processingPattern) {
|
||||
for (int i = 0; i < 18; ++i) {
|
||||
if (!matrixProcessing.getStackInSlot(i).isEmpty()) {
|
||||
if (i >= 9) {
|
||||
ItemPattern.addOutput(pattern, matrixProcessing.getStackInSlot(i));
|
||||
ItemPattern.setOutputSlot(pattern, i - 9, matrixProcessing.getStackInSlot(i));
|
||||
} else {
|
||||
ItemPattern.setSlot(pattern, i, matrixProcessing.getStackInSlot(i));
|
||||
ItemPattern.setInputSlot(pattern, i, matrixProcessing.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,7 +540,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
ItemStack ingredient = matrix.getStackInSlot(i);
|
||||
|
||||
if (!ingredient.isEmpty()) {
|
||||
ItemPattern.setSlot(pattern, i, ingredient);
|
||||
ItemPattern.setInputSlot(pattern, i, ingredient);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +576,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
|
||||
return inputsFilled > 0 && outputsFilled > 0;
|
||||
} else {
|
||||
return isPatternAvailable();
|
||||
return !result.getStackInSlot(0).isEmpty() && isPatternAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -616,8 +616,9 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
if (button == oredictPattern) {
|
||||
TileDataManager.setParameter(TileGrid.OREDICT_PATTERN, oredictPattern.isChecked());
|
||||
} else if (button == processingPattern) {
|
||||
// Rebuild the inventory slots before the slot change packet arrives
|
||||
// Rebuild the inventory slots before the slot change packet arrives.
|
||||
TileGrid.PROCESSING_PATTERN.setValue(false, processingPattern.isChecked());
|
||||
((NetworkNodeGrid) grid).clearMatrix(); // The server does this but let's do it earlier so the client doesn't notice.
|
||||
((ContainerGrid) this.inventorySlots).initSlots();
|
||||
|
||||
TileDataManager.setParameter(TileGrid.PROCESSING_PATTERN, processingPattern.isChecked());
|
||||
|
@@ -12,14 +12,11 @@ import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -31,9 +28,10 @@ import java.util.stream.Collectors;
|
||||
public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
||||
private static Map<ItemStack, CraftingPattern> PATTERN_CACHE = new HashMap<>();
|
||||
|
||||
private static final String NBT_SLOT = "Slot_%d";
|
||||
private static final String NBT_OUTPUTS = "Outputs";
|
||||
private static final String NBT_INPUT_SLOT = "Input_%d";
|
||||
private static final String NBT_OUTPUT_SLOT = "Output_%d";
|
||||
private static final String NBT_OREDICT = "Oredict";
|
||||
private static final String NBT_PROCESSING = "Processing";
|
||||
|
||||
public ItemPattern() {
|
||||
super("pattern");
|
||||
@@ -76,61 +74,64 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSlot(ItemStack pattern, int slot, ItemStack stack) {
|
||||
public static void setInputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
||||
if (!pattern.hasTagCompound()) {
|
||||
pattern.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
pattern.getTagCompound().setTag(String.format(NBT_SLOT, slot), stack.serializeNBT());
|
||||
pattern.getTagCompound().setTag(String.format(NBT_INPUT_SLOT, slot), stack.serializeNBT());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemStack getSlot(ItemStack pattern, int slot) {
|
||||
String id = String.format(NBT_SLOT, slot);
|
||||
public static ItemStack getInputSlot(ItemStack pattern, int slot) {
|
||||
String id = String.format(NBT_INPUT_SLOT, slot);
|
||||
|
||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ItemStack(pattern.getTagCompound().getCompoundTag(id));
|
||||
ItemStack stack = new ItemStack(pattern.getTagCompound().getCompoundTag(id));
|
||||
if (stack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
// @todo: Store slot number for outputs as well, so it can be filled in the pattern grid when the pattern is re-inserted. For 1.13
|
||||
public static void addOutput(ItemStack pattern, ItemStack output) {
|
||||
public static void setOutputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
||||
if (!pattern.hasTagCompound()) {
|
||||
pattern.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList outputs;
|
||||
if (!pattern.getTagCompound().hasKey(NBT_OUTPUTS)) {
|
||||
outputs = new NBTTagList();
|
||||
} else {
|
||||
outputs = pattern.getTagCompound().getTagList(NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
outputs.appendTag(output.serializeNBT());
|
||||
|
||||
pattern.getTagCompound().setTag(NBT_OUTPUTS, outputs);
|
||||
pattern.getTagCompound().setTag(String.format(NBT_OUTPUT_SLOT, slot), stack.serializeNBT());
|
||||
}
|
||||
|
||||
public static NonNullList<ItemStack> getOutputs(ItemStack pattern) {
|
||||
NonNullList<ItemStack> outputs = NonNullList.create();
|
||||
@Nullable
|
||||
public static ItemStack getOutputSlot(ItemStack pattern, int slot) {
|
||||
String id = String.format(NBT_OUTPUT_SLOT, slot);
|
||||
|
||||
NBTTagList outputsTag = pattern.getTagCompound().getTagList(NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < outputsTag.tagCount(); ++i) {
|
||||
ItemStack stack = new ItemStack(outputsTag.getCompoundTagAt(i));
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
outputs.add(stack);
|
||||
}
|
||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return outputs;
|
||||
ItemStack stack = new ItemStack(pattern.getTagCompound().getCompoundTag(id));
|
||||
if (stack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static boolean isProcessing(ItemStack pattern) {
|
||||
return pattern.hasTagCompound() && pattern.getTagCompound().hasKey(NBT_OUTPUTS);
|
||||
return pattern.hasTagCompound() && pattern.getTagCompound().hasKey(NBT_PROCESSING) && pattern.getTagCompound().getBoolean(NBT_PROCESSING);
|
||||
}
|
||||
|
||||
public static void setProcessing(ItemStack pattern, boolean processing) {
|
||||
if (!pattern.hasTagCompound()) {
|
||||
pattern.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
pattern.getTagCompound().setBoolean(NBT_PROCESSING, processing);
|
||||
}
|
||||
|
||||
public static boolean isOredict(ItemStack pattern) {
|
||||
|
@@ -45,8 +45,10 @@ public class MessageGridClear extends MessageHandlerPlayerToServer<MessageGridCl
|
||||
}
|
||||
}
|
||||
} else if (grid.getType() == GridType.PATTERN) {
|
||||
((NetworkNodeGrid) grid).onPatternMatrixClear();
|
||||
((NetworkNodeGrid) grid).clearMatrix();
|
||||
}
|
||||
|
||||
((NetworkNodeGrid) grid).sendSlotUpdate(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.raoulvdberge.refinedstorage.tile.grid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
@@ -69,16 +68,9 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateOredictPattern(p)));
|
||||
public static final TileDataParameter<Boolean, TileGrid> PROCESSING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isProcessingPattern(), (t, v) -> {
|
||||
t.getNode().setProcessingPattern(v);
|
||||
t.getNode().clearMatrix();
|
||||
t.getNode().markDirty();
|
||||
|
||||
t.getNode().onPatternMatrixClear();
|
||||
|
||||
t.world.getMinecraftServer().getPlayerList().getPlayers().stream()
|
||||
.filter(player -> player.openContainer instanceof ContainerGrid && ((ContainerGrid) player.openContainer).getTile() != null && ((ContainerGrid) player.openContainer).getTile().getPos().equals(t.getPos()))
|
||||
.forEach(player -> {
|
||||
((ContainerGrid) player.openContainer).initSlots();
|
||||
((ContainerGrid) player.openContainer).sendAllSlots();
|
||||
});
|
||||
t.getNode().sendSlotUpdate(true);
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||
|
||||
public static void trySortGrid(boolean initial) {
|
||||
|
@@ -18,7 +18,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -320,7 +319,7 @@ public final class RenderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
data = (displayAmount ? (TextFormatting.WHITE + String.valueOf(amount) + " ") : "") + TextFormatting.GRAY + data;
|
||||
data = (displayAmount ? (String.valueOf(amount) + "x ") : "") + data;
|
||||
|
||||
tooltip.add(data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user