mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 01:25:16 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
005cc66115 | ||
|
|
5360475686 | ||
|
|
15f89627c6 | ||
|
|
e42914c721 | ||
|
|
394d9cd564 | ||
|
|
f648c41890 | ||
|
|
37498dc0b1 | ||
|
|
ed1a4d010d | ||
|
|
83ee66d8a6 | ||
|
|
c4dcdd926a | ||
|
|
3048dfe09a | ||
|
|
6acfa28ef7 | ||
|
|
bac71d0894 | ||
|
|
b2dabe7bed | ||
|
|
78a8f92b2f | ||
|
|
137db44e23 | ||
|
|
d744bdf25b | ||
|
|
1eb67afea6 | ||
|
|
396dbd734a | ||
|
|
fb00790fdc | ||
|
|
39124f153f | ||
|
|
acda2b4a85 | ||
|
|
5a82bb2a5c | ||
|
|
987d5556ef | ||
|
|
f754ab5fbe | ||
|
|
4ebbd2b3e9 | ||
|
|
6598e693f9 | ||
|
|
4970a268f4 | ||
|
|
a984e2e8bd | ||
|
|
71aba4006b | ||
|
|
da64a0a019 | ||
|
|
d687bb5383 | ||
|
|
37d07ab99f | ||
|
|
172e8ca659 | ||
|
|
243ca7db20 | ||
|
|
39a979ef62 | ||
|
|
73cf134212 | ||
|
|
ae641e642d | ||
|
|
58feff48f9 | ||
|
|
c77306ae4f | ||
|
|
0ce1661a7f | ||
|
|
95adb69f55 | ||
|
|
b52b110852 | ||
|
|
7f1cb7d710 | ||
|
|
94d0f4d681 | ||
|
|
5f168bb1bc | ||
|
|
d29ecd09ce | ||
|
|
1fd33e8d7c | ||
|
|
f43bfad3d8 |
No files matched your search
@@ -1,22 +1,23 @@
|
||||
package mcp.mobius.waila;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.forge.GuiContainerManager;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.buildcraft.HUDHandlerBCTanks;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2Generator;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2Machine;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2Storage;
|
||||
import mcp.mobius.waila.addons.buildcraft.BCModule;
|
||||
import mcp.mobius.waila.addons.enderstorage.EnderStorageModule;
|
||||
import mcp.mobius.waila.addons.ic2.IC2Module;
|
||||
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
|
||||
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
|
||||
import mcp.mobius.waila.gui.ConfigKeyHandler;
|
||||
import mcp.mobius.waila.handlers.EnchantmentHandler;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerExternal;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerWaila;
|
||||
import mcp.mobius.waila.handlers.TooltipHandlerWaila;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
|
||||
public class ProxyClient extends ProxyServer {
|
||||
|
||||
@@ -26,15 +27,16 @@ public class ProxyClient extends ProxyServer {
|
||||
@Override
|
||||
public void registerHandlers(){
|
||||
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
//GuiContainerManager.addInputHandler(new EnchantementHandler());
|
||||
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.HEADER);
|
||||
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.BODY);
|
||||
API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.FOOTER);
|
||||
API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.HEADER);
|
||||
|
||||
//API.registerHighlightIdentifier(2000, new HUDHandlerExternal());
|
||||
KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
|
||||
//API.addKeyBind("showenchant", "Display enchantements", Keyboard.KEY_RSHIFT);
|
||||
|
||||
GuiContainerManager.addInputHandler(new EnchantmentHandler());
|
||||
API.addKeyBind("showenchant", "Display enchantements", Keyboard.KEY_RSHIFT);
|
||||
|
||||
this.registerMods();
|
||||
}
|
||||
|
||||
@@ -55,29 +57,16 @@ public class ProxyClient extends ProxyServer {
|
||||
*/
|
||||
|
||||
/* BUILDCRAFT */
|
||||
try {
|
||||
Class ModBuildcraftFactory = Class.forName("buildcraft.BuildCraftFactory");
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
|
||||
HUDHandlerBCTanks.register();
|
||||
ConfigHandler.instance().addConfig("Buildcraft", "bc.tankamount", "Liquid amount");
|
||||
ConfigHandler.instance().addConfig("Buildcraft", "bc.tanktype", "Liquid type");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
|
||||
}
|
||||
BCModule.register();
|
||||
|
||||
/* INDUSTRIALCRAFT2 */
|
||||
try {
|
||||
Class ModIndustrialCraft = Class.forName("ic2.core.IC2");
|
||||
mod_Waila.log.log(Level.INFO, "Industrialcraft2 mod found.");
|
||||
HUDHandlerIC2Storage.register();
|
||||
HUDHandlerIC2Machine.register();
|
||||
HUDHandlerIC2Generator.register();
|
||||
ConfigHandler.instance().addConfig("IndustrialCraft2", "ic2.inputeu", "Max EU input");
|
||||
ConfigHandler.instance().addConfig("IndustrialCraft2", "ic2.outputeu", "Max EU output");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "Industrialcraft2 mod not found. Skipping.");
|
||||
}
|
||||
IC2Module.register();
|
||||
|
||||
/*Thaumcraft*/
|
||||
ThaumcraftModule.register();
|
||||
|
||||
/*EnderStorage*/
|
||||
EnderStorageModule.register();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package mcp.mobius.waila;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class WailaExceptionHandler {
|
||||
|
||||
public WailaExceptionHandler() {}
|
||||
|
||||
private static ArrayList<String> errs = new ArrayList<String>();
|
||||
|
||||
public static List<String> handleErr(Throwable e, String className, List<String> currenttip){
|
||||
if (!errs.contains(className)){
|
||||
errs.add(className);
|
||||
mod_Waila.log.log(Level.WARNING, String.format("Catched unhandled exception : [%s] %s",className,e));
|
||||
}
|
||||
if (currenttip != null)
|
||||
currenttip.add("<ERROR>");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
@@ -11,7 +13,8 @@ import net.minecraftforge.common.Property;
|
||||
public class ConfigHandler implements IWailaConfigHandler {
|
||||
|
||||
private static ConfigHandler instance = null;
|
||||
private HashMap<String, ConfigModule> modules = new HashMap<String, ConfigModule>();
|
||||
private LinkedHashMap<String, ConfigModule> modules = new LinkedHashMap<String, ConfigModule>();
|
||||
private ArrayList<String> serverconfigs = new ArrayList<String>();
|
||||
|
||||
private ConfigHandler() {
|
||||
instance = this;
|
||||
@@ -50,14 +53,30 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
|
||||
this.modules.get(modName).addOption(key, name);
|
||||
}
|
||||
|
||||
public void addConfigServer(String modName, String key, String name){
|
||||
if (!this.modules.containsKey(modName))
|
||||
this.modules.put(modName, new ConfigModule(modName));
|
||||
|
||||
this.modules.get(modName).addOption(key, name);
|
||||
this.serverconfigs.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfig(String key, boolean defvalue){
|
||||
mod_Waila.instance.config.load();
|
||||
|
||||
if (this.serverconfigs.contains(key) && !mod_Waila.instance.serverPresent)
|
||||
return false;
|
||||
|
||||
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, defvalue);
|
||||
return prop.getBoolean(defvalue);
|
||||
}
|
||||
|
||||
public boolean isServerRequired(String key){
|
||||
return this.serverconfigs.contains(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfig(String key){
|
||||
return this.getConfig(key, true);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package mcp.mobius.waila.addons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
|
||||
@@ -12,9 +14,15 @@ import mcp.mobius.waila.handlers.HUDHandlerExternal;
|
||||
public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
|
||||
private static ExternalModulesHandler instance = null;
|
||||
public HashMap<Integer, ArrayList<IWailaDataProvider>> headProviders = new HashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public HashMap<Integer, ArrayList<IWailaDataProvider>> bodyProviders = new HashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public HashMap<Integer, ArrayList<IWailaDataProvider>> stackProviders = new HashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> headProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> bodyProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> tailProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> stackProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
|
||||
|
||||
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> headBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> bodyBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> tailBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> stackBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
|
||||
|
||||
private ExternalModulesHandler() {
|
||||
instance = this;
|
||||
@@ -31,6 +39,11 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
ConfigHandler.instance().addConfig(modname, key, configname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConfigRemote(String modname, String key, String configname) {
|
||||
ConfigHandler.instance().addConfigServer(modname, key, configname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHeadProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
if (!this.headProviders.containsKey(blockID))
|
||||
@@ -38,6 +51,13 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
this.headProviders.get(blockID).add(dataProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHeadProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.headBlockProviders.containsKey(block))
|
||||
this.headBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
this.headBlockProviders.get(block).add(dataProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBodyProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
if (!this.bodyProviders.containsKey(blockID))
|
||||
@@ -45,6 +65,25 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
this.bodyProviders.get(blockID).add(dataProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBodyProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.bodyBlockProviders.containsKey(block))
|
||||
this.bodyBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
this.bodyBlockProviders.get(block).add(dataProvider);
|
||||
}
|
||||
|
||||
public void registerTailProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
if (!this.tailProviders.containsKey(blockID))
|
||||
this.tailProviders.put(blockID, new ArrayList<IWailaDataProvider>());
|
||||
this.tailProviders.get(blockID).add(dataProvider);
|
||||
}
|
||||
|
||||
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.tailBlockProviders.containsKey(block))
|
||||
this.tailBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
this.tailBlockProviders.get(block).add(dataProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
if (!this.stackProviders.containsKey(blockID))
|
||||
@@ -52,6 +91,16 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
this.stackProviders.get(blockID).add(dataProvider);
|
||||
API.registerHighlightIdentifier(blockID, new HUDHandlerExternal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
for (int i = 0; i < Block.blocksList.length; i++)
|
||||
if (block.isInstance(Block.blocksList[i])){
|
||||
this.registerStackProvider(dataProvider, i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Arrays getters */
|
||||
|
||||
public ArrayList<IWailaDataProvider> getHeadProviders(int blockID) {
|
||||
return this.headProviders.get(blockID);
|
||||
@@ -61,10 +110,43 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
return this.bodyProviders.get(blockID);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getTailProviders(int blockID) {
|
||||
return this.tailProviders.get(blockID);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getHeadProviders(Object block) {
|
||||
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
|
||||
for (Class clazz : this.headBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
returnList.addAll(this.headBlockProviders.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getBodyProviders(Object block) {
|
||||
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
|
||||
for (Class clazz : this.bodyBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
returnList.addAll(this.bodyBlockProviders.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
|
||||
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
|
||||
for (Class clazz : this.bodyBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
returnList.addAll(this.bodyBlockProviders.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getStackProviders(int blockID) {
|
||||
return this.stackProviders.get(blockID);
|
||||
}
|
||||
|
||||
/* Providers querry methods */
|
||||
|
||||
public boolean hasHeadProviders(int blockID){
|
||||
return this.headProviders.containsKey(blockID);
|
||||
}
|
||||
@@ -72,8 +154,33 @@ public class ExternalModulesHandler implements IWailaRegistrar {
|
||||
public boolean hasBodyProviders(int blockID){
|
||||
return this.bodyProviders.containsKey(blockID);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasTailProviders(int blockID){
|
||||
return this.tailProviders.containsKey(blockID);
|
||||
}
|
||||
|
||||
public boolean hasStackProviders(int blockID){
|
||||
return this.stackProviders.containsKey(blockID);
|
||||
}
|
||||
|
||||
public boolean hasHeadProviders(Object block){
|
||||
for (Class clazz : this.headBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBodyProviders(Object block){
|
||||
for (Class clazz : this.bodyBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasTailProviders(Object block){
|
||||
for (Class clazz : this.tailBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class BCModule {
|
||||
|
||||
public static Class TileTank = null;
|
||||
public static Class IPowerReceptor = null;
|
||||
public static Class PipeTransportPower = null;
|
||||
public static Class TileGenericPipe = null;
|
||||
public static Class TileEngine = null;
|
||||
|
||||
public static Method TileTank_GetTanks = null;
|
||||
public static Method IPowerReceptor_PowerRequest = null;
|
||||
|
||||
public static void register(){
|
||||
try {
|
||||
Class ModBuildcraftFactory = Class.forName("buildcraft.BuildCraftFactory");
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileTank = Class.forName("buildcraft.factory.TileTank");
|
||||
IPowerReceptor = Class.forName("buildcraft.api.power.IPowerReceptor");
|
||||
PipeTransportPower = Class.forName("buildcraft.transport.PipeTransportPower");
|
||||
TileGenericPipe = Class.forName("buildcraft.transport.TileGenericPipe");
|
||||
TileEngine = Class.forName("buildcraft.energy.TileEngine");
|
||||
|
||||
TileTank_GetTanks = TileTank.getMethod("getTanks", ForgeDirection.class);
|
||||
IPowerReceptor_PowerRequest = IPowerReceptor.getMethod("powerRequest", ForgeDirection.class);
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BC] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BC] Method not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tankamount", "Liquid amount");
|
||||
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tanktype", "Liquid type");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Buildcraft", "bc.powerpipe", "Power pipes");
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCPipes(), TileGenericPipe);
|
||||
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCEngine(), TileEngine);
|
||||
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCIPowerReceptor(), PipeTransportPower);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerBCEngine implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("energyF")){
|
||||
//float output = tag.getFloat("energyF")*tag.getFloat("progress");
|
||||
float output = tag.getFloat("energyF");
|
||||
if (output > 1.0F)
|
||||
currenttip.add(String.format("Output : %.1f MJ",output));
|
||||
else
|
||||
currenttip.add(String.format("Output : %.2f MJ",output));
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerBCIPowerReceptor implements IWailaDataProvider {
|
||||
|
||||
public HUDHandlerBCIPowerReceptor() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
// int powerRequest = 0;
|
||||
// try{
|
||||
// powerRequest = (Integer)BCModule.IPowerReceptor_PowerRequest.invoke(BCModule.IPowerReceptor.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN);
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// mod_Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
|
||||
// return currenttip;
|
||||
// }
|
||||
// currenttip.add(String.valueOf(powerRequest));
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerBCPipes implements IWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (this.hasPartialKey(tag, "internalNextPower") && config.getConfig("bc.powerpipe")){
|
||||
double power = Math.max(0, this.getPartialKeySum(tag, "internalNextPower"));
|
||||
currenttip.add(String.format("Power : %.1f MJ", power));
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public boolean hasPartialKey(NBTTagCompound tag, String key){
|
||||
for (Object k : tag.tagMap.keySet())
|
||||
if (((String)k).contains(key))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getPartialKeySum(NBTTagCompound tag, String key){
|
||||
double retVal = 0;
|
||||
for (Object k : tag.tagMap.keySet())
|
||||
if (((String)k).contains(key))
|
||||
retVal += tag.getDouble((String)k);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -8,85 +7,57 @@ import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
|
||||
public class HUDHandlerBCTanks implements IHighlightHandler {
|
||||
|
||||
private static Class TileTank = null;
|
||||
private static Method TileTank_GetTanks = null;
|
||||
|
||||
public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
ILiquidTank tank = this.getTank(accessor);
|
||||
LiquidStack stack = tank != null ? tank.getLiquid() : null;
|
||||
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if ((entity != null) && (TileTank.isInstance(entity))){
|
||||
|
||||
ILiquidTank tank = null;
|
||||
try{
|
||||
tank = ((ILiquidTank[])TileTank_GetTanks.invoke(TileTank.cast(entity), ForgeDirection.UNKNOWN))[0];
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
LiquidStack liquidStack = tank.getLiquid();
|
||||
int liquidAmount = liquidStack != null ? liquidStack.amount:0;
|
||||
int capacity = tank.getCapacity();
|
||||
|
||||
if (liquidStack != null && layout == Layout.HEADER && ConfigHandler.instance().getConfig("bc.tanktype")){
|
||||
String name = currenttip.get(0);
|
||||
name = name + " (" + liquidStack.asItemStack().getDisplayName() + ")";
|
||||
currenttip.set(0, name);
|
||||
}
|
||||
|
||||
if (liquidStack == null && layout == Layout.HEADER && ConfigHandler.instance().getConfig("bc.tanktype")){
|
||||
String name = currenttip.get(0);
|
||||
name = name + " <Empty>";
|
||||
currenttip.set(0, name);
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ConfigHandler.instance().getConfig("bc.tankamount"))
|
||||
currenttip.add(String.valueOf(liquidAmount) + "/" + String.valueOf(capacity) + " mB");
|
||||
|
||||
}
|
||||
String name = currenttip.get(0);
|
||||
if (stack != null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " (" + stack.asItemStack().getDisplayName() + ")";
|
||||
else if (stack == null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " <Empty>";
|
||||
currenttip.set(0, name);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
TileTank = Class.forName("buildcraft.factory.TileTank");
|
||||
TileTank_GetTanks = TileTank.getMethod("getTanks", ForgeDirection.class);
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BC] TileTank class not found.");
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BB] getTanks() not found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
ILiquidTank tank = this.getTank(accessor);
|
||||
LiquidStack stack = tank != null ? tank.getLiquid() : null;
|
||||
int liquidAmount = stack != null ? stack.amount:0;
|
||||
int capacity = tank != null ? tank.getCapacity() : 0;
|
||||
|
||||
if (TileTank_GetTanks != null){
|
||||
mod_Waila.log.log(Level.INFO, "Waila module BuildcraftTank succefully hooked.");
|
||||
API.registerHighlightHandler(new HUDHandlerBCTanks(), Layout.HEADER);
|
||||
API.registerHighlightHandler(new HUDHandlerBCTanks(), Layout.BODY);
|
||||
if (ConfigHandler.instance().getConfig("bc.tankamount"))
|
||||
currenttip.add(String.valueOf(liquidAmount) + "/" + String.valueOf(capacity) + " mB");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public ILiquidTank getTank(IWailaDataAccessor accessor){
|
||||
ILiquidTank tank = null;
|
||||
try{
|
||||
tank = ((ILiquidTank[])BCModule.TileTank_GetTanks.invoke(BCModule.TileTank.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN))[0];
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return tank;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package mcp.mobius.waila.addons.enderstorage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2IEnergySink;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class EnderStorageModule {
|
||||
|
||||
public static Class TileFrequencyOwner = null;
|
||||
public static Field TileFrequencyOwner_Freq = null;
|
||||
|
||||
public static Class EnderStorageManager = null;
|
||||
public static Method GetColourFromFreq = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class EnderStorage = Class.forName("codechicken.enderstorage.EnderStorage");
|
||||
mod_Waila.log.log(Level.INFO, "EnderStorage mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
TileFrequencyOwner = Class.forName("codechicken.enderstorage.common.TileFrequencyOwner");
|
||||
TileFrequencyOwner_Freq = TileFrequencyOwner.getField("freq");
|
||||
|
||||
EnderStorageManager = Class.forName("codechicken.enderstorage.api.EnderStorageManager");
|
||||
GetColourFromFreq = EnderStorageManager.getDeclaredMethod("getColourFromFreq", Integer.TYPE, Integer.TYPE);
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfig("EnderStorage", "enderstorage.colors", "Colors");
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerStorage(), TileFrequencyOwner);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package mcp.mobius.waila.addons.enderstorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerStorage implements IWailaDataProvider {
|
||||
|
||||
private static String[] colors = {"White", "Orange", "Magenta", "LBlue", "Yellow", "Lime", "Pink", "Gray", "LGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if(config.getConfig("enderstorage.colors")){
|
||||
try{
|
||||
int freq = EnderStorageModule.TileFrequencyOwner_Freq.getInt(accessor.getTileEntity());
|
||||
int freqLeft = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 0);
|
||||
int freqCenter = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 1);
|
||||
int freqRight = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 2);
|
||||
|
||||
currenttip.add(String.format("%s/%s/%s", colors[freqLeft], colors[freqCenter], colors[freqRight]));
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerDoor implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return IC2Module.ReinforcedDoorStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
|
||||
public class HUDHandlerIC2Generator implements IHighlightHandler {
|
||||
|
||||
private static Class TEBaseGenerator = null;
|
||||
private static Method TEBaseGenerator_GetMaxOutput = null;
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
if (!ConfigHandler.instance().getConfig("ic2.outputeu"))
|
||||
return currenttip;
|
||||
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if ((entity != null) && (TEBaseGenerator.isInstance(entity))){
|
||||
int maxinput = 0;
|
||||
try{
|
||||
maxinput = (Integer)(TEBaseGenerator_GetMaxOutput.invoke(TEBaseGenerator.cast(entity)));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an TEBaseGenerator for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
currenttip.add(String.format("OUT : %s EU/t", maxinput));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
TEBaseGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityBaseGenerator");
|
||||
TEBaseGenerator_GetMaxOutput = TEBaseGenerator.getMethod("getMaxEnergyOutput");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] TEBaseGenerator class not found.");
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] One method was not found.");
|
||||
}
|
||||
|
||||
if (TEBaseGenerator_GetMaxOutput != null){
|
||||
mod_Waila.log.log(Level.INFO, "Waila module IndustrialCraft|Generator succefully hooked.");
|
||||
API.registerHighlightHandler(new HUDHandlerIC2Generator(), Layout.BODY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class HUDHandlerIC2IEnergySink implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
|
||||
int maxinput = -1;
|
||||
try{
|
||||
if (IC2Module.IEnergySink.isInstance(accessor.getTileEntity()))
|
||||
maxinput = (Integer)(IC2Module.IEnergySink_GetInput.invoke(IC2Module.IEnergySink.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySink for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
int ntransformers = this.getTransformerUpgrades(accessor);
|
||||
if (ntransformers > 0){
|
||||
maxinput = maxinput * (int)Math.pow(4.0D, Math.min(3, ntransformers));
|
||||
}
|
||||
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput > 4096))
|
||||
currenttip.add("IN : ANY");
|
||||
|
||||
else if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput != -1) && !this.canUpgrade(accessor.getNBTData()))
|
||||
currenttip.add(String.format("IN : %s EU/t", maxinput));
|
||||
|
||||
else if (ConfigHandler.instance().getConfig("ic2.inputeumach") && (maxinput != -1) && this.canUpgrade(accessor.getNBTData()))
|
||||
currenttip.add(String.format("IN : %s EU/t", maxinput));
|
||||
|
||||
if (config.getConfig("ic2.storage"))
|
||||
if (accessor.getNBTData().hasKey("energy") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
currenttip.add(String.format("Storage : %s EU", accessor.getNBTInteger(accessor.getNBTData(), "energy")));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public boolean canUpgrade(NBTTagCompound tag){
|
||||
if (tag.hasKey("InvSlots"))
|
||||
if (tag.getCompoundTag("InvSlots").hasKey("upgrade"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTransformerUpgrades(IWailaDataAccessor accessor){
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (!canUpgrade(tag)) return -1;
|
||||
|
||||
int ntransformers = 0;
|
||||
NBTTagList contents = tag.getCompoundTag("InvSlots").getCompoundTag("upgrade").getTagList("Contents");
|
||||
for (NBTTagCompound subtag : (List<NBTTagCompound>)contents.tagList){
|
||||
ItemStack currentSlot = new ItemStack(accessor.getNBTInteger(subtag, "id"),accessor.getNBTInteger(subtag, "Count"),accessor.getNBTInteger(subtag, "Damage"));
|
||||
if (IC2Module.TransformerUpgradeStack.isItemEqual(currentSlot)){
|
||||
ntransformers += currentSlot.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return ntransformers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
|
||||
public class HUDHandlerIC2IEnergySource implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
|
||||
int output = -1;
|
||||
|
||||
try{
|
||||
if (IC2Module.IEnergySource.isInstance(accessor.getTileEntity()))
|
||||
output = (Integer)(IC2Module.IEnergySource_GetOutput.invoke(IC2Module.IEnergySource.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySource for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu") && (output != -1))
|
||||
currenttip.add(String.format("OUT : %s EU/t", output));
|
||||
|
||||
if (config.getConfig("ic2.storage"))
|
||||
if (accessor.getNBTData().hasKey("storage") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
currenttip.add(String.format("Storage : %s EU", accessor.getNBTInteger(accessor.getNBTData(), "storage")));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDHandlerIC2IEnergyStorage implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("ic2.storage"))
|
||||
return currenttip;
|
||||
|
||||
int stored = -1;
|
||||
int capacity = -1;
|
||||
try{
|
||||
if (IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
capacity = (Integer)(IC2Module.IEnergyStorage_GetCapacity.invoke(IC2Module.IEnergyStorage.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergyStorage for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (accessor.getNBTData().hasKey("energy"))
|
||||
stored = accessor.getNBTInteger(accessor.getNBTData(), "energy");
|
||||
|
||||
if ((capacity != -1) && (stored != -1))
|
||||
currenttip.add(String.format("%s/%s EU", stored, capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
|
||||
public class HUDHandlerIC2Machine implements IHighlightHandler {
|
||||
|
||||
private static Class TEElectricMachine = null;
|
||||
private static Method TEElectricMachine_GetMaxSafeInput = null;
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
if (!ConfigHandler.instance().getConfig("ic2.inputeu"))
|
||||
return currenttip;
|
||||
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if ((entity != null) && (TEElectricMachine.isInstance(entity))){
|
||||
int maxinput = 0;
|
||||
try{
|
||||
maxinput = (Integer)(TEElectricMachine_GetMaxSafeInput.invoke(TEElectricMachine.cast(entity)));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergyStorage for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
currenttip.add(String.format("IN : %s EU/t", maxinput));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
TEElectricMachine = Class.forName("ic2.core.block.machine.tileentity.TileEntityElectricMachine");
|
||||
TEElectricMachine_GetMaxSafeInput = TEElectricMachine.getMethod("getMaxSafeInput");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] TileEntityElectricMachine class not found.");
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] One method was not found.");
|
||||
}
|
||||
|
||||
if (TEElectricMachine_GetMaxSafeInput != null){
|
||||
mod_Waila.log.log(Level.INFO, "Waila module IndustrialCraft|Machine succefully hooked.");
|
||||
API.registerHighlightHandler(new HUDHandlerIC2Machine(), Layout.BODY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
|
||||
public class HUDHandlerIC2Storage implements IHighlightHandler {
|
||||
|
||||
private static Class TEElectricBlock = null;
|
||||
private static Field TEElectricBlock_Energy = null;
|
||||
private static Method TEElectricBlock_GetStored = null;
|
||||
private static Method TEElectricBlock_GetCapacity = null;
|
||||
private static Method TEElectricBlock_GetOutput = null;
|
||||
private static Method TEElectricBlock_GetMaxSafeInput = null;
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if ((entity != null) && (TEElectricBlock.isInstance(entity))){
|
||||
int stored = 0;
|
||||
int capacity = 0;
|
||||
int output = 0;
|
||||
int maxinput = 0;
|
||||
try{
|
||||
//stored = (Integer)(TEElectricBlock_Energy.get(entity));
|
||||
//capacity = (Integer)(TEElectricBlock_GetCapacity.invoke(TEElectricBlock.cast(entity)));
|
||||
output = (Integer)(TEElectricBlock_GetOutput.invoke(TEElectricBlock.cast(entity)));
|
||||
maxinput = (Integer)(TEElectricBlock_GetMaxSafeInput.invoke(TEElectricBlock.cast(entity)));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergyStorage for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu") && ConfigHandler.instance().getConfig("ic2.inputeu"))
|
||||
currenttip.add(String.format("IN/OUT : %s/%s EU/t", maxinput, output));
|
||||
else if (ConfigHandler.instance().getConfig("ic2.outputeu") && !ConfigHandler.instance().getConfig("ic2.inputeu"))
|
||||
currenttip.add(String.format("OUT : %s EU/t", output));
|
||||
else if (!ConfigHandler.instance().getConfig("ic2.outputeu") && ConfigHandler.instance().getConfig("ic2.inputeu"))
|
||||
currenttip.add(String.format("IN : %s EU/t", maxinput));
|
||||
//currenttip.add(String.format("%s / %s EU", stored, capacity));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
TEElectricBlock = Class.forName("ic2.core.block.wiring.TileEntityElectricBlock");
|
||||
TEElectricBlock_GetStored = TEElectricBlock.getMethod("getStored");
|
||||
TEElectricBlock_GetCapacity = TEElectricBlock.getMethod("getCapacity");
|
||||
TEElectricBlock_GetOutput = TEElectricBlock.getMethod("getOutput");
|
||||
TEElectricBlock_GetMaxSafeInput = TEElectricBlock.getMethod("getMaxSafeInput");
|
||||
TEElectricBlock_Energy = TEElectricBlock.getField("energy");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] IEnergyStorage class not found.");
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] One method was not found.");
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] One field was not found.");
|
||||
}
|
||||
|
||||
|
||||
if (TEElectricBlock_Energy != null){
|
||||
mod_Waila.log.log(Level.INFO, "Waila module IndustrialCraft|Storage succefully hooked.");
|
||||
API.registerHighlightHandler(new HUDHandlerIC2Storage(), Layout.BODY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class IC2Module {
|
||||
|
||||
/* Our interfaces */
|
||||
public static Class IEnergyStorage = null;
|
||||
public static Class IEnergySink = null;
|
||||
public static Class IEnergySource = null;
|
||||
|
||||
/* Methods interfaces */
|
||||
public static Method IEnergyStorage_GetCapacity = null;
|
||||
public static Method IEnergySink_GetInput = null;
|
||||
public static Method IEnergySource_GetOutput = null;
|
||||
|
||||
/* Some required items */
|
||||
public static Class IC2Items = null;
|
||||
public static Field TransformerUpgrade = null;
|
||||
public static ItemStack TransformerUpgradeStack = null;
|
||||
public static Field EnergyStorageUpgrade = null;
|
||||
public static ItemStack EnergyStorageUpgradeStack = null;
|
||||
|
||||
/* Fix for doors */
|
||||
public static Class BlockIC2Door = null;
|
||||
public static Field ReinforcedDoor = null;
|
||||
public static ItemStack ReinforcedDoorStack = null;
|
||||
|
||||
|
||||
public static void register(){
|
||||
|
||||
try{
|
||||
Class ModIndustrialCraft = Class.forName("ic2.core.IC2");
|
||||
mod_Waila.log.log(Level.INFO, "Industrialcraft2 mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[IC2] Industrialcraft2 mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
IEnergyStorage = Class.forName("ic2.api.tile.IEnergyStorage");
|
||||
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
|
||||
IEnergySource = Class.forName("ic2.api.energy.tile.IEnergySource");
|
||||
|
||||
IEnergySink_GetInput = IEnergySink.getMethod("getMaxSafeInput");
|
||||
IEnergySource_GetOutput = IEnergySource.getMethod("getMaxEnergyOutput");
|
||||
IEnergyStorage_GetCapacity = IEnergyStorage.getMethod("getCapacity");
|
||||
|
||||
IC2Items = Class.forName("ic2.core.Ic2Items");
|
||||
TransformerUpgrade = IC2Items.getDeclaredField("transformerUpgrade");
|
||||
EnergyStorageUpgrade = IC2Items.getDeclaredField("energyStorageUpgrade");
|
||||
|
||||
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
|
||||
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
|
||||
|
||||
BlockIC2Door = Class.forName("ic2.core.block.BlockIC2Door");
|
||||
ReinforcedDoor = IC2Items.getDeclaredField("reinforcedDoor");
|
||||
ReinforcedDoorStack = (ItemStack)ReinforcedDoor.get(null);
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeumach", "Max EU input [Machines]");
|
||||
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.inputeuother", "Max EU input [Other]");
|
||||
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.outputeu", "Max EU output");
|
||||
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.storage", "Energy stored");
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySink(), IEnergySink);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySource(), IEnergySource);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergyStorage(), IEnergyStorage);
|
||||
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerDoor(), BlockIC2Door);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDHandlerCapacitor implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (config.getConfig("thaumcraft.storedvis")){
|
||||
try{
|
||||
short storedVis = ThaumcraftModule.TileCrystalCapacitor_StoredVis.getShort(accessor.getTileEntity());
|
||||
short maxVis = ThaumcraftModule.TileCrystalCapacitor_MaxVis.getShort(accessor.getTileEntity());
|
||||
|
||||
currenttip.add(String.format("%s/%s vis", storedVis, maxVis));
|
||||
}catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getClass().getName(), currenttip);
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerLeaves implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerPlants implements IWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerDoor;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2IEnergySink;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2IEnergySource;
|
||||
import mcp.mobius.waila.addons.ic2.HUDHandlerIC2IEnergyStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ThaumcraftModule {
|
||||
|
||||
public static Class BlockMagicalLeaves = null;
|
||||
public static Class BlockCustomPlant = null;
|
||||
|
||||
public static Class TileCrystalCapacitor = null;
|
||||
public static Field TileCrystalCapacitor_StoredVis = null;
|
||||
public static Field TileCrystalCapacitor_MaxVis = null;
|
||||
|
||||
public static void register(){
|
||||
|
||||
try{
|
||||
Class ModThaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
|
||||
mod_Waila.log.log(Level.INFO, "Thaumcraft mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
BlockMagicalLeaves = Class.forName("thaumcraft.common.world.BlockMagicalLeaves");
|
||||
BlockCustomPlant = Class.forName("thaumcraft.common.world.BlockCustomPlant");
|
||||
|
||||
TileCrystalCapacitor = Class.forName("thaumcraft.common.tiles.TileCrystalCapacitor");
|
||||
TileCrystalCapacitor_StoredVis = TileCrystalCapacitor.getField("storedVis");
|
||||
TileCrystalCapacitor_MaxVis = TileCrystalCapacitor.getField("maxVis");
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Class not found. " + e);
|
||||
return;
|
||||
// } catch (NoSuchMethodException e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Method not found." + e);
|
||||
// return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Field not found." + e);
|
||||
return;
|
||||
// } catch (Exception e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
|
||||
// return;
|
||||
}
|
||||
ExternalModulesHandler.instance().addConfig("Thaumcraft", "thaumcraft.storedvis", "Capacitor storage");
|
||||
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerLeaves(), BlockMagicalLeaves);
|
||||
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,15 @@ package mcp.mobius.waila.addons.vanillamc;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.tileentity.TileEntityRecordPlayer;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
@@ -21,51 +22,124 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
static int pumpkinStemID = Block.pumpkinStem.blockID;
|
||||
static int carrotID = Block.carrot.blockID;
|
||||
static int potatoID = Block.potato.blockID;
|
||||
static int leverID = Block.lever.blockID;
|
||||
static int repeaterIdle = Block.redstoneRepeaterIdle.blockID;
|
||||
static int repeaterActv = Block.redstoneRepeaterActive.blockID;
|
||||
static int comparatorIdl = Block.redstoneComparatorIdle.blockID;
|
||||
static int comparatorAct = Block.redstoneComparatorActive.blockID;
|
||||
static int redstone = Block.redstoneWire.blockID;
|
||||
static int jukebox = Block.jukebox.blockID;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, IWailaConfigHandler config) {
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = block.blockID;
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
/* Mob spawner handler */
|
||||
if (blockID == mobSpawnerID && entity instanceof TileEntityMobSpawner && config.getConfig("vanilla.showspawntype")){
|
||||
if (blockID == mobSpawnerID && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
|
||||
String name = currenttip.get(0);
|
||||
String mobname = ((TileEntityMobSpawner)entity).func_98049_a().getEntityNameToSpawn();
|
||||
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).func_98049_a().getEntityNameToSpawn();
|
||||
currenttip.set(0, String.format("%s (%s)", name, mobname));
|
||||
}
|
||||
|
||||
if (blockID == redstone){
|
||||
String name = currenttip.get(0).replaceFirst(String.format(" %s", accessor.getMetadata()), "");
|
||||
currenttip.set(0, name);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = block.blockID;
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
/* Crops */
|
||||
if (config.getConfig("vanilla.showgrowthvalue"))
|
||||
if (config.getConfig("vanilla.growthvalue"))
|
||||
if (blockID == cropsID || blockID == melonStemID || blockID == pumpkinStemID || blockID == carrotID || blockID == potatoID){
|
||||
float growthValue = ((float)world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ) / 7.0F) * 100.0F;
|
||||
float growthValue = (accessor.getMetadata() / 7.0F) * 100.0F;
|
||||
if (growthValue != 100.0)
|
||||
currenttip.add(String.format("Growth : %.0f %%", growthValue));
|
||||
else
|
||||
currenttip.add("Growth : Mature");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.leverstate"))
|
||||
if (blockID == leverID){
|
||||
String redstoneOn = (accessor.getMetadata() & 8) == 0 ? "Off" : "On";
|
||||
currenttip.add("State : " + redstoneOn);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.repeater"))
|
||||
if ((blockID == repeaterIdle) ||(blockID == repeaterActv)){
|
||||
int tick = (accessor.getMetadata() >> 2) + 1 ;
|
||||
if (tick == 1)
|
||||
currenttip.add(String.format("Delay : %s tick", tick));
|
||||
else
|
||||
currenttip.add(String.format("Delay : %s ticks", tick));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.comparator"))
|
||||
if ((blockID == comparatorIdl) ||(blockID == comparatorAct)){
|
||||
String mode = ((accessor.getMetadata() >> 2) & 1) == 0 ? "Comparator" : "Subtractor";
|
||||
//int outputSignal = ((TileEntityComparator)entity).func_96100_a();
|
||||
currenttip.add("Mode : " + mode);
|
||||
//currenttip.add(String.format("Out : %s", outputSignal));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.redstone"))
|
||||
if (blockID == redstone){
|
||||
currenttip.add(String.format("Power : %s" , accessor.getMetadata()));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.jukebox"))
|
||||
if (blockID == jukebox){
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
Item record = null;
|
||||
if (tag.hasKey("Record")){
|
||||
record = Item.itemsList[accessor.getNBTInteger(tag, "Record")];
|
||||
currenttip.add(((ItemRecord)record).getRecordTitle());
|
||||
} else {
|
||||
currenttip.add("<Empty>");
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void register(){
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.showspawntype", "Spawner type");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.showgrowthvalue", "Growth value");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.spawntype", "Spawner type");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.growthvalue", "Growth value");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.leverstate", "Lever state");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.repeater", "Repeater delay");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.comparator", "Comparator mode");
|
||||
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.redstone", "Redstone power");
|
||||
ExternalModulesHandler.instance().addConfigRemote("VanillaMC", "vanilla.jukebox", "Jukebox disk");
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), mobSpawnerID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), cropsID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), melonStemID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), pumpkinStemID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), carrotID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), potatoID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), potatoID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), leverID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterIdle);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterActv);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorIdl);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorAct);
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), redstone);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), redstone);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), jukebox);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,12 +2,7 @@ package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IWailaBlock {
|
||||
/*
|
||||
@@ -15,7 +10,7 @@ public interface IWailaBlock {
|
||||
* Return null if you want to use the default lookup system.
|
||||
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
|
||||
*/
|
||||
ItemStack getWailaStack(World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, IWailaConfigHandler config);
|
||||
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
|
||||
* body to where you mostly want to put informations, and I reserve the tail for modname display
|
||||
@@ -32,6 +27,6 @@ public interface IWailaBlock {
|
||||
* Always return the currenttip is you don't want to modify the current zone.
|
||||
*/
|
||||
|
||||
List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Block getBlock();
|
||||
int getBlockID();
|
||||
int getMetadata();
|
||||
TileEntity getTileEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package mcp.mobius.waila.api;
|
||||
public interface IWailaRegistrar {
|
||||
/* Add a config option in the section modname with displayed text configtext and access key keyname */
|
||||
public void addConfig(String modname, String keyname, String configtext);
|
||||
public void addConfigRemote(String modname, String keyname, String configtext);
|
||||
|
||||
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
@@ -10,4 +11,10 @@ public interface IWailaRegistrar {
|
||||
|
||||
/* Register a stack overrider for the given blockID */
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
|
||||
|
||||
|
||||
/* Same thing, but works on a class hierarchy instead */
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
|
||||
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
|
||||
}
|
||||
@@ -7,8 +7,13 @@ import org.lwjgl.input.Keyboard;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.handlers.DataAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
@@ -19,14 +24,17 @@ public class ConfigKeyHandler extends KeyHandler {
|
||||
{
|
||||
super(new KeyBinding[]{
|
||||
new KeyBinding("key.wailaconfig", Keyboard.KEY_NUMPAD0),
|
||||
new KeyBinding("key.wailadisplay", Keyboard.KEY_NUMPAD1)
|
||||
new KeyBinding("key.wailadisplay", Keyboard.KEY_NUMPAD1),
|
||||
new KeyBinding("key.wailatedump", Keyboard.KEY_NUMPAD1),
|
||||
}, new boolean[]{
|
||||
false,
|
||||
false,
|
||||
false
|
||||
});
|
||||
|
||||
LanguageRegistry.instance().addStringLocalization("key.wailaconfig", "[Waila] Config screen");
|
||||
LanguageRegistry.instance().addStringLocalization("key.wailadisplay", "[Waila] Show/Hide");
|
||||
LanguageRegistry.instance().addStringLocalization("key.wailadisplay", "[Waila] Show/Hide");
|
||||
LanguageRegistry.instance().addStringLocalization("key.wailatedump", "[Waila] Dump server TE");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +52,56 @@ public class ConfigKeyHandler extends KeyHandler {
|
||||
else if (kb.keyDescription == "key.wailadisplay" && !ConfigHandler.instance().getConfig("waila.showmode")){
|
||||
NEIClientConfig.getSetting("options.inworld tooltips").setBooleanValue(true);
|
||||
}
|
||||
else if (kb.keyDescription == "key.wailatedump"){
|
||||
this.dumpTag(DataAccessor.instance.remoteNbt, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dumpTag(NBTTagCompound nbt, int tab){
|
||||
if (nbt == null) return;
|
||||
|
||||
for (Object s : nbt.tagMap.keySet()){
|
||||
for (int i = 0; i < tab; i++)
|
||||
System.out.printf("\t");
|
||||
|
||||
String key = (String)s;
|
||||
NBTBase tag = nbt.getTag(key);
|
||||
String tagtype = tag.getClass().getSimpleName();
|
||||
|
||||
if (!(tag instanceof NBTTagCompound) && !(tag instanceof NBTTagList))
|
||||
System.out.printf("[%s]%s : %s\n", tagtype, key, tag);
|
||||
|
||||
if (tag instanceof NBTTagByteArray){
|
||||
byte[] array = nbt.getByteArray(key);
|
||||
for (int i = 0; i < array.length; i++)
|
||||
System.out.printf("%s ", array[i]);
|
||||
System.out.printf("\n");
|
||||
}
|
||||
|
||||
if (tag instanceof NBTTagCompound){
|
||||
System.out.printf("[%s]%s\n", tagtype, s);
|
||||
this.dumpTag(nbt.getCompoundTag(key), tab + 1);
|
||||
}
|
||||
|
||||
if (tag instanceof NBTTagList){
|
||||
System.out.printf("[%s]%s\n", tagtype, s);
|
||||
|
||||
for (Object o : nbt.getTagList(key).tagList){
|
||||
NBTBase subtag = (NBTBase)o;
|
||||
|
||||
if (!(subtag instanceof NBTTagCompound))
|
||||
System.out.printf("[%s]%s : %s\n", subtag.getClass().getSimpleName(), subtag.getName(), subtag);
|
||||
|
||||
if (subtag instanceof NBTTagCompound)
|
||||
this.dumpTag((NBTTagCompound)subtag, tab + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
|
||||
if (!tickEnd) return;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.gui.widget.ContainerTable;
|
||||
import mcp.mobius.waila.gui.widget.Label;
|
||||
import mcp.mobius.waila.gui.widget.StackDisplay;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
public class GUIEnchantScreen extends GuiBaseWailaScreen {
|
||||
|
||||
public ContainerTable widTable;
|
||||
public StackDisplay widStackDisplay;
|
||||
public Label widStackName;
|
||||
public Label widStackEnchantability;
|
||||
|
||||
public GUIEnchantScreen(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
this.zLevel = -1.0F;
|
||||
|
||||
this.widTable = new ContainerTable(this);
|
||||
this.widStackDisplay = new StackDisplay(this);
|
||||
this.widStackName = new Label(this);
|
||||
this.widStackEnchantability = new Label(this);
|
||||
|
||||
this.widTable.setColumns(8, "\u00a7a\u00a7oName", "\u00a7a\u00a7oMin lvl", "\u00a7a\u00a7oMax lvl", "\u00a7a\u00a7oMod");
|
||||
this.widTable.setHeight(this.res.getScaledHeight() - 16 - 32);
|
||||
|
||||
this.addWidget("datatable", this.widTable);
|
||||
this.addWidget("stackdisplay", this.widStackDisplay);
|
||||
this.addWidget("stackname", this.widStackName);
|
||||
this.addWidget("stackenchant", this.widStackEnchantability);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we draw anything special, and super takes care of the buttons for us */
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
//this.parentGui.drawScreen(i, j, f);
|
||||
//this.parentGui.allowUserInput = false;
|
||||
|
||||
super.drawScreen(i, j, f);
|
||||
widTable.draw(this.getXCentered(widTable.getWidth()), 32, 0);
|
||||
widStackDisplay.draw(this.getXCentered(widTable.getWidth()), 0, 0);
|
||||
widStackName.draw(this.getXCentered(widTable.getWidth())+32, 0, 0);
|
||||
widStackEnchantability.draw(this.getXCentered(widTable.getWidth())+32, 8, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDefaultBackground()
|
||||
{
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import mcp.mobius.waila.gui.widget.Button2States;
|
||||
import mcp.mobius.waila.gui.widget.ButtonChangeScreen;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiBaseConfigScreen extends GuiScreen {
|
||||
|
||||
protected GuiScreen parentGui; // GUI we will return to in the case we are call from a GUI
|
||||
|
||||
public GuiBaseConfigScreen(GuiScreen _parentGui) {
|
||||
this.parentGui = _parentGui;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we draw anything special, and super takes care of the buttons for us */
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we handle key presses. Super will just close the gui on ESC, and we like it like that */
|
||||
public void keyTyped(char keyChar, int keyID)
|
||||
{
|
||||
super.keyTyped(keyChar, keyID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
if (guibutton instanceof ButtonChangeScreen)
|
||||
((ButtonChangeScreen)guibutton).pressButton();
|
||||
|
||||
else if (guibutton instanceof Button2States)
|
||||
((Button2States)guibutton).pressButton();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import mcp.mobius.waila.gui.widget.IWidget;
|
||||
import mcp.mobius.waila.gui.widget_old.Button2States;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
public class GuiBaseWailaScreen extends GuiScreen{
|
||||
|
||||
protected GuiScreen parentGui; // GUI we will return to in the case we are call from a GUI
|
||||
public ScaledResolution res;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
|
||||
/* Custom mouse handling */
|
||||
private int lastMouseButton = -1;
|
||||
private long lastMouseEvent = -1;
|
||||
private static int buttonCount = Mouse.getButtonCount();
|
||||
private boolean[] buttonStates = new boolean[buttonCount];
|
||||
|
||||
|
||||
|
||||
public GuiBaseWailaScreen(GuiScreen _parentGui) {
|
||||
this.parentGui = _parentGui;
|
||||
res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
Mouse.getDWheel();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we draw anything special, and super takes care of the buttons for us */
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we handle key presses. Super will just close the gui on ESC, and we like it like that */
|
||||
public void keyTyped(char keyChar, int keyID)
|
||||
{
|
||||
if (keyID == 1)
|
||||
{
|
||||
if (this.parentGui == null){
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
this.mc.setIngameFocus();
|
||||
} else {
|
||||
this.mc.displayGuiScreen(this.parentGui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
if (guibutton instanceof ButtonChangeScreen)
|
||||
((ButtonChangeScreen)guibutton).pressButton();
|
||||
|
||||
else if (guibutton instanceof Button2States)
|
||||
((Button2States)guibutton).pressButton();
|
||||
}
|
||||
|
||||
protected int getXCentered(int width){
|
||||
return (this.res.getScaledWidth() - width)/ 2;
|
||||
}
|
||||
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget == null || !widget.mouseClicked(mouseX, mouseY, buttonID))
|
||||
super.mouseClicked(mouseX, mouseY, buttonID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget == null || !widget.mouseMovedOrUp(mouseX, mouseY, buttonID))
|
||||
super.mouseMovedOrUp(mouseX, mouseY, buttonID);
|
||||
}
|
||||
|
||||
public void mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
}
|
||||
|
||||
public void mouseMoved(int mouseX, int mouseY){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseMoved(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
|
||||
//System.out.printf("%s %s %s %s %s %s\n", mouseX, mouseY, buttonID, deltaTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
int mouseZ = Mouse.getEventDWheel();
|
||||
|
||||
if (mouseZ != 0)
|
||||
this.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
int changedButton = -1;
|
||||
boolean hasStateChanged = false;
|
||||
if (Mouse.getEventButtonState()){
|
||||
hasStateChanged = true;
|
||||
changedButton = Mouse.getEventButton();
|
||||
}
|
||||
for (int i = 0; i < this.buttonStates.length; i++)
|
||||
this.buttonStates[i] = Mouse.isButtonDown(i);
|
||||
|
||||
if (hasStateChanged)
|
||||
{
|
||||
this.lastMouseButton = changedButton;
|
||||
this.lastMouseEvent = Minecraft.getSystemTime();
|
||||
this.mouseClicked(mouseX, mouseY, this.lastMouseButton);
|
||||
}
|
||||
else if (changedButton != -1)
|
||||
{
|
||||
this.lastMouseButton = -1;
|
||||
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
|
||||
}
|
||||
else if (this.lastMouseButton != -1 && this.lastMouseEvent > 0L)
|
||||
{
|
||||
long deltaTime = Minecraft.getSystemTime() - this.lastMouseEvent;
|
||||
this.mouseDragged(mouseX, mouseY, this.lastMouseButton, deltaTime);
|
||||
}
|
||||
else if (Mouse.getDX() != 0 || Mouse.getDY() != 0)
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
}
|
||||
|
||||
private IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import mcp.mobius.waila.gui.widget.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget.ContainerButtons;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiConfigScreen extends GuiBaseConfigScreen {
|
||||
public class GuiConfigScreen extends GuiBaseWailaScreen {
|
||||
|
||||
public GuiConfigScreen(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.widget.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget.ButtonConfigOption;
|
||||
import mcp.mobius.waila.gui.widget.ContainerButtons;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonConfigRemote;
|
||||
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiModuleOptions extends GuiBaseConfigScreen {
|
||||
public class GuiModuleOptions extends GuiBaseWailaScreen {
|
||||
|
||||
private String modName;
|
||||
|
||||
@@ -22,7 +23,10 @@ public class GuiModuleOptions extends GuiBaseConfigScreen {
|
||||
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
|
||||
|
||||
for (String key:ConfigHandler.instance().getConfigKeys(this.modName).keySet()){
|
||||
container.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
|
||||
if (ConfigHandler.instance().isServerRequired(key))
|
||||
container.addButton(new ButtonConfigRemote(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
|
||||
else
|
||||
container.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package mcp.mobius.waila.gui;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.widget.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget.ContainerButtons;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiModules extends GuiBaseConfigScreen {
|
||||
public class GuiModules extends GuiBaseWailaScreen {
|
||||
|
||||
private HashMap<String, GuiScreen> screens = new HashMap<String, GuiScreen>();
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package mcp.mobius.waila.gui;
|
||||
|
||||
import mcp.mobius.waila.gui.widget.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget.ButtonConfigNEI;
|
||||
import mcp.mobius.waila.gui.widget.ButtonConfigOption;
|
||||
import mcp.mobius.waila.gui.widget.ContainerButtons;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonConfigNEI;
|
||||
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
|
||||
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiWailaConfig extends GuiBaseConfigScreen {
|
||||
public class GuiWailaConfig extends GuiBaseWailaScreen {
|
||||
|
||||
public GuiWailaConfig(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
@@ -20,7 +20,7 @@ public class GuiWailaConfig extends GuiBaseConfigScreen {
|
||||
|
||||
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
|
||||
container.addButton(new ButtonConfigNEI(-1, "Hidden", "Shown", "Show/Hide Waila", "options.inworld tooltips" ));
|
||||
container.addButton(new ButtonConfigOption(-1, "Maintened", "Toggled", "Toggle/Maintened", "waila.showmode" ));
|
||||
container.addButton(new ButtonConfigOption(-1, "Maintained", "Toggled", "Toggle/Maintained", "waila.showmode" ));
|
||||
container.addButton(new ButtonConfigOption(-1, "Hidden", "Visible", "Show ID:Metadata", "waila.showmetadata", false ));
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
|
||||
public abstract class BaseWidget implements IWidget {
|
||||
|
||||
protected int width, height;
|
||||
protected String label;
|
||||
protected int posX, posY, posZ;
|
||||
protected GuiScreen parent;
|
||||
protected FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;;
|
||||
protected RenderEngine renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
|
||||
public BaseWidget(){}
|
||||
|
||||
@Override
|
||||
public abstract int getWidth();
|
||||
@Override
|
||||
public abstract int getHeight();
|
||||
@Override
|
||||
public void setWidth(int width) { this.width = width; }
|
||||
@Override
|
||||
public void setHeight(int height) { this.height = height; }
|
||||
|
||||
@Override
|
||||
public void setPos (int posX, int posY, int posZ){
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posZ = posZ;
|
||||
}
|
||||
@Override
|
||||
public int getPosX(){return this.posX;}
|
||||
@Override
|
||||
public int getPosY(){return this.posY;}
|
||||
|
||||
@Override
|
||||
public String getLabel(){ return this.label;}
|
||||
@Override
|
||||
public void setLabel(String label){ this.label = label; }
|
||||
|
||||
@Override
|
||||
public abstract void draw();
|
||||
@Override
|
||||
public void draw(int x, int y, int z){
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseClicked(mouseX, mouseY, buttonID);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){return false;}
|
||||
@Override
|
||||
public boolean mouseMovedOrUp(int mouseX, int mouseY, int buttonID){return false;}
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){return false;}
|
||||
|
||||
public void startScissorFilter(int posX, int posY, int width, int height){
|
||||
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
int scaleFactor = res.getScaleFactor();
|
||||
|
||||
int glLeft = posX * scaleFactor;
|
||||
int glBottom = (res.getScaledHeight() - (posY + height)) * scaleFactor;
|
||||
|
||||
GL11.glScissor(posX*scaleFactor, glBottom, width*scaleFactor, height*scaleFactor);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
public void stopScissorFilter(){
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
@Override
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
@Override
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSlot;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
public class ContainerTable extends BaseWidget{
|
||||
int rowHeight;
|
||||
int ncolumns;
|
||||
//int viewportYPos = 0;
|
||||
int tableHeight = 0;
|
||||
int tableWidth = 0;
|
||||
int scrollWidth = 8;
|
||||
int scrollButtonHeight = 16;
|
||||
boolean isScrollActive = false;
|
||||
FontRenderer fontRender;
|
||||
int[] columnPos;
|
||||
int[] columnWidth;
|
||||
ArrayList<IWidget[]> table = new ArrayList<IWidget[]>();
|
||||
VerticalScrollBar scrollbar = new VerticalScrollBar();
|
||||
Label[] columnnames;
|
||||
|
||||
public ContainerTable(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
};
|
||||
|
||||
public ContainerTable( GuiScreen parent, int height, int ncolumns, String[] columnnames) {
|
||||
this.parent = parent;
|
||||
this.height = height;
|
||||
this.rowHeight = 8;
|
||||
this.fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
this.ncolumns = ncolumns;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(columnnames[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
}
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
}
|
||||
|
||||
public void setColumns(int rowHeight, String... header){
|
||||
this.rowHeight = rowHeight;
|
||||
this.ncolumns = header.length;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(header[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.table.size();
|
||||
}
|
||||
|
||||
public void addRow(IWidget... data){
|
||||
this.table.add(data);
|
||||
for (int i = 0; i < data.length; i++)
|
||||
this.addWidget(String.format("row_%s_%s", this.table.size(), i), data[i]);
|
||||
|
||||
for (int i = 0; i < ncolumns; i++){
|
||||
this.columnWidth[i] = Math.max(data[i].getWidth() + 8, this.columnWidth[i]);
|
||||
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
|
||||
}
|
||||
|
||||
this.columnPos[0] = 0;
|
||||
for (int i = 1; i < this.ncolumns; i++)
|
||||
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
|
||||
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawTitle(this.posX, this.posY);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
|
||||
this.startScissorFilter(this.posX, this.posY + this.rowHeight, this.getWidth(), this.getViewportHeight());
|
||||
|
||||
for (int i = 0; i < this.table.size(); i++)
|
||||
this.drawRow(i, this.posX, this.posY+(i+1)*this.rowHeight);
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.isScrollActive){
|
||||
this.updateScrollBar();
|
||||
this.scrollbar.draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateScrollBar(){
|
||||
int scrollbarX = this.posX + this.getWidth() - this.scrollWidth;
|
||||
int scrollbarY = this.posY + this.rowHeight;
|
||||
int scrollbarW = this.scrollWidth;
|
||||
int scrollbarH = this.getViewportHeight();
|
||||
int maxvalue = this.getTableHeight() - this.getViewportHeight();
|
||||
|
||||
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
int width = 0;
|
||||
for (int i: this.columnWidth)
|
||||
width += i;
|
||||
|
||||
if (this.isScrollActive)
|
||||
width += this.scrollWidth;
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getTableHeight(){
|
||||
return this.rowHeight * this.getSize();
|
||||
}
|
||||
|
||||
public int getViewportHeight(){
|
||||
return this.getHeight() - this.rowHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeight(int height){
|
||||
this.height = height;
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
public void drawTitle(int rowleft, int rowtop)
|
||||
{
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
this.columnnames[j].setWidth(this.columnWidth[j]);
|
||||
this.columnnames[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRow(int index, int rowleft, int rowtop)
|
||||
{
|
||||
if (index%2 == 0)
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff333333, 0xff333333);
|
||||
else
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff000000, 0xff000000);
|
||||
|
||||
IWidget[] data = this.table.get(index);
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
data[j].setWidth(this.columnWidth[j]);
|
||||
data[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IWidget {
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
String getLabel();
|
||||
int getPosX();
|
||||
int getPosY();
|
||||
|
||||
void setWidth(int width);
|
||||
void setHeight(int height);
|
||||
void setLabel(String label);
|
||||
void setPos(int posX, int posY, int posZ);
|
||||
|
||||
boolean mouseClicked(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseWheel(int mouseX, int mouseY, int mouseZ);
|
||||
boolean mouseMovedOrUp(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseMoved(int mouseX, int mouseY);
|
||||
|
||||
void draw();
|
||||
void draw(int x, int y, int z);
|
||||
|
||||
IWidget getWidgetAtCoordinates(int posX, int posY);
|
||||
public void addWidget(String name, IWidget widget);
|
||||
public Collection<IWidget> getWidgets();
|
||||
public IWidget getWidget(String name);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class Label extends BaseWidget {
|
||||
|
||||
public Label(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Label(GuiScreen parent, String label){
|
||||
this.parent = parent;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public Label(String label){
|
||||
this.parent = null;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public int getCharWidth(){
|
||||
return this.fontRenderer.getCharWidth((char)32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.renderString(this.posX, this.posY, 0, 0xffffffff);
|
||||
}
|
||||
|
||||
public String getTrimLabel(){
|
||||
int maxchars = this.width / this.getCharWidth();
|
||||
return this.label.substring(0, Math.min(this.label.length(), maxchars));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String label){
|
||||
this.label = label;
|
||||
this.width = this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
public void renderString(int x, int y, int z, int color){
|
||||
//this.fontrender.drawString(this.getTrimLabel(), x, y, color);
|
||||
this.fontRenderer.drawString(this.getLabel(), x, y, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class StackDisplay extends BaseWidget {
|
||||
|
||||
protected static RenderItem drawItems = new RenderItem();
|
||||
protected ItemStack stack;
|
||||
protected Icon icon;
|
||||
protected int sizeX;
|
||||
protected int sizeY;
|
||||
|
||||
public StackDisplay(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
};
|
||||
|
||||
public void setStack(ItemStack stack){
|
||||
this.stack = stack;
|
||||
this.icon = stack.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
drawItems.renderItemAndEffectIntoGUI(this.fontRenderer, this.renderEngine, this.stack, this.posX, this.posY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class VerticalScrollBar extends BaseWidget {
|
||||
|
||||
private int maxvalue;
|
||||
private int currvalue = 0;
|
||||
private int buttonH;
|
||||
private int buttonTop;
|
||||
private int step = 6;
|
||||
|
||||
public VerticalScrollBar(){};
|
||||
|
||||
public void setup(GuiScreen parent, int posX, int posY, int width, int height, int buttonH, int maxvalue) {
|
||||
this.parent = parent;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.maxvalue = maxvalue;
|
||||
this.buttonH = buttonH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
this.posY,
|
||||
this.posX + this.getWidth(),
|
||||
this.posY + this.getHeight(),
|
||||
0xff999999, 0xff999999);
|
||||
|
||||
float currentRatio = (float)(this.currvalue) / (float)(this.maxvalue);
|
||||
this.buttonTop = (int)((this.getHeight() - this.buttonH) * currentRatio) + this.posY;
|
||||
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
buttonTop,
|
||||
this.posX + this.getWidth(),
|
||||
buttonTop + this.buttonH,
|
||||
0xffffffff, 0xffffffff);
|
||||
|
||||
}
|
||||
|
||||
public void setCurrentValue(int currvalue){
|
||||
this.currvalue = currvalue;
|
||||
}
|
||||
|
||||
public void addCurrentValue(int value){
|
||||
this.currvalue += value;
|
||||
this.currvalue = Math.max(0, this.currvalue);
|
||||
this.currvalue = Math.min(this.maxvalue, this.currvalue);
|
||||
}
|
||||
|
||||
public int getCurrentValue(){
|
||||
return this.currvalue;
|
||||
}
|
||||
|
||||
public int getStep(){
|
||||
return this.step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
if(mouseY < this.buttonTop)
|
||||
this.addCurrentValue(-1 * this.step);
|
||||
else if (mouseY > this.buttonTop + this.buttonH)
|
||||
this.addCurrentValue(this.step);
|
||||
else
|
||||
System.out.printf("Clicked on button\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
@@ -0,0 +1,43 @@
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ButtonConfigRemote extends ButtonConfigOption {
|
||||
|
||||
public ButtonConfigRemote(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey) {
|
||||
super(par1, _stateFalse, _stateTrue, _label, _configKey);
|
||||
}
|
||||
public ButtonConfigRemote(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey, boolean _state) {
|
||||
super(par1, _stateFalse, _stateTrue, _label, _configKey, _state);
|
||||
}
|
||||
public ButtonConfigRemote(int par1, int par2, int par3, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
|
||||
super(par1, par2, par3, _stateFalse, _stateTrue, _label, _labelSize, _state, _configKey);
|
||||
}
|
||||
|
||||
public ButtonConfigRemote(int par1, int par2, int par3, int par4, int par5, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
|
||||
super(par1, par2, par3, par4, par5, _stateFalse, _stateTrue, _label, _labelSize, _state, _configKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
this.enabled = mod_Waila.instance.serverPresent;
|
||||
super.drawButton(par1Minecraft, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
this.enabled = mod_Waila.instance.serverPresent;
|
||||
return super.mousePressed(par1Minecraft, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHoverState(boolean par1)
|
||||
{
|
||||
this.enabled = mod_Waila.instance.serverPresent;
|
||||
return super.getHoverState(par1);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.gui.widget;
|
||||
package mcp.mobius.waila.gui.widget_old;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
public class DataAccessor implements IWailaDataAccessor {
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Block block;
|
||||
public int blockID;
|
||||
public int metadata;
|
||||
public TileEntity entity;
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
|
||||
public static DataAccessor instance = new DataAccessor();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.block = Block.blocksList[this.blockID];
|
||||
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = world.getBlockTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNbt))
|
||||
return this.remoteNbt;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
NBTBase subtag = tag.getTag(keyname);
|
||||
if (subtag instanceof NBTTagInt)
|
||||
return tag.getInteger(keyname);
|
||||
if (subtag instanceof NBTTagShort)
|
||||
return tag.getShort(keyname);
|
||||
if (subtag instanceof NBTTagByte)
|
||||
return tag.getByte(keyname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockID() {
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
if (tag == null){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+74
-12
@@ -1,13 +1,25 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.gui.GUIEnchantScreen;
|
||||
import mcp.mobius.waila.gui.widget.ContainerTable;
|
||||
import mcp.mobius.waila.gui.widget.Label;
|
||||
import mcp.mobius.waila.gui.widget.StackDisplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.forge.IContainerInputHandler;
|
||||
|
||||
public class EnchantementHandler implements IContainerInputHandler {
|
||||
public class EnchantmentHandler implements IContainerInputHandler {
|
||||
|
||||
static Class EplusApi;
|
||||
static Method Tooltip;
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -25,17 +37,27 @@ public class EnchantementHandler implements IContainerInputHandler {
|
||||
ItemStack stackover = gui.manager.getStackMouseOver();
|
||||
if(stackover == null)
|
||||
return false;
|
||||
|
||||
|
||||
if(keyID == NEIClientConfig.getKeyBinding("showenchant")){
|
||||
try{
|
||||
System.out.printf("==== ENCHANTS ====\n");
|
||||
|
||||
//try{
|
||||
int itemEnchantability = stackover.getItem().getItemEnchantability();
|
||||
if (itemEnchantability == 0){return false;}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GUIEnchantScreen enchantScreen = new GUIEnchantScreen(mc.currentScreen);
|
||||
enchantScreen.widStackDisplay.setStack(stackover);
|
||||
enchantScreen.widStackName.setLabel("\u00a7f" + stackover.getDisplayName());
|
||||
enchantScreen.widStackEnchantability.setLabel(String.format("\u00a7fEnchantability : %s", itemEnchantability));
|
||||
|
||||
for(Enchantment enchant : Enchantment.enchantmentsList){
|
||||
Enchantment[] enchants = null;
|
||||
if (stackover.getItem() == Item.book)
|
||||
enchants = Enchantment.field_92090_c;
|
||||
else
|
||||
enchants = Enchantment.enchantmentsList;
|
||||
|
||||
for(Enchantment enchant : enchants){
|
||||
if (enchant == null){continue;}
|
||||
if (enchant.canApplyAtEnchantingTable(stackover)){
|
||||
if (enchant.canApplyAtEnchantingTable(stackover) || stackover.getItem() == Item.book){
|
||||
for (int lvl = enchant.getMinLevel(); lvl <= enchant.getMaxLevel(); lvl++){
|
||||
int minEnchantEnchantability = enchant.getMinEnchantability(lvl);
|
||||
int maxEnchantEnchantability = enchant.getMaxEnchantability(lvl);
|
||||
@@ -54,18 +76,41 @@ public class EnchantementHandler implements IContainerInputHandler {
|
||||
int meanMinLevel = (int) ((minEnchantEnchantability - meanModifiedEnchantability)/1.0);
|
||||
int meanMaxLevel = (int) ((maxEnchantEnchantability - meanModifiedEnchantability)/1.0);
|
||||
|
||||
System.out.printf("%s [%s / %s / %s / %s]\n", enchant.getTranslatedName(lvl), minLevel, maxLevel, meanMinLevel, meanMaxLevel);
|
||||
enchantScreen.widTable.addRow(new Label(enchant.getTranslatedName(lvl)),
|
||||
new Label(String.valueOf(minLevel)),
|
||||
new Label(String.valueOf(maxLevel)),
|
||||
//new Label(String.valueOf(meanMinLevel)),
|
||||
//new Label(String.valueOf(meanMaxLevel)),
|
||||
new Label("\u00a79\u00a7o"+ this.getEnchantModName(enchant))
|
||||
);
|
||||
|
||||
//String description = this.getEnchantmentToolTip(enchant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e){
|
||||
System.out.printf("%s\n", e);
|
||||
}
|
||||
mc.displayGuiScreen(enchantScreen);
|
||||
//}
|
||||
//catch (NullPointerException e){
|
||||
// System.out.printf("%s\n", e);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getEnchantModName(Enchantment enchant){
|
||||
String enchantPath = enchant.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
|
||||
String enchantModName = "<Unknown>";
|
||||
for (String s: mod_Waila.instance.modSourceList.keySet())
|
||||
if (enchantPath.contains(s))
|
||||
enchantModName = mod_Waila.instance.modSourceList.get(s);
|
||||
|
||||
if (enchantModName.equals("Minecraft Coder Pack"))
|
||||
enchantModName = "Minecraft";
|
||||
return enchantModName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
@@ -107,4 +152,21 @@ public class EnchantementHandler implements IContainerInputHandler {
|
||||
|
||||
}
|
||||
|
||||
private String getEnchantmentToolTip(Enchantment enchantment) {
|
||||
try {
|
||||
|
||||
if (EplusApi == null) {
|
||||
EplusApi = Class.forName("eplus.api.EplusApi");
|
||||
}
|
||||
|
||||
if (Tooltip == null) {
|
||||
Tooltip = EplusApi.getMethod("getEnchantmentToolTip", Enchantment.class);
|
||||
}
|
||||
|
||||
return String.valueOf(Tooltip.invoke(null, enchantment));
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaBlock;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.network.Packet0x01TERequest;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,47 +19,121 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class HUDHandlerExternal implements IHighlightHandler {
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
Block block = Block.blocksList[blockID];
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (IWailaBlock.class.isInstance(block))
|
||||
return ((IWailaBlock)block).getWailaStack(world, player, entity, block, mop, ConfigHandler.instance());
|
||||
|
||||
if(ExternalModulesHandler.instance().hasStackProviders(blockID))
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
|
||||
ItemStack retval = dataProvider.getWailaStack(world, player, entity, block, mop, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
return retval;
|
||||
if (IWailaBlock.class.isInstance(block)){
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaStack(accessor, ConfigHandler.instance());
|
||||
}catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, block.getClass().toString(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(ExternalModulesHandler.instance().hasStackProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
|
||||
try{
|
||||
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
return retval;
|
||||
}catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
Block block = Block.blocksList[blockID];
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (IWailaBlock.class.isInstance(block))
|
||||
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent && (System.currentTimeMillis() - accessor.timeLastUpdate >= 250) ){
|
||||
accessor.timeLastUpdate = System.currentTimeMillis();
|
||||
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
|
||||
}
|
||||
|
||||
if (IWailaBlock.class.isInstance(block)){
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
if (layout == Layout.HEADER)
|
||||
return ((IWailaBlock)block).getWailaHead(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
|
||||
}
|
||||
else if (layout == Layout.BODY)
|
||||
return ((IWailaBlock)block).getWailaBody(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID))
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(blockID))
|
||||
currenttip = dataProvider.getWailaHead(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID))
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(blockID))
|
||||
currenttip = dataProvider.getWailaBody(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(block))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(block))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(accessor.getTileEntity())){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(accessor.getTileEntity()))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(accessor.getTileEntity())){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(accessor.getTileEntity()))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
@@ -26,9 +27,13 @@ public class HUDHandlerWaila implements IHighlightHandler {
|
||||
if (modName != null && !modName.equals(""))
|
||||
currenttip.add("\u00a79\u00a7o" + modName);
|
||||
} else if (layout == Layout.HEADER && ConfigHandler.instance().getConfig("waila.showmetadata", false)){
|
||||
String name = currenttip.get(0);
|
||||
currenttip.set(0, name + String.format(" %s:%s", world.getBlockId(mop.blockX, mop.blockY, mop.blockZ), world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ)));
|
||||
}
|
||||
if (currenttip.size() == 0)
|
||||
currenttip.add("< Unnamed >");
|
||||
else{
|
||||
String name = currenttip.get(0);
|
||||
currenttip.set(0, name + String.format(" %s:%s", world.getBlockId(mop.blockX, mop.blockY, mop.blockZ), world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ)));
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.util.logging.Logger;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.network.WailaConnectionHandler;
|
||||
import mcp.mobius.waila.network.WailaPacketHandler;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -14,6 +17,7 @@ import net.minecraftforge.common.Configuration;
|
||||
import codechicken.core.CommonUtils;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.IMCCallback;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
@@ -25,23 +29,27 @@ import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
|
||||
@Mod(modid="Waila", name="Waila", version="1.2.0_RC1")
|
||||
//@NetworkMod(channels = {"Waila"},clientSideRequired=true, serverSideRequired=false)
|
||||
@Mod(modid="Waila", name="Waila", version="1.3.4_dev")
|
||||
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class, packetHandler = WailaPacketHandler.class)
|
||||
|
||||
public class mod_Waila {
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("Waila")
|
||||
public static mod_Waila instance;
|
||||
|
||||
@SidedProxy(clientSide="mcp.mobius.waila.ProxyClient", serverSide="mcp.mobius.waila.ProxyServer")
|
||||
@SidedProxy(clientSide="mcp.mobius.waila.ProxyClient", serverSide="mcp.mobius.waila.server.ProxyServer")
|
||||
public static ProxyServer proxy;
|
||||
|
||||
public static Logger log = Logger.getLogger("Waila");
|
||||
private HashMap<Integer, String> itemMap = new HashMap<Integer, String>();
|
||||
public Configuration config = null;
|
||||
public boolean serverPresent = false;
|
||||
public HashMap<String, String> modSourceList = new HashMap<String, String>();
|
||||
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@@ -65,6 +73,16 @@ public class mod_Waila {
|
||||
ItemData itemData = new ItemData((NBTTagCompound) itemDataList.tagAt(i));
|
||||
this.itemMap.put(itemData.getItemId(), itemData.getModId());
|
||||
}
|
||||
|
||||
for (ModContainer mod : Loader.instance().getModList()) {
|
||||
this.modSourceList.put(mod.getSource().getName(), mod.getName());
|
||||
System.out.printf("%s\n", mod.getSource().getName());
|
||||
}
|
||||
|
||||
// for (String s : this.modSourceList.keySet())
|
||||
// if (this.modSourceList.get(s) == "Minecraft Coder Pack")
|
||||
// this.modSourceList.put(s, "Minecraft");
|
||||
|
||||
}
|
||||
|
||||
@IMCCallback
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
public class Packet0x00ServerPing {
|
||||
|
||||
public byte header;
|
||||
|
||||
public Packet0x00ServerPing(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x00);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Packet0x01TERequest {
|
||||
|
||||
public byte header;
|
||||
public int worldID;
|
||||
public int posX;
|
||||
public int posY;
|
||||
public int posZ;
|
||||
|
||||
public Packet0x01TERequest(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.worldID = inputStream.readInt();
|
||||
this.posX = inputStream.readInt();
|
||||
this.posY = inputStream.readInt();
|
||||
this.posZ = inputStream.readInt();
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(World world, MovingObjectPosition mop){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x01);
|
||||
outputStream.writeInt(world.getWorldInfo().getDimension());
|
||||
outputStream.writeInt(mop.blockX);
|
||||
outputStream.writeInt(mop.blockY);
|
||||
outputStream.writeInt(mop.blockZ);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
public class Packet0x02TENBTData {
|
||||
public byte header;
|
||||
public NBTTagCompound tag;
|
||||
|
||||
public Packet0x02TENBTData(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.tag = Packet0x02TENBTData.readNBTTagCompound(inputStream);
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(NBTTagCompound tag){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x02);
|
||||
Packet0x02TENBTData.writeNBTTagCompound(tag, outputStream);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutputStream par1DataOutputStream) throws IOException
|
||||
{
|
||||
if (par0NBTTagCompound == null)
|
||||
{
|
||||
par1DataOutputStream.writeShort(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = CompressedStreamTools.compress(par0NBTTagCompound);
|
||||
par1DataOutputStream.writeShort((short)abyte.length);
|
||||
par1DataOutputStream.write(abyte);
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream) throws IOException
|
||||
{
|
||||
short short1 = par0DataInputStream.readShort();
|
||||
|
||||
if (short1 < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = new byte[short1];
|
||||
par0DataInputStream.readFully(abyte);
|
||||
return CompressedStreamTools.decompress(abyte);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class WailaConnectionHandler implements IConnectionHandler {
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
|
||||
PacketDispatcher.sendPacketToPlayer(Packet0x00ServerPing.create(), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.handlers.DataAccessor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class WailaPacketHandler implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player){
|
||||
if (packet.channel.equals("Waila")) {
|
||||
byte header = this.getHeader(packet);
|
||||
if (header == 0x00){
|
||||
mod_Waila.log.info("Received server authentication msg. Remote sync will be activated");
|
||||
mod_Waila.instance.serverPresent = true;
|
||||
}
|
||||
else if (header == 0x01){
|
||||
Packet0x01TERequest castedPacket = new Packet0x01TERequest(packet);
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
TileEntity entity = server.worldServers[castedPacket.worldID].getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
|
||||
if (entity != null){
|
||||
try{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet0x02TENBTData.create(tag), player);
|
||||
}catch(Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (header == 0x02){
|
||||
Packet0x02TENBTData castedPacket = new Packet0x02TENBTData(packet);
|
||||
DataAccessor.instance.remoteNbt = castedPacket.tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte getHeader(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
return inputStream.readByte();
|
||||
} catch (IOException e){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila;
|
||||
package mcp.mobius.waila.server;
|
||||
|
||||
public class ProxyServer {
|
||||
|
||||
Reference in new issue
Block a user