Skip to content

Commit

Permalink
Merge branch 'GlodBlock:1.7.10' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master authored Jun 22, 2022
2 parents db9c1f9 + 0845c25 commit 594fbd7
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 56 deletions.
1 change: 0 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,16 @@ protected void handleMouseClick( final Slot slot, final int slotIdx, final int c

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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -252,7 +253,7 @@ public void drawFG( final int offsetX, final int offsetY, final int mouseX, fina

if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}

downY += 5;
Expand All @@ -277,7 +278,7 @@ public void drawFG( final int offsetX, final int offsetY, final int mouseX, fina

if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}

red = true;
Expand Down Expand Up @@ -310,7 +311,7 @@ public void drawFG( final int offsetX, final int offsetY, final int mouseX, fina
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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ protected void standardDetectAndSendChanges()
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ public void doAction(EntityPlayerMP player, InventoryAction action, int slotId,
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) {
Expand Down Expand Up @@ -177,11 +185,6 @@ public void doAction(EntityPlayerMP player, InventoryAction action, int slotId,
}
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ public void doAction(EntityPlayerMP player, InventoryAction action, int slotId,
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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;
Expand All @@ -16,7 +15,9 @@
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;
Expand All @@ -32,8 +33,6 @@
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;
Expand All @@ -49,13 +48,13 @@ public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monit
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 ) );
}
}

Expand Down Expand Up @@ -323,13 +322,6 @@ public boolean useRealItems()
return false;
}

public void toggleSubstitute()
{
this.substitute = !this.substitute;

this.detectAndSendChanges();
}

public PartFluidPatternTerminalEx getPatternTerminal()
{
return this.patternTerminal;
Expand All @@ -340,11 +332,6 @@ private boolean isSubstitute()
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public ItemFluidPacket() {
@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);
}
Expand All @@ -42,6 +46,8 @@ public String getItemStackDisplayName(ItemStack stack) {
@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);
Expand All @@ -51,6 +57,13 @@ public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, b
}
}

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;
Expand All @@ -76,6 +89,22 @@ public static ItemStack newStack(@Nullable FluidStack fluid) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ public IInventory getInventoryByName(String name) {
}

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
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);
Expand Down Expand Up @@ -99,4 +100,63 @@ public void readFromNBTEvent(NBTTagCompound data) {
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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -27,6 +24,10 @@ public byte[] transform(String name, String transformedName, byte[] code) {
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;
}
Expand Down
Loading

0 comments on commit 594fbd7

Please sign in to comment.