Skip to content

Commit

Permalink
fix #35
Browse files Browse the repository at this point in the history
  • Loading branch information
vfyjxf committed Nov 27, 2022
1 parent 0a40019 commit 7b7618a
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 57 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ dependencies {

deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
// compile "curse.maven:modularui-624243:3895901"
// AE2 Unofficial Extended Life
// deobfCompile "curse.maven:ae2-extended-life-570458:4094223"
deobfCompile "curse.maven:applied-energistics-2-223794:2747063"
deobfCompile "curse.maven:wireless-crafting-terminal-244559:2830252"
compile "curse.maven:ae2wtlib-304024:2830114"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false
# General Specifications
mc_version=1.12.2
jei_version=4.16.1.302
mod_version=2.0.0
mod_version=2.0.1
forge_version=14.23.5.2847
mod_group=com.github.vfyjxf.neenergistics
mod_id=neenergistics
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/github/vfyjxf/nee/NotEnoughEnergistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.vfyjxf.nee.network.NEEGuiHandler;
import com.github.vfyjxf.nee.proxy.CommonProxy;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
Expand All @@ -14,16 +14,16 @@
import org.apache.logging.log4j.Logger;


@Mod(modid = Gobals.MOD_ID,
version = Gobals.VERSION,
name = Gobals.NAME,
dependencies = Gobals.DEPENDENCIES,
guiFactory = Gobals.GUI_FACTORY,
@Mod(modid = Globals.MOD_ID,
version = Globals.VERSION,
name = Globals.NAME,
dependencies = Globals.DEPENDENCIES,
guiFactory = Globals.GUI_FACTORY,
useMetadata = true)
public class NotEnoughEnergistics {
public static final Logger logger = LogManager.getLogger("NotEnoughEnergistics");

@Mod.Instance(Gobals.MOD_ID)
@Mod.Instance(Globals.MOD_ID)
public static NotEnoughEnergistics instance;

@SidedProxy(clientSide = "com.github.vfyjxf.nee.proxy.ClientProxy", serverSide = "com.github.vfyjxf.nee.proxy.ServerProxy")
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/github/vfyjxf/nee/asm/AppengHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import appeng.client.gui.implementations.GuiMEMonitorable;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import com.github.vfyjxf.nee.utils.Globals;
import mezz.jei.gui.recipes.RecipesGui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraftforge.fml.common.Optional;
import p455w0rd.wct.client.gui.GuiWCT;

import java.util.List;
Expand All @@ -17,9 +20,11 @@ public class AppengHooks {
/**
* Before {@link appeng.core.sync.packets.PacketMEInventoryUpdate#clientPacketData(INetworkInfo, AppEngPacket, EntityPlayer)} Return
*/
public static void updateMeInventory(GuiScreen screen, final List<IAEItemStack> list) {
if (screen instanceof RecipesGui) {
GuiScreen parent = ((RecipesGui) screen).getParentScreen();
public static void updateMeInventory(Object obj, final List<IAEItemStack> list) {
if (obj instanceof Container) return;

if (obj instanceof RecipesGui) {
GuiScreen parent = ((RecipesGui) obj).getParentScreen();
if (parent instanceof GuiMEMonitorable) {
((GuiMEMonitorable) parent).postUpdate(list);
}
Expand All @@ -29,7 +34,8 @@ public static void updateMeInventory(GuiScreen screen, final List<IAEItemStack>
/**
* Before {@link appeng.client.gui.implementations.GuiMEMonitorable#postUpdate(List)} Return
*/
public static void updateWirelessInventory(GuiScreen screen, final List<IAEItemStack> list){
@Optional.Method(modid = Globals.WCT)
public static void updateWirelessInventory(GuiScreen screen, final List<IAEItemStack> list) {
if (screen instanceof RecipesGui) {
GuiScreen parent = ((RecipesGui) screen).getParentScreen();
if (parent instanceof GuiWCT) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.vfyjxf.nee.asm;

import com.github.vfyjxf.nee.NotEnoughEnergistics;
import com.github.vfyjxf.nee.helper.ModChecker;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
Expand Down Expand Up @@ -48,6 +49,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
return classWriter.toByteArray();
}
if ("appeng/core/sync/packets/PacketMEInventoryUpdate".equals(internalName)) {
if (ModChecker.isUnofficialAppeng) return basicClass;

ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(basicClass);
classReader.accept(classNode, 0);
Expand All @@ -70,7 +73,7 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
insnList.add(new MethodInsnNode(INVOKESTATIC,
"com/github/vfyjxf/nee/asm/AppengHooks",
"updateMeInventory",
"(Lnet/minecraft/client/gui/GuiScreen;Ljava/util/List;)V",
"(Ljava/lang/Object;Ljava/util/List;)V",
false));
methodNode.instructions.insertBefore(instruction, insnList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import appeng.block.AEBaseTileBlock;
import com.github.vfyjxf.nee.block.tile.TilePatternInterface;
import com.github.vfyjxf.nee.network.NEEGuiHandler;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -22,12 +22,12 @@
public class BlockPatternInterface extends AEBaseTileBlock {

public static BlockPatternInterface BLOCK_INSTANCE = new BlockPatternInterface();
public static Item ITEM_INSTANCE = new AEBaseItemBlock(BLOCK_INSTANCE).setRegistryName(Gobals.MOD_ID, "pattern_interface").setTranslationKey(Gobals.MOD_ID + "." + "pattern_interface");
public static Item ITEM_INSTANCE = new AEBaseItemBlock(BLOCK_INSTANCE).setRegistryName(Globals.MOD_ID, "pattern_interface").setTranslationKey(Globals.MOD_ID + "." + "pattern_interface");

public BlockPatternInterface() {
super(Material.IRON);
setRegistryName(Gobals.MOD_ID, "pattern_interface");
setTranslationKey(Gobals.MOD_ID + "." + "pattern_interface");
setRegistryName(Globals.MOD_ID, "pattern_interface");
setTranslationKey(Globals.MOD_ID + "." + "pattern_interface");
setTileEntity(TilePatternInterface.class);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.github.vfyjxf.nee.container.ContainerCraftingAmount;
import com.github.vfyjxf.nee.network.NEENetworkHandler;
import com.github.vfyjxf.nee.network.packet.PacketCraftingRequest;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import com.github.vfyjxf.nee.utils.GuiUtils;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
Expand Down Expand Up @@ -102,7 +102,7 @@ public void initGui() {
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}

if (Loader.isModLoaded(Gobals.WCT) && GuiUtils.isWirelessTerminalGuiObject(target) && this.wctObj != null) {
if (Loader.isModLoaded(Globals.WCT) && GuiUtils.isWirelessTerminalGuiObject(target) && this.wctObj != null) {
myIcon = getIcon();
}

Expand Down Expand Up @@ -191,7 +191,7 @@ protected void actionPerformed(@Nonnull final GuiButton btn) throws IOException
if (btn == this.originalGuiBtn) {
if (!this.isWirelessCrafting) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(this.originalGui));
} else if (Loader.isModLoaded(Gobals.WCT)) {
} else if (Loader.isModLoaded(Globals.WCT)) {
openWirelessTerminalGui();
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ private void addQty(final int i) {
}
}

@Optional.Method(modid = Gobals.WCT)
@Optional.Method(modid = Globals.WCT)
private ItemStack getIcon() {
if (wctObj instanceof ContainerWCT) {
ContainerWCT wct = (ContainerWCT) this.wctObj;
Expand All @@ -266,7 +266,7 @@ private ItemStack getIcon() {
return null;
}

@Optional.Method(modid = Gobals.WCT)
@Optional.Method(modid = Globals.WCT)
private void openWirelessTerminalGui() {
ModNetworking.instance().sendToServer(new p455w0rd.wct.sync.packets.PacketSwitchGuis(ModGuiHandler.GUI_WCT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.vfyjxf.nee.jei.PatternTransferHandler;
import com.github.vfyjxf.nee.network.NEENetworkHandler;
import com.github.vfyjxf.nee.network.packet.PacketSlotStackSwitch;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import com.github.vfyjxf.nee.utils.GuiUtils;
import com.github.vfyjxf.nee.utils.ItemUtils;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void draw(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
RenderHelper.disableStandardItemLighting();
GlStateManager.disableDepth();
TextureManager textureManager = mc.getTextureManager();
textureManager.bindTexture(new ResourceLocation(Gobals.MOD_ID, "textures/gui/ingredient_switcher_widget.png"));
textureManager.bindTexture(new ResourceLocation(Globals.MOD_ID, "textures/gui/ingredient_switcher_widget.png"));
drawModalRectWithCustomSizedTexture(x, y, 0, 0, this.width, this.height, this.width, this.height);
this.searchField.drawTextBox();
this.addButton.drawButton(mc, mouseX, mouseY, partialTicks);
Expand All @@ -125,7 +125,7 @@ private void drawScrollBar(TextureManager textureManager) {
if (maxScroll <= 0) return;
int scrollBarLeft = x + width - 13;
int scrollBarTop = y + 20;
textureManager.bindTexture(new ResourceLocation(Gobals.MOD_ID, "textures/gui/states.png"));
textureManager.bindTexture(new ResourceLocation(Globals.MOD_ID, "textures/gui/states.png"));
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
if (this.scrollOffset == 0) {
drawTexturedModalRect(scrollBarLeft, scrollBarTop, 4, 51, 7, 11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.github.vfyjxf.nee.container.ContainerPatternInterface;
import com.github.vfyjxf.nee.network.NEENetworkHandler;
import com.github.vfyjxf.nee.network.packet.PacketValueConfigServer;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -66,6 +66,6 @@ protected void mouseClicked(int mouseX, int mouseY, int btn) throws IOException
}

private ResourceLocation getBackground() {
return new ResourceLocation(Gobals.MOD_ID, "textures/gui/pattern_interface.png");
return new ResourceLocation(Globals.MOD_ID, "textures/gui/pattern_interface.png");
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/github/vfyjxf/nee/config/NEEConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.vfyjxf.nee.config;

import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
Expand Down Expand Up @@ -49,8 +49,8 @@ private NEEConfig() {
private static boolean syncIngredientSwitcher = true;

public static void preInit(FMLPreInitializationEvent event) {
File configDir = new File(event.getModConfigurationDirectory(), Gobals.MOD_ID);
modConfigFile = new File(configDir, Gobals.MOD_ID + ".cfg");
File configDir = new File(event.getModConfigurationDirectory(), Globals.MOD_ID);
modConfigFile = new File(configDir, Globals.MOD_ID + ".cfg");
preferenceConfigFile = new File(configDir, "preference.ini");
blacklistFile = new File(configDir, "blacklist.ini");
config = new Configuration(modConfigFile);
Expand Down Expand Up @@ -259,7 +259,7 @@ public static void setMergeBlacklist(String[] mergeBlacklist) {

@SubscribeEvent
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(Gobals.MOD_ID)) {
if (event.getModID().equals(Globals.MOD_ID)) {
if (config.hasChanged()) {
config.save();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.vfyjxf.nee.config;

import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
Expand All @@ -27,7 +27,7 @@ public boolean hasConfigGui() {

@Override
public GuiScreen createConfigGui(GuiScreen parentScreen) {
return new GuiConfig(parentScreen, getConfigElements(), Gobals.MOD_ID, false, false, Gobals.NAME);
return new GuiConfig(parentScreen, getConfigElements(), Globals.MOD_ID, false, false, Globals.NAME);
}

@Override
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/github/vfyjxf/nee/helper/ModChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.vfyjxf.nee.helper;

/**
* Used to check the information of other mods to determine what mod they are.
*/
public class ModChecker {

public static boolean isUnofficialAppeng = false;

static {
checkUnofficial();
}

public static void checkUnofficial() {
try {
Class.forName("appeng.container.slot.IJEITargetSlot");
isUnofficialAppeng = true;
} catch (ClassNotFoundException e) {
isUnofficialAppeng = false;
}
}

}
11 changes: 7 additions & 4 deletions src/main/java/com/github/vfyjxf/nee/helper/RecipeAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import appeng.client.me.ItemRepo;
import appeng.util.item.AEItemStack;
import com.github.vfyjxf.nee.config.NEEConfig;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import com.github.vfyjxf.nee.utils.IngredientStatus;
import com.github.vfyjxf.nee.utils.ItemUtils;
import mezz.jei.api.gui.IGuiIngredient;
Expand Down Expand Up @@ -75,11 +75,14 @@ public RecipeAnalyzer(GuiCraftingTerm craftingTerm, boolean cleanCache) {
if (allStacksCache.isEmpty()) allStacksCache = getStorage();
}

public RecipeAnalyzer(GuiWCT wirelessTerm) {
/**
*For some reason, we can't explicitly reference GuiWCT。
*/
public RecipeAnalyzer(GuiContainer wirelessTerm) {
this(wirelessTerm, shouldCleanCache);
}

public RecipeAnalyzer(GuiWCT wirelessTerm, boolean cleanCache) {
public RecipeAnalyzer(GuiContainer wirelessTerm, boolean cleanCache) {
this.term = wirelessTerm;
this.craftableOnly = false;
this.isWireless = true;
Expand Down Expand Up @@ -282,7 +285,7 @@ private ItemRepo getRepo() {
}
}

@Optional.Method(modid = Gobals.WCT)
@Optional.Method(modid = Globals.WCT)
private ItemRepo getWirelessRepo() {
return getPrivateValue(GuiWCT.class, (GuiWCT) term, "repo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.github.vfyjxf.nee.helper.CraftingHelper;
import com.github.vfyjxf.nee.helper.IngredientRequester;
import com.github.vfyjxf.nee.helper.RecipeAnalyzer;
import com.github.vfyjxf.nee.utils.Gobals;
import com.github.vfyjxf.nee.utils.Globals;
import com.github.vfyjxf.nee.utils.GuiUtils;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
Expand All @@ -31,7 +31,6 @@
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.items.IItemHandler;
import p455w0rd.wct.client.gui.GuiWCT;
import p455w0rd.wct.init.ModNetworking;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -102,15 +101,15 @@ private RecipeAnalyzer createAnalyzer(@Nonnull GuiScreen screen) {
if (screen instanceof GuiCraftingTerm) {
return new RecipeAnalyzer(((GuiCraftingTerm) screen));
}
if (Loader.isModLoaded(Gobals.WCT)) {
if (Loader.isModLoaded(Globals.WCT)) {
return createAnalyzer((GuiContainer) screen);
}
return null;
}

@Optional.Method(modid = Gobals.WCT)
@Optional.Method(modid = Globals.WCT)
private RecipeAnalyzer createAnalyzer(@Nonnull GuiContainer wirelessTerm) {
return new RecipeAnalyzer((GuiWCT) wirelessTerm);
return new RecipeAnalyzer(wirelessTerm);
}

/**
Expand Down Expand Up @@ -241,7 +240,7 @@ private void openWirelessCraftingAmountGui(Container container, IRecipeLayout re
*/

@Optional.Method(modid = Gobals.WCT)
@Optional.Method(modid = Globals.WCT)
private void moveItemsForWirelessTerm(NBTTagCompound recipe) {
try {
ModNetworking.instance().sendToServer(new p455w0rd.wct.sync.packets.PacketJEIRecipe(recipe));
Expand Down
Loading

0 comments on commit 7b7618a

Please sign in to comment.