mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
fix wrong bytes display when ingrentent isn't enough and a possible dupe from fluid packet decoder
This commit is contained in:
1 parent
b6b9f71677
commit
ab4acbe5eb
7 files changed
+56
-33
No files matched your search
-1
@@ -112,7 +112,6 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
|
||||
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
|
||||
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
|
||||
pattern.setCombine(this.combine ? 1:0);
|
||||
pattern.setPriority(this.prioritize? 1:0);
|
||||
pattern.setInputs(collectInventory(craftingSlots));
|
||||
pattern.setOutputs(collectInventory(outputSlots));
|
||||
patternSlotOUT.putStack(pattern.writeToStack());
|
||||
|
||||
@@ -32,19 +32,22 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_ENCODED_PATTERN, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo )
|
||||
{
|
||||
NBTTagCompound data = stack.getTagCompound();
|
||||
final boolean combine = data.getBoolean("combine");
|
||||
final boolean prio = data.getBoolean("prioritize");
|
||||
super.addCheckedInformation(stack,player,lines,displayMoreInfo);
|
||||
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
|
||||
// lines.add(String.format("%s: %s",combine ? StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
|
||||
// lines.add(String.format("%s: %s",prio ? StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
@@ -64,12 +64,13 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
|
||||
inventory.setInventorySlotContents(0, null);
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
IAEFluidStack aeFluid = AEFluidStack.create(fluid);
|
||||
IAEFluidStack aeFluid = AEFluidStack.create(fluid.copy());
|
||||
IEnergyGrid energyGrid = node.getGrid().getCache(IEnergyGrid.class);
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = node.getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
IAEFluidStack remaining = Platform.poweredInsert(energyGrid, fluidGrid, aeFluid, ownActionSource);
|
||||
if (remaining != null) {
|
||||
if (remaining.getStackSize() == aeFluid.getStackSize()) {
|
||||
inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(remaining.getFluidStack()));
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(remaining.getFluidStack()));
|
||||
|
||||
@@ -74,7 +74,14 @@ public class CoreModHooks {
|
||||
|
||||
public static long getCraftingByteCost(IAEItemStack stack) {
|
||||
return stack.getItem() instanceof ItemFluidDrop
|
||||
? (long)Math.ceil(stack.getStackSize() / 1000D) : stack.getStackSize();
|
||||
? (long) Math.ceil(stack.getStackSize() / 1000D) : stack.getStackSize();
|
||||
}
|
||||
|
||||
public static long getFluidDropsByteCost(long totalBytes, long originByte, IAEItemStack stack) {
|
||||
if (stack != null && stack.getItem() instanceof ItemFluidDrop) {
|
||||
return (long) Math.ceil(originByte / 1000D) + totalBytes;
|
||||
}
|
||||
return originByte + totalBytes;
|
||||
}
|
||||
|
||||
public static IAEItemStack[] flattenFluidPackets(IAEItemStack[] stacks) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
|
||||
private static class TransformRequest extends MethodVisitor {
|
||||
|
||||
private boolean writingBytes = false;
|
||||
private int cnt = 0;
|
||||
|
||||
TransformRequest(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
@@ -62,6 +63,7 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
|
||||
if (writingBytes && opcode == Opcodes.INVOKEINTERFACE
|
||||
&& owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getStackSize")) {
|
||||
writingBytes = false;
|
||||
cnt ++;
|
||||
super.visitMethodInsn(Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"getCraftingByteCost",
|
||||
@@ -72,6 +74,27 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInsn(int opcode) {
|
||||
if (writingBytes && cnt == 5 && opcode == Opcodes.LADD) {
|
||||
super.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
super.visitFieldInsn(Opcodes.GETFIELD,
|
||||
"appeng/crafting/CraftingTreeNode",
|
||||
"what",
|
||||
"Lappeng/api/storage/data/IAEItemStack;"
|
||||
);
|
||||
super.visitMethodInsn(Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"getFluidDropsByteCost",
|
||||
"(JJLappeng/api/storage/data/IAEItemStack;)J",
|
||||
false);
|
||||
writingBytes = false;
|
||||
cnt ++;
|
||||
return;
|
||||
}
|
||||
super.visitInsn(opcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,8 +13,6 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<FluidPatternDetails>{
|
||||
@@ -43,8 +42,14 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
public void setCombine(int combine){ this.combine = combine;}
|
||||
public int getCombine(){return combine;}
|
||||
|
||||
public void setCombine(int combine) {
|
||||
this.combine = combine;
|
||||
}
|
||||
|
||||
public int getCombine() {
|
||||
return combine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftable() {
|
||||
@@ -99,20 +104,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
}
|
||||
|
||||
private static IAEItemStack[] condenseStacks(IAEItemStack[] stacks) {
|
||||
// AE item stacks are equivalent iff they are of the same item type (not accounting for stack size)
|
||||
// thus, it's not the semantically-correct definition of "equal" but it's useful for matching item types
|
||||
Map<IAEItemStack, IAEItemStack> accMap = new HashMap<>();
|
||||
for (IAEItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
IAEItemStack acc = accMap.get(stack);
|
||||
if (acc == null) {
|
||||
accMap.put(stack, stack.copy());
|
||||
} else {
|
||||
acc.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
return accMap.values().toArray(new IAEItemStack[0]);
|
||||
return PatternHelper.convertToCondensedList(stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,8 +149,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
//Shits
|
||||
tag.setTag("in", writeStackArray(checkInitialized(inputs)));
|
||||
tag.setTag("out", writeStackArray(checkInitialized(outputs)));
|
||||
tag.setInteger("prioritize",this.getPriority());
|
||||
tag.setInteger("combine",this.getCombine());
|
||||
tag.setInteger("combine", this.getCombine());
|
||||
patternStack.setTagCompound(tag);
|
||||
patternStackAe = Objects.requireNonNull(AEItemStack.create(patternStack));
|
||||
return patternStack;
|
||||
@@ -170,7 +161,6 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
// see note at top of class
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
if (stack != null) stack.writeToNBT(stackTag);
|
||||
|
||||
listTag.appendTag(stackTag);
|
||||
}
|
||||
return listTag;
|
||||
|
||||
Reference in new issue
Block a user