mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 17:44:46 +00:00
Compare commits
59
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb9de99f39 | ||
|
|
1580296a2c | ||
|
|
9d272f2e34 | ||
|
|
2259e27f60 | ||
|
|
716498256b | ||
|
|
bcd36dd638 | ||
|
|
f790ac948d | ||
|
|
f282be75f4 | ||
|
|
ec1ab8e548 | ||
|
|
add57cbd6b | ||
|
|
ce249c806e | ||
|
|
3f6da9018c | ||
|
|
2b7f3866a5 | ||
|
|
b83d5bd297 | ||
|
|
4e7e32fba7 | ||
|
|
2346ffd559 | ||
|
|
49a2a32a77 | ||
|
|
47fb4c55a8 | ||
|
|
b6b5404440 | ||
|
|
89fc1c8ce7 | ||
|
|
79107209d9 | ||
|
|
3533ea2d23 | ||
|
|
f1a4056431 | ||
|
|
dcc35737be | ||
|
|
4a3015eb21 | ||
|
|
d3a317e3dd | ||
|
|
9d1045333a | ||
|
|
80e30abec3 | ||
|
|
2dd88b9c13 | ||
|
|
f46d9393b5 | ||
|
|
d2f8911797 | ||
|
|
a1365b2db3 | ||
|
|
0988ee744e | ||
|
|
537c3dc1af | ||
|
|
5f7bf6cc5c | ||
|
|
904fe472b8 | ||
|
|
0ef5f65067 | ||
|
|
b6d529575d | ||
|
|
669435f153 | ||
|
|
f1c484d390 | ||
|
|
ef20dcc4c6 | ||
|
|
1bbf3e8747 | ||
|
|
3bc29dd907 | ||
|
|
23bbd2ceb4 | ||
|
|
d0e2932257 | ||
|
|
cf6ecd55e5 | ||
|
|
bfc2e5dec6 | ||
|
|
d6589ec1c1 | ||
|
|
1cadab1320 | ||
|
|
91aea326c7 | ||
|
|
d2c6d95e75 | ||
|
|
5a8673d322 | ||
|
|
917eaab8be | ||
|
|
198d0c7079 | ||
|
|
03f4bed4fe | ||
|
|
1bfcc07e1f | ||
|
|
ef9a1bedfc | ||
|
|
4121e689fd | ||
|
|
0b1911b711 |
No files matched your search
@@ -18,6 +18,8 @@ choice.showhidewaila=Show/Hide Waila
|
||||
choice.showhideidmeta=Show ID:Metadata
|
||||
choice.toggledmaintained=Toggled/Maintained
|
||||
choice.showliquids=Liquids
|
||||
choice.shifttoggledblock=Sneak toggle blocks
|
||||
choice.shifttoggledents=Sneak toggle entities
|
||||
screen.button.configureaspect=Configure aspect...
|
||||
|
||||
enchant.title.name=Name
|
||||
@@ -122,6 +124,7 @@ option.vanilla.repeater=Repeater delay
|
||||
option.vanilla.comparator=Comparator mode
|
||||
option.vanilla.redstone=Redstone power
|
||||
option.vanilla.jukebox=Jukebox disk
|
||||
option.vanilla.silverfish=Hide silverfish
|
||||
option.etb.displaydata=Show socket data
|
||||
option.enderio.inout=Show input/output
|
||||
option.enderio.storage=Show stored MJ
|
||||
@@ -134,4 +137,9 @@ option.pr.showio=Show gates IO
|
||||
option.pr.showdata=Show gates data
|
||||
option.extrautilities.fluidamount=Show fluid amount
|
||||
option.openblocks.fluidamount=Show fluid amount
|
||||
option.railcraft.fluidamount=Show fluid amount
|
||||
option.railcraft.fluidamount=Show fluid amount
|
||||
option.secretrooms.hide=Hide camo blocks
|
||||
option.carpenters.hide=Hide camo blocks
|
||||
option.stevescarts.showall=Show data
|
||||
option.stevescarts.colorblind=Colorblind mode
|
||||
option.stevescarts.shifttoggle=Shift toggle
|
||||
@@ -1,3 +0,0 @@
|
||||
#gource --file-idle-time 0 --camera-mode overview --title "Minecraft Coder Pack" -s 2 --hide-filenames --stop-at-end --disable-progress --output-ppm-stream - | ffmpeg -y -r 60 -b 6000K -f image2pipe -vcodec ppm -i - -vcodec libtheora out.ogg
|
||||
gource --file-idle-time 0 --camera-mode overview --title "Waila" -s 2 --hide-filenames --stop-at-end --disable-progress --output-ppm-stream - | ffmpeg -y -f image2pipe -vcodec ppm -i - -vpre libx264-medium -vcodec libx264 out_small.mkv
|
||||
|
||||
@@ -2,9 +2,6 @@ package mcp.mobius.waila;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
@@ -12,37 +9,25 @@ import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.client.WailaClientEventHandler;
|
||||
import mcp.mobius.waila.network.WailaConnectionHandler;
|
||||
import mcp.mobius.waila.network.WailaPacketHandler;
|
||||
import mcp.mobius.waila.overlay.OverlayConfig;
|
||||
import mcp.mobius.waila.overlay.DecoratorRenderer;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import mcp.mobius.waila.tools.Reflect;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLModContainer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.IMCCallback;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
@@ -51,63 +36,29 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
||||
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;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
@Mod(modid="Waila", name="Waila", version="1.4.5", dependencies="required-after:NotEnoughItems")
|
||||
@Mod(modid="Waila", name="Waila", version="1.5.0_dev1", dependencies="required-after:NotEnoughItems")
|
||||
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
|
||||
packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
|
||||
//packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
|
||||
packetHandler = WailaPacketHandler.class)
|
||||
|
||||
public class mod_Waila {
|
||||
public class Waila {
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("Waila")
|
||||
public static mod_Waila instance;
|
||||
public static Waila instance;
|
||||
|
||||
@SidedProxy(clientSide="mcp.mobius.waila.client.ProxyClient", serverSide="mcp.mobius.waila.server.ProxyServer")
|
||||
public static ProxyServer proxy;
|
||||
|
||||
public static Logger log = Logger.getLogger("Waila");
|
||||
public Configuration config = null;
|
||||
public boolean serverPresent = false;
|
||||
|
||||
public static int posX;
|
||||
public static int posY;
|
||||
public static int alpha;
|
||||
public static int bgcolor;
|
||||
public static int gradient1;
|
||||
public static int gradient2;
|
||||
public static int fontcolor;
|
||||
public static float scale;
|
||||
|
||||
/* INIT SEQUENCE */
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, false);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
|
||||
|
||||
|
||||
|
||||
posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
|
||||
posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
|
||||
|
||||
alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
|
||||
bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010).getInt();
|
||||
gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff).getInt();
|
||||
gradient2 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2, 0x28007f).getInt();
|
||||
fontcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR, 0xA0A0A0).getInt();
|
||||
scale = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, 100).getInt() / 100.0f;
|
||||
|
||||
config.save();
|
||||
|
||||
updateColors();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new WailaClientEventHandler());
|
||||
ConfigHandler.instance().loadDefaultConfig(event);
|
||||
OverlayConfig.updateColors();
|
||||
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -125,7 +76,7 @@ public class mod_Waila {
|
||||
proxy.registerHandlers();
|
||||
ModIdentification.init();
|
||||
|
||||
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_KEYBIND)){
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true)){
|
||||
|
||||
for (String key: ModIdentification.keyhandlerStrings.keySet()){
|
||||
String orig = I18n.getString(key);
|
||||
@@ -180,15 +131,15 @@ public class mod_Waila {
|
||||
if (imcMessage.key.equalsIgnoreCase("addconfig")){
|
||||
String[] params = imcMessage.getStringValue().split("\\$\\$");
|
||||
if (params.length != 3){
|
||||
mod_Waila.log.warning(String.format("Error while parsing config option from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
Waila.log.warning(String.format("Error while parsing config option from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
continue;
|
||||
}
|
||||
mod_Waila.log.info(String.format("Receiving config request from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
Waila.log.info(String.format("Receiving config request from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
ConfigHandler.instance().addConfig(params[0], params[1], params[2]);
|
||||
}
|
||||
|
||||
if (imcMessage.key.equalsIgnoreCase("register")){
|
||||
mod_Waila.log.info(String.format("Receiving registration request from [ %s ] for method %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
Waila.log.info(String.format("Receiving registration request from [ %s ] for method %s", imcMessage.getSender(), imcMessage.getStringValue()));
|
||||
this.callbackRegistration(imcMessage.getStringValue(), imcMessage.getSender());
|
||||
}
|
||||
}
|
||||
@@ -199,31 +150,22 @@ public class mod_Waila {
|
||||
String methodName = splitName[splitName.length-1];
|
||||
String className = method.substring(0, method.length()-methodName.length()-1);
|
||||
|
||||
mod_Waila.log.info(String.format("Trying to reflect %s %s", className, methodName));
|
||||
Waila.log.info(String.format("Trying to reflect %s %s", className, methodName));
|
||||
|
||||
try{
|
||||
Class reflectClass = Class.forName(className);
|
||||
Method reflectMethod = reflectClass.getDeclaredMethod(methodName, IWailaRegistrar.class);
|
||||
reflectMethod.invoke(null, (IWailaRegistrar)ModuleRegistrar.instance());
|
||||
|
||||
mod_Waila.log.info(String.format("Success in registering %s", modname));
|
||||
Waila.log.info(String.format("Success in registering %s", modname));
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.warning(String.format("Could not find class %s", className));
|
||||
Waila.log.warning(String.format("Could not find class %s", className));
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.warning(String.format("Could not find method %s", methodName));
|
||||
Waila.log.warning(String.format("Could not find method %s", methodName));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.warning(String.format("Exception while trying to access the method : %s", e.toString()));
|
||||
Waila.log.warning(String.format("Exception while trying to access the method : %s", e.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void updateColors(){
|
||||
alpha = (int)(ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f * 256) << 24;
|
||||
bgcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_BGCOLOR);
|
||||
gradient1 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT1);
|
||||
gradient2 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT2);
|
||||
fontcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_FONTCOLOR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.logging.Level;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class AppEngModule {
|
||||
@@ -26,18 +26,19 @@ public class AppEngModule {
|
||||
IAEItemStack_getItemStack = IAEItemStack.getMethod("getItemStack");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[AppEng] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[AppEng] Class not found. " + e);
|
||||
return;
|
||||
} catch (SecurityException e) {
|
||||
mod_Waila.log.log(Level.WARNING, "[AppEng] Security Exception. " + e);
|
||||
Waila.log.log(Level.WARNING, "[AppEng] Security Exception. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e) {
|
||||
mod_Waila.log.log(Level.WARNING, "[AppEng] Method not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[AppEng] Method not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
mod_Waila.log.log(Level.INFO, "AppEng mod found.");
|
||||
Waila.log.log(Level.INFO, "AppEng mod found.");
|
||||
ModuleRegistrar.instance().addConfig("Applied Energetic", "appeng.monitorcontent");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileStorageMonitor);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ 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.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import codechicken.nei.api.API;
|
||||
@@ -24,15 +24,15 @@ public class BetterBarrelsModule {
|
||||
IBarrelStorage_getItem = IBarrelStorage.getMethod("getItem");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BB] BetterBarrel classes not found.");
|
||||
Waila.log.log(Level.WARNING, "[BB] BetterBarrel classes not found.");
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BB] Storage field not found.");
|
||||
Waila.log.log(Level.WARNING, "[BB] Storage field not found.");
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BB] getItem() not found.");
|
||||
Waila.log.log(Level.WARNING, "[BB] getItem() not found.");
|
||||
}
|
||||
|
||||
if (IBarrelStorage_getItem != null){
|
||||
mod_Waila.log.log(Level.INFO, "Waila module BetterBarrel succefully hooked.");
|
||||
Waila.log.log(Level.INFO, "Waila module BetterBarrel succefully hooked.");
|
||||
ModuleRegistrar.instance().addConfig("BetterBarrels", "bb.content");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBBContent(), TileEntityBarrel);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
@@ -43,7 +43,7 @@ public class HUDHandlerBBContent implements IWailaDataProvider {
|
||||
try {
|
||||
stack = (ItemStack) BetterBarrelsModule.IBarrelStorage_getItem.invoke(BetterBarrelsModule.TileEntityBarrel_Storage.get(entity));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[BB] Unhandled exception trying to access a barrel storage for display !.\n" + String.valueOf(e));
|
||||
Waila.log.log(Level.SEVERE, "[BB] Unhandled exception trying to access a barrel storage for display !.\n" + String.valueOf(e));
|
||||
currenttip.add("<ERROR!>");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ 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.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
@@ -20,9 +20,9 @@ public class BCModule {
|
||||
public static void register(){
|
||||
try {
|
||||
Class ModBuildcraftFactory = Class.forName("buildcraft.BuildCraftFactory");
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
|
||||
Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
|
||||
Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ public class BCModule {
|
||||
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[BC] Class not found. " + e);
|
||||
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);
|
||||
Waila.log.log(Level.WARNING, "[BC] Method not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BCModule {
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTank);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class BCPowerAPIModule {
|
||||
@@ -30,9 +30,9 @@ public class BCPowerAPIModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModClass = Class.forName("buildcraft.api.power.IPowerReceptor");
|
||||
mod_Waila.log.log(Level.INFO, "Buildcraft Power API found.");
|
||||
Waila.log.log(Level.INFO, "Buildcraft Power API found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Buildcraft Power API] Buildcraft Power API mod not found.");
|
||||
Waila.log.log(Level.INFO, "[Buildcraft Power API] Buildcraft Power API mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,23 +56,24 @@ public class BCPowerAPIModule {
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
|
||||
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);
|
||||
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);
|
||||
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("BuildcraftAPI", "bcapi.storage");
|
||||
ModuleRegistrar.instance().addConfig("BuildcraftAPI", "bcapi.consump");
|
||||
ModuleRegistrar.instance().addConfig("BuildcraftAPI", "bcapi.trigger");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIPowerReceptor(), IPowerReceptor);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIPowerReceptor(), IPowerReceptor);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", IPowerReceptor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.logging.Level;
|
||||
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
@@ -70,7 +70,7 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
try{
|
||||
tank = ((FluidTankInfo[])BCModule.TileTank_getTankInfo.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));
|
||||
Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
|
||||
return null;
|
||||
}
|
||||
return tank;
|
||||
|
||||
@@ -5,10 +5,10 @@ import java.util.List;
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerIPowerReceptor implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package mcp.mobius.waila.addons.carpenters;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class CarpentersModule {
|
||||
|
||||
public static Class TEBase = null;
|
||||
public static Class BlockCarpentersDoor = null;
|
||||
public static Class BlockCarpentersHatch = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class CarpentersBlocks = Class.forName("carpentersblocks.CarpentersBlocks");
|
||||
Waila.log.log(Level.INFO, "CarpentersBlocks mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[CarpentersBlocks] CarpentersBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TEBase = Class.forName("carpentersblocks.tileentity.TEBase");
|
||||
BlockCarpentersDoor = Class.forName("carpentersblocks.block.BlockCarpentersDoor");
|
||||
BlockCarpentersHatch = Class.forName("carpentersblocks.block.BlockCarpentersHatch");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[CarpentersBlocks] Class not found. " + e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARNING, "[CarpentersBlocks] Error while loading module. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Carpenter's Blocks", "carpenters.hide");
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersDoor);
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersHatch);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("data", TEBase);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("cover_6", TEBase);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package mcp.mobius.waila.addons.carpenters;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDCarpentersBlocksTE implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("carpenters.hide")) return null;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
short data = tag.getShort("data");
|
||||
short cover = tag.getShort("cover_6");
|
||||
|
||||
if(CarpentersModule.BlockCarpentersDoor.isInstance(accessor.getBlock())){
|
||||
int type = data & 0x7;
|
||||
if (type != 5) return null;
|
||||
if (cover == 0) return null;
|
||||
|
||||
return new ItemStack(cover & 0xfff, 0, (cover & 0xf000) >>> 12);
|
||||
}
|
||||
|
||||
else if (CarpentersModule.BlockCarpentersHatch.isInstance(accessor.getBlock())){
|
||||
int type = data & 0x7;
|
||||
if (type != 0) return null;
|
||||
if (cover == 0) return null;
|
||||
|
||||
return new ItemStack(cover & 0xfff, 0, (cover & 0xf000) >>> 12);
|
||||
}
|
||||
|
||||
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) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class EnderIOModule {
|
||||
@@ -22,9 +22,9 @@ public class EnderIOModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModClass = Class.forName("crazypants.enderio.EnderIO");
|
||||
mod_Waila.log.log(Level.INFO, "EnderIO mod found.");
|
||||
Waila.log.log(Level.INFO, "EnderIO mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
|
||||
Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,16 +40,16 @@ public class EnderIOModule {
|
||||
TileTesseract = Class.forName("crazypants.enderio.machine.hypercube.TileHyperCube");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
|
||||
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);
|
||||
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);
|
||||
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ public class EnderIOModule {
|
||||
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.channel");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCapacitorBank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileCapacitorBank);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTesseract);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerCapacitor implements IWailaDataProvider{
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class EnderStorageModule {
|
||||
@@ -20,9 +20,9 @@ public class EnderStorageModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class EnderStorage = Class.forName("codechicken.enderstorage.EnderStorage");
|
||||
mod_Waila.log.log(Level.INFO, "EnderStorage mod found.");
|
||||
Waila.log.log(Level.INFO, "EnderStorage mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
|
||||
Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,20 +37,21 @@ public class EnderStorageModule {
|
||||
TileEnderTank = Class.forName("codechicken.enderstorage.storage.liquid.TileEnderTank");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
|
||||
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);
|
||||
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);
|
||||
Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfig("EnderStorage", "enderstorage.colors");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerStorage(), TileFrequencyOwner);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileFrequencyOwner);
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerStorage implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ETBModule {
|
||||
@@ -29,9 +29,9 @@ public class ETBModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModClass = Class.forName("emasher.sockets.TileSocket");
|
||||
mod_Waila.log.log(Level.INFO, "Engineer Toolbox mod found.");
|
||||
Waila.log.log(Level.INFO, "Engineer Toolbox mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Engineer Toolbox] Engineer Toolbox mod not found.");
|
||||
Waila.log.log(Level.INFO, "[Engineer Toolbox] Engineer Toolbox mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ public class ETBModule {
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Class not found. " + e);
|
||||
return;
|
||||
// } catch (NoSuchMethodException e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Method not found." + e);
|
||||
// return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Field not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Unhandled exception." + e);
|
||||
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfig("Engineer Toolbox", "etb.displaydata");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerSocket(), TileSocket);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileSocket);
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerSocket implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package mcp.mobius.waila.addons.exu;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ExtraUtilitiesModule {
|
||||
@@ -15,20 +15,21 @@ public class ExtraUtilitiesModule {
|
||||
|
||||
try{
|
||||
Class ModExtraUtilities = Class.forName("extrautils.ExtraUtils");
|
||||
mod_Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityDrum = Class.forName("extrautils.tileentity.TileEntityDrum");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[ExtraUtilities] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[ExtraUtilities] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityDrum);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package mcp.mobius.waila.addons.gravestone;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class GravestoneModule {
|
||||
@@ -13,20 +13,21 @@ public class GravestoneModule {
|
||||
|
||||
try{
|
||||
Class ModGravestone = Class.forName("GraveStone.ModGraveStone");
|
||||
mod_Waila.log.log(Level.INFO, "GraveStone mod found.");
|
||||
Waila.log.log(Level.INFO, "GraveStone mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[GraveStone] GraveStone mod not found.");
|
||||
Waila.log.log(Level.INFO, "[GraveStone] GraveStone mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
BlockGraveStone = Class.forName("GraveStone.block.BlockGSGraveStone");
|
||||
} catch (ClassNotFoundException e) {
|
||||
mod_Waila.log.log(Level.WARNING, "[GraveStone] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[GraveStone] Class not found. " + e);
|
||||
}
|
||||
|
||||
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockGraveStone);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.addons.harvestcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class HUDHandlerPamCrop 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) {
|
||||
int growthStage = NBTUtil.getNBTInteger(accessor.getNBTData(), "growthStage");
|
||||
|
||||
float growthValue = (growthStage / 2.0F) * 100.0F;
|
||||
if (growthValue < 100.0)
|
||||
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
|
||||
else
|
||||
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
|
||||
return currenttip;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package mcp.mobius.waila.addons.harvestcraft;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class HarvestcraftModule {
|
||||
public static Class TileEntityPamCrop = null;
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class PamHarvestCraft = Class.forName("assets.pamharvestcraft.PamHarvestCraft");
|
||||
Waila.log.log(Level.INFO, "PamHarvestCraft mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[PamHarvestCraft] PamHarvestCraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityPamCrop = Class.forName("assets.pamharvestcraft.TileEntityPamCrop");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[PamHarvestCraft] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerPamCrop(), TileEntityPamCrop);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
|
||||
@@ -50,7 +51,7 @@ public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
if ( stored >= 0.0 && storage > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
|
||||
//else if (stored >= 0.0)
|
||||
// currenttip.add(String.format("Stored : %d EU", stored));
|
||||
@@ -58,7 +59,7 @@ public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
|
||||
@@ -4,11 +4,12 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
|
||||
|
||||
@@ -37,13 +38,13 @@ public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
|
||||
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
|
||||
@@ -4,11 +4,12 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
|
||||
|
||||
@@ -53,17 +54,17 @@ public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.consump")){
|
||||
if ( consumption > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", powerStr, consumption ));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", powerStr, TAB + ALIGNRIGHT, consumption ));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
|
||||
if ( maxinput > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", maxPowerStr, maxinput ));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", maxPowerStr, TAB + ALIGNRIGHT, maxinput ));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
|
||||
@@ -10,6 +10,7 @@ import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTETradeOMat implements IWailaDataProvider {
|
||||
|
||||
@@ -38,13 +39,13 @@ public class HUDHandlerTETradeOMat implements IWailaDataProvider {
|
||||
if (offer.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, is.stackSize, is.getDisplayName()));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
if (demand.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, is.stackSize, is.getDisplayName()));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -5,14 +5,15 @@ import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.tools.AccessHelper;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
|
||||
public class IC2Module {
|
||||
|
||||
@@ -96,19 +97,19 @@ public class IC2Module {
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,7 +125,14 @@ public class IC2Module {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTradeOMat);
|
||||
}
|
||||
|
||||
/* Retuns the current stored energy if available in the nbt and config is true */
|
||||
@@ -150,7 +158,8 @@ public class IC2Module {
|
||||
|
||||
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
|
||||
|
||||
List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
|
||||
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
|
||||
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
|
||||
|
||||
for (Object subobj : tagList){
|
||||
NBTTagCompound subtag = (NBTTagCompound)subobj;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package mcp.mobius.waila.addons.magicalcrops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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 HUDHandlerMagicalCrops 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) {
|
||||
int growthStage = accessor.getMetadata();
|
||||
|
||||
float growthValue = (growthStage / 7.0F) * 100.0F;
|
||||
if (growthValue < 100.0)
|
||||
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
|
||||
else
|
||||
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package mcp.mobius.waila.addons.magicalcrops;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class MagicalCropsModule {
|
||||
public static Class BlockMagicalCrops = null;
|
||||
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class MagicalCrops = Class.forName("magicalcrops.mod_sCrops");
|
||||
Waila.log.log(Level.INFO, "MagicalCrops mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[MagicalCrops] MagicalCrops mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
BlockMagicalCrops = Class.forName("magicalcrops.BlockMagicalCrops");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[MagicalCrops] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerMagicalCrops(), BlockMagicalCrops);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package mcp.mobius.waila.addons.openblocks;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class OpenBlocksModule {
|
||||
@@ -13,21 +13,22 @@ public class OpenBlocksModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModOpenBlocks = Class.forName("openblocks.OpenBlocks");
|
||||
mod_Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[OpenBlocks] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[OpenBlocks] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTank);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,12 @@ import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPDecorator;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
|
||||
public class HUDDecoratorRsGateLogic implements IWailaFMPDecorator {
|
||||
|
||||
static byte[][] IOARRAY={
|
||||
{1,1,2,1} /* OR */, {1,1,2,1} /* NOR */, {1,2,2,2} /* NOT */, {1,1,2,1} /* AND */,
|
||||
@@ -22,36 +25,28 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
|
||||
{11,12,11,12} /* Inver */, {11,12,11,12} /* Buff */, {1,9,2,8} /* Cmp */, {1,12,2,12} /* And */,
|
||||
};
|
||||
|
||||
|
||||
static byte[][] IOARRAYALTER={
|
||||
{1,8,2,9} /* Cmp 1*/, {1,6,2,2} /* State 1*/, {2,8,2,9} /* Count 1*/, {6,2,2,1} /* Transp 1*/,
|
||||
{2,1,2,1} /* Latch 1*/, {2,1,2,1} /* Latch 2*/, {2,1,2,1} /* Latch 3*/
|
||||
};
|
||||
|
||||
static String[] IONAMES={ "", "IN", "OUT", "SWAP", "IN_A", "IN_B", "LOCK", "IO", "POS", "NEG", "BUS", "A", "B"};
|
||||
|
||||
@Override
|
||||
public void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
public void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("pr.showio")) return;
|
||||
|
||||
|
||||
int orient = 0;
|
||||
int subID = 0;
|
||||
int shape = 0;
|
||||
boolean found = false;
|
||||
|
||||
if (!accessor.getNBTData().hasKey("parts")) return;
|
||||
NBTTagList parts = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < parts.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (id.equals("pr_sgate") || id.equals("pr_igate") ||
|
||||
id.equals("pr_tgate") || id.equals("pr_bgate") ||
|
||||
id.equals("pr_agate") || id.equals("pr_rgate")){
|
||||
orient = accessor.getNBTInteger(subtag, "orient");
|
||||
subID = accessor.getNBTInteger(subtag, "subID");
|
||||
shape = accessor.getNBTInteger(subtag, "shape");
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
orient = NBTUtil.getNBTInteger(accessor.getNBTData(), "orient");
|
||||
subID = NBTUtil.getNBTInteger(accessor.getNBTData(), "subID");
|
||||
shape = NBTUtil.getNBTInteger(accessor.getNBTData(), "shape");
|
||||
|
||||
if (!found) return;
|
||||
|
||||
//orient = orient - ((orient & 0x10) + (orient & 0x8) + (orient & 0x4));
|
||||
int hOrient = orient & 0x3;
|
||||
ForgeDirection vOrient = ForgeDirection.getOrientation((orient - (orient & 0x3)) >> 2);
|
||||
@@ -68,8 +63,27 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
|
||||
hOrient = 3;
|
||||
|
||||
String[] IOStr = new String[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
IOStr[i] = IONAMES[IOARRAY[subID][i]];
|
||||
if (shape != 0){
|
||||
int altIndex = -1;
|
||||
if (subID == 26 && shape == 1) altIndex = 0;
|
||||
if (subID == 20 && shape == 1) altIndex = 1;
|
||||
if (subID == 19 && shape == 1) altIndex = 2;
|
||||
if (subID == 14 && shape == 1) altIndex = 3;
|
||||
if (subID == 12 && shape == 1) altIndex = 4;
|
||||
if (subID == 12 && shape == 2) altIndex = 5;
|
||||
if (subID == 12 && shape == 3) altIndex = 6;
|
||||
|
||||
if (altIndex == -1)
|
||||
for (int i = 0; i < 4; i++)
|
||||
IOStr[i] = IONAMES[IOARRAY[subID][i]];
|
||||
else
|
||||
for (int i = 0; i < 4; i++)
|
||||
IOStr[i] = IONAMES[IOARRAYALTER[altIndex][i]];
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++)
|
||||
IOStr[i] = IONAMES[IOARRAY[subID][i]];
|
||||
|
||||
}
|
||||
|
||||
String[] IOStrRot = new String[4];
|
||||
|
||||
@@ -118,7 +132,6 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
double x = accessor.getRenderingPosition().xCoord;
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDFMPGateLogic implements IWailaFMPProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("pr.showdata")) return currenttip;
|
||||
|
||||
int orient = 0;
|
||||
int subID = 0;
|
||||
int shape = 0;
|
||||
int pmax = 0;
|
||||
int val = 0;
|
||||
int max = 0;
|
||||
int dec = 0;
|
||||
int inc = 0;
|
||||
|
||||
orient = NBTUtil.getNBTInteger(accessor.getNBTData(), "orient");
|
||||
subID = NBTUtil.getNBTInteger(accessor.getNBTData(), "subID");
|
||||
shape = NBTUtil.getNBTInteger(accessor.getNBTData(), "shape");
|
||||
|
||||
if (subID == 17)
|
||||
pmax = NBTUtil.getNBTInteger(accessor.getNBTData(), "pmax");
|
||||
|
||||
if (subID == 19){
|
||||
val = NBTUtil.getNBTInteger(accessor.getNBTData(), "val");
|
||||
max = NBTUtil.getNBTInteger(accessor.getNBTData(), "max");
|
||||
dec = NBTUtil.getNBTInteger(accessor.getNBTData(), "dec");
|
||||
inc = NBTUtil.getNBTInteger(accessor.getNBTData(), "inc");
|
||||
}
|
||||
|
||||
switch(subID){
|
||||
case 10:
|
||||
currenttip.add(String.format("[Repeater]" + TAB + ALIGNRIGHT + WHITE + "%d" + GRAY + " ticks", (int)Math.pow(2, shape)));
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (shape == 0)
|
||||
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Open");
|
||||
if (shape == 1)
|
||||
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Half closed");
|
||||
if (shape == 2)
|
||||
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Closed");
|
||||
break;
|
||||
|
||||
case 17:
|
||||
currenttip.add(String.format("[Timer delay]" + TAB + ALIGNRIGHT + WHITE + "%d " + GRAY + "ms", (pmax + 2) * 50));
|
||||
break;
|
||||
|
||||
case 19:
|
||||
|
||||
|
||||
currenttip.add(String.format("[Counter value]"+ TAB + ALIGNRIGHT + WHITE + "%d " + GRAY + "/ " + WHITE + "%d", val, max));
|
||||
currenttip.add(String.format("[Counter step]" + TAB + ALIGNRIGHT + WHITE + "-%d " + GRAY + "/ " + WHITE + "+%d", dec, inc));
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerRsGateLogic 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("pr.showdata")) return currenttip;
|
||||
|
||||
int orient = 0;
|
||||
int subID = 0;
|
||||
int shape = 0;
|
||||
int pmax = 0;
|
||||
int val = 0;
|
||||
int max = 0;
|
||||
int dec = 0;
|
||||
int inc = 0;
|
||||
|
||||
boolean found = false;
|
||||
|
||||
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
|
||||
NBTTagList parts = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < parts.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (id.equals("pr_sgate") || id.equals("pr_igate") ||
|
||||
id.equals("pr_tgate") || id.equals("pr_bgate") ||
|
||||
id.equals("pr_agate") || id.equals("pr_rgate")){
|
||||
orient = accessor.getNBTInteger(subtag, "orient");
|
||||
subID = accessor.getNBTInteger(subtag, "subID");
|
||||
shape = accessor.getNBTInteger(subtag, "shape");
|
||||
|
||||
if (subID == 17)
|
||||
pmax = accessor.getNBTInteger(subtag, "pmax");
|
||||
|
||||
if (subID == 19){
|
||||
val = accessor.getNBTInteger(subtag, "val");
|
||||
max = accessor.getNBTInteger(subtag, "max");
|
||||
dec = accessor.getNBTInteger(subtag, "dec");
|
||||
inc = accessor.getNBTInteger(subtag, "inc");
|
||||
}
|
||||
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return currenttip;
|
||||
|
||||
switch(subID){
|
||||
case 10:
|
||||
currenttip.add(String.format("Delay : \u00a7f%d ticks", (int)Math.pow(2, shape)));
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (shape == 0)
|
||||
currenttip.add("Shape : \u00a7fOpen");
|
||||
if (shape == 1)
|
||||
currenttip.add("Shape : \u00a7fHalf closed");
|
||||
if (shape == 2)
|
||||
currenttip.add("Shape : \u00a7fclosed");
|
||||
break;
|
||||
|
||||
case 17:
|
||||
currenttip.add(String.format("Timer : \u00a7f%d \u00a7rms", (pmax + 2) * 50));
|
||||
break;
|
||||
|
||||
case 19:
|
||||
|
||||
|
||||
currenttip.add(String.format("Value : \u00a7f%d \u00a7r/ \u00a7f%d", val, max));
|
||||
currenttip.add(String.format("Step : \u00a7f-%d \u00a7r/ \u00a7f+%d", dec, inc));
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,47 +5,40 @@ import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ProjectRedModule {
|
||||
|
||||
|
||||
public static Class BlockMultipart = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModClass = Class.forName("mrtjp.projectred.ProjectRedIntegration");
|
||||
mod_Waila.log.log(Level.INFO, "ProjectRed|Integration mod found.");
|
||||
Waila.log.log(Level.INFO, "ProjectRed|Integration mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[ProjectRed] ProjectRed|Integration mod not found.");
|
||||
Waila.log.log(Level.INFO, "[ProjectRed] ProjectRed|Integration mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
//InstancedRsGateLogic = Class.forName("mrtjp.projectred.integration.InstancedRsGateLogic");
|
||||
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showio");
|
||||
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showdata");
|
||||
|
||||
ModuleRegistrar.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_sgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_igate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_tgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_bgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_agate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_rgate");
|
||||
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_sgate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_igate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_tgate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_bgate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_agate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_rgate");
|
||||
|
||||
//ModuleRegistrar.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
|
||||
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
|
||||
//ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMultipart);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package mcp.mobius.waila.addons.railcraft;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class RailcraftModule {
|
||||
@@ -15,9 +15,9 @@ public class RailcraftModule {
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModRailcraft = Class.forName("mods.railcraft.common.core.Railcraft");
|
||||
mod_Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
|
||||
Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,15 +28,16 @@ public class RailcraftModule {
|
||||
//StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Railcraft] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[Railcraft] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Railcraft] Method not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[Railcraft] Method not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTankBase);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package mcp.mobius.waila.addons.secretrooms;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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 HUDTileEntityCamo implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("secretrooms.hide")) return null;
|
||||
|
||||
if ( SecretRoomsModule.BlockCamoTrapDoor.isInstance(accessor.getBlock()) ){
|
||||
return this.getTrapDoorBlock(accessor);
|
||||
|
||||
}
|
||||
|
||||
else if ( SecretRoomsModule.BlockTorchLever.isInstance(accessor.getBlock()) ){
|
||||
return new ItemStack(Block.torchWood);
|
||||
}
|
||||
|
||||
else if (accessor.getNBTData() != null){
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
if (tag.hasKey("copyID") && tag.hasKey("copyMeta")){
|
||||
int copyID = accessor.getNBTInteger(tag, "copyID");
|
||||
int copyMeta = accessor.getNBTInteger(tag, "copyMeta");
|
||||
return new ItemStack(copyID, 1, copyMeta);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
private ItemStack getTrapDoorBlock(IWailaDataAccessor accessor){
|
||||
// modify coordinates to get hinge Block.
|
||||
int i = accessor.getMetadata();
|
||||
int j = accessor.getPosition().blockX;
|
||||
int k = accessor.getPosition().blockZ;
|
||||
|
||||
if ((i & 3) == 0)
|
||||
{
|
||||
k++;
|
||||
}
|
||||
|
||||
if ((i & 3) == 1)
|
||||
{
|
||||
k--;
|
||||
}
|
||||
|
||||
if ((i & 3) == 2)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
|
||||
if ((i & 3) == 3)
|
||||
{
|
||||
j--;
|
||||
}
|
||||
|
||||
int blockID = accessor.getWorld().getBlockId(j, accessor.getPosition().blockY, k);
|
||||
int blockMeta = accessor.getWorld().getBlockMetadata(j, accessor.getPosition().blockY, k);
|
||||
|
||||
return new ItemStack(blockID, 1, blockMeta);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package mcp.mobius.waila.addons.secretrooms;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class SecretRoomsModule {
|
||||
|
||||
public static Class TileEntityCamo = null;
|
||||
public static Class BlockTorchLever = null;
|
||||
public static Class BlockCamoTrapDoor = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class SecretRooms = Class.forName("com.github.AbrarSyed.secretroomsmod.common.SecretRooms");
|
||||
Waila.log.log(Level.INFO, "SecretRooms mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[SecretRooms] SecretRooms mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityCamo = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.TileEntityCamo");
|
||||
BlockTorchLever = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.BlockTorchLever");
|
||||
BlockCamoTrapDoor = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.BlockCamoTrapDoor");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[SecretRooms] Class not found. " + e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARNING, "[SecretRooms] Error while loading module. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("SecretRooms", "secretrooms.hide");
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), TileEntityCamo);
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), BlockTorchLever);
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), BlockCamoTrapDoor);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("copyID", TileEntityCamo);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("copyMeta", TileEntityCamo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
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;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDCargoManager implements IWailaDataProvider {
|
||||
|
||||
private static String colors[] = {"NA", "Red", "Blue", "Yellow", "Green", "Dis."};
|
||||
private static String sides[] = {"Yellow", "Blue", "Green", "Red"};
|
||||
|
||||
@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("stevescarts.showall")) return currenttip;
|
||||
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
if (config.getConfig("stevescarts.colorblind")){
|
||||
int side = accessor.getSide().ordinal() - 2;
|
||||
if (side >= 0)
|
||||
currenttip.add("Looking at side " + WHITE + sides[side]);
|
||||
}
|
||||
|
||||
int layout = accessor.getNBTInteger(tag, "layout");
|
||||
switch(layout){
|
||||
case 0:
|
||||
currenttip.add("Slots : "+ WHITE + "Shared");
|
||||
break;
|
||||
case 1:
|
||||
currenttip.add("Slots : "+ WHITE + "By side");
|
||||
break;
|
||||
case 2:
|
||||
currenttip.add("Slots : "+ WHITE + "By color");
|
||||
break;
|
||||
}
|
||||
|
||||
try{
|
||||
ArrayList<Object> itemSelection = (ArrayList<Object>) StevesCartsModule.ItemSelections.get(accessor.getTileEntity());
|
||||
|
||||
int toCart = accessor.getNBTInteger(tag, "tocart");
|
||||
int doReturn = accessor.getNBTInteger(tag, "doReturn");
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
int target = accessor.getNBTInteger(tag, "target" + String.valueOf(i));
|
||||
int color = accessor.getNBTInteger(tag, "color" + String.valueOf(i));
|
||||
int amount = accessor.getNBTInteger(tag, "amount" + String.valueOf(i));
|
||||
if (color == 5) continue;
|
||||
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All" : String.valueOf(this.getAmount(amount) + " " + this.getAmountType(amount));
|
||||
|
||||
String selection = (String) StevesCartsModule.GetSelectionName.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
|
||||
currenttip.add(String.format("Side %s %s[ %s ]%s[ %s , %s]%s[ %s ]", WHITE + colors[color] + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + selection + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + direction + GRAY,
|
||||
TAB + ALIGNRIGHT + WHITE + shouldReturn + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + sAmount + GRAY));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public int getAmount(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
|
||||
case 2:
|
||||
return 3;
|
||||
|
||||
case 3:
|
||||
return 8;
|
||||
|
||||
case 4:
|
||||
return 16;
|
||||
|
||||
case 5:
|
||||
return 32;
|
||||
|
||||
case 6:
|
||||
return 64;
|
||||
|
||||
case 7:
|
||||
return 1;
|
||||
|
||||
case 8:
|
||||
return 2;
|
||||
|
||||
case 9:
|
||||
return 3;
|
||||
|
||||
case 10:
|
||||
return 5;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//0 - MAX
|
||||
//1 - Items
|
||||
//2 - Stacks
|
||||
public String getAmountType(int id)
|
||||
{
|
||||
if (id <= 6)
|
||||
{
|
||||
return "I";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "S";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDCartAssembler 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("stevescarts.showall")) return currenttip;
|
||||
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
int currTime = accessor.getNBTInteger(accessor.getNBTData(), "currentTime");
|
||||
int maxTime = accessor.getNBTInteger(accessor.getNBTData(), "maxTime");
|
||||
int isAssembling = accessor.getNBTInteger(accessor.getNBTData(), "isAssembling");
|
||||
NBTTagList slots = accessor.getNBTData().getTagList("Items");
|
||||
boolean hasOutput = false;
|
||||
Item ItemCartModule = null;
|
||||
try {
|
||||
ItemCartModule = (Item)StevesCartsModule.ItemCartModule.get(null);
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
for (int i = 0; i < slots.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound)(slots.tagAt(i));
|
||||
byte slot = subtag.getByte("Slot");
|
||||
if (slot == 30)
|
||||
hasOutput = true;
|
||||
}
|
||||
|
||||
if (isAssembling == 1){
|
||||
currenttip.add(String.format("Time remaining : %.1f sec", (maxTime - currTime) / 20.0f));
|
||||
|
||||
NBTTagCompound output = accessor.getNBTData().getCompoundTag("Output");
|
||||
short outID = output.getShort("id");
|
||||
byte[] metas = output.getCompoundTag("tag").getByteArray("Modules");
|
||||
|
||||
for (byte b : metas){
|
||||
currenttip.add(new ItemStack(ItemCartModule, 1, b).getDisplayName());
|
||||
}
|
||||
}
|
||||
else
|
||||
if (hasOutput)
|
||||
currenttip.add(String.format("Time remaining : <Done>"));
|
||||
else
|
||||
currenttip.add(String.format("Time remaining : <Idle>"));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
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;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
|
||||
public class HUDLiquidManager implements IWailaDataProvider {
|
||||
|
||||
private static String colors[] = {"NA", "Red", "Blue", "Yellow", "Green", "Dis."};
|
||||
private static String sides[] = {"Yellow", "Blue", "Green", "Red"};
|
||||
|
||||
@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("stevescarts.showall")) return currenttip;
|
||||
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
|
||||
if (config.getConfig("stevescarts.colorblind")){
|
||||
int side = accessor.getSide().ordinal() - 2;
|
||||
if (side >= 0)
|
||||
currenttip.add("Looking at side " + WHITE + sides[side]);
|
||||
}
|
||||
|
||||
int layout = accessor.getNBTInteger(tag, "layout");
|
||||
switch(layout){
|
||||
case 0:
|
||||
currenttip.add("Tanks : "+ WHITE + "Shared");
|
||||
break;
|
||||
case 1:
|
||||
currenttip.add("Tanks : "+ WHITE + "By side");
|
||||
break;
|
||||
case 2:
|
||||
currenttip.add("Tanks : "+ WHITE + "By color");
|
||||
break;
|
||||
}
|
||||
|
||||
int toCart = accessor.getNBTInteger(tag, "tocart");
|
||||
int doReturn = accessor.getNBTInteger(tag, "doReturn");
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
int target = accessor.getNBTInteger(tag, "target" + String.valueOf(i));
|
||||
int color = accessor.getNBTInteger(tag, "color" + String.valueOf(i));
|
||||
int amount = accessor.getNBTInteger(tag, "amount" + String.valueOf(i));
|
||||
|
||||
String fluidName = "<Empty>";
|
||||
int fluidAmount = 0;
|
||||
if (tag.hasKey("Fluid" + i)){
|
||||
fluidName = tag.getCompoundTag("Fluid" + i).getString("FluidName");
|
||||
fluidAmount = tag.getCompoundTag("Fluid" + i).getInteger("Amount");
|
||||
}
|
||||
|
||||
String fluidString = fluidAmount == 0 ? "<Empty>" : String.format("%s mB of %s", fluidAmount, fluidName);
|
||||
|
||||
if (color == 5) continue;
|
||||
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All" : String.valueOf(this.getMaxAmountBuckets(amount)) + " mB";
|
||||
|
||||
//String selection = (String) StevesCartsModule.GetSelectionName.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
|
||||
currenttip.add(String.format("Side %s %s[ %s ]%s[ %s , %s]%s[ %s ]", WHITE + colors[color] + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + fluidString + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + direction + GRAY,
|
||||
TAB + ALIGNRIGHT + WHITE + shouldReturn + GRAY,
|
||||
TAB + ALIGNRIGHT, WHITE + sAmount + GRAY));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public int getMaxAmountBuckets(int id) {
|
||||
switch(id) {
|
||||
case 1:
|
||||
return 250;
|
||||
case 2:
|
||||
return 500;
|
||||
case 3:
|
||||
return 750;
|
||||
case 4:
|
||||
return 1000;
|
||||
case 5:
|
||||
return 2000;
|
||||
case 6:
|
||||
return 3000;
|
||||
case 7:
|
||||
return 5000;
|
||||
case 8:
|
||||
return 7500;
|
||||
case 9:
|
||||
return 10000;
|
||||
case 10:
|
||||
return 15000;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDMinecartModular implements IWailaEntityProvider {
|
||||
|
||||
@Override
|
||||
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
if (currenttip.get(0).contains("entity.StevesCarts.Minecart")){
|
||||
currenttip.remove(0);
|
||||
currenttip.add(WHITE + "Modular Minecart");
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("stevescarts.showall")) return currenttip;
|
||||
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
Item ItemCartModule = null;
|
||||
try {
|
||||
ItemCartModule = (Item)StevesCartsModule.ItemCartModule.get(null);
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getEntity().getClass().getName(), currenttip);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Modules")){
|
||||
byte[] metas = tag.getByteArray("Modules");
|
||||
|
||||
for (int i = 0; i < metas.length; i++){
|
||||
if (tag.hasKey("module" + String.valueOf(i) + "Fuel")){
|
||||
|
||||
int fuel = accessor.getNBTInteger(tag, "module" + String.valueOf(i) + "Fuel");
|
||||
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " [ " + WHITE + fuel + GRAY + " POW ]");
|
||||
|
||||
} else if (tag.hasKey("module" + String.valueOf(i) + "Fluid")){
|
||||
|
||||
NBTTagCompound subtag = tag.getCompoundTag("module" + String.valueOf(i) + "Fluid");
|
||||
if (subtag.hasKey("amount")){
|
||||
int amount = accessor.getNBTInteger(subtag, "Amount");
|
||||
String fluid = subtag.getString("FluidName");
|
||||
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " [ " + WHITE + String.valueOf(amount) + GRAY + " mB of " + WHITE + fluid + GRAY + " ]");
|
||||
} else {
|
||||
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " < " + WHITE + "Empty" + GRAY + " > ");
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class StevesCartsModule {
|
||||
|
||||
public static Class TileEntityCartAssembler = null;
|
||||
public static Class TileEntityCargo = null;
|
||||
public static Class TileEntityLiquid = null;
|
||||
public static Class MinecartModular = null;
|
||||
public static Class StevesItems = null;
|
||||
public static Class CargoItemSelection = null;
|
||||
|
||||
public static Field ItemCartComponent = null; //Items.component
|
||||
public static Field ItemCartModule = null; //Items.modules
|
||||
public static Field ItemSelections = null; //TileEntityCargo.itemSelections
|
||||
|
||||
public static Method GetSelectionName = null; // CargoItemSelection.getName
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModStevesCarts = Class.forName("vswe.stevescarts.StevesCarts");
|
||||
Waila.log.log(Level.INFO, "StevesCarts mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[StevesCarts] StevesCarts mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityCartAssembler = Class.forName("vswe.stevescarts.TileEntities.TileEntityCartAssembler");
|
||||
TileEntityCargo = Class.forName("vswe.stevescarts.TileEntities.TileEntityCargo");
|
||||
TileEntityLiquid = Class.forName("vswe.stevescarts.TileEntities.TileEntityLiquid");
|
||||
MinecartModular = Class.forName("vswe.stevescarts.Carts.MinecartModular");
|
||||
StevesItems = Class.forName("vswe.stevescarts.Items.Items");
|
||||
CargoItemSelection = Class.forName("vswe.stevescarts.Helpers.CargoItemSelection");
|
||||
|
||||
ItemCartComponent = StevesItems.getDeclaredField("component");
|
||||
ItemCartModule = StevesItems.getDeclaredField("modules");
|
||||
ItemSelections = TileEntityCargo.getDeclaredField("itemSelections");
|
||||
|
||||
GetSelectionName = CargoItemSelection.getDeclaredMethod("getName");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[StevesCarts] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e) {
|
||||
Waila.log.log(Level.WARNING, "[StevesCarts] Field not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e) {
|
||||
Waila.log.log(Level.WARNING, "[StevesCarts] Method not found. " + e);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARNING, "[StevesCarts] Error while loading module. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.showall");
|
||||
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.colorblind");
|
||||
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.shifttoggle");
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDCartAssembler(), TileEntityCartAssembler);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDCargoManager(), TileEntityCargo);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDLiquidManager(), TileEntityLiquid);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDMinecartModular(), MinecartModular);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDMinecartModular(), MinecartModular);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityCartAssembler);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", MinecartModular);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityCargo);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityLiquid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDHandlerCapacitor implements IWailaDataProvider {
|
||||
|
||||
@@ -3,7 +3,7 @@ package mcp.mobius.waila.addons.thaumcraft;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ThaumcraftModule {
|
||||
@@ -19,9 +19,9 @@ public class ThaumcraftModule {
|
||||
|
||||
try{
|
||||
Class ModThaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
|
||||
mod_Waila.log.log(Level.INFO, "Thaumcraft mod found.");
|
||||
Waila.log.log(Level.INFO, "Thaumcraft mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
|
||||
Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ public class ThaumcraftModule {
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Class not found. " + e);
|
||||
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);
|
||||
Waila.log.log(Level.WARNING, "[Thaumcraft] Field not found." + e);
|
||||
return;
|
||||
// } catch (Exception e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
|
||||
@@ -52,6 +52,9 @@ public class ThaumcraftModule {
|
||||
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMagicalLeaves);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockCustomPlant);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileCrystalCapacitor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerConduitFluid implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
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;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerEnergyCell implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.List;
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ThermalExpansionModule {
|
||||
@@ -45,9 +45,9 @@ public class ThermalExpansionModule {
|
||||
|
||||
try{
|
||||
Class ModThermalExpansion = Class.forName("thermalexpansion.ThermalExpansion");
|
||||
mod_Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
|
||||
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Thermal Expansion] ThermalExpansion mod not found.");
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] ThermalExpansion mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@ public class ThermalExpansionModule {
|
||||
//TileEnergyCell_energySend = TileEnergyCell.getField("energySend");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[Thermal Expansion] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Method not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[Thermal Expansion] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Field not found." + e);
|
||||
Waila.log.log(Level.WARNING, "[Thermal Expansion] Field not found." + e);
|
||||
return;
|
||||
// } catch (Exception e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Unhandled exception." + e);
|
||||
@@ -119,6 +119,12 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitFluid(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitItem(), BlockMultipart);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", IEnergyHandler);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTank);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTesseract);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", ISecureTile);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMultipart);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package mcp.mobius.waila.addons.twilightforest;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class TwilightForestModule {
|
||||
@@ -15,9 +15,9 @@ public class TwilightForestModule {
|
||||
|
||||
try{
|
||||
Class TwilightForestMod = Class.forName("twilightforest.TwilightForestMod");
|
||||
mod_Waila.log.log(Level.INFO, "TwilightForestMod mod found.");
|
||||
Waila.log.log(Level.INFO, "TwilightForestMod mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[TwilightForestMod] TwilightForestMod mod not found.");
|
||||
Waila.log.log(Level.INFO, "[TwilightForestMod] TwilightForestMod mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,16 @@ public class TwilightForestModule {
|
||||
BlockTFPlant = Class.forName("twilightforest.block.BlockTFPlant");
|
||||
BlockTFSapling = Class.forName("twilightforest.block.BlockTFSapling");
|
||||
} catch (ClassNotFoundException e) {
|
||||
mod_Waila.log.log(Level.WARNING, "[TwilightForestMod] Class not found. " + e);
|
||||
Waila.log.log(Level.WARNING, "[TwilightForestMod] Class not found. " + e);
|
||||
}
|
||||
|
||||
|
||||
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFRoots);
|
||||
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFPlant);
|
||||
//ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFSapling);
|
||||
//ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFSapling);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockTFRoots);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockTFPlant);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,28 +17,28 @@ import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
|
||||
static int mobSpawnerID = Block.mobSpawner.blockID;
|
||||
static int cropsID = Block.crops.blockID;
|
||||
static int melonStemID = Block.melonStem.blockID;
|
||||
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;
|
||||
static int cocoa = Block.cocoaPlant.blockID;
|
||||
static int netherwart = Block.netherStalk.blockID;
|
||||
static int silverfish = Block.silverfish.blockID;
|
||||
static Block mobSpawner = Block.mobSpawner;
|
||||
static Block crops = Block.crops;
|
||||
static Block melonStem = Block.melonStem;
|
||||
static Block pumpkinStem = Block.pumpkinStem;
|
||||
static Block carrot = Block.carrot;
|
||||
static Block potato = Block.potato;
|
||||
static Block lever = Block.lever;
|
||||
static Block repeaterIdle = Block.redstoneRepeaterIdle;
|
||||
static Block repeaterActv = Block.redstoneRepeaterActive;
|
||||
static Block comparatorIdl = Block.redstoneComparatorIdle;
|
||||
static Block comparatorAct = Block.redstoneComparatorActive;
|
||||
static Block redstone = Block.redstoneWire;
|
||||
static Block jukebox = Block.jukebox;
|
||||
static Block cocoa = Block.cocoaPlant;
|
||||
static Block netherwart = Block.netherStalk;
|
||||
static Block silverfish = Block.silverfish;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
Block block = accessor.getBlock();
|
||||
|
||||
if (blockID == silverfish){
|
||||
if (block == silverfish && config.getConfig("vanilla.silverfish")){
|
||||
int metadata = accessor.getMetadata();
|
||||
switch(metadata){
|
||||
case 0:
|
||||
@@ -52,7 +52,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (blockID == redstone){
|
||||
if (block == redstone){
|
||||
return new ItemStack(Item.redstone);
|
||||
}
|
||||
|
||||
@@ -62,16 +62,16 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
Block block = accessor.getBlock();
|
||||
|
||||
/* Mob spawner handler */
|
||||
if (blockID == mobSpawnerID && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
|
||||
if (block == mobSpawner && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
|
||||
String name = currenttip.get(0);
|
||||
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).getSpawnerLogic().getEntityNameToSpawn();
|
||||
currenttip.set(0, String.format("%s (%s)", name, mobname));
|
||||
}
|
||||
|
||||
if (blockID == redstone){
|
||||
if (block == redstone){
|
||||
String name = currenttip.get(0).replaceFirst(String.format(" %s", accessor.getMetadata()), "");
|
||||
currenttip.set(0, name);
|
||||
}
|
||||
@@ -81,10 +81,11 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
Block block = accessor.getBlock();
|
||||
/* Crops */
|
||||
boolean iscrop = crops.getClass().isInstance(block); //Done to cover all inheriting mods
|
||||
if (config.getConfig("vanilla.growthvalue"))
|
||||
if (blockID == cropsID || blockID == melonStemID || blockID == pumpkinStemID || blockID == carrotID || blockID == potatoID){
|
||||
if (iscrop || block == melonStem || block == pumpkinStem || block == carrot || block == potato){
|
||||
float growthValue = (accessor.getMetadata() / 7.0F) * 100.0F;
|
||||
if (growthValue < 100.0)
|
||||
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
|
||||
@@ -93,7 +94,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (blockID == cocoa){
|
||||
if (block == cocoa){
|
||||
|
||||
float growthValue = ((accessor.getMetadata() >> 2) / 2.0F) * 100.0F;
|
||||
if (growthValue < 100.0)
|
||||
@@ -103,7 +104,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (blockID == netherwart){
|
||||
if (block == netherwart){
|
||||
float growthValue = (accessor.getMetadata() / 3.0F) * 100.0F;
|
||||
if (growthValue < 100.0)
|
||||
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
|
||||
@@ -113,14 +114,14 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.leverstate"))
|
||||
if (blockID == leverID){
|
||||
if (block == lever){
|
||||
String redstoneOn = (accessor.getMetadata() & 8) == 0 ? LangUtil.translateG("hud.msg.off") : LangUtil.translateG("hud.msg.on");
|
||||
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.state"), redstoneOn));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.repeater"))
|
||||
if ((blockID == repeaterIdle) ||(blockID == repeaterActv)){
|
||||
if ((block == repeaterIdle) ||(block == repeaterActv)){
|
||||
int tick = (accessor.getMetadata() >> 2) + 1 ;
|
||||
if (tick == 1)
|
||||
currenttip.add(String.format("%s : %s tick", LangUtil.translateG("hud.msg.delay"), tick));
|
||||
@@ -130,7 +131,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.comparator"))
|
||||
if ((blockID == comparatorIdl) ||(blockID == comparatorAct)){
|
||||
if ((block == comparatorIdl) ||(block == comparatorAct)){
|
||||
String mode = ((accessor.getMetadata() >> 2) & 1) == 0 ? LangUtil.translateG("hud.msg.comparator") : LangUtil.translateG("hud.msg.substractor");
|
||||
//int outputSignal = ((TileEntityComparator)entity).func_96100_a();
|
||||
currenttip.add("Mode : " + mode);
|
||||
@@ -139,13 +140,13 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.redstone"))
|
||||
if (blockID == redstone){
|
||||
if (block == redstone){
|
||||
currenttip.add(String.format("%s : %s" , LangUtil.translateG("hud.msg.power"), accessor.getMetadata()));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (config.getConfig("vanilla.jukebox"))
|
||||
if (blockID == jukebox){
|
||||
if (block == jukebox){
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
Item record = null;
|
||||
if (tag.hasKey("Record")){
|
||||
@@ -171,28 +172,46 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.repeater");
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.comparator");
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.redstone");
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.silverfish");
|
||||
ModuleRegistrar.instance().addConfigRemote("VanillaMC", "vanilla.jukebox");
|
||||
|
||||
IWailaDataProvider provider = new HUDHandlerVanilla();
|
||||
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, silverfish);
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, redstone);
|
||||
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawnerID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, cropsID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, melonStemID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, pumpkinStemID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, carrotID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, potatoID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, leverID);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterIdle);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterActv);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorIdl);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorAct);
|
||||
ModuleRegistrar.instance().registerHeadProvider(provider, redstone);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, redstone);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, jukebox);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, cocoa);
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, netherwart);
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, silverfish.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, redstone.getClass());
|
||||
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawner.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, crops.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, melonStem.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, pumpkinStem.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, carrot.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, potato.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, lever.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterIdle.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterActv.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorIdl.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorAct.getClass());
|
||||
ModuleRegistrar.instance().registerHeadProvider(provider, redstone.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, redstone.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, jukebox.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, cocoa.getClass());
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, netherwart.getClass());
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.mobSpawner.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.crops.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.melonStem.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.pumpkinStem.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.carrot.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.potato.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.lever.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneRepeaterIdle.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneRepeaterActive.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneComparatorIdle.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneComparatorActive.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneWire.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.jukebox.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.cocoaPlant.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.netherStalk.getClass());
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.silverfish.getClass());
|
||||
|
||||
ModuleRegistrar.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaBlockDecorator {
|
||||
|
||||
@@ -24,5 +24,5 @@ public interface IWailaConfigHandler {
|
||||
/* Returns the current value of an option (true/false) with a default value true if not set*/
|
||||
public boolean getConfig(String key);
|
||||
|
||||
public void setConfig(String key, boolean value);
|
||||
//public void setConfig(String key, boolean value);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mcp.mobius.waila.api;
|
||||
|
||||
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;
|
||||
@@ -9,7 +10,13 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Block getBlock();
|
||||
@@ -22,4 +29,5 @@ public interface IWailaDataAccessor {
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
ForgeDirection getSide();
|
||||
ItemStack getStack();
|
||||
}
|
||||
@@ -1,4 +1,33 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
public interface IWailaDataProvider extends IWailaBlock{
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaDataProvider{
|
||||
/*
|
||||
* Use this method to return an item stack in case the default lookup system fails.
|
||||
* 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(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
|
||||
*/
|
||||
|
||||
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD.
|
||||
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack().
|
||||
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info.
|
||||
* currenttip represents the current list of text lines in the tooltip zone.
|
||||
* For example, getWailaHead() will have the current item name as currenttip.
|
||||
* You can modify the tips, add more, remove some, etc.
|
||||
* When you are done, just returns the currenttip and it will display in Waila.
|
||||
*
|
||||
* Always return the currenttip is you don't want to modify the current zone.
|
||||
*/
|
||||
|
||||
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaEntityAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Entity getEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
Vec3 getRenderingPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IWailaEntityProvider {
|
||||
|
||||
/* A way to get an override on the entity returned by the raytracing */
|
||||
Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
/* The classical HEAD/BODY/TAIL text getters */
|
||||
List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
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.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/* The Accessor is used to get some basic data out of the game without having to request
|
||||
* direct access to the game engine.
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
|
||||
*/
|
||||
|
||||
public interface IWailaFMPAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
TileEntity getTileEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
NBTTagCompound getFullNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
Vec3 getRenderingPosition();
|
||||
String getID();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaFMPDecorator {
|
||||
void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IWailaFMPProvider {
|
||||
/* The classical HEAD/BODY/TAIL text getters */
|
||||
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -8,11 +8,15 @@ public interface IWailaRegistrar {
|
||||
public void addConfigRemote(String modname, String keyname);
|
||||
|
||||
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
|
||||
@Deprecated
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
@Deprecated
|
||||
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
@Deprecated
|
||||
public void registerTailProvider (IWailaDataProvider dataProvider, int blockID);
|
||||
|
||||
/* Register a stack overrider for the given blockID */
|
||||
@Deprecated
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
|
||||
|
||||
@@ -20,12 +24,33 @@ public interface IWailaRegistrar {
|
||||
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
|
||||
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
|
||||
public void registerTailProvider (IWailaDataProvider dataProvider, Class block);
|
||||
|
||||
/* Entity text registration methods */
|
||||
public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity);
|
||||
|
||||
/* FMP Providers */
|
||||
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name);
|
||||
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name);
|
||||
public void registerTailProvider(IWailaFMPProvider dataProvider, String name);
|
||||
|
||||
/* The block decorators */
|
||||
public void registerBlockDecorator (IWailaBlockDecorator decorator, int blockID);
|
||||
public void registerBlockDecorator (IWailaBlockDecorator decorator, Class block);
|
||||
@Deprecated
|
||||
public void registerDecorator (IWailaBlockDecorator decorator, int blockID);
|
||||
public void registerDecorator (IWailaBlockDecorator decorator, Class block);
|
||||
public void registerDecorator (IWailaFMPDecorator decorator, String name);
|
||||
|
||||
/* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent).
|
||||
* Accept * as a ending wildcard
|
||||
* registerNBTKey("bob.*", MyBlock.class)
|
||||
* registerNBTKey("data.life", MyEntity.class)
|
||||
* registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5
|
||||
* */
|
||||
public void registerSyncedNBTKey(String key, Class target);
|
||||
|
||||
/* UNUSED FOR NOW (Will be used for the ingame wiki */
|
||||
public void registerDocTextFile (String filename);
|
||||
|
||||
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
|
||||
}
|
||||
@@ -5,26 +5,27 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.overlay.OverlayConfig;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.Property;
|
||||
|
||||
public class ConfigHandler implements IWailaConfigHandler {
|
||||
|
||||
private static ConfigHandler instance = null;
|
||||
private LinkedHashMap<String, ConfigModule> modules = new LinkedHashMap<String, ConfigModule>();
|
||||
private ArrayList<String> serverconfigs = new ArrayList<String>();
|
||||
/* SINGLETON */
|
||||
private static ConfigHandler _instance = null;
|
||||
private ConfigHandler() { _instance = this; }
|
||||
public static ConfigHandler instance(){ return _instance == null ? new ConfigHandler() : _instance; }
|
||||
/* === */
|
||||
|
||||
private LinkedHashMap<String, ConfigModule> modules = new LinkedHashMap<String, ConfigModule>();
|
||||
private ArrayList<String> serverconfigs = new ArrayList<String>();
|
||||
public HashMap<String, Boolean> forcedConfigs = new HashMap<String, Boolean>();
|
||||
public Configuration config = null;
|
||||
|
||||
private ConfigHandler() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static ConfigHandler instance(){
|
||||
if (ConfigHandler.instance == null)
|
||||
ConfigHandler.instance = new ConfigHandler();
|
||||
return ConfigHandler.instance;
|
||||
}
|
||||
|
||||
public void addModule(String modName, HashMap<String, String> options){
|
||||
this.addModule(modName, new ConfigModule(modName, options));
|
||||
@@ -47,7 +48,15 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveModuleKey(String modName, String key){
|
||||
config.get(Constants.CATEGORY_MODULES, key, true);
|
||||
config.get(Constants.CATEGORY_SERVER , key, Constants.SERVER_FREE);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void addConfig(String modName, String key, String name){
|
||||
this.saveModuleKey(modName, key);
|
||||
|
||||
if (!this.modules.containsKey(modName))
|
||||
this.modules.put(modName, new ConfigModule(modName));
|
||||
|
||||
@@ -55,6 +64,8 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
}
|
||||
|
||||
public void addConfigServer(String modName, String key, String name){
|
||||
this.saveModuleKey(modName, key);
|
||||
|
||||
if (!this.modules.containsKey(modName))
|
||||
this.modules.put(modName, new ConfigModule(modName));
|
||||
|
||||
@@ -62,42 +73,83 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
this.serverconfigs.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfig(String key){
|
||||
return this.getConfig(key, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfig(String key, boolean defvalue){
|
||||
mod_Waila.instance.config.load();
|
||||
|
||||
if (this.serverconfigs.contains(key) && !mod_Waila.instance.serverPresent)
|
||||
if (this.serverconfigs.contains(key) && !Waila.instance.serverPresent)
|
||||
return false;
|
||||
|
||||
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, defvalue);
|
||||
if (this.forcedConfigs.containsKey(key))
|
||||
return this.forcedConfigs.get(key);
|
||||
|
||||
Property prop = config.get(Constants.CATEGORY_MODULES, 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);
|
||||
|
||||
|
||||
|
||||
|
||||
/* GENERAL ACCESS METHODS TO GET/SET VALUES IN THE CONFIG FILE */
|
||||
|
||||
public boolean getConfig(String category, String key, boolean default_){
|
||||
Property prop = config.get(category, key, default_);
|
||||
return prop.getBoolean(default_);
|
||||
}
|
||||
|
||||
public void setConfig(String category, String key, boolean state){
|
||||
config.getCategory(category).put(key, new Property(key,String.valueOf(state),Property.Type.BOOLEAN));
|
||||
config.save();
|
||||
}
|
||||
|
||||
public int getConfigInt(String key){
|
||||
mod_Waila.instance.config.load();
|
||||
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0);
|
||||
return prop.getInt();
|
||||
}
|
||||
public int getConfig(String category, String key, int default_){
|
||||
Property prop = config.get(category, key, default_);
|
||||
return prop.getInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(String key, boolean value){
|
||||
mod_Waila.instance.config.load();
|
||||
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, true).set(value);;
|
||||
mod_Waila.instance.config.save();
|
||||
public void setConfig(String category, String key, int state){
|
||||
config.getCategory(category).put(key, new Property(key,String.valueOf(state),Property.Type.INTEGER));
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public void setConfigInt(String key, int value){
|
||||
mod_Waila.instance.config.load();
|
||||
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0).set(value);;
|
||||
mod_Waila.instance.config.save();
|
||||
|
||||
|
||||
|
||||
|
||||
/* Default config loading */
|
||||
|
||||
public void loadDefaultConfig(FMLPreInitializationEvent event){
|
||||
config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, false);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
|
||||
|
||||
OverlayConfig.posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
|
||||
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
|
||||
|
||||
OverlayConfig.alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
|
||||
OverlayConfig.bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010).getInt();
|
||||
OverlayConfig.gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff).getInt();
|
||||
OverlayConfig.gradient2 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2, 0x28007f).getInt();
|
||||
OverlayConfig.fontcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR, 0xA0A0A0).getInt();
|
||||
OverlayConfig.scale = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, 100).getInt() / 100.0f;
|
||||
|
||||
config.getCategory(Constants.CATEGORY_MODULES).setComment("Those are the config keys defined in modules.\nServer side, it is used to enforce keys client side using the next section.");
|
||||
config.getCategory(Constants.CATEGORY_SERVER).setComment("Any key set to true here will ensure that the client is using the configuration set in the 'module' section above.\nThis is useful for enforcing false to 'cheating' keys like silverfish.");
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
+22
-27
@@ -3,6 +3,7 @@ package mcp.mobius.waila.api.impl;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -14,8 +15,9 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessor implements IWailaDataAccessor {
|
||||
public class DataAccessorBlock implements IWailaDataAccessor {
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
@@ -28,8 +30,9 @@ public class DataAccessor implements IWailaDataAccessor {
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
public ItemStack stack;
|
||||
|
||||
public static DataAccessor instance = new DataAccessor();
|
||||
public static DataAccessorBlock instance = new DataAccessorBlock();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
@@ -43,6 +46,8 @@ public class DataAccessor implements IWailaDataAccessor {
|
||||
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);
|
||||
try{ this.stack = new ItemStack(this.blockID, 1, this.metadata); } catch (Exception e) {}
|
||||
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
@@ -114,15 +119,7 @@ public class DataAccessor implements IWailaDataAccessor {
|
||||
|
||||
@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;
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
@@ -155,22 +152,20 @@ public class DataAccessor implements IWailaDataAccessor {
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide(){
|
||||
int side = this.getPosition().sideHit;
|
||||
switch (side){
|
||||
case 0:
|
||||
return ForgeDirection.DOWN;
|
||||
case 1:
|
||||
return ForgeDirection.UP;
|
||||
case 2:
|
||||
return ForgeDirection.EAST;
|
||||
case 3:
|
||||
return ForgeDirection.WEST;
|
||||
case 4:
|
||||
return ForgeDirection.NORTH;
|
||||
case 5:
|
||||
return ForgeDirection.SOUTH;
|
||||
}
|
||||
return ForgeDirection.UNKNOWN;
|
||||
return ForgeDirection.getOrientation(this.getPosition().sideHit);
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.NBTTagShort;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorEntity implements IWailaEntityAccessor {
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public Entity entity;
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
|
||||
public static DataAccessorEntity instance = new DataAccessorEntity();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.entity = _mop.entityHit;
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
public String id;
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public TileEntity entity;
|
||||
public NBTTagCompound partialNBT = null;
|
||||
public NBTTagCompound remoteNBT = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
|
||||
public static DataAccessorFMP instance = new DataAccessorFMP();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT, String id) {
|
||||
this.set(_world, _player, _mop, _partialNBT, id, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT, String id, Vec3 renderVec, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.entity = world.getBlockTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.partialNBT = _partialNBT;
|
||||
this.id = id;
|
||||
this.renderingvec = renderVec;
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
return this.partialNBT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getFullNBTData() {
|
||||
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) {
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaBlock;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.network.Packet0x01TERequest;
|
||||
import mcp.mobius.waila.network.Packet0x03EntRequest;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -19,13 +23,18 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class MetaDataProvider{
|
||||
|
||||
private ArrayList<IWailaDataProvider> headProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> bodyProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> tailProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> headBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> bodyBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> tailBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
|
||||
private ArrayList<IWailaEntityProvider> headEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
private ArrayList<IWailaEntityProvider> bodyEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
private ArrayList<IWailaEntityProvider> tailEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
|
||||
private Class prevBlock = null;
|
||||
private Class prevTile = null;
|
||||
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor accessor) {
|
||||
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
@@ -37,8 +46,8 @@ public class MetaDataProvider{
|
||||
}
|
||||
}
|
||||
|
||||
if(ModuleRegistrar.instance().hasStackProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ModuleRegistrar.instance().getStackProviders(blockID)){
|
||||
if(ModuleRegistrar.instance().hasStackProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ModuleRegistrar.instance().getStackProviders(block)){
|
||||
try{
|
||||
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
@@ -51,14 +60,21 @@ public class MetaDataProvider{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor accessor, List<String> currenttip, Layout layout) {
|
||||
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor, List<String> currenttip, Layout layout) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent &&
|
||||
((System.currentTimeMillis() - accessor.timeLastUpdate >= 250))){
|
||||
accessor.timeLastUpdate = System.currentTimeMillis();
|
||||
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
|
||||
if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
accessor.resetTimer();
|
||||
HashSet<String> keys = new HashSet<String>();
|
||||
|
||||
if (ModuleRegistrar.instance().hasSyncedNBTKeys(block))
|
||||
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(block));
|
||||
|
||||
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getTileEntity()))
|
||||
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getTileEntity()));
|
||||
|
||||
if (keys.size() != 0)
|
||||
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop, keys));
|
||||
}
|
||||
|
||||
/* Interface IWailaBlock */
|
||||
@@ -84,34 +100,34 @@ public class MetaDataProvider{
|
||||
}
|
||||
}
|
||||
|
||||
headProviders.clear();
|
||||
bodyProviders.clear();
|
||||
tailProviders.clear();
|
||||
headBlockProviders.clear();
|
||||
bodyBlockProviders.clear();
|
||||
tailBlockProviders.clear();
|
||||
|
||||
/* Lookup by class (for blocks)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(block))
|
||||
headProviders.addAll(ModuleRegistrar.instance().getHeadProviders(block));
|
||||
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(block));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(block))
|
||||
bodyProviders.addAll(ModuleRegistrar.instance().getBodyProviders(block));
|
||||
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(block));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(block))
|
||||
tailProviders.addAll(ModuleRegistrar.instance().getTailProviders(block));
|
||||
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(block));
|
||||
|
||||
|
||||
/* Lookup by class (for tileentities)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(accessor.getTileEntity()))
|
||||
headProviders.addAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
|
||||
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(accessor.getTileEntity()))
|
||||
bodyProviders.addAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
|
||||
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(accessor.getTileEntity()))
|
||||
tailProviders.addAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
|
||||
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
|
||||
|
||||
/* Apply all collected providers */
|
||||
if (layout == Layout.HEADER)
|
||||
for (IWailaDataProvider dataProvider : headProviders)
|
||||
for (IWailaDataProvider dataProvider : headBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
@@ -119,7 +135,7 @@ public class MetaDataProvider{
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY)
|
||||
for (IWailaDataProvider dataProvider : bodyProviders)
|
||||
for (IWailaDataProvider dataProvider : bodyBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
@@ -127,7 +143,7 @@ public class MetaDataProvider{
|
||||
}
|
||||
|
||||
if (layout == Layout.FOOTER)
|
||||
for (IWailaDataProvider dataProvider : tailProviders)
|
||||
for (IWailaDataProvider dataProvider : tailBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
@@ -136,4 +152,59 @@ public class MetaDataProvider{
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorEntity accessor, List<String> currenttip, Layout layout) {
|
||||
|
||||
if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
accessor.resetTimer();
|
||||
HashSet<String> keys = new HashSet<String>();
|
||||
|
||||
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getEntity()))
|
||||
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getEntity()));
|
||||
|
||||
if (keys.size() != 0)
|
||||
PacketDispatcher.sendPacketToServer(Packet0x03EntRequest.create(world, accessor.getEntity(), keys));
|
||||
}
|
||||
|
||||
headEntityProviders.clear();
|
||||
bodyEntityProviders.clear();
|
||||
tailEntityProviders.clear();
|
||||
|
||||
/* Lookup by class (for entities)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadEntityProviders(entity))
|
||||
headEntityProviders.addAll(ModuleRegistrar.instance().getHeadEntityProviders(entity));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyEntityProviders(entity))
|
||||
bodyEntityProviders.addAll(ModuleRegistrar.instance().getBodyEntityProviders(entity));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailEntityProviders(entity))
|
||||
tailEntityProviders.addAll(ModuleRegistrar.instance().getTailEntityProviders(entity));
|
||||
|
||||
/* Apply all collected providers */
|
||||
if (layout == Layout.HEADER)
|
||||
for (IWailaEntityProvider dataProvider : headEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY)
|
||||
for (IWailaEntityProvider dataProvider : bodyEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
|
||||
if (layout == Layout.FOOTER)
|
||||
for (IWailaEntityProvider dataProvider : tailEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -13,42 +14,53 @@ import java.util.logging.Level;
|
||||
import au.com.bytecode.opencsv.CSVReader;
|
||||
import net.minecraft.block.Block;
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.IWailaFMPDecorator;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.IWailaSummaryProvider;
|
||||
|
||||
public class ModuleRegistrar implements IWailaRegistrar {
|
||||
|
||||
private static ModuleRegistrar instance = null;
|
||||
//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>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> stackBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
|
||||
|
||||
public LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>> blockClassDecorators = new LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>>();
|
||||
|
||||
public LinkedHashMap<Integer, ArrayList<IWailaBlockDecorator>> blockIdDecorators = new LinkedHashMap<Integer, ArrayList<IWailaBlockDecorator>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>> blockClassDecorators = new LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> headEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> bodyEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> tailEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
|
||||
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> overrideEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
|
||||
|
||||
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> headFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
|
||||
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> bodyFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
|
||||
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> tailFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
|
||||
|
||||
public LinkedHashMap<String, ArrayList<IWailaFMPDecorator>> FMPClassDecorators = new LinkedHashMap<String, ArrayList<IWailaFMPDecorator>>();
|
||||
|
||||
public LinkedHashMap<Class, HashSet<String>> syncedNBTKeys = new LinkedHashMap<Class, HashSet<String>>();
|
||||
|
||||
public LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>> wikiDescriptions = new LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>>();
|
||||
|
||||
public LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>> summaryProviders = new LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>>();
|
||||
|
||||
private ModuleRegistrar() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static ModuleRegistrar instance(){
|
||||
public static ModuleRegistrar instance(){
|
||||
if (ModuleRegistrar.instance == null)
|
||||
ModuleRegistrar.instance = new ModuleRegistrar();
|
||||
return ModuleRegistrar.instance;
|
||||
}
|
||||
|
||||
/* CONFIG HANDLING */
|
||||
@Override
|
||||
public void addConfig(String modname, String key, String configname) {
|
||||
ConfigHandler.instance().addConfig(modname, key, LangUtil.translateG(configname));
|
||||
@@ -69,182 +81,283 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG("option." + key));
|
||||
}
|
||||
|
||||
|
||||
/* REGISTRATION METHODS */
|
||||
@Override
|
||||
@Deprecated
|
||||
public void registerHeadProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
this.registerHeadProvider(dataProvider, Block.blocksList[blockID].getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHeadProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.headBlockProviders.containsKey(block))
|
||||
this.headBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
|
||||
ArrayList<IWailaDataProvider> providers = this.headBlockProviders.get(block);
|
||||
if (providers.contains(dataProvider)) return;
|
||||
|
||||
this.headBlockProviders.get(block).add(dataProvider);
|
||||
this.registerProvider(dataProvider, block, this.headBlockProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void registerBodyProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
this.registerBodyProvider(dataProvider, Block.blocksList[blockID].getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBodyProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.bodyBlockProviders.containsKey(block))
|
||||
this.bodyBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
|
||||
ArrayList<IWailaDataProvider> providers = this.bodyBlockProviders.get(block);
|
||||
if (providers.contains(dataProvider)) return;
|
||||
|
||||
this.bodyBlockProviders.get(block).add(dataProvider);
|
||||
this.registerProvider(dataProvider, block, this.bodyBlockProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void registerTailProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
this.registerTailProvider(dataProvider, Block.blocksList[blockID].getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
|
||||
if (!this.tailBlockProviders.containsKey(block))
|
||||
this.tailBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
|
||||
|
||||
ArrayList<IWailaDataProvider> providers = this.tailBlockProviders.get(block);
|
||||
if (providers.contains(dataProvider)) return;
|
||||
|
||||
this.tailBlockProviders.get(block).add(dataProvider);
|
||||
this.registerProvider(dataProvider, block, this.tailBlockProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID) {
|
||||
if (!this.stackProviders.containsKey(blockID))
|
||||
this.stackProviders.put(blockID, new ArrayList<IWailaDataProvider>());
|
||||
this.stackProviders.get(blockID).add(dataProvider);
|
||||
this.registerStackProvider(dataProvider, Block.blocksList[blockID].getClass());
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
this.registerProvider(dataProvider, block, this.stackBlockProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerShortDataProvider(IWailaSummaryProvider dataProvider, Class item) {
|
||||
if (!this.summaryProviders.containsKey(item))
|
||||
this.summaryProviders.put(item, new ArrayList<IWailaSummaryProvider>());
|
||||
this.summaryProviders.get(item).add(dataProvider);
|
||||
public void registerHeadProvider(IWailaEntityProvider dataProvider, Class entity) {
|
||||
this.registerProvider(dataProvider, entity, this.headEntityProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBodyProvider(IWailaEntityProvider dataProvider, Class entity) {
|
||||
this.registerProvider(dataProvider, entity, this.bodyEntityProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockDecorator(IWailaBlockDecorator decorator, int blockID) {
|
||||
if (!this.blockIdDecorators.containsKey(blockID))
|
||||
this.blockIdDecorators.put(blockID, new ArrayList<IWailaBlockDecorator>());
|
||||
this.blockIdDecorators.get(blockID).add(decorator);
|
||||
public void registerTailProvider(IWailaEntityProvider dataProvider, Class entity) {
|
||||
this.registerProvider(dataProvider, entity, this.tailEntityProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name) {
|
||||
this.registerProvider(dataProvider, name, this.headFMPProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name) {
|
||||
this.registerProvider(dataProvider, name, this.bodyFMPProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTailProvider(IWailaFMPProvider dataProvider, String name) {
|
||||
this.registerProvider(dataProvider, name, this.tailFMPProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity){
|
||||
this.registerProvider(dataProvider, entity, this.overrideEntityProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerShortDataProvider(IWailaSummaryProvider dataProvider, Class item) {
|
||||
this.registerProvider(dataProvider, item, this.summaryProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void registerDecorator(IWailaBlockDecorator decorator, int blockID) {
|
||||
this.registerDecorator(decorator, Block.blocksList[blockID].getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockDecorator(IWailaBlockDecorator decorator, Class block) {
|
||||
if (!this.blockClassDecorators.containsKey(block))
|
||||
this.blockClassDecorators.put(block, new ArrayList<IWailaBlockDecorator>());
|
||||
this.blockClassDecorators.get(block).add(decorator);
|
||||
public void registerDecorator(IWailaBlockDecorator decorator, Class block) {
|
||||
this.registerProvider(decorator, block, this.blockClassDecorators);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerDecorator(IWailaFMPDecorator decorator, String name) {
|
||||
this.registerProvider(decorator, name, this.FMPClassDecorators);
|
||||
}
|
||||
|
||||
private <T, V> void registerProvider(T dataProvider, V clazz, LinkedHashMap<V, ArrayList<T>> target) {
|
||||
if (!target.containsKey(clazz))
|
||||
target.put(clazz, new ArrayList<T>());
|
||||
|
||||
ArrayList<T> providers =target.get(clazz);
|
||||
if (providers.contains(dataProvider)) return;
|
||||
|
||||
target.get(clazz).add(dataProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSyncedNBTKey(String key, Class target){
|
||||
if (!this.syncedNBTKeys.containsKey(target))
|
||||
this.syncedNBTKeys.put(target, new HashSet<String>());
|
||||
|
||||
this.syncedNBTKeys.get(target).add(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* PROVIDER GETTERS */
|
||||
|
||||
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;
|
||||
return getProviders(block, this.headBlockProviders);
|
||||
}
|
||||
|
||||
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;
|
||||
return getProviders(block, this.bodyBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
|
||||
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
|
||||
for (Class clazz : this.tailBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
returnList.addAll(this.tailBlockProviders.get(clazz));
|
||||
|
||||
return returnList;
|
||||
return getProviders(block, this.tailBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getStackProviders(int blockID) {
|
||||
return this.stackProviders.get(blockID);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
|
||||
ArrayList<IWailaSummaryProvider> returnList = new ArrayList<IWailaSummaryProvider>();
|
||||
for (Class clazz : this.summaryProviders.keySet())
|
||||
if (clazz.isInstance(item))
|
||||
returnList.addAll(this.summaryProviders.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
public ArrayList<IWailaDataProvider> getStackProviders(Object block) {
|
||||
return getProviders(block, this.stackBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaBlockDecorator> getBlockDecorators(int blockID){
|
||||
return this.blockIdDecorators.get(blockID);
|
||||
public ArrayList<IWailaEntityProvider> getHeadEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.headEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getBodyEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.bodyEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getTailEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.tailEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getOverrideEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.overrideEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getHeadFMPProviders(String name) {
|
||||
return getProviders(name, this.headFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getBodyFMPProviders(String name) {
|
||||
return getProviders(name, this.bodyFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getTailFMPProviders(String name) {
|
||||
return getProviders(name, this.tailFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
|
||||
return getProviders(item, this.summaryProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaBlockDecorator> getBlockDecorators(Object block){
|
||||
ArrayList<IWailaBlockDecorator> returnList = new ArrayList<IWailaBlockDecorator>();
|
||||
for (Class clazz : this.blockClassDecorators.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
returnList.addAll(this.blockClassDecorators.get(clazz));
|
||||
return getProviders(block, this.blockClassDecorators);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPDecorator> getFMPDecorators(String name){
|
||||
return getProviders(name, this.FMPClassDecorators);
|
||||
}
|
||||
|
||||
private <T> ArrayList<T> getProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
|
||||
ArrayList<T> returnList = new ArrayList<T>();
|
||||
for (Class clazz : target.keySet())
|
||||
if (clazz.isInstance(obj))
|
||||
returnList.addAll(target.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public boolean hasStackProviders(int blockID){
|
||||
return this.stackProviders.containsKey(blockID);
|
||||
private <T> ArrayList<T> getProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
|
||||
return target.get(name);
|
||||
}
|
||||
|
||||
public HashSet<String> getSyncedNBTKeys(Object target){
|
||||
HashSet<String> returnList = new HashSet<String>();
|
||||
for (Class clazz : this.syncedNBTKeys.keySet())
|
||||
if (clazz.isInstance(target))
|
||||
returnList.addAll(this.syncedNBTKeys.get(clazz));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/* HAS METHODS */
|
||||
|
||||
public boolean hasStackProviders(Object block){
|
||||
return hasProviders(block, this.stackBlockProviders);
|
||||
}
|
||||
|
||||
public boolean hasHeadProviders(Object block){
|
||||
for (Class clazz : this.headBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
return hasProviders(block, this.headBlockProviders);
|
||||
}
|
||||
|
||||
public boolean hasBodyProviders(Object block){
|
||||
for (Class clazz : this.bodyBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
return hasProviders(block, this.bodyBlockProviders);
|
||||
}
|
||||
|
||||
public boolean hasTailProviders(Object block){
|
||||
for (Class clazz : this.tailBlockProviders.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
return true;
|
||||
return false;
|
||||
return hasProviders(block, this.tailBlockProviders);
|
||||
}
|
||||
|
||||
public boolean hasHeadEntityProviders(Object entity){
|
||||
return hasProviders(entity, this.headEntityProviders);
|
||||
}
|
||||
|
||||
public boolean hasBodyEntityProviders(Object entity){
|
||||
return hasProviders(entity, this.bodyEntityProviders);
|
||||
}
|
||||
|
||||
public boolean hasTailEntityProviders(Object entity){
|
||||
return hasProviders(entity, this.tailEntityProviders);
|
||||
}
|
||||
|
||||
public boolean hasOverrideEntityProviders(Object entity){
|
||||
return hasProviders(entity, this.overrideEntityProviders);
|
||||
}
|
||||
|
||||
public boolean hasHeadFMPProviders(String name){
|
||||
return hasProviders(name, this.headFMPProviders);
|
||||
}
|
||||
|
||||
public boolean hasBodyFMPProviders(String name){
|
||||
return hasProviders(name, this.bodyFMPProviders);
|
||||
}
|
||||
|
||||
public boolean hasTailFMPProviders(String name){
|
||||
return hasProviders(name, this.tailFMPProviders);
|
||||
}
|
||||
|
||||
public boolean hasBlockDecorator(Object block){
|
||||
return hasProviders(block, this.blockClassDecorators);
|
||||
}
|
||||
|
||||
public boolean hasFMPDecorator(String name){
|
||||
return hasProviders(name, this.FMPClassDecorators);
|
||||
}
|
||||
|
||||
private <T> boolean hasProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
|
||||
for (Class clazz : target.keySet())
|
||||
if (clazz.isInstance(obj))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private <T> boolean hasProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
|
||||
return target.containsKey(name);
|
||||
}
|
||||
|
||||
public boolean hasSummaryProvider(Class item){
|
||||
return this.summaryProviders.containsKey(item);
|
||||
}
|
||||
|
||||
public boolean hasBlockDecorator(int blockID){
|
||||
return this.blockIdDecorators.containsKey(blockID);
|
||||
}
|
||||
|
||||
public boolean hasBlockDecorator(Object block){
|
||||
for (Class clazz : this.blockClassDecorators.keySet())
|
||||
if (clazz.isInstance(block))
|
||||
public boolean hasSyncedNBTKeys(Object target){
|
||||
for (Class clazz : this.syncedNBTKeys.keySet())
|
||||
if (clazz.isInstance(target))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------- */
|
||||
@Override
|
||||
@@ -256,7 +369,7 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
try{
|
||||
docData = this.readFileAsString(filename);
|
||||
} catch (IOException e){
|
||||
mod_Waila.log.log(Level.WARNING, String.format("Error while accessing file %s : %s", filename, e));
|
||||
Waila.log.log(Level.WARNING, String.format("Error while accessing file %s : %s", filename, e));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,7 +408,7 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
}
|
||||
}
|
||||
*/
|
||||
mod_Waila.log.log(Level.INFO, String.format("Registered %s entries from %s", nentries, filename));
|
||||
Waila.log.log(Level.INFO, String.format("Registered %s entries from %s", nentries, filename));
|
||||
}
|
||||
|
||||
public boolean hasDocTextModID(String modid){
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
@API(apiVersion="1.0",owner="Waila",provides="WailaAPI")
|
||||
package mcp.mobius.waila.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -3,18 +3,19 @@ package mcp.mobius.waila.client;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
|
||||
import mcp.mobius.waila.handlers.nei.HandlerEnchants;
|
||||
import mcp.mobius.waila.overlay.RayTracing;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -25,7 +26,6 @@ import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class ConfigKeyHandler extends KeyHandler {
|
||||
|
||||
@@ -81,18 +81,18 @@ public class ConfigKeyHandler extends KeyHandler {
|
||||
if (mc.currentScreen != null)
|
||||
return;
|
||||
|
||||
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
|
||||
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_SHOW);
|
||||
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, !status);
|
||||
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
|
||||
boolean status = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, !status);
|
||||
}
|
||||
|
||||
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
|
||||
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, true);
|
||||
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
|
||||
}
|
||||
|
||||
else if (kb.keyDescription == Constants.BIND_WAILA_LIQUID){
|
||||
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID);
|
||||
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_LIQUID, !status);
|
||||
boolean status = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true);
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, !status);
|
||||
}
|
||||
|
||||
else if (kb.keyDescription == Constants.BIND_WAILA_RECIPE){
|
||||
@@ -148,8 +148,8 @@ public class ConfigKeyHandler extends KeyHandler {
|
||||
@Override
|
||||
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
|
||||
if (!tickEnd) return;
|
||||
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
|
||||
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, false);
|
||||
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,44 +1,51 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.appeng.AppEngModule;
|
||||
import mcp.mobius.waila.addons.buildcraft.BCModule;
|
||||
import mcp.mobius.waila.addons.buildcraft.BCPowerAPIModule;
|
||||
import mcp.mobius.waila.addons.carpenters.CarpentersModule;
|
||||
import mcp.mobius.waila.addons.enderio.EnderIOModule;
|
||||
import mcp.mobius.waila.addons.enderstorage.EnderStorageModule;
|
||||
import mcp.mobius.waila.addons.etb.ETBModule;
|
||||
import mcp.mobius.waila.addons.exu.ExtraUtilitiesModule;
|
||||
import mcp.mobius.waila.addons.gravestone.GravestoneModule;
|
||||
import mcp.mobius.waila.addons.harvestcraft.HarvestcraftModule;
|
||||
import mcp.mobius.waila.addons.ic2.IC2Module;
|
||||
import mcp.mobius.waila.addons.magicalcrops.MagicalCropsModule;
|
||||
import mcp.mobius.waila.addons.openblocks.OpenBlocksModule;
|
||||
import mcp.mobius.waila.addons.projectred.ProjectRedModule;
|
||||
import mcp.mobius.waila.addons.railcraft.RailcraftModule;
|
||||
import mcp.mobius.waila.addons.secretrooms.SecretRoomsModule;
|
||||
import mcp.mobius.waila.addons.stevescarts.StevesCartsModule;
|
||||
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
|
||||
import mcp.mobius.waila.addons.thermalexpansion.ThermalExpansionModule;
|
||||
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
|
||||
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.gui.truetyper.FontLoader;
|
||||
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerWaila;
|
||||
import mcp.mobius.waila.handlers.DecoratorFMP;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerBlocks;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerEntities;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerFMP;
|
||||
import mcp.mobius.waila.handlers.SummaryProviderDefault;
|
||||
import mcp.mobius.waila.handlers.nei.TooltipHandlerWaila;
|
||||
import mcp.mobius.waila.overlay.WailaTickHandler;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.forge.GuiContainerManager;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@@ -54,7 +61,7 @@ public class ProxyClient extends ProxyServer {
|
||||
@Override
|
||||
public void registerHandlers(){
|
||||
|
||||
LangUtil.instance.loadLangDir("waila");
|
||||
LangUtil.loadLangDir("waila");
|
||||
|
||||
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
|
||||
|
||||
@@ -62,12 +69,6 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
|
||||
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.HEADER);
|
||||
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.BODY);
|
||||
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.FOOTER);
|
||||
//API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.FOOTER);
|
||||
//API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.HEADER);
|
||||
|
||||
KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
|
||||
|
||||
// We mute the default keybind for displaying the tooltip
|
||||
@@ -77,8 +78,12 @@ public class ProxyClient extends ProxyServer {
|
||||
//API.addKeyBind(Constants.BIND_WIKI, "Display wiki", Keyboard.KEY_RSHIFT);
|
||||
//API.addKeyBind(Constants.BIND_TECH, "Display techtree", Keyboard.KEY_RSHIFT);
|
||||
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerWaila(), Block.class);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerWaila(), Block.class);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBlocks(), Block.class);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerBlocks(), Block.class);
|
||||
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerEntities(), Entity.class);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerEntities(), Entity.class);
|
||||
|
||||
ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
|
||||
}
|
||||
|
||||
@@ -133,7 +138,31 @@ public class ProxyClient extends ProxyServer {
|
||||
OpenBlocksModule.register();
|
||||
|
||||
/* Railcraft */
|
||||
RailcraftModule.register();
|
||||
RailcraftModule.register();
|
||||
|
||||
/* Steve's Carts */
|
||||
StevesCartsModule.register();
|
||||
|
||||
/* Secret Rooms */
|
||||
SecretRoomsModule.register();
|
||||
|
||||
/* Carpenter's Blocks */
|
||||
CarpentersModule.register();
|
||||
|
||||
/* Pam's HarvestCraft */
|
||||
HarvestcraftModule.register();
|
||||
|
||||
/* Magical crops */
|
||||
MagicalCropsModule.register();
|
||||
|
||||
if(Loader.isModLoaded("ForgeMultipart")){
|
||||
HUDHandlerFMP.register();
|
||||
DecoratorFMP.register();
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), Block.class);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), TileEntity.class);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEntities(), Entity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.gui.screens.config;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.gui.interfaces.CType;
|
||||
import mcp.mobius.waila.gui.interfaces.WAlign;
|
||||
import mcp.mobius.waila.gui.screens.ScreenBase;
|
||||
@@ -10,6 +9,7 @@ import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class ScreenConfig extends ScreenBase {
|
||||
|
||||
@@ -2,8 +2,7 @@ package mcp.mobius.waila.gui.screens.config;
|
||||
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.interfaces.CType;
|
||||
@@ -19,7 +18,10 @@ import mcp.mobius.waila.gui.widgets.WidgetGeometry;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonLabel;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.gui.widgets.movable.PictureMovableRC;
|
||||
import mcp.mobius.waila.overlay.OverlayConfig;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
public class ScreenHUDConfig extends ScreenBase {
|
||||
|
||||
@@ -48,10 +50,10 @@ public class ScreenHUDConfig extends ScreenBase {
|
||||
layoutY.addWidget("ValueDisplayY", new LabelFixedFont(null, "0")).setGeometry(new WidgetGeometry(50.0,50.0,20,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
|
||||
*/
|
||||
|
||||
double picX = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSX) / 100.0;
|
||||
double picY = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSY) / 100.0;
|
||||
float picAlpha = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f;
|
||||
scale = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_SCALE) / 100.0f;
|
||||
double picX = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0) / 100.0;
|
||||
double picY = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0) / 100.0;
|
||||
float picAlpha = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA,0) / 100.0f;
|
||||
scale = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE,0) / 100.0f;
|
||||
|
||||
int picSX = (int)(180 / this.rez.getScaleFactor() * scale), picSY = (int)(62 / this.rez.getScaleFactor() * scale);
|
||||
this.addWidget("Layout", new LayoutMargin(null), RenderPriority.HIGH);
|
||||
@@ -219,17 +221,17 @@ public class ScreenHUDConfig extends ScreenBase {
|
||||
|
||||
}
|
||||
if (srcwidget.equals(this.getWidget("ButtonOk")) && signal == Signal.CLICKED){
|
||||
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_POSX, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getX() * 100.0));
|
||||
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_POSY, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getY() * 100.0));
|
||||
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_ALPHA, (int)(this.getWidget("Layout").getWidget("Picture").getAlpha() * 100.0));
|
||||
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_SCALE, (int)(scale * 100.0));
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getX() * 100.0));
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getY() * 100.0));
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, (int)(this.getWidget("Layout").getWidget("Picture").getAlpha() * 100.0));
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, (int)(scale * 100.0));
|
||||
|
||||
mod_Waila.alpha = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA);
|
||||
mod_Waila.posX = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSX);
|
||||
mod_Waila.posY = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSY);
|
||||
mod_Waila.scale = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_SCALE) / 100.0f;
|
||||
OverlayConfig.alpha = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA,0);
|
||||
OverlayConfig.posX = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 0);
|
||||
OverlayConfig.posY = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 0);
|
||||
OverlayConfig.scale = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE,0) / 100.0f;
|
||||
|
||||
mod_Waila.updateColors();
|
||||
OverlayConfig.updateColors();
|
||||
}
|
||||
|
||||
if (srcwidget.equals(this.getWidget("ButtonDefault")) && signal == Signal.CLICKED){
|
||||
|
||||
@@ -11,6 +11,7 @@ import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfigRemote;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class ScreenModuleConfig extends ScreenBase {
|
||||
@@ -29,9 +30,9 @@ public class ScreenModuleConfig extends ScreenBase {
|
||||
|
||||
for (String key:ConfigHandler.instance().getConfigKeys(this.modName).keySet()){
|
||||
if (ConfigHandler.instance().isServerRequired(key))
|
||||
buttonContainer.addButton(new ButtonBooleanConfigRemote(this.getRoot(), key, "screen.button.no", "screen.button.yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
|
||||
buttonContainer.addButton(new ButtonBooleanConfigRemote(this.getRoot(), Constants.CATEGORY_MODULES, key, "screen.button.no", "screen.button.yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
|
||||
else
|
||||
buttonContainer.addButton(new ButtonBooleanConfig(this.getRoot(), key, "screen.button.no", "screen.button.yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
|
||||
buttonContainer.addButton(new ButtonBooleanConfig(this.getRoot(), Constants.CATEGORY_MODULES, key, "screen.button.no", "screen.button.yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
|
||||
//buttonContainer.addButton(new ButtonConfigRemote(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
|
||||
//else
|
||||
//buttonContainer.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package mcp.mobius.waila.gui.screens.config;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import mcp.mobius.waila.Constants;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.gui.interfaces.CType;
|
||||
import mcp.mobius.waila.gui.interfaces.WAlign;
|
||||
import mcp.mobius.waila.gui.screens.ScreenBase;
|
||||
@@ -11,6 +11,7 @@ import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonIntegerConfig;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
public class ScreenWailaConfig extends ScreenBase {
|
||||
public ScreenWailaConfig(GuiScreen parent){
|
||||
@@ -21,10 +22,12 @@ public class ScreenWailaConfig extends ScreenBase {
|
||||
|
||||
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel)this.getRoot().getWidget("ButtonContainer"));
|
||||
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_SHOW, true, true, "screen.button.hidden", "screen.button.visible"), "choice.showhidewaila");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_MODE, true, true, "screen.button.maintained", "screen.button.toggled"), "choice.toggledmaintained");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_METADATA, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showhideidmeta");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_LIQUID, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showliquids");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true, true, "screen.button.hidden", "screen.button.visible"), "choice.showhidewaila");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true, true, "screen.button.maintained", "screen.button.toggled"), "choice.toggledmaintained");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showhideidmeta");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true, false,"screen.button.hidden", "screen.button.visible"), "choice.showliquids");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTBLOCK, true, false,"screen.button.no", "screen.button.yes"), "choice.shifttoggledblock");
|
||||
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, true, false,"screen.button.no", "screen.button.yes"), "choice.shifttoggledents");
|
||||
|
||||
|
||||
this.getRoot().addWidget("LayoutConfigPos", new LayoutBase(this.getRoot()));
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
package mcp.mobius.waila.gui.widgets.buttons;
|
||||
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.Property;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
|
||||
public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
|
||||
private String configKey;
|
||||
private boolean instant;
|
||||
protected String category;
|
||||
protected String configKey;
|
||||
protected boolean instant;
|
||||
|
||||
public ButtonBooleanConfig(IWidget parent, String configKey, String textFalse, String textTrue){
|
||||
this(parent, configKey, true, true, textFalse, textTrue);
|
||||
public ButtonBooleanConfig(IWidget parent, String category, String configKey, String textFalse, String textTrue){
|
||||
this(parent, category, configKey, true, true, textFalse, textTrue);
|
||||
}
|
||||
|
||||
public ButtonBooleanConfig(IWidget parent, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
|
||||
public ButtonBooleanConfig(IWidget parent, String category, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
|
||||
super(parent, textFalse, textTrue);
|
||||
this.category = category;
|
||||
this.configKey = configKey;
|
||||
this.instant = instant;
|
||||
|
||||
mod_Waila.instance.config.load();
|
||||
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, this.configKey, state_);
|
||||
this.state = prop.getBoolean(state_);
|
||||
this.state = ConfigHandler.instance().getConfig(this.category, this.configKey, state_);
|
||||
|
||||
if (this.state){
|
||||
this.getWidget("LabelTrue").show();
|
||||
@@ -35,12 +39,24 @@ public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
|
||||
@Override
|
||||
public void onMouseClick(MouseEvent event){
|
||||
super.onMouseClick(event);
|
||||
if (!ConfigHandler.instance().forcedConfigs.containsKey(this.configKey))
|
||||
super.onMouseClick(event);
|
||||
|
||||
if (this.instant){
|
||||
mod_Waila.instance.config.getCategory(Configuration.CATEGORY_GENERAL).put(this.configKey, new Property(this.configKey,String.valueOf(this.state),Property.Type.BOOLEAN));
|
||||
mod_Waila.instance.config.save();
|
||||
}
|
||||
if (this.instant)
|
||||
ConfigHandler.instance().setConfig(this.category, this.configKey, this.state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {
|
||||
if (!ConfigHandler.instance().forcedConfigs.containsKey(this.configKey))
|
||||
super.draw(pos);
|
||||
else{
|
||||
this.saveGLState();
|
||||
int texOffset = -1;
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@ import org.lwjgl.util.Point;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.Property;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
@@ -13,13 +14,13 @@ import mcp.mobius.waila.gui.widgets.LabelFixedFont;
|
||||
|
||||
public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
|
||||
public ButtonBooleanConfigRemote(IWidget parent, String configKey, String textFalse, String textTrue){
|
||||
this(parent, configKey, true, true, textFalse, textTrue);
|
||||
public ButtonBooleanConfigRemote(IWidget parent, String category, String configKey, String textFalse, String textTrue){
|
||||
this(parent, category, configKey, true, true, textFalse, textTrue);
|
||||
}
|
||||
|
||||
public ButtonBooleanConfigRemote(IWidget parent, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
|
||||
super(parent, configKey, instant, state_, textFalse, textTrue);
|
||||
if (!mod_Waila.instance.serverPresent)
|
||||
public ButtonBooleanConfigRemote(IWidget parent, String category, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
|
||||
super(parent, category, configKey, instant, state_, textFalse, textTrue);
|
||||
if (!Waila.instance.serverPresent)
|
||||
this.state = false;
|
||||
|
||||
if (this.state){
|
||||
@@ -33,13 +34,13 @@ public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
|
||||
@Override
|
||||
public void onMouseClick(MouseEvent event){
|
||||
if (mod_Waila.instance.serverPresent)
|
||||
if ((Waila.instance.serverPresent) && !ConfigHandler.instance().forcedConfigs.containsKey(this.configKey))
|
||||
super.onMouseClick(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {
|
||||
if (mod_Waila.instance.serverPresent)
|
||||
if ((Waila.instance.serverPresent) && !ConfigHandler.instance().forcedConfigs.containsKey(this.configKey))
|
||||
super.draw(pos);
|
||||
else{
|
||||
this.saveGLState();
|
||||
|
||||
@@ -5,28 +5,29 @@ import net.minecraftforge.common.Property;
|
||||
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
import mcp.mobius.waila.gui.widgets.WidgetBase;
|
||||
|
||||
public class ButtonIntegerConfig extends ButtonInteger {
|
||||
|
||||
private String category;
|
||||
private String configKey;
|
||||
private boolean instant;
|
||||
|
||||
public ButtonIntegerConfig(IWidget parent, String configKey, String... texts){
|
||||
this(parent, configKey, true, 0, texts);
|
||||
public ButtonIntegerConfig(IWidget parent, String category, String configKey, String... texts){
|
||||
this(parent, category, configKey, true, 0, texts);
|
||||
}
|
||||
|
||||
public ButtonIntegerConfig(IWidget parent, String configKey, boolean instant, int state_, String... texts){
|
||||
public ButtonIntegerConfig(IWidget parent, String category, String configKey, boolean instant, int state_, String... texts){
|
||||
super(parent, texts);
|
||||
this.category = category;
|
||||
this.configKey = configKey;
|
||||
this.instant = instant;
|
||||
|
||||
mod_Waila.instance.config.load();
|
||||
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, this.configKey, state_);
|
||||
this.state = prop.getInt();
|
||||
this.state = ConfigHandler.instance().getConfig(this.category, this.configKey, state_);
|
||||
|
||||
for (int i = 0; i < this.nStates; i++)
|
||||
this.getWidget(String.format("Label_%d", i)).hide();
|
||||
@@ -38,10 +39,8 @@ public class ButtonIntegerConfig extends ButtonInteger {
|
||||
public void onMouseClick(MouseEvent event){
|
||||
super.onMouseClick(event);
|
||||
|
||||
if (this.instant){
|
||||
mod_Waila.instance.config.getCategory(Configuration.CATEGORY_GENERAL).put(this.configKey, new Property(this.configKey,String.valueOf(this.state),Property.Type.INTEGER));
|
||||
mod_Waila.instance.config.save();
|
||||
}
|
||||
if (this.instant)
|
||||
ConfigHandler.instance().setConfig(this.category, this.configKey, this.state);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPDecorator;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorFMP;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class DecoratorFMP implements IWailaBlockDecorator {
|
||||
|
||||
@Override
|
||||
public void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
NBTTagList list = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound) list.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (ModuleRegistrar.instance().hasFMPDecorator(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id, accessor.getRenderingPosition(), accessor.getPartialFrame());
|
||||
|
||||
for (IWailaFMPDecorator provider : ModuleRegistrar.instance().getFMPDecorators(id))
|
||||
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void register(){
|
||||
Class BlockMultipart = null;
|
||||
try{
|
||||
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[FMP] Class not found. " + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARNING, "[FMP] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerDecorator(new DecoratorFMP(), BlockMultipart);
|
||||
}
|
||||
|
||||
}
|
||||
+20
-7
@@ -2,16 +2,19 @@ package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static mcp.mobius.waila.SpecialChars.*;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import codechicken.nei.forge.GuiContainerManager;
|
||||
|
||||
public class HUDHandlerWaila implements IWailaDataProvider {
|
||||
public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -47,22 +50,32 @@ public class HUDHandlerWaila implements IWailaDataProvider {
|
||||
if (currenttip.size() == 0)
|
||||
currenttip.add("< Unnamed >");
|
||||
else{
|
||||
name = currenttip.get(0);
|
||||
currenttip.set(0, name + String.format(" %s:%s", accessor.getBlockID(), accessor.getMetadata()));
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, true)){
|
||||
name = currenttip.get(0);
|
||||
//currenttip.set(0, name + String.format(" %s:%s", accessor.getBlockID(), accessor.getMetadata()));
|
||||
currenttip.set(0, name + String.format(" %s:%s", itemStack.itemID, itemStack.getItemDamage()));
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTBLOCK, false) && currenttip.size() > 0 && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.clear();
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
String modName = ModIdentification.nameFromStack(itemStack);
|
||||
if (modName != null && !modName.equals(""))
|
||||
currenttip.add(BLUE + ITALIC + modName);
|
||||
if (modName != null && !modName.equals("")){
|
||||
currenttip.add(BLUE + ITALIC + modName );
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerEntities implements IWailaEntityProvider {
|
||||
|
||||
@Override
|
||||
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
try{
|
||||
currenttip.add(WHITE + entity.getEntityName());
|
||||
} catch (Exception e){
|
||||
currenttip.add(WHITE + "Unknown");
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
if (entity instanceof EntityLivingBase){
|
||||
String hptip = "";
|
||||
|
||||
float health = ((EntityLivingBase)entity).getHealth() / 2.0f;
|
||||
float maxhp = ((EntityLivingBase)entity).getMaxHealth() / 2.0f;;
|
||||
|
||||
for (int i = 0; i < MathHelper.floor_float(health); i++)
|
||||
hptip += HEART;
|
||||
|
||||
if (((EntityLivingBase)entity).getHealth() > MathHelper.floor_float(health) * 2.0f)
|
||||
hptip += HHEART;
|
||||
|
||||
for (int i = 0; i < MathHelper.floor_float(maxhp - health); i++)
|
||||
hptip += EHEART;
|
||||
|
||||
currenttip.add(hptip);
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHIFTENTS, false) && currenttip.size() > 0 && !accessor.getPlayer().isSneaking()){
|
||||
currenttip.clear();
|
||||
currenttip.add(ITALIC + "Press shift for more data");
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
try{
|
||||
currenttip.add(BLUE + ITALIC + getEntityMod(entity));
|
||||
} catch (Exception e){
|
||||
currenttip.add(BLUE + ITALIC + "Unknown");
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
private static String getEntityMod(Entity entity){
|
||||
String modName = "";
|
||||
try{
|
||||
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), true);
|
||||
ModContainer modC = er.getContainer();
|
||||
modName = modC.getName();
|
||||
} catch (NullPointerException e){
|
||||
modName = "Minecraft";
|
||||
}
|
||||
return modName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorFMP;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class HUDHandlerFMP 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) {
|
||||
NBTTagList list = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound) list.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (ModuleRegistrar.instance().hasHeadFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getHeadFMPProviders(id))
|
||||
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
NBTTagList list = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound) list.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (ModuleRegistrar.instance().hasBodyFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getBodyFMPProviders(id))
|
||||
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
NBTTagList list = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound) list.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (ModuleRegistrar.instance().hasTailFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getTailFMPProviders(id))
|
||||
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public static void register(){
|
||||
Class BlockMultipart = null;
|
||||
try{
|
||||
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARNING, "[FMP] Class not found. " + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARNING, "[FMP] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerFMP(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerFMP(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerFMP(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMultipart);
|
||||
|
||||
Waila.log.log(Level.INFO, "Forge Multipart found and dedicated handler registered");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
import java.util.Map;
|
||||
import mcp.mobius.waila.Constants;
|
||||
|
||||
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
|
||||
@@ -2,7 +2,7 @@ package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.forge.IContainerTooltipHandler;
|
||||
|
||||
@@ -5,17 +5,32 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ConfigCategory;
|
||||
|
||||
public class Packet0x00ServerPing {
|
||||
|
||||
public byte header;
|
||||
|
||||
public HashMap<String, Boolean> forcedKeys = new HashMap<String, Boolean>();
|
||||
|
||||
public Packet0x00ServerPing(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
|
||||
forcedKeys.clear();
|
||||
while (true){
|
||||
String key = Packet.readString(inputStream, 255);
|
||||
if (key.equals("END OF LIST")) break;
|
||||
boolean value = inputStream.readBoolean();
|
||||
forcedKeys.put(key, value);
|
||||
}
|
||||
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
@@ -26,6 +41,18 @@ public class Packet0x00ServerPing {
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x00);
|
||||
|
||||
ConfigCategory serverForcing = ConfigHandler.instance().config.getCategory(Constants.CATEGORY_SERVER);
|
||||
|
||||
for (String key : serverForcing.keySet()){
|
||||
if (serverForcing.get(key).getBoolean(false)){
|
||||
Packet.writeString(key, outputStream);
|
||||
outputStream.writeBoolean(ConfigHandler.instance().getConfig(key));
|
||||
}
|
||||
}
|
||||
|
||||
Packet.writeString("END OF LIST", outputStream);
|
||||
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
|
||||
@@ -5,7 +5,9 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
@@ -17,29 +19,43 @@ public class Packet0x01TERequest {
|
||||
public int posX;
|
||||
public int posY;
|
||||
public int posZ;
|
||||
|
||||
public HashSet<String> keys = new HashSet<String> ();
|
||||
|
||||
public Packet0x01TERequest(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
keys.clear();
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.worldID = inputStream.readInt();
|
||||
this.posX = inputStream.readInt();
|
||||
this.posY = inputStream.readInt();
|
||||
this.posZ = inputStream.readInt();
|
||||
|
||||
int nkeys = inputStream.readInt();
|
||||
for (int i = 0; i < nkeys; i++)
|
||||
keys.add(Packet.readString(inputStream, 250));
|
||||
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(World world, MovingObjectPosition mop){
|
||||
public static Packet250CustomPayload create(World world, MovingObjectPosition mop, HashSet<String> keys){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
keys.add("x"); keys.add("y"); keys.add("z");
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x01);
|
||||
outputStream.writeInt(world.provider.dimensionId);
|
||||
outputStream.writeInt(mop.blockX);
|
||||
outputStream.writeInt(mop.blockY);
|
||||
outputStream.writeInt(mop.blockZ);
|
||||
outputStream.writeInt(mop.blockZ);
|
||||
outputStream.writeInt(keys.size());
|
||||
|
||||
for (String key : keys)
|
||||
Packet.writeString(key, outputStream);
|
||||
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
@@ -18,7 +19,7 @@ public class Packet0x02TENBTData {
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.tag = Packet0x02TENBTData.readNBTTagCompound(inputStream);
|
||||
this.tag = NBTUtil.readNBTTagCompound(inputStream);
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
@@ -29,7 +30,7 @@ public class Packet0x02TENBTData {
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x02);
|
||||
Packet0x02TENBTData.writeNBTTagCompound(tag, outputStream);
|
||||
NBTUtil.writeNBTTagCompound(tag, outputStream);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
@@ -38,40 +39,4 @@ public class Packet0x02TENBTData {
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutputStream par1DataOutputStream) throws IOException
|
||||
{
|
||||
if (par0NBTTagCompound == null)
|
||||
{
|
||||
par1DataOutputStream.writeShort(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = CompressedStreamTools.compress(par0NBTTagCompound);
|
||||
|
||||
if (abyte.length > 32000)
|
||||
par1DataOutputStream.writeShort(-1);
|
||||
else{
|
||||
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,60 @@
|
||||
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 java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Packet0x03EntRequest {
|
||||
|
||||
public byte header;
|
||||
public int worldID;
|
||||
public int id;
|
||||
public HashSet<String> keys = new HashSet<String> ();
|
||||
|
||||
public Packet0x03EntRequest(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
keys.clear();
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.worldID = inputStream.readInt();
|
||||
this.id = inputStream.readInt();
|
||||
|
||||
int nkeys = inputStream.readInt();
|
||||
for (int i = 0; i < nkeys; i++)
|
||||
keys.add(Packet.readString(inputStream, 250));
|
||||
|
||||
} catch (IOException e){}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(World world, Entity ent, HashSet<String> keys){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try{
|
||||
outputStream.writeByte(0x03);
|
||||
outputStream.writeInt(world.provider.dimensionId);
|
||||
outputStream.writeInt(ent.entityId);
|
||||
outputStream.writeInt(keys.size());
|
||||
|
||||
for (String key : keys)
|
||||
Packet.writeString(key, outputStream);
|
||||
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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 mcp.mobius.waila.utils.NBTUtil;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
public class Packet0x04EntNBTData {
|
||||
public byte header;
|
||||
public NBTTagCompound tag;
|
||||
|
||||
public Packet0x04EntNBTData(Packet250CustomPayload packet){
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.tag = NBTUtil.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(0x04);
|
||||
NBTUtil.writeNBTTagCompound(tag, outputStream);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Waila";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,9 +4,13 @@ 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.api.impl.DataAccessor;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
@@ -27,19 +31,25 @@ public class WailaPacketHandler implements IPacketHandler {
|
||||
|
||||
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;
|
||||
Packet0x00ServerPing castedPacket = new Packet0x00ServerPing(packet);
|
||||
Waila.log.info("Received server authentication msg. Remote sync will be activated");
|
||||
Waila.instance.serverPresent = true;
|
||||
|
||||
for (String key : castedPacket.forcedKeys.keySet())
|
||||
Waila.log.info(String.format("Received forced key config %s : %s", key, castedPacket.forcedKeys.get(key)));
|
||||
|
||||
ConfigHandler.instance().forcedConfigs = castedPacket.forcedKeys;
|
||||
}
|
||||
|
||||
else if (header == 0x01){
|
||||
Packet0x01TERequest castedPacket = new Packet0x01TERequest(packet);
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
TileEntity entity = DimensionManager.getWorld(castedPacket.worldID).getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
|
||||
//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);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet0x02TENBTData.create(NBTUtil.createTag(tag, castedPacket.keys)), player);
|
||||
}catch(Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
|
||||
}
|
||||
@@ -47,8 +57,28 @@ public class WailaPacketHandler implements IPacketHandler {
|
||||
}
|
||||
else if (header == 0x02){
|
||||
Packet0x02TENBTData castedPacket = new Packet0x02TENBTData(packet);
|
||||
DataAccessor.instance.remoteNbt = castedPacket.tag;
|
||||
DataAccessorBlock.instance.remoteNbt = castedPacket.tag;
|
||||
}
|
||||
|
||||
else if (header == 0x03){
|
||||
Packet0x03EntRequest castedPacket = new Packet0x03EntRequest(packet);
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
Entity entity = DimensionManager.getWorld(castedPacket.worldID).getEntityByID(castedPacket.id);
|
||||
if (entity != null){
|
||||
try{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
entity.writeToNBT(tag);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet0x04EntNBTData.create(NBTUtil.createTag(tag, castedPacket.keys)), player);
|
||||
}catch(Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (header == 0x04){
|
||||
Packet0x04EntNBTData castedPacket = new Packet0x04EntNBTData(packet);
|
||||
DataAccessorEntity.instance.remoteNbt = castedPacket.tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
+6
-23
@@ -1,27 +1,23 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessor;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.RayTracing;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
public class WailaClientEventHandler {
|
||||
public class DecoratorRenderer {
|
||||
|
||||
@ForgeSubscribe
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -30,7 +26,7 @@ public class WailaClientEventHandler {
|
||||
|
||||
double partialTicks = event.partialTicks;
|
||||
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
EntityLivingBase viewEntity = Minecraft.getMinecraft().renderViewEntity;
|
||||
@@ -40,27 +36,14 @@ public class WailaClientEventHandler {
|
||||
accessor.set(world, player, RayTracing.instance().getTarget(), viewEntity, partialTicks);
|
||||
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (!ModuleRegistrar.instance().hasBlockDecorator(blockID) && !ModuleRegistrar.instance().hasBlockDecorator(block)) return;
|
||||
if (!ModuleRegistrar.instance().hasBlockDecorator(block)) return;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
if (ModuleRegistrar.instance().hasBlockDecorator(blockID)){
|
||||
for (IWailaBlockDecorator decorator : ModuleRegistrar.instance().getBlockDecorators(blockID))
|
||||
try{
|
||||
GL11.glPushMatrix();
|
||||
decorator.decorateBlock(RayTracing.instance().getTargetStack(), accessor, ConfigHandler.instance());
|
||||
GL11.glPopMatrix();
|
||||
} catch (Throwable e){
|
||||
GL11.glPopMatrix();
|
||||
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModuleRegistrar.instance().hasBlockDecorator(block)){
|
||||
for (IWailaBlockDecorator decorator : ModuleRegistrar.instance().getBlockDecorators(block))
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public enum IconUI {
|
||||
HEART (52, 0, 9, 9, 52, 9, 9, 9, "a"),
|
||||
HHEART(61, 0, 9, 9, 52, 9, 9, 9, "b"),
|
||||
EHEART(52, 9, 9, 9, "c");
|
||||
|
||||
private final static HashMap<String, IconUI> lk = new HashMap<String, IconUI>();
|
||||
static {
|
||||
for (IconUI icon : IconUI.values()){
|
||||
lk.put(icon.symbol, icon);
|
||||
}
|
||||
}
|
||||
|
||||
public final int u, v, su, sv;
|
||||
public final int bu, bv, bsu, bsv;
|
||||
public final String symbol;
|
||||
|
||||
private IconUI(int u, int v, int su, int sv, String symbol){
|
||||
this(u,v,su,sv,-1,-1,-1,-1,symbol);
|
||||
}
|
||||
|
||||
private IconUI(int u, int v, int su, int sv, int bu, int bv, int bsu, int bsv, String symbol){
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
this.su = su;
|
||||
this.sv = sv;
|
||||
this.bu = bu;
|
||||
this.bv = bv;
|
||||
this.bsu = bsu;
|
||||
this.bsv = bsv;
|
||||
this.symbol = WailaStyle + WailaIcon + symbol;
|
||||
}
|
||||
|
||||
public static IconUI bySymbol(String s){
|
||||
return lk.get(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
public class OverlayConfig {
|
||||
public static int posX;
|
||||
public static int posY;
|
||||
public static int alpha;
|
||||
public static int bgcolor;
|
||||
public static int gradient1;
|
||||
public static int gradient2;
|
||||
public static int fontcolor;
|
||||
public static float scale;
|
||||
|
||||
public static void updateColors(){
|
||||
OverlayConfig.alpha = (int)(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA,0) / 100.0f * 256) << 24;
|
||||
OverlayConfig.bgcolor = OverlayConfig.alpha + ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR,0);
|
||||
OverlayConfig.gradient1 = OverlayConfig.alpha + ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1,0);
|
||||
OverlayConfig.gradient2 = OverlayConfig.alpha + ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2,0);
|
||||
OverlayConfig.fontcolor = OverlayConfig.alpha + ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR,0);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,18 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.nei.forge.GuiContainerManager;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import static codechicken.core.gui.GuiDraw.*;
|
||||
|
||||
public class OverlayRenderer {
|
||||
@@ -30,143 +20,64 @@ public class OverlayRenderer {
|
||||
protected static boolean hasBlending;
|
||||
protected static boolean hasLight;
|
||||
protected static int boundTexIndex;
|
||||
protected static RenderItem renderItem = new RenderItem();
|
||||
|
||||
public static void renderOverlay()
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(!(mc.currentScreen == null &&
|
||||
mc.theWorld != null &&
|
||||
mc.isGuiEnabled() &&
|
||||
Minecraft.isGuiEnabled() &&
|
||||
!mc.gameSettings.keyBindPlayerList.pressed &&
|
||||
ConfigHandler.instance().getConfig(Constants.CFG_WAILA_SHOW, true) &&
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true) &&
|
||||
RayTracing.instance().getTarget() != null))
|
||||
return;
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.TILE && RayTracing.instance().getTargetStack() != null)
|
||||
{
|
||||
renderOverlay(RayTracing.instance().getTargetStack(), WailaTickHandler.instance().currenttip, getPositioning());
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
}
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.ENTITY)
|
||||
{
|
||||
Entity ent = RayTracing.instance().getTarget().entityHit;
|
||||
String modName = getEntityMod(ent);
|
||||
|
||||
List<String> textData = new ArrayList<String>();
|
||||
try{
|
||||
textData.add("\u00a7f" + ent.getEntityName());
|
||||
} catch (Exception e){
|
||||
textData.add("\u00a7f" + "Unknown");
|
||||
}
|
||||
textData.add("\u00a79\u00a7o" + modName);
|
||||
|
||||
renderOverlay(ent, textData, getPositioning());
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getEntityMod(Entity entity){
|
||||
String modName = "";
|
||||
try{
|
||||
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), true);
|
||||
ModContainer modC = er.getContainer();
|
||||
modName = modC.getName();
|
||||
} catch (NullPointerException e){
|
||||
modName = "Minecraft";
|
||||
}
|
||||
return modName;
|
||||
}
|
||||
|
||||
private static Point getPositioning()
|
||||
{
|
||||
return new Point(ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSX), ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSY));
|
||||
}
|
||||
|
||||
/*
|
||||
public static int getColor(String key){
|
||||
int alpha = (int)(ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f * 256) << 24;
|
||||
return alpha + ConfigHandler.instance().getConfigInt(key);
|
||||
}
|
||||
*/
|
||||
|
||||
public static void renderOverlay(ItemStack stack, List<String> textData, Point pos)
|
||||
public static void renderOverlay(Tooltip tooltip)
|
||||
{
|
||||
TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
|
||||
//TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(mod_Waila.scale, mod_Waila.scale, 1.0f);
|
||||
GL11.glScalef(OverlayConfig.scale, OverlayConfig.scale, 1.0f);
|
||||
|
||||
int w = 0;
|
||||
for (String s : textData)
|
||||
w = Math.max(w, getStringWidth(s)+29);
|
||||
int h = Math.max(24, 10 + 10*textData.size());
|
||||
|
||||
Dimension size = displaySize();
|
||||
int x = ((int)(size.width / mod_Waila.scale)-w-1)*pos.x/10000;
|
||||
int y = ((int)(size.height / mod_Waila.scale)-h-1)*pos.y/10000;
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
drawTooltipBox(x, y, w, h, mod_Waila.bgcolor, mod_Waila.gradient1, mod_Waila.gradient2);
|
||||
|
||||
int ty = (h-10*textData.size())/2;
|
||||
drawTooltipBox(tooltip.x, tooltip.y, tooltip.w, tooltip.h, OverlayConfig.bgcolor, OverlayConfig.gradient1, OverlayConfig.gradient2);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (int i = 0; i < textData.size(); i++)
|
||||
//FontHelper.drawString(textData.get(i), x + 24, y + ty + 10*i, font, 1.0f, 1.0f, new float[] {1.0f, 1.0f, 1.0f});
|
||||
drawString(textData.get(i), x + 24, y + ty + 10*i, mod_Waila.fontcolor, true);
|
||||
tooltip.drawStrings();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
tooltip.drawIcons();
|
||||
|
||||
|
||||
if (tooltip.hasIcon)
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
if (stack.getItem() != null)
|
||||
GuiContainerManager.drawItem(x+5, y+h/2-8, stack);
|
||||
if (tooltip.hasIcon && tooltip.stack != null && tooltip.stack.getItem() != null)
|
||||
GuiContainerManager.drawItem(tooltip.x+5, tooltip.y+tooltip.h/2-8, tooltip.stack);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderOverlay(Entity entity, List<String> textData, Point pos)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(mod_Waila.scale, mod_Waila.scale, 1.0f);
|
||||
|
||||
int w = 0;
|
||||
for (String s : textData)
|
||||
w = Math.max(w, getStringWidth(s)+10);
|
||||
int h = Math.max(24, 10 + 10*textData.size());
|
||||
|
||||
Dimension size = displaySize();
|
||||
int x = ((int)(size.width / mod_Waila.scale)-w-1)*pos.x/10000;
|
||||
int y = ((int)(size.height / mod_Waila.scale)-h-1)*pos.y/10000;
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
drawTooltipBox(x, y, w, h, mod_Waila.bgcolor, mod_Waila.gradient1, mod_Waila.gradient2);
|
||||
|
||||
int ty = (h-10*textData.size())/2;
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (int i = 0; i < textData.size(); i++)
|
||||
drawString(textData.get(i), x + 6, y + ty + 10*i, mod_Waila.fontcolor, true);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
//RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void saveGLState(){
|
||||
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
|
||||
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
|
||||
@@ -199,4 +110,25 @@ public class OverlayRenderer {
|
||||
drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
|
||||
tessellator.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
if (icon.bu != -1)
|
||||
drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
|
||||
drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,24 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessor;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
|
||||
public class RayTracing {
|
||||
@@ -32,6 +36,7 @@ public class RayTracing {
|
||||
|
||||
private MovingObjectPosition target = null;
|
||||
private ItemStack targetStack = null;
|
||||
private Entity targetEntity= null;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public void fire(){
|
||||
@@ -62,13 +67,22 @@ public class RayTracing {
|
||||
return this.targetStack;
|
||||
}
|
||||
|
||||
public Entity getTargetEntity(){
|
||||
if (this.target.typeOfHit == EnumMovingObjectType.ENTITY)
|
||||
this.targetEntity = this.getIdentifierEntity();
|
||||
else
|
||||
this.targetEntity = null;
|
||||
|
||||
return this.targetEntity;
|
||||
}
|
||||
|
||||
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3)
|
||||
{
|
||||
Vec3 vec3 = entity.getPosition(par3);
|
||||
Vec3 vec31 = entity.getLook(par3);
|
||||
Vec3 vec32 = vec3.addVector(vec31.xCoord * par1, vec31.yCoord * par1, vec31.zCoord * par1);
|
||||
|
||||
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID))
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true))
|
||||
return entity.worldObj.clip(vec3, vec32, true);
|
||||
else
|
||||
return entity.worldObj.clip(vec3, vec32, false);
|
||||
@@ -92,6 +106,21 @@ public class RayTracing {
|
||||
return items.get(0);
|
||||
}
|
||||
|
||||
public Entity getIdentifierEntity(){
|
||||
ArrayList<Entity> ents = new ArrayList<Entity>();
|
||||
|
||||
if (this.target == null)
|
||||
return null;
|
||||
|
||||
if (ModuleRegistrar.instance().hasOverrideEntityProviders(this.target.entityHit))
|
||||
ents.add(ModuleRegistrar.instance().getOverrideEntityProviders(this.target.entityHit).get(0).getWailaOverride(DataAccessorEntity.instance, ConfigHandler.instance()));
|
||||
|
||||
if(ents.size() > 0)
|
||||
return ents.get(0);
|
||||
else
|
||||
return this.target.entityHit;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getIdentifierItems()
|
||||
{
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
@@ -105,28 +134,22 @@ public class RayTracing {
|
||||
int x = this.target.blockX;
|
||||
int y = this.target.blockY;
|
||||
int z = this.target.blockZ;
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
Block mouseoverBlock = Block.blocksList[blockID];
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
Block mouseoverBlock = Block.blocksList[blockID];
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
if (mouseoverBlock == null) return items;
|
||||
|
||||
// TODO This block need to be redone to handle Waila API
|
||||
/*
|
||||
ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
|
||||
if(ItemInfo.highlightIdentifiers.get(0) != null)
|
||||
handlers.addAll(ItemInfo.highlightIdentifiers.get(0));
|
||||
if(ItemInfo.highlightIdentifiers.get(mouseoverBlock.blockID) != null)
|
||||
handlers.addAll(ItemInfo.highlightIdentifiers.get(mouseoverBlock.blockID));
|
||||
|
||||
for(IHighlightHandler ident : handlers)
|
||||
{
|
||||
ItemStack item = ident.identifyHighlight(world, player, this.target);
|
||||
if(item != null)
|
||||
items.add(item);
|
||||
if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
}
|
||||
*/
|
||||
|
||||
if (ModuleRegistrar.instance().hasStackProviders(blockID))
|
||||
items.add(ModuleRegistrar.instance().getStackProviders(blockID).get(0).getWailaStack(DataAccessor.instance, ConfigHandler.instance()));
|
||||
if (tileEntity != null && ModuleRegistrar.instance().hasStackProviders(tileEntity)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
}
|
||||
|
||||
if(items.size() > 0)
|
||||
return items;
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import static codechicken.core.gui.GuiDraw.*;
|
||||
import static mcp.mobius.waila.utils.SpecialChars.*;
|
||||
|
||||
public class Tooltip {
|
||||
public static int TabSpacing = 8;
|
||||
public static int IconSize = 8;
|
||||
|
||||
ArrayList<Line> lines = new ArrayList<Line>();
|
||||
int w,h,x,y,ty;
|
||||
int offsetX;
|
||||
int maxStringW;
|
||||
Point pos;
|
||||
boolean hasIcon = false;
|
||||
ItemStack stack;
|
||||
|
||||
int[] columnsWidth;
|
||||
int[] columnsPos;
|
||||
int ncolumns = 0;
|
||||
|
||||
private class Line{
|
||||
String[] columnsRaw;
|
||||
ArrayList<ArrayList<String>> columns = new ArrayList<ArrayList<String>>();
|
||||
int ncolumns;
|
||||
int[] columnsWidth;
|
||||
int lineWidth;
|
||||
|
||||
public Line(String text){
|
||||
columnsRaw = text.split(TAB);
|
||||
ncolumns = columnsRaw.length;
|
||||
columnsWidth = new int[ncolumns];
|
||||
lineWidth = 0;
|
||||
|
||||
for (String s : columnsRaw)
|
||||
columns.add(parseString(s));
|
||||
|
||||
for (int i = 0; i < ncolumns; i++){
|
||||
for (String s : columns.get(i)){
|
||||
if (s.startsWith(WailaStyle + WailaIcon))
|
||||
columnsWidth[i] += IconSize;
|
||||
else if (s.startsWith(WailaStyle + WailaStyle))
|
||||
columnsWidth[i] += 0;
|
||||
else
|
||||
columnsWidth[i] += getStringWidth(s);
|
||||
}
|
||||
lineWidth += columnsWidth[i];
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> parseString(String s){
|
||||
ArrayList<String> retList = new ArrayList<String>();
|
||||
Pattern pattern = Pattern.compile(WailaStyle + "..");
|
||||
Matcher matcher = pattern.matcher(s);
|
||||
|
||||
int prevIndex = 0;
|
||||
while (matcher.find()){
|
||||
String substring = s.substring(prevIndex, matcher.start());
|
||||
if (!substring.equals(""))
|
||||
retList.add(substring);
|
||||
retList.add(s.substring(matcher.start(), matcher.end()));
|
||||
prevIndex = matcher.end();
|
||||
}
|
||||
retList.add(s.substring(prevIndex));
|
||||
return retList;
|
||||
}
|
||||
}
|
||||
|
||||
public Tooltip(List<String> textData, ItemStack stack){
|
||||
this(textData, true);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public Tooltip(List<String> textData, boolean hasIcon){
|
||||
for (String s : textData)
|
||||
lines.add(new Line(s));
|
||||
|
||||
for (Line l : lines)
|
||||
ncolumns = Math.max(ncolumns, l.ncolumns);
|
||||
|
||||
columnsWidth = new int[ncolumns];
|
||||
columnsPos = new int[ncolumns];
|
||||
|
||||
for (Line l : lines){
|
||||
for (int i = 0; i < l.ncolumns; i++){
|
||||
if (l.ncolumns > 1 && ncolumns != 1)
|
||||
columnsWidth[i] = Math.max(columnsWidth[i], l.columnsWidth[i]);
|
||||
else if (ncolumns == 1)
|
||||
columnsWidth[i] = Math.max(columnsWidth[i], l.columnsWidth[i]);
|
||||
}
|
||||
}
|
||||
|
||||
maxStringW = 0;
|
||||
for (int i = 0; i < ncolumns; i++)
|
||||
maxStringW += columnsWidth[i];
|
||||
maxStringW += ncolumns * TabSpacing;
|
||||
|
||||
|
||||
for (int i = 0; i < ncolumns - 1; i++)
|
||||
columnsPos[i + 1] = columnsWidth[i] + columnsPos[i];
|
||||
|
||||
this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0),
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0));
|
||||
this.hasIcon = hasIcon;
|
||||
|
||||
int paddingW = hasIcon ? 29 : 13;
|
||||
int paddingH = hasIcon ? 24 : 0;
|
||||
offsetX = hasIcon ? 24 : 6;
|
||||
|
||||
w = maxStringW + paddingW;
|
||||
|
||||
h = Math.max(paddingH, 10 + 10*lines.size());
|
||||
|
||||
Dimension size = displaySize();
|
||||
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
|
||||
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
|
||||
|
||||
ty = (h-10*lines.size())/2;
|
||||
}
|
||||
|
||||
public void drawStrings(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++){
|
||||
int offX = 0;
|
||||
|
||||
for (int is = 0; is < lines.get(i).columns.get(c).size(); is++){
|
||||
String s = lines.get(i).columns.get(c).get(is);
|
||||
if (s.startsWith(WailaStyle + WailaIcon))
|
||||
offX += IconSize;
|
||||
|
||||
else if (s.startsWith(ALIGNRIGHT))
|
||||
offX += columnsWidth[c] - getStringWidth(lines.get(i).columns.get(c).get(is + 1));
|
||||
|
||||
else{
|
||||
drawString(s, x + offsetX + columnsPos[c] + c*TabSpacing + offX, y + ty + 10*i, OverlayConfig.fontcolor, true);
|
||||
offX += getStringWidth(s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawIcons(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++){
|
||||
int offX = 0;
|
||||
for (String s : lines.get(i).columns.get(c)){
|
||||
if (s.startsWith(WailaStyle + WailaIcon)){
|
||||
OverlayRenderer.renderIcon(x + offsetX + columnsPos[c] + c*TabSpacing + offX, y + ty + 10*i, IconSize, IconSize, IconUI.bySymbol(s));
|
||||
offX += IconSize;
|
||||
}else{
|
||||
offX += getStringWidth(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,15 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.impl.DataAccessor;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemBlockWithMetadata;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
@@ -24,8 +25,12 @@ public class WailaTickHandler implements ITickHandler {
|
||||
|
||||
private int ticks = 0;
|
||||
public ItemStack identifiedHighlight = new ItemStack(Block.dirt);
|
||||
public List<String> currenttip = new ArrayList<String>();
|
||||
public MetaDataProvider handler = new MetaDataProvider();
|
||||
private List<String> currenttip = new ArrayList<String>();
|
||||
private List<String> currenttipHead = new ArrayList<String>();
|
||||
private List<String> currenttipBody = new ArrayList<String>();
|
||||
private List<String> currenttipTail = new ArrayList<String>();
|
||||
public Tooltip tooltip = null;
|
||||
public MetaDataProvider handler = new MetaDataProvider();
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static WailaTickHandler _instance;
|
||||
@@ -54,18 +59,51 @@ public class WailaTickHandler implements ITickHandler {
|
||||
RayTracing.instance().fire();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
if (target != null){
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
if (target != null && target.typeOfHit == EnumMovingObjectType.TILE){
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack();
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack or the override
|
||||
|
||||
if (targetStack != null){
|
||||
this.currenttip.clear();
|
||||
this.currenttipHead.clear();
|
||||
this.currenttipBody.clear();
|
||||
this.currenttipTail.clear();
|
||||
|
||||
|
||||
//this.identifiedHighlight = handler.identifyHighlight(world, player, target);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.HEADER);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.BODY);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.FOOTER);
|
||||
this.currenttipHead = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttipHead, Layout.HEADER);
|
||||
this.currenttipBody = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttipBody, Layout.BODY);
|
||||
this.currenttipTail = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttipTail, Layout.FOOTER);
|
||||
|
||||
this.currenttip.addAll(this.currenttipHead);
|
||||
this.currenttip.addAll(this.currenttipBody);
|
||||
this.currenttip.addAll(this.currenttipTail);
|
||||
|
||||
this.tooltip = new Tooltip(this.currenttip, targetStack);
|
||||
}
|
||||
}
|
||||
else if (target != null && target.typeOfHit == EnumMovingObjectType.ENTITY){
|
||||
DataAccessorEntity accessor = DataAccessorEntity.instance;
|
||||
accessor.set(world, player, target);
|
||||
|
||||
Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override check.
|
||||
|
||||
if (targetEnt != null){
|
||||
this.currenttip.clear();
|
||||
this.currenttipHead.clear();
|
||||
this.currenttipBody.clear();
|
||||
this.currenttipTail.clear();
|
||||
|
||||
this.currenttipHead = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipHead, Layout.HEADER);
|
||||
this.currenttipBody = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipBody, Layout.BODY);
|
||||
this.currenttipTail = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipTail, Layout.FOOTER);
|
||||
|
||||
this.currenttip.addAll(this.currenttipHead);
|
||||
this.currenttip.addAll(this.currenttipBody);
|
||||
this.currenttip.addAll(this.currenttipTail);
|
||||
|
||||
this.tooltip = new Tooltip(this.currenttip, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package mcp.mobius.waila.tools;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class Reflect {
|
||||
|
||||
public static Object getFieldValue(String className, String fieldname, Object obj){
|
||||
try {
|
||||
|
||||
Class class_ = Class.forName(className);
|
||||
Field field_ = class_.getField(fieldname);
|
||||
field_.setAccessible(true);
|
||||
Object object_ = field_.get(obj);
|
||||
return object_;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+15
-15
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.tools;
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -21,19 +21,19 @@ public class AccessHelper {
|
||||
Class class_ = Class.forName(classname);
|
||||
Field field_ = class_.getDeclaredField(fieldname);
|
||||
field_.setAccessible(true);
|
||||
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
return field_;
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
mod_Waila.log.warning(String.format("== Field %s %s not found !\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== Field %s %s not found !\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
catch (SecurityException e) {
|
||||
mod_Waila.log.warning(String.format("== Field %s %s security exception !\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== Field %s %s security exception !\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
mod_Waila.log.warning(String.format("== Class %s not found !\n", classname));
|
||||
Waila.log.warning(String.format("== Class %s not found !\n", classname));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -45,25 +45,25 @@ public class AccessHelper {
|
||||
Field field_ = class_.getDeclaredField(fieldname);
|
||||
field_.setAccessible(true);
|
||||
|
||||
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
return field_.get(instance);
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
mod_Waila.log.warning(String.format("== Field %s %s not found !\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== Field %s %s not found !\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
catch (SecurityException e) {
|
||||
mod_Waila.log.warning(String.format("== Field %s %s security exception !\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== Field %s %s security exception !\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
mod_Waila.log.warning(String.format("== Class %s not found !\n", classname));
|
||||
Waila.log.warning(String.format("== Class %s not found !\n", classname));
|
||||
return null;
|
||||
} catch (IllegalArgumentException e) {
|
||||
mod_Waila.log.warning(String.format("== %s\n", e));
|
||||
Waila.log.warning(String.format("== %s\n", e));
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
mod_Waila.log.warning(String.format("== %s\n", e));
|
||||
Waila.log.warning(String.format("== %s\n", e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class AccessHelper {
|
||||
Field field_ = class_.getDeclaredField(fieldname);
|
||||
field_.setAccessible(true);
|
||||
|
||||
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
|
||||
return field_.get(instance);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class AccessHelper {
|
||||
return (Block)field_.get(Block.class);
|
||||
} catch (Exception e) {
|
||||
System.out.printf("%s\n", e);
|
||||
mod_Waila.log.warning(String.format("== ERROR GETTING BLOCK %s %s\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== ERROR GETTING BLOCK %s %s\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class AccessHelper {
|
||||
return (Item)field_.get(Item.class);
|
||||
} catch (Exception e) {
|
||||
System.out.printf("%s\n", e);
|
||||
mod_Waila.log.warning(String.format("== ERROR GETTING ITEM %s %s\n", classname, fieldname));
|
||||
Waila.log.warning(String.format("== ERROR GETTING ITEM %s %s\n", classname, fieldname));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila;
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
public final class Constants {
|
||||
public static String BIND_SCREEN_WIKI = "showwiki";
|
||||
@@ -22,7 +22,9 @@ public final class Constants {
|
||||
public static String CFG_WAILA_KEYBIND = "waila.cfg.keybind";
|
||||
public static String CFG_WAILA_POSX = "waila.cfg.posx";
|
||||
public static String CFG_WAILA_POSY = "waila.cfg.posy";
|
||||
public static String CFG_WAILA_SCALE = "waila.cfg.scale";
|
||||
public static String CFG_WAILA_SCALE = "waila.cfg.scale";
|
||||
public static String CFG_WAILA_SHIFTBLOCK = "waila.cfg.shiftblock";
|
||||
public static String CFG_WAILA_SHIFTENTS = "waila.cfg.shiftents";
|
||||
|
||||
|
||||
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
|
||||
@@ -31,5 +33,9 @@ public final class Constants {
|
||||
public static String CFG_WAILA_GRADIENT2 = "waila.cfg.gradient2";
|
||||
public static String CFG_WAILA_FONTCOLOR = "waila.cfg.fontcolor";
|
||||
|
||||
public static String CATEGORY_MODULES = "modules";
|
||||
public static String CATEGORY_SERVER = "server_forcing";
|
||||
public static boolean SERVER_FREE = false;
|
||||
public static boolean SERVER_FORCED = true;
|
||||
|
||||
}
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user