Compare commits

...
16 Commits
Author SHA1 Message Date
Thomas Guimbretiere 9b3cf62785 check for NEK and version bump. 2014-03-30 19:53:19 +02:00
Thomas Guimbretiere 0bb6caf334 Cleanup of TC module and addition of TT helmets handling. 2014-02-23 18:56:46 +01:00
Thomas Guimbretiere 5ac5f7956c Fixed Thaumcraft module. 2014-02-23 18:29:19 +01:00
Thomas Guimbretiere d00c17b3bb Fixed double registration of crops. 2014-02-23 17:34:36 +01:00
Thomas Guimbretiere 52ac40a10e Workaround for Morph eye height. 2014-02-23 17:29:09 +01:00
Thomas Guimbretiere 40facdda4b Added config option for Thaumcraft 2014-02-20 01:22:52 +01:00
Thomas Guimbretiere 3505888a82 Added new module section called "General".
Growth value and entity health are now config options there.
2014-02-20 00:34:09 +01:00
Thomas Guimbretiere 7eb35b7544 Max hp before text is now a config option 2014-02-20 00:24:22 +01:00
Thomas Guimbretiere 78039db017 Added support for Agriculture crop 2014-02-20 00:02:27 +01:00
Thomas Guimbretiere 17b5cbead9 Added tag Waila_1.5.0 for changeset ad46f8b41bbe 2014-02-19 23:44:28 +01:00
Thomas Guimbretiere d355ec28bb Added try/catch around NBT dumping client side. 2014-02-19 23:44:13 +01:00
Thomas Guimbretiere bd675cee28 Max hearts per line can be changed.
HP turns to text when max > 40
2014-02-19 23:21:42 +01:00
Thomas Guimbretiere 7c74db3640 Added lookup for known aspects. 2014-02-19 22:42:55 +01:00
Thomas Guimbretiere b65dc58fc6 Fixed tooltip size when name is bigger than tabbed display data. 2014-02-19 21:54:42 +01:00
Thomas Guimbretiere 1438d6a701 First fix for Entity hp display
Thaumcraft module will show aspects if the player is wearing googles of revealing.
2014-02-19 21:36:42 +01:00
Thomas Guimbretiere 223e2c7da6 Stopped bleeding gl constants at the end of rendering. 2014-02-19 18:52:27 +01:00
20 changed files with 342 additions and 153 deletions

No files matched your search

