Merge pull request #23 from GTNewHorizons/fix

fix wrong bytes display when ingrentent isn't enough and a possible d…
This commit is contained in:
Martin Robertz authored and GitHub committed 2022-10-07 21:38:14 +02:00
commit d8140da431
7 files changed
+55 -32

No files matched your search

+8 -8
View File
@@ -2,25 +2,25 @@
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-108-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-109-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:ExtraCells2:2.5.20:dev') {transitive = false}
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.8.5:dev")
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.7:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.27:dev')
compileOnly('com.github.GTNewHorizons:EnderCore:0.2.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.29:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.29:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.49:dev') {transitive = false}
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
@@ -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()));
@@ -77,6 +77,13 @@ public class CoreModHooks {
? (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) {
for (int i = 0; i < stacks.length; i++) {
if (stacks[i].getItem() instanceof ItemFluidPacket) {
@@ -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;