Fixed issue where alternatives in the Pattern Grid weren't being saved properly. Fixes #2732
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
- Fixed Refined Storage sidebuttons displaying over the JEI bookmark pagination buttons (raoulvdberge)
|
||||
- Fixed issue where Crafters may fail to recognize an inventory/tank for some patterns (Darkere)
|
||||
- Fixed issue where the Crafter Manager can crash on invalid patterns (raoulvdberge)
|
||||
- Fixed issue where alternatives in the Pattern Grid weren't being saved properly (raoulvdberge)
|
||||
|
||||
### 1.9.8
|
||||
|
||||
|
@@ -94,6 +94,18 @@ public class AllowedTagList {
|
||||
notifyListener();
|
||||
}
|
||||
|
||||
public void setAllowedItemTags(int slot, Set<ResourceLocation> allowedItemTags) {
|
||||
this.allowedItemTags.set(slot, allowedItemTags);
|
||||
|
||||
notifyListener();
|
||||
}
|
||||
|
||||
public void setAllowedFluidTags(int slot, Set<ResourceLocation> allowedFluidTags) {
|
||||
this.allowedFluidTags.set(slot, allowedFluidTags);
|
||||
|
||||
notifyListener();
|
||||
}
|
||||
|
||||
public void clearItemTags(int slot) {
|
||||
this.allowedItemTags.get(slot).clear();
|
||||
|
||||
|
@@ -1,17 +1,20 @@
|
||||
package com.refinedmods.refinedstorage.network;
|
||||
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.container.GridContainer;
|
||||
import com.refinedmods.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.refinedmods.refinedstorage.container.slot.legacy.LegacyFilterSlot;
|
||||
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SetFilterSlotMessage {
|
||||
@@ -54,22 +57,24 @@ public class SetFilterSlotMessage {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof FilterSlot || slot instanceof LegacyFilterSlot) {
|
||||
// Avoid resetting allowed tag list in the pattern grid.
|
||||
if (API.instance().getComparer().isEqualNoQuantity(slot.getStack(), message.stack)) {
|
||||
slot.getStack().setCount(message.stack.getCount());
|
||||
Runnable postAction = () -> {
|
||||
};
|
||||
|
||||
if (slot instanceof FilterSlot) {
|
||||
IItemHandler itemHandler = ((FilterSlot) slot).getItemHandler();
|
||||
// Prevent the grid crafting matrix inventory listener from resetting the list.
|
||||
if (container instanceof GridContainer) {
|
||||
IGrid grid = ((GridContainer) container).getGrid();
|
||||
if (grid instanceof GridNetworkNode) {
|
||||
Set<ResourceLocation> list = new HashSet<>(((GridNetworkNode) grid).getAllowedTagList().getAllowedItemTags().get(slot.getSlotIndex()));
|
||||
|
||||
if (itemHandler instanceof BaseItemHandler) {
|
||||
((BaseItemHandler) itemHandler).onChanged(slot.getSlotIndex());
|
||||
postAction = () -> {
|
||||
((GridNetworkNode) grid).getAllowedTagList().setAllowedItemTags(slot.getSlotIndex(), list);
|
||||
((GridNetworkNode) grid).markDirty();
|
||||
};
|
||||
}
|
||||
} else {
|
||||
slot.inventory.markDirty();
|
||||
}
|
||||
} else {
|
||||
|
||||
slot.putStack(message.stack);
|
||||
}
|
||||
postAction.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,19 @@
|
||||
package com.refinedmods.refinedstorage.network;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.util.IComparer;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.IGrid;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.refinedmods.refinedstorage.container.GridContainer;
|
||||
import com.refinedmods.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SetFluidFilterSlotMessage {
|
||||
@@ -52,15 +56,26 @@ public class SetFluidFilterSlotMessage {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof FluidFilterSlot) {
|
||||
FluidFilterSlot fluidFilterSlot = (FluidFilterSlot) slot;
|
||||
Runnable postAction = () -> {
|
||||
};
|
||||
|
||||
// Avoid resetting allowed tag list in the pattern grid.
|
||||
if (API.instance().getComparer().isEqual(fluidFilterSlot.getFluidInventory().getFluid(slot.getSlotIndex()), message.stack, IComparer.COMPARE_NBT)) {
|
||||
fluidFilterSlot.getFluidInventory().getFluid(slot.getSlotIndex()).setAmount(message.stack.getAmount());
|
||||
fluidFilterSlot.getFluidInventory().onChanged(slot.getSlotIndex());
|
||||
} else {
|
||||
fluidFilterSlot.getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
}
|
||||
// Prevent the grid crafting matrix inventory listener from resetting the list.
|
||||
if (container instanceof GridContainer) {
|
||||
IGrid grid = ((GridContainer) container).getGrid();
|
||||
if (grid instanceof GridNetworkNode) {
|
||||
Set<ResourceLocation> list = new HashSet<>(((GridNetworkNode) grid).getAllowedTagList().getAllowedFluidTags().get(slot.getSlotIndex()));
|
||||
|
||||
postAction = () -> {
|
||||
((GridNetworkNode) grid).getAllowedTagList().setAllowedFluidTags(slot.getSlotIndex(), list);
|
||||
((GridNetworkNode) grid).markDirty();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
FluidFilterSlot fluidSlot = (FluidFilterSlot) slot;
|
||||
|
||||
fluidSlot.getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
postAction.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user