mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-17 02:45:29 +00:00
Fix stack size overflow in NEI overlay handlers (#36)
* Fix stack size overflow in NEI overlay handlers * update gradle+bs+deps * fix wci --------- Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
1 parent
233f2460ac
commit
13e0e65fc4
26 files changed
+348
-147
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.block.tile;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -23,7 +27,12 @@ import appeng.api.implementations.tiles.ICraftingMachine;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.*;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
|
||||
@@ -4,8 +4,11 @@ import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.github.vfyjxf.nee.nei;
|
||||
import static com.github.vfyjxf.nee.processor.RecipeProcessor.NULL_IDENTIFIER;
|
||||
import static com.github.vfyjxf.nee.utils.GuiUtils.isPatternTerm;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -163,7 +167,9 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
currentStack.stackSize = 1;
|
||||
}
|
||||
|
||||
recipeInputs.setTag("#" + inputIndex, currentStack.writeToNBT(new NBTTagCompound()));
|
||||
recipeInputs.setTag(
|
||||
"#" + inputIndex,
|
||||
ItemUtils.writeItemStackToNBT(currentStack, new NBTTagCompound()));
|
||||
NEECraftingHandler.ingredients.put(INPUT_KEY + inputIndex, positionedStack);
|
||||
inputIndex++;
|
||||
}
|
||||
@@ -181,7 +187,9 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
outputStack.stackSize = 1;
|
||||
}
|
||||
|
||||
recipeOutputs.setTag(OUTPUT_KEY + outputIndex, outputStack.writeToNBT(new NBTTagCompound()));
|
||||
recipeOutputs.setTag(
|
||||
OUTPUT_KEY + outputIndex,
|
||||
ItemUtils.writeItemStackToNBT(outputStack, new NBTTagCompound()));
|
||||
outputIndex++;
|
||||
}
|
||||
break;
|
||||
@@ -220,7 +228,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
|
||||
recipeInputs.setTag("#" + slotIndex, stack.writeToNBT(new NBTTagCompound()));
|
||||
recipeInputs.setTag("#" + slotIndex, ItemUtils.writeItemStackToNBT(stack, new NBTTagCompound()));
|
||||
NEECraftingHandler.ingredients.put(INPUT_KEY + slotIndex, positionedStack);
|
||||
}
|
||||
}
|
||||
@@ -249,7 +257,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
stack = currentStack.copy();
|
||||
}
|
||||
}
|
||||
recipeInputs.setTag("#" + slotIndex, stack.writeToNBT(new NBTTagCompound()));
|
||||
recipeInputs.setTag("#" + slotIndex, ItemUtils.writeItemStackToNBT(stack, new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
return new PacketArcaneRecipe(recipeInputs);
|
||||
@@ -282,7 +290,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
currentStack = stack.copy();
|
||||
}
|
||||
}
|
||||
recipeInputs.setTag("#" + slotIndex, currentStack.writeToNBT(new NBTTagCompound()));
|
||||
recipeInputs.setTag("#" + slotIndex, ItemUtils.writeItemStackToNBT(currentStack, new NBTTagCompound()));
|
||||
}
|
||||
return new PacketExtremeRecipe(recipeInputs);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package com.github.vfyjxf.nee.network;
|
||||
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.github.vfyjxf.nee.network.packet.*;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketArcaneRecipe;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketCraftingRequest;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketExtremeRecipe;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketNEIPatternRecipe;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketOpenCraftAmount;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketOpenGui;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketSetRecipe;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketSlotStackChange;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketStackCountChange;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketValueConfigClient;
|
||||
import com.github.vfyjxf.nee.network.packet.PacketValueConfigServer;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@@ -7,6 +7,8 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -50,7 +52,7 @@ public class PacketArcaneRecipe implements IMessage {
|
||||
NBTTagCompound currentStack;
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
recipeInput[i] = currentStack == null ? null : ItemUtils.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
Field craftingSlots = ReflectionHelper.findField(ContainerKnowledgeInscriber.class, "craftingSlots");
|
||||
|
||||
@@ -11,6 +11,8 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -58,7 +60,7 @@ public class PacketExtremeRecipe implements IMessage {
|
||||
NBTTagCompound currentStack;
|
||||
for (int i = 0; i < recipeInputs.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInputs[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
recipeInputs[i] = currentStack == null ? null : ItemUtils.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
int inputIndex = 0;
|
||||
for (int i = 81; i < 162; i++) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.github.vfyjxf.nee.utils.ItemUtils;
|
||||
import com.github.vfyjxf.nee.utils.ModIDs;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
@@ -103,7 +104,7 @@ public class PacketNEIPatternRecipe implements IMessage {
|
||||
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
recipeInput[i] = currentStack == null ? null : ItemUtils.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) container;
|
||||
@@ -150,12 +151,12 @@ public class PacketNEIPatternRecipe implements IMessage {
|
||||
|
||||
for (int i = 0; i < recipeInput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
recipeInput[i] = currentStack == null ? null : ItemUtils.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
for (int i = 0; i < recipeOutput.length; i++) {
|
||||
NBTTagCompound currentStack = (NBTTagCompound) message.output.getTag(OUTPUT_KEY + i);
|
||||
recipeOutput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
recipeOutput[i] = currentStack == null ? null : ItemUtils.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
if (inv != null && message.input != null && security != null) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
+5
-1
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.github.vfyjxf.nee.processor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.github.vfyjxf.nee.utils;
|
||||
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.*;
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.transformBlacklist;
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.transformPriorityList;
|
||||
import static com.github.vfyjxf.nee.config.NEEConfig.transformPriorityModList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -210,6 +212,19 @@ public final class ItemUtils {
|
||||
+ "}";
|
||||
}
|
||||
|
||||
public static NBTTagCompound writeItemStackToNBT(ItemStack itemStack, NBTTagCompound tag) {
|
||||
itemStack.writeToNBT(tag);
|
||||
tag.setInteger("Count", itemStack.stackSize);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static ItemStack loadItemStackFromNBT(NBTTagCompound tag) {
|
||||
ItemStack itemStack = ItemStack.loadItemStackFromNBT(tag);
|
||||
if (itemStack == null) return null;
|
||||
itemStack.stackSize = tag.getInteger("Count");
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static boolean hasRecipeProcessor(String processorId) {
|
||||
for (IRecipeProcessor processor : RecipeProcessor.recipeProcessors) {
|
||||
if (processor.getRecipeProcessorId().equals(processorId)) {
|
||||
|
||||
Reference in new issue
Block a user