Merge branch 'GlodBlock:1.7.10' into master

This commit is contained in:
Martin Robertz authored and GitHub committed 2022-06-22 10:05:22 +02:00
commit 594fbd7f69
15 files changed
+200 -56

No files matched your search

-1
View File
@@ -1,7 +1,6 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
@@ -6,11 +6,9 @@ import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.slot.AppEngSlot;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -24,9 +22,6 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0";
public FCBasePartContainerEx container;
private GuiImgButton substitutionsEnabledBtn;
@@ -376,7 +376,16 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if( slot instanceof SlotFake)
{
final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
}
else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
@@ -13,6 +13,7 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.coremod.hooker.CoreModHooks;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
@@ -252,7 +253,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}
downY += 5;
@@ -277,7 +278,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}
red = true;
@@ -310,7 +311,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = refStack.copy().getItemStack();
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
if( this.tooltip == z - viewStart )
{
@@ -131,10 +131,7 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
public void setFluid(int id, IAEFluidStack fluidStack) {
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
if (inv != null && this.isValidForConfig(id, AEFluidStack.create(fluidStack))) {
ItemStack tmp = ItemFluidPacket.newStack(fluidStack.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluidStack.getFluidStack().getLocalizedName());
}
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluidStack.getFluidStack());
inv.setInventorySlotContents(id, tmp);
}
}
@@ -148,6 +148,14 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
@@ -177,11 +185,6 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack == null && slot.getStack() != null && slot.getStack().getItem() instanceof ItemFluidPacket) {
return;
}
}
super.doAction(player, action, slotId, id);
}
@@ -141,6 +141,14 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
@@ -6,7 +6,6 @@ import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
import appeng.helpers.IContainerCraftingPacket;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
@@ -16,7 +15,9 @@ import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -32,8 +33,6 @@ import java.util.stream.Collectors;
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private final PartFluidPatternTerminalEx patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final IInventory crafting;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[16];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[4];
protected final SlotRestrictedInput patternSlotIN;
@@ -49,13 +48,13 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" );
IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting");
for( int y = 0; y < 4; y++ )
{
for( int x = 0; x < 4; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix( this.crafting, x + y * 4, 15 + x * 18, -83 + y * 18 ) );
this.addSlotToContainer( this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix(crafting, x + y * 4, 15 + x * 18, -83 + y * 18 ) );
}
}
@@ -323,13 +322,6 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return false;
}
public void toggleSubstitute()
{
this.substitute = !this.substitute;
this.detectAndSendChanges();
}
public PartFluidPatternTerminalEx getPatternTerminal()
{
return this.patternTerminal;
@@ -340,11 +332,6 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return this.substitute;
}
public void setSubstitute( final boolean substitute )
{
this.substitute = substitute;
}
static boolean canDoubleStacks(SlotFake[] slots)
{
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
@@ -34,6 +34,10 @@ public class ItemFluidPacket extends Item {
@Override
public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) {
return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack);
}
return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
: super.getItemStackDisplayName(stack);
}
@@ -42,6 +46,8 @@ public class ItemFluidPacket extends Item {
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) return;
if (fluid != null) {
for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) {
tooltip.add(EnumChatFormatting.GRAY + line);
@@ -51,6 +57,13 @@ public class ItemFluidPacket extends Item {
}
}
public static boolean isDisplay(ItemStack stack) {
if (stack == null || !stack.hasTagCompound() || stack.getTagCompound() == null) {
return false;
}
return stack.getTagCompound().getBoolean("DisplayOnly");
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null || !stack.hasTagCompound()) {
return null;
@@ -76,6 +89,22 @@ public class ItemFluidPacket extends Item {
return stack;
}
public static ItemStack newDisplayStack(@Nullable FluidStack fluid) {
if (fluid == null) {
return null;
}
FluidStack copy = fluid.copy();
copy.amount = 1000;
ItemStack stack = new ItemStack(ItemAndBlockHolder.PACKET);
NBTTagCompound tag = new NBTTagCompound();
NBTTagCompound fluidTag = new NBTTagCompound();
copy.writeToNBT(fluidTag);
tag.setTag("FluidStack", fluidTag);
tag.setBoolean("DisplayOnly", true);
stack.setTagCompound(tag);
return stack;
}
@Nullable
public static IAEItemStack newAeStack(@Nullable FluidStack fluid) {
return AEItemStack.create(newStack(fluid));
@@ -163,10 +163,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
}
public void setFluidInSlot(int id, IAEFluidStack fluid) {
ItemStack tmp = ItemFluidPacket.newStack(fluid == null ? null : fluid.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluid.getFluidStack().getLocalizedName());
}
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
this.config.setInventorySlotContents(id, tmp);
}
@@ -22,12 +22,13 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory {
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory, IInventory {
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
private final BaseActionSource ownActionSource = new MachineSource(this);
@@ -99,4 +100,63 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
inventory.readFromNBT(data, "Inventory");
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
return inventory.decrStackSize(slot, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return inventory.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory.setInventorySlotContents(slot, stack);
}
@Override
public String getInventoryName() {
return inventory.getInventoryName();
}
@Override
public boolean hasCustomInventoryName() {
return inventory.hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit() {
return inventory.getInventoryStackLimit();
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return inventory.isUseableByPlayer(player);
}
@Override
public void openInventory() {
inventory.openInventory();
}
@Override
public void closeInventory() {
inventory.openInventory();
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return inventory.isItemValidForSlot(slot, stack);
}
}
@@ -1,9 +1,6 @@
package com.glodblock.github.coremod;
import com.glodblock.github.coremod.transform.ContainerInterfaceTerminalTransformer;
import com.glodblock.github.coremod.transform.CraftingCpuTransformer;
import com.glodblock.github.coremod.transform.CraftingTreeNodeTransformer;
import com.glodblock.github.coremod.transform.DualityInterfaceTransformer;
import com.glodblock.github.coremod.transform.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@@ -27,6 +24,10 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.container.implementations.ContainerInterfaceTerminal":
tform = ContainerInterfaceTerminalTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiCraftingCPU":
case "appeng.client.gui.implementations.GuiCraftConfirm":
tform = GuiCraftingTransformer.INSTANCE;
break;
default:
return code;
}
@@ -21,8 +21,10 @@ import com.glodblock.github.util.SetBackedMachineSet;
import com.glodblock.github.util.Util;
import com.google.common.collect.Sets;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
import java.util.HashSet;
@@ -88,4 +90,12 @@ public class CoreModHooks {
}
}
public static ItemStack displayFluid(IAEItemStack aeStack) {
if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) {
FluidStack fluid = ItemFluidDrop.getFluidStack(aeStack.getItemStack());
return ItemFluidPacket.newDisplayStack(fluid);
}
else return aeStack.getItemStack();
}
}
@@ -0,0 +1,58 @@
package com.glodblock.github.coremod.transform;
import com.glodblock.github.coremod.FCClassTransformer;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
public static final GuiCraftingTransformer INSTANCE = new GuiCraftingTransformer();
private GuiCraftingTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new TransformGuiCrafting(Opcodes.ASM5, downstream);
}
private static class TransformGuiCrafting extends ClassVisitor {
TransformGuiCrafting(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if ("drawFG".equals(name)) {
return new TransformFluidIcon(api, super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformFluidIcon extends MethodVisitor {
TransformFluidIcon(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getItemStack")) {
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"displayFluid",
"(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;",
false);
}
else {
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
}
}
@@ -63,11 +63,6 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
}
public boolean setInputs(IAEItemStack[] inputs) {
for (IAEItemStack stack : inputs) { // see note at top of class
if (stack == null) {
return false;
}
}
IAEItemStack[] condensed = condenseStacks(inputs);
if (condensed.length == 0) {
return false;
@@ -88,11 +83,6 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
}
public boolean setOutputs(IAEItemStack[] outputs) {
for (IAEItemStack stack : outputs) { // see note at top of class
if (stack == null) {
return false;
}
}
IAEItemStack[] condensed = condenseStacks(outputs);
if (condensed.length == 0) {
return false;