Fixed a duplication bug when pressing clear on a Wireless Crafting Grid. Fixes #2024
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
- Fixed oredict autocrafting sometimes reporting that a craftable item is missing (raoulvdberge)
|
||||
- Fixed fluid autocrafting without item inputs locking when there's not enough space for the fluids (raoulvdberge)
|
||||
- Fixed Grid "last changed" date not changing when using clear button or JEI transfer (raoulvdberge)
|
||||
- Fixed a duplication bug when pressing clear on a Wireless Crafting Grid (raoulvdberge)
|
||||
- Fixed duplication bug with autocrafting and External Storages (raoulvdberge)
|
||||
- Fixed Crafting Manager displaying wrong name for chained crafters connected to some blocks (raoulvdberge)
|
||||
- Removed handling of reusable items in autocrafting, to avoid problems (raoulvdberge)
|
||||
|
@@ -437,8 +437,6 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
} else if (grid.isActive()) {
|
||||
if (clickedClear && grid instanceof IGridNetworkAware) {
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridClear());
|
||||
|
||||
MessageGridClear.clear((IGridNetworkAware) grid, null); // Clear clientside
|
||||
}
|
||||
|
||||
ItemStack held = ((ContainerGrid) this.inventorySlots).getPlayer().inventory.getItemStack();
|
||||
|
@@ -8,15 +8,12 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MessageGridClear extends MessageHandlerPlayerToServer<MessageGridClear> implements IMessage {
|
||||
public MessageGridClear() {
|
||||
}
|
||||
@@ -36,27 +33,23 @@ public class MessageGridClear extends MessageHandlerPlayerToServer<MessageGridCl
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container instanceof ContainerGrid && ((ContainerGrid) container).getGrid() instanceof IGridNetworkAware) {
|
||||
clear((IGridNetworkAware) ((ContainerGrid) container).getGrid(), player);
|
||||
}
|
||||
}
|
||||
IGridNetworkAware grid = (IGridNetworkAware) ((ContainerGrid) container).getGrid();
|
||||
|
||||
public static void clear(IGridNetworkAware grid, @Nullable EntityPlayer player) {
|
||||
InventoryCrafting matrix = grid.getCraftingMatrix();
|
||||
if (grid.getGridType() == GridType.CRAFTING && grid.getNetwork() != null && grid.getNetwork().getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||
InventoryCrafting matrix = grid.getCraftingMatrix();
|
||||
|
||||
if (grid.getGridType() == GridType.CRAFTING && grid.getNetwork() != null && (player == null || grid.getNetwork().getSecurityManager().hasPermission(Permission.INSERT, player))) {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(grid.getNetwork().insertItem(slot, slot.getCount(), Action.PERFORM)));
|
||||
if (!slot.isEmpty()) {
|
||||
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(grid.getNetwork().insertItem(slot, slot.getCount(), Action.PERFORM)));
|
||||
|
||||
if (player != null) {
|
||||
grid.getNetwork().getItemStorageTracker().changed(player, slot.copy());
|
||||
}
|
||||
}
|
||||
} else if (grid.getGridType() == GridType.PATTERN) {
|
||||
((NetworkNodeGrid) grid).clearMatrix();
|
||||
}
|
||||
} else if (grid.getGridType() == GridType.PATTERN) {
|
||||
((NetworkNodeGrid) grid).clearMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user