Fixed pattern stack copying

This commit is contained in:
raoulvdberge
2017-11-28 13:44:48 +01:00
parent d8d26a071b
commit 74ae66d247
3 changed files with 4 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ public interface ICraftingPatternProvider {
* Creates a crafting pattern. * Creates a crafting pattern.
* *
* @param world the world * @param world the world
* @param stack the pattern stack * @param stack the pattern stack, the implementor needs to copy it
* @param container the {@link ICraftingPatternContainer} where the pattern is in * @param container the {@link ICraftingPatternContainer} where the pattern is in
* @return the crafting pattern * @return the crafting pattern
*/ */

View File

@@ -63,8 +63,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
ItemStack patternStack = patterns.getStackInSlot(i); ItemStack patternStack = patterns.getStackInSlot(i);
if (!patternStack.isEmpty()) { if (!patternStack.isEmpty()) {
// We copy the pattern stack because if we remove it from the inventory, the crafting task will use a pattern with an invalid stack... ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(world, patternStack, this);
ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(world, patternStack.copy(), this);
if (pattern.isValid()) { if (pattern.isValid()) {
actualPatterns.add(pattern); actualPatterns.add(pattern);

View File

@@ -202,6 +202,7 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
@Override @Override
@Nonnull @Nonnull
public ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container) { public ICraftingPattern create(World world, ItemStack stack, ICraftingPatternContainer container) {
return new CraftingPattern(world, container, stack); // We copy the pattern stack because if we remove it from the inventory, the crafting task will use a pattern with an invalid stack...
return new CraftingPattern(world, container, stack.copy());
} }
} }