Compare commits

...
7 Commits
Author SHA1 Message Date
Martin Robertz 594fbd7f69 Merge branch 'GlodBlock:1.7.10' into master 2022-06-22 10:05:22 +02:00
GlodBlock 0845c25190 remove unnecessary null fail 2022-06-21 21:12:30 +08:00
GlodBlock bb600eed3f imp inventory for decoder 2022-06-18 17:18:24 +08:00
GlodBlock e1213b2d5a small clean up 2022-06-13 10:36:41 +08:00
GlodBlock 12565b1389 fluid display 2022-06-13 10:24:38 +08:00
GlodBlock 213b43d213 allow code fluid container 2022-06-12 23:30:30 +08:00
Martin Robertz db9c1f9529 fix version tag 2022-06-05 18:56:02 +02:00
16 changed files with 274 additions and 76 deletions

No files matched your search

+74 -20
View File
@@ -1,4 +1,4 @@
//version: 1644894948
//version: 1650343995
/*
DO NOT CHANGE THIS FILE!
@@ -6,12 +6,11 @@ Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput.Style
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import java.util.concurrent.TimeUnit
@@ -104,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
@@ -180,6 +180,11 @@ catch (Exception ignored) {
}
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception ignored) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
@@ -187,11 +192,15 @@ catch (Exception ignored) {
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
String versionTag = gitVersion().split("-")[gitVersion().split("-").length - 1]
version = minecraftVersion + '-' + versionTag
version = minecraftVersion + '-' + identifiedVersion
ext {
modVersion = versionTag
modVersion = identifiedVersion
}
if(identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
@@ -205,13 +214,17 @@ else {
def arguments = []
def jvmArguments = []
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
jvmArguments += [
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
if (usesMixinDebug.toBoolean()) {
jvmArguments += [
"-Dmixin.debug.countInjections=true",
"-Dmixin.debug.verbose=true",
"-Dmixin.debug.export=true"
]
}
}
minecraft {
@@ -303,18 +316,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
if (usesMixins.toBoolean()) {
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
if (!mixinConfigFile.exists()) {
mixinConfigFile.text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
"""
}
}
}
@@ -453,7 +471,7 @@ def getManifestAttributes() {
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (sourceSets.main.allSource)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
@@ -508,7 +526,7 @@ task devJar(type: Jar) {
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
@@ -550,7 +568,7 @@ publishing {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
@@ -560,7 +578,7 @@ publishing {
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: versionTag
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
@@ -597,10 +615,46 @@ publishing {
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
-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;