+4 -1
View File
@@ -142,4 +142,7 @@ 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
option.stevescarts.shifttoggle=Shift toggle
option.general.showhp=Show entities health
option.general.showcrop=Show crop growth
option.thaumcraft.aspects=Show aspects
+5 -4
View File
@@ -19,6 +19,7 @@ import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
@@ -38,10 +39,10 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid="Waila", name="Waila", version="1.5.0", dependencies="required-after:NotEnoughItems")
@Mod(modid="Waila", name="Waila", version="1.5.2", dependencies="required-after:NotEnoughItems")
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
//packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
packetHandler = WailaPacketHandler.class)
packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)")
//packetHandler = WailaPacketHandler.class)
public class Waila {
// The instance of your mod that Forge uses.
@@ -76,7 +77,7 @@ public class Waila {
proxy.registerHandlers();
ModIdentification.init();
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true)){
if (!ModLoader.isModLoaded("nek") && ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true)){
for (String key: ModIdentification.keyhandlerStrings.keySet()){
String orig = I18n.getString(key);
@@ -0,0 +1,30 @@
package mcp.mobius.waila.addons.agriculture;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class AgricultureModule {
public static Class BlockCrop = null;
public static void register(){
try{
Class Agriculture = Class.forName("com.teammetallurgy.agriculture.Agriculture");
Waila.log.log(Level.INFO, "Agriculture mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[Agriculture] Agriculture mod not found.");
return;
}
try{
BlockCrop = Class.forName("com.teammetallurgy.agriculture.crops.BlockCrop");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[Agriculture] Class not found. " + e);
return;
}
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCrop(), BlockCrop);
}
}
@@ -1,31 +1,42 @@
package mcp.mobius.waila.addons.thaumcraft;
package mcp.mobius.waila.addons.agriculture;
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 HUDHandlerLeaves implements IWailaDataProvider {
public class HUDHandlerCrop implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showcrop")) return currenttip;
int growthStage = accessor.getMetadata();
float growthValue = (growthStage / 6.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;
}
}
}
@@ -23,6 +23,8 @@ public class HUDHandlerPamCrop implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showcrop")) return currenttip;
int growthStage = NBTUtil.getNBTInteger(accessor.getNBTData(), "growthStage");
float growthValue = (growthStage / 2.0F) * 100.0F;
@@ -22,6 +22,8 @@ public class HUDHandlerMagicalCrops implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showcrop")) return currenttip;
int growthStage = accessor.getMetadata();
float growthValue = (growthStage / 7.0F) * 100.0F;
@@ -1,43 +0,0 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
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 {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (config.getConfig("thaumcraft.storedvis")){
try{
short storedVis = ThaumcraftModule.TileCrystalCapacitor_StoredVis.getShort(accessor.getTileEntity());
short maxVis = ThaumcraftModule.TileCrystalCapacitor_MaxVis.getShort(accessor.getTileEntity());
currenttip.add(String.format("%s/%s vis", storedVis, maxVis));
}catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getClass().getName(), currenttip);
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -0,0 +1,108 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StringUtils;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.NBTUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerIAspectContainer implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("thaumcraft.aspects")) return currenttip;
ItemStack headSlot = accessor.getPlayer().inventory.armorInventory[3];
if (headSlot == null) return currenttip;
boolean hasReveal = ThaumcraftModule.ItemGoggles.isInstance(headSlot.getItem()) ||
(ThaumcraftModule.ItemRevealingHelm != null && ThaumcraftModule.ItemRevealingHelm.isInstance(headSlot.getItem())) ||
(ThaumcraftModule.ItemGemHelm != null && ThaumcraftModule.ItemGemHelm.isInstance(headSlot.getItem()));
if (!hasReveal) return currenttip;
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("Aspect") && tag.hasKey("Amount") && !tag.getString("Aspect").equals("")){
String aspect = Character.toUpperCase(tag.getString("Aspect").charAt(0)) + tag.getString("Aspect").substring(1);
currenttip.add(this.getAspectString(tag, "Aspect", "Amount", accessor));
}
if (tag.hasKey("aspect") && tag.hasKey("amount") && !tag.getString("aspect").equals("")){
String aspect = Character.toUpperCase(tag.getString("aspect").charAt(0)) + tag.getString("aspect").substring(1);
currenttip.add(this.getAspectString(tag, "aspect", "amount", accessor));
}
if (tag.hasKey("Aspects")){
NBTTagList taglist = tag.getTagList("Aspects");
for (int i = 0; i < taglist.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)taglist.tagAt(i);
if (subtag.hasKey("amount") && subtag.hasKey("key") && !subtag.getString("key").equals("")){
currenttip.add(this.getAspectString(subtag, "key", "amount", accessor));
}
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
private String getAspectString(NBTTagCompound tag, String keyAspect, String keyAmount, IWailaDataAccessor accessor){
String aspect = tag.getString(keyAspect);
aspect = knowAspect(aspect, accessor) ? aspect : "????";
aspect = Character.toUpperCase(aspect.charAt(0)) + aspect.substring(1);
String amount = String.valueOf(NBTUtil.getNBTInteger(tag, keyAmount));
return String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount);
}
private boolean knowAspect(String name, IWailaDataAccessor accessor){
try{
Object proxy = ThaumcraftModule.TC_proxy.get(null);
Object known = ThaumcraftModule.getKnownAspects.invoke(proxy, (Object[])null);
Object listAspc = ((Map<String, Object>)known).get(accessor.getPlayer().username);
//Object research = ThaumcraftModule.playerResearch.get(proxy);
//Object aspect = ThaumcraftModule.getAspect.invoke(null, name);
//Object knownaspects = ThaumcraftModule.aspectsDiscovered.get(research);
//Boolean known = (Boolean)ThaumcraftModule.hasDiscoveredAspect.invoke(research, accessor.getPlayer().username, aspect);
Object[] aspects = (Object[])ThaumcraftModule.list_getAspects.invoke(listAspc);
for (Object o : aspects){
if (ThaumcraftModule.aspect_tag.get(o).equals(name)){
return true;
}
}
return false;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
return false;
}
}
}
@@ -1,30 +0,0 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerPlants implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -1,60 +1,92 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class ThaumcraftModule {
public static Class BlockMagicalLeaves = null;
public static Class BlockCustomPlant = null;
public static Class IAspectContainer = null;
public static Class TileAlchemyFurnace = null;
public static Class ItemGoggles = null;
public static Class ItemRevealingHelm = null;
public static Class ItemGemHelm = null;
public static Class TileCrystalCapacitor = null;
public static Field TileCrystalCapacitor_StoredVis = null;
public static Field TileCrystalCapacitor_MaxVis = null;
public static Class Thaumcraft = null;
public static Class TCClientProxy = null;
public static Class TCCommonProxy = null;
//public static Class PlayerKnowledge = null;
public static Class Aspect = null;
public static Class AspectList = null;
public static Field TC_proxy = null; //Thaumcraft.proxy
//public static Field playerResearch = null; //ClientProxy.playerResearch
//public static Field aspectsDiscovered = null; //PlayerKnowledge.aspectsDiscovered
public static Field aspect_tag = null; //Aspect.tag
//public static Method hasDiscoveredAspect = null; //PlayerKnowledge.hasDiscoveredAspect
//public static Method getAspect = null; //Aspect.getAspect
public static Method getKnownAspects = null; //CommonProxy.getKnownAspects
public static Method list_getAspects = null; //AspectList.getAspects
public static void register(){
try{
Class ModThaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
Thaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
Waila.log.log(Level.INFO, "Thaumcraft mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
return;
}
try{
ItemRevealingHelm = Class.forName("vazkii.tinkerer.common.item.ItemRevealingHelm");
} catch (ClassNotFoundException e){ }
try{
BlockMagicalLeaves = Class.forName("thaumcraft.common.world.BlockMagicalLeaves");
BlockCustomPlant = Class.forName("thaumcraft.common.world.BlockCustomPlant");
ItemGemHelm = Class.forName("vazkii.tinkerer.common.item.kami.armor.ItemGemHelm");
} catch (ClassNotFoundException e){ }
try{
IAspectContainer = Class.forName("thaumcraft.api.aspects.IAspectContainer");
TileAlchemyFurnace = Class.forName("thaumcraft.common.tiles.TileAlchemyFurnace");
ItemGoggles = Class.forName("thaumcraft.common.items.armor.ItemGoggles");
TCClientProxy = Class.forName("thaumcraft.client.ClientProxy");
TCCommonProxy = Class.forName("thaumcraft.common.CommonProxy");
//PlayerKnowledge = Class.forName("thaumcraft.common.lib.research.PlayerKnowledge");
Aspect = Class.forName("thaumcraft.api.aspects.Aspect");
AspectList = Class.forName("thaumcraft.api.aspects.AspectList");
TileCrystalCapacitor = Class.forName("thaumcraft.common.tiles.TileCrystalCapacitor");
TileCrystalCapacitor_StoredVis = TileCrystalCapacitor.getField("storedVis");
TileCrystalCapacitor_MaxVis = TileCrystalCapacitor.getField("maxVis");
TC_proxy = Thaumcraft.getDeclaredField("proxy");
//playerResearch = TCClientProxy.getDeclaredField("playerResearch");
//aspectsDiscovered = PlayerKnowledge.getDeclaredField("aspectsDiscovered");
//playerResearch.setAccessible(true);
aspect_tag = Aspect.getDeclaredField("tag");
aspect_tag.setAccessible(true);
//hasDiscoveredAspect = PlayerKnowledge.getDeclaredMethod("hasDiscoveredAspect", String.class, Aspect);
//getAspect = Aspect.getDeclaredMethod("getAspect", String.class);
getKnownAspects = TCCommonProxy.getDeclaredMethod("getKnownAspects");
list_getAspects = AspectList.getDeclaredMethod("getAspects");
} catch (ClassNotFoundException 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){
Waila.log.log(Level.WARNING, "[Thaumcraft] Field not found." + e);
} catch (Exception e){
Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
//WailaExceptionHandler.handleErr(e, null, null);
return;
// } catch (Exception e){
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
// return;
}
ModuleRegistrar.instance().addConfig("Thaumcraft", "thaumcraft.storedvis");
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerLeaves(), BlockMagicalLeaves);
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
}
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMagicalLeaves);
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockCustomPlant);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileCrystalCapacitor);
ModuleRegistrar.instance().addConfigRemote("Thaumcraft", "thaumcraft.aspects");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), IAspectContainer);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), TileAlchemyFurnace);
ModuleRegistrar.instance().registerSyncedNBTKey("*", IAspectContainer);
}
}
@@ -84,7 +84,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
Block block = accessor.getBlock();
/* Crops */
boolean iscrop = crops.getClass().isInstance(block); //Done to cover all inheriting mods
if (config.getConfig("vanilla.growthvalue"))
if (config.getConfig("general.showcrop"))
if (iscrop || block == melonStem || block == pumpkinStem || block == carrot || block == potato){
float growthValue = (accessor.getMetadata() / 7.0F) * 100.0F;
if (growthValue < 100.0)
@@ -94,7 +94,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return currenttip;
}
if (block == cocoa){
if (block == cocoa && config.getConfig("general.showcrop")){
float growthValue = ((accessor.getMetadata() >> 2) / 2.0F) * 100.0F;
if (growthValue < 100.0)
@@ -104,7 +104,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return currenttip;
}
if (block == netherwart){
if (block == netherwart && config.getConfig("general.showcrop")){
float growthValue = (accessor.getMetadata() / 3.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
@@ -167,7 +167,6 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
public static void register(){
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.spawntype");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.growthvalue");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.leverstate");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.repeater");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.comparator");
@@ -183,8 +182,8 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
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, 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());
@@ -8,6 +8,7 @@ import java.util.Set;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.overlay.OverlayConfig;
import mcp.mobius.waila.utils.Constants;
import net.minecraftforge.common.Configuration;
@@ -147,6 +148,9 @@ public class ConfigHandler implements IWailaConfigHandler {
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;
HUDHandlerEntities.nhearts = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NHEARTS, 20).getInt();
HUDHandlerEntities.maxhpfortext = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MAXHP, 40).getInt();
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.");
@@ -78,9 +78,13 @@ public class MetaDataProvider{
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop, keys));
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
NBTTagCompound tag = new NBTTagCompound();
accessor.getTileEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
try{
NBTTagCompound tag = new NBTTagCompound();
accessor.getTileEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
}
}
/* Interface IWailaBlock */
@@ -173,9 +177,13 @@ public class MetaDataProvider{
} else if (accessor.getEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
NBTTagCompound tag = new NBTTagCompound();
accessor.getEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
try{
NBTTagCompound tag = new NBTTagCompound();
accessor.getEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
}
}
headEntityProviders.clear();
+8 -1
View File
@@ -1,5 +1,6 @@
package mcp.mobius.waila.client;
import mcp.mobius.waila.addons.agriculture.AgricultureModule;
import mcp.mobius.waila.addons.appeng.AppEngModule;
import mcp.mobius.waila.addons.buildcraft.BCModule;
import mcp.mobius.waila.addons.buildcraft.BCPowerAPIModule;
@@ -84,9 +85,13 @@ public class ProxyClient extends ProxyServer {
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerBlocks(), Block.class);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
ModuleRegistrar.instance().addConfig("General", "general.showhp");
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
}
@Override
@@ -160,6 +165,9 @@ public class ProxyClient extends ProxyServer {
/* Statues */
StatuesModule.register();
/* Agriculture */
AgricultureModule.register();
if(Loader.isModLoaded("ForgeMultipart")){
HUDHandlerFMP.register();
DecoratorFMP.register();
@@ -167,7 +175,6 @@ public class ProxyClient extends ProxyServer {
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), Block.class);
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), TileEntity.class);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEntities(), Entity.class);
}
@Override
@@ -18,6 +18,9 @@ import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerEntities implements IWailaEntityProvider {
public static int nhearts = 20;
public static float maxhpfortext = 40.0f;
@Override
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
return null;
@@ -35,31 +38,48 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showhp")) return currenttip;
if (entity instanceof EntityLivingBase){
String hptip = "";
nhearts = nhearts <= 0 ? 20 : nhearts;
float health = ((EntityLivingBase)entity).getHealth() / 2.0f;
float maxhp = ((EntityLivingBase)entity).getMaxHealth() / 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() > maxhpfortext)
currenttip.add(String.format("HP : " + WHITE + "%.0f" + GRAY + " / " + WHITE + "%.0f", ((EntityLivingBase)entity).getHealth(), ((EntityLivingBase)entity).getMaxHealth()));
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);
else{
for (int i = 0; i < MathHelper.floor_float(health); i++){
hptip += HEART;
if(hptip.length() % (nhearts * HEART.length()) == 0){
currenttip.add(hptip);
hptip = "";
}
}
if (((EntityLivingBase)entity).getHealth() > MathHelper.floor_float(health) * 2.0f){
hptip += HHEART;
if(hptip.length() % (nhearts * HEART.length()) == 0){
currenttip.add(hptip);
hptip = "";
}
}
for (int i = 0; i < MathHelper.floor_float(maxhp - health); i++){
hptip += EHEART;
if(hptip.length() % (nhearts * HEART.length()) == 0){
currenttip.add(hptip);
hptip = "";
}
}
if (!hptip.equals(""))
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;
}
@@ -44,6 +44,16 @@ public class Packet0x00ServerPing {
ConfigCategory serverForcing = ConfigHandler.instance().config.getCategory(Constants.CATEGORY_SERVER);
/*
ConfigCategory serverModules = ConfigHandler.instance().config.getCategory(Constants.CATEGORY_MODULES);
HashMap<String, Boolean> keys = new HashMap<String, Boolean>();
for (String key : serverModules.keySet()){
keys.put(key, serverModules.get(key).getBoolean(true));
}
*/
for (String key : serverForcing.keySet()){
if (serverForcing.get(key).getBoolean(false)){
Packet.writeString(key, outputStream);
+24 -6
View File
@@ -19,6 +19,11 @@ public class OverlayRenderer {
protected static boolean hasBlending;
protected static boolean hasLight;
protected static boolean hasDepthTest;
protected static boolean hasLight0;
protected static boolean hasLight1;
protected static boolean hasRescaleNormal;
protected static boolean hasColorMaterial;
protected static int boundTexIndex;
protected static RenderItem renderItem = new RenderItem();
@@ -37,7 +42,7 @@ public class OverlayRenderer {
{
renderOverlay(WailaTickHandler.instance().tooltip);
}
if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.ENTITY)
{
renderOverlay(WailaTickHandler.instance().tooltip);
@@ -49,6 +54,7 @@ public class OverlayRenderer {
//TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
GL11.glPushMatrix();
saveGLState();
GL11.glScalef(OverlayConfig.scale, OverlayConfig.scale, 1.0f);
@@ -66,7 +72,6 @@ public class OverlayRenderer {
tooltip.drawIcons();
if (tooltip.hasIcon)
RenderHelper.enableGUIStandardItemLighting();
@@ -75,19 +80,32 @@ public class OverlayRenderer {
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();
loadGLState();
GL11.glPopMatrix();
}
public static void saveGLState(){
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
//hasLight0 = GL11.glGetBoolean(GL11.GL_LIGHT0);
//hasLight1 = GL11.glGetBoolean(GL11.GL_LIGHT1);
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
//hasRescaleNormal = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
//hasColorMaterial = GL11.glGetBoolean(GL11.GL_COLOR_MATERIAL);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
}
public static void loadGLState(){
if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
//if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
//if (hasLight0) GL11.glEnable(GL11.GL_LIGHT0); else GL11.glDisable(GL11.GL_LIGHT0);
if (hasLight1) GL11.glEnable(GL11.GL_LIGHT1); else GL11.glDisable(GL11.GL_LIGHT1);
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST); else GL11.glDisable(GL11.GL_DEPTH_TEST);
//if (hasRescaleNormal) GL11.glEnable(GL12.GL_RESCALE_NORMAL); else GL11.glDisable(GL12.GL_RESCALE_NORMAL);
//if (hasColorMaterial) GL11.glEnable(GL11.GL_COLOR_MATERIAL); else GL11.glDisable(GL11.GL_COLOR_MATERIAL);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopAttrib();
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+4 -1
View File
@@ -78,7 +78,10 @@ public class RayTracing {
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3)
{
Vec3 vec3 = entity.getPosition(par3);
Vec3 vec3 = entity.getPosition(par3);
if (entity.getEyeHeight() != 0.12F)
vec3.yCoord += entity.getEyeHeight();
Vec3 vec31 = entity.getLook(par3);
Vec3 vec32 = vec3.addVector(vec31.xCoord * par1, vec31.yCoord * par1, vec31.zCoord * par1);
+7 -4
View File
@@ -27,6 +27,7 @@ public class Tooltip {
ItemStack stack;
int[] columnsWidth;
int columnsWidthMono;
int[] columnsPos;
int ncolumns = 0;
@@ -89,16 +90,17 @@ public class Tooltip {
for (Line l : lines)
ncolumns = Math.max(ncolumns, l.ncolumns);
columnsWidth = new int[ncolumns];
columnsPos = new int[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]);
}
columnsWidthMono = Math.max(columnsWidthMono, l.columnsWidth[0]);
}
maxStringW = 0;
@@ -106,6 +108,7 @@ public class Tooltip {
maxStringW += columnsWidth[i];
maxStringW += ncolumns * TabSpacing;
maxStringW = Math.max(maxStringW, columnsWidthMono);
for (int i = 0; i < ncolumns - 1; i++)
columnsPos[i + 1] = columnsWidth[i] + columnsPos[i];
+2 -1
View File
@@ -25,7 +25,8 @@ public final class Constants {
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_NHEARTS = "waila.cfg.heartsperline";
public static String CFG_WAILA_MAXHP = "waila.cfg.maxhpbeforetext";
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";