Skip to content

Commit

Permalink
fix jei item transfer size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock committed Jul 29, 2023
1 parent 999dd09 commit 167c0c6
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
deobfCompile 'curse.maven:modular-machinery-270790:2761302' // 1.11.1
deobfCompile 'curse.maven:codechicken-lib-1-8-242818:2779848' //ccl
deobfCompile 'curse.maven:gregtech-ce-unofficial-557242:3784798' // gt
deobfCompile 'curse.maven:ae2-extended-life-570458:4429430' //pae2
deobfCompile 'curse.maven:ae2-extended-life-570458:4646658' //pae2
deobfCompile 'curse.maven:dynamistics-383632:3056455' // dy
compileOnly 'curse.maven:opencomputers-223008:4630537' //oc
runtime 'curse.maven:opencomputers-223008:4630537' //oc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ else if (!slot.getStack().isEmpty()) {
}

@Override
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean combine) {
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean combine) {
if (part instanceof PartExtendedFluidPatternTerminal) {
((PartExtendedFluidPatternTerminal) part).onChangeCrafting(inputs, outputs, combine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void doAction(EntityPlayerMP player, InventoryAction action, int slotId,
}

@Override
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean combine) {
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean combine) {
AeStackInventory<IAEItemStack> craftingSlot = tile.getCraftingSlots();
AeStackInventory<IAEItemStack> outputSlot = tile.getOutputSlots();
for (int index : inputs.keySet()) {
Expand All @@ -165,9 +165,9 @@ public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs
craftingSlot.setStack(index, AEItemStack.fromItemStack(items[0]));
}
}
int bound = Math.min(outputSlot.getSlotCount(), outputs.length);
int bound = Math.min(outputSlot.getSlotCount(), outputs.size());
for (int index = 0; index < bound; index ++) {
outputSlot.setStack(index, AEItemStack.fromItemStack(outputs[index]));
outputSlot.setStack(index, AEItemStack.fromItemStack(outputs.get(index)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static IAEItemStack[] collectInventory(Slot[] slots) {
}

@Override
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean combine) {
public void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean combine) {
if (Ae2Reflect.getPart(this) instanceof PartFluidPatternTerminal) {
((PartFluidPatternTerminal) Ae2Reflect.getPart(this)).onChangeCrafting(inputs, outputs, combine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraftforge.items.IItemHandlerModifiable;

import javax.annotation.Nonnull;
import java.util.List;

public class PartExtendedFluidPatternTerminal extends PartExpandedProcessingPatternTerminal {

Expand Down Expand Up @@ -125,7 +126,7 @@ public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemS
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
}

public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean combine) {
public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean combine) {
IItemHandler crafting = this.getInventoryByName("crafting");
IItemHandler output = this.getInventoryByName("output");
IItemList<IAEItemStack> storageList = this.getInventory(Util.ITEM) == null ?
Expand All @@ -145,9 +146,9 @@ public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outp
final ItemStack item = fuzzyFind[x];
((AppEngInternalInventory) crafting).setStackInSlot(x, item == null ? ItemStack.EMPTY : item);
}
bound = Math.min(output.getSlots(), outputs.length);
bound = Math.min(output.getSlots(), outputs.size());
for (int x = 0; x < bound; x++) {
final ItemStack item = outputs[x];
final ItemStack item = outputs.get(x);
((AppEngInternalInventory) output).setStackInSlot(x, item == null ? ItemStack.EMPTY : item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraftforge.items.IItemHandlerModifiable;

import javax.annotation.Nonnull;
import java.util.List;

public class PartFluidPatternTerminal extends PartPatternTerminal {

Expand Down Expand Up @@ -168,7 +169,7 @@ public void putPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
}
}

public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean combine) {
public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean combine) {
IItemHandler crafting = this.getInventoryByName("crafting");
IItemHandler output = this.getInventoryByName("output");
IItemList<IAEItemStack> storageList = this.getInventory(Util.ITEM) == null ?
Expand All @@ -188,9 +189,9 @@ public void onChangeCrafting(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outp
final ItemStack item = fuzzyFind[x];
((AppEngInternalInventory) crafting).setStackInSlot(x, item == null ? ItemStack.EMPTY : item);
}
bound = Math.min(output.getSlots(), outputs.length);
bound = Math.min(output.getSlots(), outputs.size());
for (int x = 0; x < bound; x++) {
final ItemStack item = outputs[x];
final ItemStack item = outputs.get(x);
((AppEngInternalInventory) output).setStackInSlot(x, item == null ? ItemStack.EMPTY : item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public IRecipeTransferError transferRecipe(@Nonnull ContainerExtendedFluidPatter
}

if (doTransfer && container.part instanceof PartExtendedFluidPatternTerminal) {
PartExtendedFluidPatternTerminal tile = (PartExtendedFluidPatternTerminal)container.part;
RecipeTransferBuilder transfer = new RecipeTransferBuilder(
tile.getInventoryByName("crafting").getSlots(),
tile.getInventoryByName("output").getSlots(),
recipeLayout)
.clearEmptySlot(true)
.putFluidFirst(container.fluidFirst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public IRecipeTransferError transferRecipe(@Nonnull ContainerFluidPatternEncoder
return new RecipeTransferErrorTooltip(I18n.format(NameConst.TT_PROCESSING_RECIPE_ONLY));
}
if (doTransfer) {
TileFluidPatternEncoder tile = container.getTile();
RecipeTransferBuilder transfer = new RecipeTransferBuilder(
tile.getCraftingSlots().getSlotCount(),
tile.getOutputSlots().getSlotCount(),
recipeLayout)
.clearEmptySlot(true)
.putFluidFirst(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ else if (!container.isCraftingMode() && recipeLayout.getRecipeCategory().getUid(
}
} catch (IOException ignore) {
}
PartFluidPatternTerminal tile = (PartFluidPatternTerminal) Ae2Reflect.getPart(container);
RecipeTransferBuilder transfer = new RecipeTransferBuilder(
tile.getInventoryByName("crafting").getSlots(),
tile.getInventoryByName("output").getSlots(),
recipeLayout)
.clearEmptySlot(!craftMode)
.putFluidFirst(container.fluidFirst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class RecipeTransferBuilder {
private static final int MAX_ITEMS = 16;

private final Int2ObjectArrayMap<ItemStack[]> in;
private final int bound;
private final ItemStack[] out;
private final List<ItemStack> out;
private final IRecipeLayout recipe;
private List<ItemStack[]> itemsIn;
private List<FluidStack> fluidIn;
Expand All @@ -29,10 +28,9 @@ public class RecipeTransferBuilder {
private boolean noNull = true;
private boolean fluidFirst = false;

public RecipeTransferBuilder(int maxInput, int maxOutput, IRecipeLayout recipe) {
public RecipeTransferBuilder(IRecipeLayout recipe) {
this.in = new Int2ObjectArrayMap<>();
this.bound = maxInput;
this.out = new ItemStack[maxOutput];
this.out = new ArrayList<>();
this.recipe = recipe;
this.itemsIn = new ArrayList<>();
this.itemOut = new ArrayList<>();
Expand Down Expand Up @@ -88,7 +86,7 @@ private void split() {
}

private void setItemIn(int offset) {
int bound = Math.min(this.bound, this.itemsIn.size() + offset);
int bound = this.itemsIn.size() + offset;
for (int index = offset; index < bound; index ++) {
int i = index - offset;
if (this.itemsIn.get(i) != null && this.itemsIn.get(i).length > 0) {
Expand All @@ -98,7 +96,7 @@ private void setItemIn(int offset) {
}

private void setFluidIn(int offset) {
int bound = Math.min(this.bound, this.fluidIn.size() + offset);
int bound = this.fluidIn.size() + offset;
for (int index = offset; index < bound; index ++) {
int i = index - offset;
if (this.fluidIn.get(i) != null) {
Expand All @@ -108,11 +106,11 @@ private void setFluidIn(int offset) {
}

private void setOutputs() {
for (int index = 0; index < this.out.length; index ++) {
for (int index = 0; index < this.out.size(); index ++) {
if (index < this.itemOut.size()) {
this.out[index] = this.itemOut.get(index);
this.out.add(this.itemOut.get(index));
} else if (index - this.itemOut.size() < this.fluidOut.size()) {
this.out[index] = ItemFluidPacket.newStack(this.fluidOut.get(index - this.itemOut.size()));
this.out.add(ItemFluidPacket.newStack(this.fluidOut.get(index - this.itemOut.size())));
}
}
}
Expand Down Expand Up @@ -145,7 +143,7 @@ public RecipeTransferBuilder build() {
return this;
}

public ItemStack[] getOutput() {
public List<ItemStack> getOutput() {
return this.out;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.item.ItemStack;

import java.util.List;

public interface PatternConsumer {

void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, ItemStack[] outputs, boolean compress);
void acceptPattern(Int2ObjectMap<ItemStack[]> inputs, List<ItemStack> outputs, boolean compress);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import scala.actors.threadpool.Arrays;

import javax.annotation.Nullable;
import java.util.List;

public class CPacketLoadPattern implements IMessage {

private ItemStack[] output;
private List<ItemStack> output;
private Int2ObjectMap<ItemStack[]> crafting;
private boolean compress;
private static final int SLOT_SIZE = 16;

public CPacketLoadPattern(Int2ObjectMap<ItemStack[]> crafting, ItemStack[] output, boolean compress) {
public CPacketLoadPattern(Int2ObjectMap<ItemStack[]> crafting, List<ItemStack> output, boolean compress) {
this.crafting = crafting;
this.output = output;
this.compress = compress;
Expand All @@ -38,11 +40,12 @@ public void toBytes(ByteBuf buf) {
for (int index : crafting.keySet()) {
writeItemArray(msg, crafting.get(index), index + "#");
}
writeItemArray(msg, output, "o");
writeItemArray(msg, output.toArray(new ItemStack[0]), "o");
Util.writeNBTToBytes(buf, msg);
}

@Override
@SuppressWarnings("unchecked")
public void fromBytes(ByteBuf buf) {
crafting = new Int2ObjectArrayMap<>();
compress = buf.readBoolean();
Expand All @@ -52,7 +55,7 @@ public void fromBytes(ByteBuf buf) {
crafting.put(i, readItemArray(msg, i + "#"));
}
}
output = readItemArray(msg, "o");
output = Arrays.asList(readItemArray(msg, "o"));
}

private void writeItemArray(NBTTagCompound nbt, ItemStack[] itemList, String key) {
Expand Down

0 comments on commit 167c0c6

Please sign in to comment.