mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 09:34:53 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c115d9af3 | ||
|
|
c0a119902a | ||
|
|
93485e1525 | ||
|
|
ceb94e3e2c | ||
|
|
8ea26bf073 | ||
|
|
2aabfdb64c | ||
|
|
a34460c159 | ||
|
|
1f3fd64a38 | ||
|
|
191a916896 | ||
|
|
ee1ed27a3a | ||
|
|
07b9d1bf92 | ||
|
|
e82729a113 | ||
|
|
c938ccf542 | ||
|
|
c2e8b44f2b |
No files matched your search
@@ -28,3 +28,4 @@ whitelist.json
|
||||
src/main/resources/mixins.*.json
|
||||
*.bat
|
||||
layout.json
|
||||
.DS_Store
|
||||
@@ -0,0 +1,13 @@
|
||||
# Waila
|
||||
|
||||
## Contribution
|
||||
|
||||
When forking this repository, make sure to uncheck the `Copy the master branch only` option.
|
||||
This will copy all tags to your fork, so the build system can detect the latest mod version.
|
||||
If you leave it checked, you won't be able to enter the world in a local client run because Waila [will think the mod is outdated](https://github.com/GTNewHorizons/waila/blob/master/src/main/java/mcp/mobius/waila/Waila.java#L133).
|
||||
|
||||
If you already forked the repository without tags, you can fetch them manually:
|
||||
```
|
||||
git remote add upstream https://github.com/GTNewHorizons/waila
|
||||
git fetch upstream --tags
|
||||
```
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.91-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.69:dev") { transitive = false }
|
||||
}
|
||||
+3
-1
@@ -96,7 +96,9 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.46'
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class BCModule {
|
||||
|
||||
@@ -15,21 +16,26 @@ public class BCModule {
|
||||
public static Method TileTank_getTankInfo = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileTank = Class.forName("buildcraft.factory.TileTank");
|
||||
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
|
||||
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
|
||||
Waila.log.log(Level.INFO, "Buildcraft mod found.");
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
Waila.log.log(Level.INFO, "[BC] Buildcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
Waila.log.log(Level.INFO, "Buildcraft mod found.");
|
||||
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
|
||||
}
|
||||
|
||||
}
|
||||
+23
-8
@@ -19,8 +19,9 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
|
||||
public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -30,27 +31,41 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!ConfigHandler.instance().getConfig("bc.tanktype")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
FluidTankInfo tank = this.getTank(accessor);
|
||||
FluidStack stack = tank != null ? tank.fluid : null;
|
||||
|
||||
String name = currenttip.get(0);
|
||||
if (stack != null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " (" + stack.getFluid().getName() + ")";
|
||||
else if (stack == null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " " + LangUtil.translateG("hud.msg.empty");
|
||||
currenttip.set(0, name);
|
||||
String fluidName = stack == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: stack.getFluid().getLocalizedName(stack);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!ConfigHandler.instance().getConfig("bc.tankamount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
FluidTankInfo tank = this.getTank(accessor);
|
||||
FluidStack stack = tank != null ? tank.fluid : null;
|
||||
int liquidAmount = stack != null ? stack.amount : 0;
|
||||
int capacity = tank != null ? tank.capacity : 0;
|
||||
|
||||
if (ConfigHandler.instance().getConfig("bc.tankamount")) currenttip.add(liquidAmount + "/" + capacity + " mB");
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(liquidAmount),
|
||||
NumberFormatter.format(capacity),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
+10
-8
@@ -14,8 +14,10 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
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.NumberFormatter;
|
||||
|
||||
public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
public class DrumFluidHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -34,18 +36,19 @@ public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
|
||||
if (!config.getConfig("extrautilities.fluidamount")) return currenttip;
|
||||
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound subtag = accessor.getNBTData().getCompoundTag("tank");
|
||||
if (subtag.hasKey("Amount")) amount = accessor.getNBTInteger(subtag, "Amount");
|
||||
|
||||
IFluidHandler handler = (IFluidHandler) accessor.getTileEntity();
|
||||
if (handler == null) return currenttip;
|
||||
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(amount),
|
||||
NumberFormatter.format(tanks[0].capacity),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -59,7 +62,6 @@ public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -4,30 +4,26 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ExtraUtilitiesModule {
|
||||
|
||||
public static Class<?> TileEntityDrum = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("com.rwtema.extrautils.ExtraUtils");
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[ExtraUtilities] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new DrumFluidHandler(), TileEntityDrum);
|
||||
}
|
||||
}
|
||||
@@ -4,30 +4,29 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class OpenBlocksModule {
|
||||
|
||||
public static Class<?> TileEntityTank = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("openblocks.OpenBlocks");
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[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().registerNBTProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileEntityTank);
|
||||
}
|
||||
}
|
||||
+13
-12
@@ -15,9 +15,11 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
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.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -37,14 +39,10 @@ public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
FluidStack fluid = tanks[0].fluid;
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -60,9 +58,13 @@ public class HUDHandlerTank implements IWailaDataProvider {
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
if (tanks[0].fluid != null)
|
||||
currenttip.add(String.format("%d / %d mB", tanks[0].fluid.amount, tanks[0].capacity));
|
||||
else currenttip.add(String.format("0 / %d mB", tanks[0].capacity));
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(amount),
|
||||
NumberFormatter.format(tanks[0].capacity),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -76,7 +78,6 @@ public class HUDHandlerTank implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerTank 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) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
try {
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
try {
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid != null) currenttip.add(String.format("%d / %d mB", fluid.amount, tank.getInfo().capacity));
|
||||
else currenttip.add(String.format("0 / %d mB", tank.getInfo().capacity));
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +1,59 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class RailcraftModule {
|
||||
|
||||
public static Class<?> TileTankBase = null;
|
||||
public static Class<?> ITankTile = null;
|
||||
public static Method ITankTile_getTank = null;
|
||||
public static Method TileTankBase_getTank = null;
|
||||
|
||||
public static Class<?> StandardTank = null;
|
||||
public static Field StandardTank_capacity = null;
|
||||
public static Field StandardTank_renderData = null;
|
||||
|
||||
public static Field StandardTank_renderDataFluid = null;
|
||||
public static Field StandardTank_renderDataAmount = null;
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
Class.forName("mods.railcraft.common.core.Railcraft");
|
||||
Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
|
||||
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
|
||||
ITankTile_getTank = ITankTile.getMethod("getTank");
|
||||
TileTankBase_getTank = TileTankBase.getMethod("getTank");
|
||||
|
||||
StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
|
||||
StandardTank_capacity = StandardTank.getSuperclass().getDeclaredField("capacity");
|
||||
StandardTank_capacity.setAccessible(true);
|
||||
StandardTank_renderData = StandardTank.getField("renderData");
|
||||
|
||||
StandardTank_renderDataFluid = StandardTank_renderData.getType().getField("fluid");
|
||||
StandardTank_renderDataAmount = StandardTank_renderData.getType().getField("amount");
|
||||
|
||||
Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Field not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTankBase);
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTankBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTankBase);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
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.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankFluidHandler 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) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
IFluidTank tank = this.getTank(accessor.getTileEntity());
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
IFluidTank tank = this.getTank(accessor.getTileEntity());
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
int amount = fluid == null ? 0 : fluid.amount;
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(amount),
|
||||
NumberFormatter.format(tank.getCapacity()),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
private FluidTank getTank(TileEntity tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Object tank = RailcraftModule.TileTankBase_getTank.invoke(tileEntity);
|
||||
|
||||
int capacity = RailcraftModule.StandardTank_capacity.getInt(tank);
|
||||
Object renderData = RailcraftModule.StandardTank_renderData.get(tank);
|
||||
|
||||
Fluid fluid = (Fluid) RailcraftModule.StandardTank_renderDataFluid.get(renderData);
|
||||
int amount = RailcraftModule.StandardTank_renderDataAmount.getInt(renderData);
|
||||
|
||||
return new FluidTank(fluid, amount, capacity);
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
@@ -57,9 +58,10 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
total += value;
|
||||
String amount = String.valueOf(value);
|
||||
|
||||
if (!aspect.equals("???"))
|
||||
currenttip.add(String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount));
|
||||
else unknownAspects.add(String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount));
|
||||
if (!aspect.equals("???")) currenttip.add(
|
||||
SpecialChars.getRenderString("waila.tcaspect", aspect) + TAB + ALIGNRIGHT + WHITE + amount);
|
||||
else unknownAspects.add(
|
||||
SpecialChars.getRenderString("waila.tcaspect", aspect) + TAB + ALIGNRIGHT + WHITE + amount);
|
||||
}
|
||||
|
||||
String id = tag.getString("WailaID");
|
||||
@@ -118,7 +120,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
if (tileAspects.get(o) > 0) {
|
||||
if (playerAspects.containsKey(o)) {
|
||||
NBTTagCompound cmptag = new NBTTagCompound();
|
||||
cmptag.setString("key", (String) ThaumcraftModule.Aspect_getName.invoke(o));
|
||||
cmptag.setString("key", (String) ThaumcraftModule.Aspect_tag.get(o));
|
||||
cmptag.setInteger("value", tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -30,12 +32,17 @@ public class ThaumcraftModule {
|
||||
public static Class<?> Aspect = null;
|
||||
public static Field Aspect_tag = null;
|
||||
public static Method Aspect_getName = null;
|
||||
public static Method Aspect_getAspect = null;
|
||||
public static Method Aspect_getImage = null;
|
||||
public static Method Aspect_getColor = null;
|
||||
|
||||
public static Class<?> CommonProxy = null;
|
||||
public static Method CommonProxy_getKnownAspects = null;
|
||||
|
||||
public static Class<?> IGoggles = null;
|
||||
|
||||
public static ResourceLocation unknownAspectTexture = null;
|
||||
public static Color unknownAspectColor = null;
|
||||
public static Function<ItemStack, Boolean> isGoggles = stack -> IGoggles.isInstance(stack.getItem());
|
||||
|
||||
public static void register() {
|
||||
@@ -57,12 +64,18 @@ public class ThaumcraftModule {
|
||||
Aspect_tag = Aspect.getDeclaredField("tag");
|
||||
Aspect_tag.setAccessible(true);
|
||||
Aspect_getName = Aspect.getDeclaredMethod("getName");
|
||||
Aspect_getAspect = Aspect.getMethod("getAspect", java.lang.String.class);
|
||||
Aspect_getImage = Aspect.getDeclaredMethod("getImage");
|
||||
Aspect_getColor = Aspect.getDeclaredMethod("getColor");
|
||||
|
||||
CommonProxy = Class.forName("thaumcraft.common.CommonProxy");
|
||||
CommonProxy_getKnownAspects = CommonProxy.getDeclaredMethod("getKnownAspects");
|
||||
|
||||
IGoggles = Class.forName("thaumcraft.api.IGoggles");
|
||||
|
||||
unknownAspectTexture = new ResourceLocation("thaumcraft", "textures/aspects/_unknown.png");
|
||||
unknownAspectColor = new Color(0x654242);
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thaumcraft", "thaumcraft.aspects");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), IAspectContainer);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), TileAlchemyFurnace);
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
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.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class FluiductFluidHandler 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) {
|
||||
|
||||
if (!config.getConfig("thermaldynamics.fluiductsFluid")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluid"));
|
||||
int capacity = tag.getInteger("capacity");
|
||||
|
||||
if (capacity == 0) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluid"));
|
||||
int amount = fluid == null ? 0 : fluid.amount;
|
||||
int capacity = tag.getInteger("capacity");
|
||||
|
||||
if (capacity == 0) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(amount),
|
||||
NumberFormatter.format(capacity),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te instanceof IFluidHandler fluidHandler) {
|
||||
FluidTankInfo[] infos = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (infos.length != 1) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
FluidTankInfo info = infos[0];
|
||||
|
||||
if (info.fluid != null) {
|
||||
NBTTagCompound fluidNBT = info.fluid.writeToNBT(new NBTTagCompound());
|
||||
tag.setTag("fluid", fluidNBT);
|
||||
}
|
||||
|
||||
tag.setInteger("capacity", info.capacity);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,31 +4,35 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ThermalDynamicsModule {
|
||||
|
||||
public static Class<?> TileFluidDuct = null;
|
||||
|
||||
public static void register() {
|
||||
// XXX : We register the Fluiduct
|
||||
try {
|
||||
TileFluidDuct = Class.forName("cofh.thermaldynamics.ducts.fluid.TileFluidDuct");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
|
||||
}
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
|
||||
|
||||
try {
|
||||
TileFluidDuct = Class.forName("cofh.thermaldynamics.duct.fluid.TileFluidDuct");
|
||||
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
|
||||
|
||||
FluiductFluidHandler fluiductFluidHandler = new FluiductFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerBodyProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerNBTProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,14 +40,17 @@ public class HUDHandlerCache implements IWailaDataProvider {
|
||||
if (storedItem != null) {
|
||||
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
|
||||
name += String.format(
|
||||
" < " + SpecialChars.getRenderString(
|
||||
" < %s %s >",
|
||||
SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
namex,
|
||||
"0",
|
||||
String.valueOf(storedItem.getItemDamage())) + color + " %s >",
|
||||
String.valueOf(storedItem.getItemDamage())) + color,
|
||||
storedItem.getDisplayName());
|
||||
} else name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
} else {
|
||||
name += " < " + LangUtil.translateG("hud.msg.empty") + " >";
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerTank 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) {
|
||||
if (!config.getConfig("thermalexpansion.fluidtype")) return currenttip;
|
||||
|
||||
try {
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid
|
||||
.invoke(accessor.getTileEntity());
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
try {
|
||||
if (config.getConfig("thermalexpansion.fluidamount")) {
|
||||
int amount = 0;
|
||||
if (accessor.getNBTData().hasKey("Amount"))
|
||||
amount = accessor.getNBTInteger(accessor.getNBTData(), "Amount");
|
||||
|
||||
Integer capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity
|
||||
.invoke(accessor.getTileEntity());
|
||||
|
||||
currenttip.add(String.format("%d / %d mB", amount, capacity));
|
||||
}
|
||||
|
||||
if (config.getConfig("thermalexpansion.tankmode")) {
|
||||
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
|
||||
if (mode == 0) currenttip.add(
|
||||
String.format(
|
||||
"%s : \u00a7a%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
LangUtil.translateG("hud.msg.input")));
|
||||
else if (mode == 1) currenttip.add(
|
||||
String.format(
|
||||
"%s : \u00a7c%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
LangUtil.translateG("hud.msg.output")));
|
||||
else currenttip.add(String.format("Mode : Unknown (%d)", mode));
|
||||
}
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(te);
|
||||
tag.setInteger("Amount", amount);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
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.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankFluidHandler 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) {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.fluidtype")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
|
||||
try {
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid.invoke(tileEntity);
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.fluidamount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(tileEntity);
|
||||
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(tileEntity);
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s / %s %s",
|
||||
NumberFormatter.format(amount),
|
||||
NumberFormatter.format(capacity),
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
+24
-27
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,17 +7,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class HUDHandlerDuct implements IWailaDataProvider {
|
||||
public class TankModeHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -27,33 +25,33 @@ public class HUDHandlerDuct implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermaldynamics.fluiductsFluid")) return currenttip;
|
||||
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(accessor.getNBTData());
|
||||
|
||||
String name = "";
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.add(name);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) return currenttip;
|
||||
try {
|
||||
if (config.getConfig("thermalexpansion.tankmode")) {
|
||||
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
|
||||
if (mode == 0) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.GREEN + LangUtil.translateG("hud.msg.input")));
|
||||
} else if (mode == 1) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.RED + LangUtil.translateG("hud.msg.output")));
|
||||
}
|
||||
}
|
||||
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Amount")) amount = accessor.getNBTInteger(tag, "Amount");
|
||||
|
||||
currenttip.add(String.format(" %d / 1000 mB", amount));
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -67,7 +65,6 @@ public class HUDHandlerDuct implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
+51
-55
@@ -9,6 +9,7 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ThermalExpansionModule {
|
||||
|
||||
@@ -74,13 +75,11 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
printedThermalExpansionNotFound = true;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
printedThermalExpansionNotFound = true;
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
|
||||
}
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
|
||||
}
|
||||
|
||||
// XXX : We register the energy cell
|
||||
@@ -93,41 +92,43 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
|
||||
}
|
||||
|
||||
// XXX : We register the Tank interface
|
||||
try {
|
||||
TileTank = Class.forName("cofh.thermalexpansion.block.tank.TileTank");
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
TileTank_mode = TileTank.getField("mode");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTank);
|
||||
if (!LoadedMods.WAILA_PLUGINS) {
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new TankModeHandler(), TileTank);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
|
||||
}
|
||||
|
||||
// XXX : We register the Tesseract interface
|
||||
@@ -142,15 +143,13 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
}
|
||||
|
||||
// XXX : We register the ISecureTile interface
|
||||
@@ -163,15 +162,13 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
|
||||
}
|
||||
|
||||
// XXX : We register the Cache interface
|
||||
@@ -186,16 +183,15 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCache(), TileCache);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCache(), TileCache);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
}
|
||||
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface IWailaDataProvider {
|
||||
* @param config Current configuration of Waila.
|
||||
* @return True if advanced body information is available, false otherwise.
|
||||
*/
|
||||
default boolean hasAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
default boolean hasWailaAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return false; // Default to false for backward compatibility
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
/**
|
||||
* Interface for tooltip renderers that adjust their width depending on the width of the rest of the tooltip.
|
||||
* setMaxLineWidth is called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render to inform the
|
||||
* renderer of the width of the longest line in the tooltip.
|
||||
*/
|
||||
public interface IWailaVariableWidthTooltipRenderer extends IWailaTooltipRenderer {
|
||||
|
||||
/**
|
||||
* Return the size of the tooltip. for variable width renderers it is recommended to return the minimum width needed
|
||||
* for the line, then draw the actual width using getMaxLineWidth(). They do not need to actually match.
|
||||
*
|
||||
* @param params Array of string parameters as passed to the RENDER arg in the tooltip
|
||||
* ({rendername,param1,param2,...})
|
||||
* @param accessor A global accessor for TileEntities and Entities
|
||||
* @return Dimension of the reserved area
|
||||
*/
|
||||
Dimension getSize(String[] params, IWailaCommonAccessor accessor);
|
||||
|
||||
/**
|
||||
* Informs the renderer of what the length of the longest line is.</br>
|
||||
* Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.</br>
|
||||
*
|
||||
* @param width The width of the longest line in the tooltip.
|
||||
*
|
||||
*/
|
||||
void setMaxLineWidth(int width);
|
||||
|
||||
/**
|
||||
* Returns the width of the longest line in the current tooltip.</br>
|
||||
* With icons disabled the tooltip's background box is always 2 pixels wider to the right of the line than it is to
|
||||
* the left.</br>
|
||||
*
|
||||
* @return The width of the longest line in the tooltip
|
||||
*
|
||||
*/
|
||||
int getMaxLineWidth();
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public class SpecialChars {
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
public static String WailaRenderer = "\u00A6";
|
||||
public static String WailaRendererComma = "\u0082";
|
||||
public static String TAB = WailaStyle + WailaStyle + "a";
|
||||
public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b";
|
||||
public static String ALIGNCENTER = WailaStyle + WailaStyle + "c";
|
||||
@@ -43,12 +44,19 @@ public class SpecialChars {
|
||||
|
||||
public static final Pattern patternMinecraft = Pattern.compile("(?i)" + MCStyle + "[0-9A-FK-OR]");
|
||||
public static final Pattern patternWaila = Pattern.compile("(?i)(" + WailaStyle + "(?<type>..))");
|
||||
public static final Pattern patternRender = Pattern
|
||||
.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<args>[^}]*)\\})");
|
||||
// (?i)(¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\})
|
||||
public static final Pattern patternRender = Pattern.compile(
|
||||
"(?i)(" + RENDER
|
||||
+ "\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\})");
|
||||
public static final Pattern patternTab = Pattern.compile("(?i)" + TAB);
|
||||
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
|
||||
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
|
||||
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9a-z]))");
|
||||
// (?i)(¤¤[^¤]+|¤¥[0-9A-Z]|¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\}|[^¤]+)
|
||||
public static final Pattern patternLineSplit = Pattern.compile(
|
||||
"(?i)(" + WailaStyle
|
||||
+ WailaStyle
|
||||
@@ -60,7 +68,11 @@ public class SpecialChars {
|
||||
+ "[0-9A-Z]|"
|
||||
+ WailaStyle
|
||||
+ WailaRenderer
|
||||
+ "a\\{([^,}]*),?([^}]*)\\}|[^"
|
||||
+ "a\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\}|[^"
|
||||
+ WailaStyle
|
||||
+ "]+)");
|
||||
|
||||
@@ -71,7 +83,7 @@ public class SpecialChars {
|
||||
public static String getRenderString(String name, String... params) {
|
||||
StringBuilder result = new StringBuilder(RENDER + "{" + name);
|
||||
for (String s : params) {
|
||||
result.append(",").append(s);
|
||||
result.append(WailaRendererComma).append(s);
|
||||
}
|
||||
result.append("}");
|
||||
return result.toString();
|
||||
|
||||
@@ -34,6 +34,8 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
public HashMap<String, Boolean> forcedConfigs = new HashMap<>();
|
||||
public Configuration config = null;
|
||||
|
||||
public String fluidUnit;
|
||||
|
||||
public void addModule(String modName, HashMap<String, String> options) {
|
||||
this.addModule(modName, new ConfigModule(modName, options));
|
||||
}
|
||||
@@ -150,6 +152,7 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NEWFILTERS, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOWICON, true);
|
||||
fluidUnit = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FLUIDUNIT, "mB").getString();
|
||||
|
||||
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();
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MetaDataProvider {
|
||||
for (IWailaDataProvider dataProvider : providersList) try {
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
|
||||
if (dataProvider.hasAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
if (dataProvider.hasWailaAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
hasAdvancedBodyAvailable = true;
|
||||
|
||||
if (isAdvancedKeyDown) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
@@ -15,6 +14,7 @@ import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
import mcp.mobius.waila.handlers.nei.NEIHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class KeyEvent {
|
||||
|
||||
@@ -63,14 +63,10 @@ public class KeyEvent {
|
||||
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 (key_recipe.isPressed()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
NEIHandler.openRecipeGUI(true);
|
||||
}
|
||||
} else if (key_usage.isPressed()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
NEIHandler.openRecipeGUI(false);
|
||||
}
|
||||
} else if (LoadedMods.NEI && key_recipe.isPressed()) {
|
||||
NEIHandler.openRecipeGUI(true);
|
||||
} else if (LoadedMods.NEI && key_usage.isPressed()) {
|
||||
NEIHandler.openRecipeGUI(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
@@ -17,10 +20,14 @@ import mcp.mobius.waila.handlers.HUDHandlerBlocks;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerEntities;
|
||||
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
|
||||
import mcp.mobius.waila.handlers.nei.NEIHandler;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
|
||||
public class ProxyClient extends ProxyServer {
|
||||
|
||||
@@ -33,7 +40,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
LangUtil.loadLangDir("waila");
|
||||
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
if (LoadedMods.NEI) {
|
||||
NEIHandler.register();
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
|
||||
@@ -53,8 +60,14 @@ public class ProxyClient extends ProxyServer {
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.tcaspect", new TTRenderAspectString());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new WorldUnloadEventHandler());
|
||||
|
||||
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager())
|
||||
.registerReloadListener(new NumberFormatterReloadListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,4 +86,12 @@ public class ProxyClient extends ProxyServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class NumberFormatterReloadListener implements IResourceManagerReloadListener {
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
NumberFormatter.onResourcesReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,7 +71,7 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
currenttip.add(RENDER + "{Plip}" + RENDER + "{Plop,thisisatest,222,333}");
|
||||
// currenttip.add(RENDER + "{Plip}" + RENDER + "{Plop,thisisatest,222,333}");
|
||||
|
||||
String modName = ModIdentification.nameFromStack(itemStack);
|
||||
if (modName != null && !modName.isEmpty()) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
@@ -41,8 +42,9 @@ public class DisplayUtil {
|
||||
Matcher renderMatcher = patternRender.matcher(s);
|
||||
while (renderMatcher.find()) {
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
if (renderer != null) width += renderer.getSize(
|
||||
renderMatcher.group("args").split(SpecialChars.WailaRendererComma),
|
||||
DataAccessorCommon.instance).width;
|
||||
}
|
||||
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
@@ -180,7 +182,10 @@ public class Tooltip {
|
||||
renderable = new Renderable(
|
||||
renderer,
|
||||
new Point(offsetX, offsetY),
|
||||
renderMatcher.group("args").split(","));
|
||||
renderMatcher.group("args").split(SpecialChars.WailaRendererComma));
|
||||
if (renderer instanceof IWailaVariableWidthTooltipRenderer variableWidthRenderer) {
|
||||
variableWidthRenderer.setMaxLineWidth(maxStringW);
|
||||
}
|
||||
this.elements2nd.add(renderable);
|
||||
}
|
||||
} else if (iconMatcher.find()) {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.overlay.OverlayConfig;
|
||||
|
||||
public class TTRenderAspectString implements IWailaTooltipRenderer {
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
int width;
|
||||
if (params[0].equals("???")) {
|
||||
width = DisplayUtil.getDisplayWidth(params[0]);
|
||||
} else {
|
||||
try {
|
||||
Object aspect = ThaumcraftModule.Aspect_getAspect.invoke(null, params[0]);
|
||||
if (aspect == null) {
|
||||
width = DisplayUtil.getDisplayWidth(params[0]);
|
||||
} else width = DisplayUtil.getDisplayWidth((String) ThaumcraftModule.Aspect_getName.invoke(aspect));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return new Dimension(width + 10, params[0].isEmpty() ? 0 : 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
try {
|
||||
if (params[0].equals("???")) {
|
||||
drawTag(0, 0, ThaumcraftModule.unknownAspectTexture, ThaumcraftModule.unknownAspectColor, 200);
|
||||
DisplayUtil.drawString(params[0], 10, 0, OverlayConfig.fontcolor, true);
|
||||
return;
|
||||
}
|
||||
Object aspect = ThaumcraftModule.Aspect_getAspect.invoke(null, params[0]);
|
||||
if (aspect == null) return;
|
||||
drawTag(
|
||||
0,
|
||||
0,
|
||||
(ResourceLocation) ThaumcraftModule.Aspect_getImage.invoke(aspect),
|
||||
new Color((int) ThaumcraftModule.Aspect_getColor.invoke(aspect)),
|
||||
200);
|
||||
DisplayUtil.drawString(
|
||||
(String) ThaumcraftModule.Aspect_getName.invoke(aspect),
|
||||
10,
|
||||
0,
|
||||
OverlayConfig.fontcolor,
|
||||
true);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
DisplayUtil.drawString(params[0], 10, 0, OverlayConfig.fontcolor, true);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTag(double x, double y, ResourceLocation image, Color color, double z) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.renderEngine.bindTexture(image);
|
||||
GL11.glColor4f(
|
||||
(float) color.getRed() / 255.0F,
|
||||
(float) color.getGreen() / 255.0F,
|
||||
(float) color.getBlue() / 255.0F,
|
||||
1);
|
||||
|
||||
Tessellator var9 = Tessellator.instance;
|
||||
var9.startDrawingQuads();
|
||||
var9.setColorRGBA_F(
|
||||
(float) color.getRed() / 255.0F,
|
||||
(float) color.getGreen() / 255.0F,
|
||||
(float) color.getBlue() / 255.0F,
|
||||
1);
|
||||
|
||||
var9.addVertexWithUV(x + 0.0D, y + 8.0D, z, 0.0D, 1.0D);
|
||||
var9.addVertexWithUV(x + 8.0D, y + 8.0D, z, 1.0D, 1.0D);
|
||||
var9.addVertexWithUV(x + 8.0D, y + 0.0D, z, 1.0D, 0.0D);
|
||||
var9.addVertexWithUV(x + 0.0D, y + 0.0D, z, 0.0D, 0.0D);
|
||||
var9.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import gregtech.api.util.GTUtil;
|
||||
import gregtech.common.fluid.GTFluid;
|
||||
import gtPlusPlus.api.objects.minecraft.FluidGT6;
|
||||
import gtPlusPlus.core.util.minecraft.FluidUtils;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
import mcp.mobius.waila.utils.NumberFormatter;
|
||||
|
||||
public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
int maxStringW;
|
||||
|
||||
private final Consumer<String> bindColor;
|
||||
private static final int height = 12;
|
||||
|
||||
public TTRenderFluidBar() {
|
||||
if (LoadedMods.GT5U) {
|
||||
bindColor = (fluidName) -> {
|
||||
FluidStack aCheck = FluidUtils.getWildcardFluidStack(fluidName, 1000);
|
||||
if (aCheck != null && (aCheck.getFluid() instanceof FluidGT6 || aCheck.getFluid() instanceof GTFluid)) {
|
||||
short[] RGBa = GTUtil.getRGBaArray(aCheck.getFluid().getColor());
|
||||
GL11.glColor4f(RGBa[0] / 255F, RGBa[1] / 255F, RGBa[2] / 255F, 1F);
|
||||
} else {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
bindColor = (fluidName) -> GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
int commaCount = (int) (Math.floor((params[2].length() - 1) / 3D) + Math.floor((params[3].length() - 1) / 3D));
|
||||
// ",".repeat(commaCount) doesn't exist in java 8 so do this instead.
|
||||
StringBuilder sb = new StringBuilder(commaCount);
|
||||
for (int i = 0; i < commaCount; i++) {
|
||||
sb.append(",");
|
||||
}
|
||||
return new Dimension(
|
||||
DisplayUtil.getDisplayWidth(
|
||||
params[2] + " / " + params[3] + ConfigHandler.instance().fluidUnit + params[1] + sb) + 4,
|
||||
height);
|
||||
}
|
||||
|
||||
public static final ResourceLocation gradient = new ResourceLocation("waila", "textures/gradient.png");
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
String fluidName = params[0];
|
||||
String localizedName = params[1];
|
||||
double amount = Double.parseDouble(params[2]);
|
||||
double capacity = Double.parseDouble(params[3]);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
IIcon icon = FluidRegistry.getFluid(fluidName).getIcon();
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
bindColor.accept(fluidName);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
// Intentionally draw 2 pixels taller than needed than cover with the border to make the texture more visible
|
||||
int i = (int) ((double) (maxStringW - 2) * amount / capacity);
|
||||
int j = 0;
|
||||
for (; i > height; i = i - height) {
|
||||
drawRectFromIcon(tessellator, 1 + (j * height), 0, 0, icon, height, height);
|
||||
j++;
|
||||
}
|
||||
if (i > 0) drawRect(
|
||||
tessellator,
|
||||
1 + (j * height),
|
||||
0,
|
||||
0,
|
||||
i,
|
||||
height,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMinU() + ((icon.getMaxU() - icon.getMinU()) * ((double) i / height)),
|
||||
icon.getMaxV());
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.70F);
|
||||
mc.getTextureManager().bindTexture(gradient);
|
||||
tessellator.startDrawingQuads();
|
||||
drawRect(tessellator, 1, 0, 0, maxStringW - 2, height - 1, 0, 0, 1, 1);
|
||||
tessellator.draw();
|
||||
|
||||
drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
|
||||
|
||||
DisplayUtil.drawString(
|
||||
NumberFormatter.format((int) amount) + " / "
|
||||
+ NumberFormatter.format((int) capacity)
|
||||
+ " "
|
||||
+ ConfigHandler.instance().fluidUnit
|
||||
+ " "
|
||||
+ localizedName,
|
||||
2,
|
||||
2,
|
||||
0xFFFFFFFF,
|
||||
true);
|
||||
|
||||
}
|
||||
|
||||
public static void drawRectFromIcon(Tessellator tessellator, int x, int y, double z, IIcon icon, int width,
|
||||
int height) {
|
||||
drawRect(tessellator, x, y, z, width, height, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV());
|
||||
}
|
||||
|
||||
public static void drawRect(Tessellator tessellator, int x, int y, double z, int width, int height, double minU,
|
||||
double minV, double maxU, double maxV) {
|
||||
tessellator.addVertexWithUV(x, y + height, z, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, z, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y, z, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y, z, minU, minV);
|
||||
}
|
||||
|
||||
public static void drawThickBeveledBox(int x1, int y1, int x2, int y2, int thickness, int topleftcolor,
|
||||
int botrightcolor, int fillcolor) {
|
||||
if (fillcolor != -1) {
|
||||
Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
|
||||
}
|
||||
Gui.drawRect(x1, y1, x2 - 1, y1 + thickness, topleftcolor);
|
||||
Gui.drawRect(x1, y1, x1 + thickness, y2 - 1, topleftcolor);
|
||||
Gui.drawRect(x2 - thickness, y1, x2, y2 - 1, botrightcolor);
|
||||
Gui.drawRect(x1, y2 - thickness, x2, y2, botrightcolor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package mcp.mobius.waila.server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.addons.agriculture.AgricultureModule;
|
||||
import mcp.mobius.waila.addons.buildcraft.BCModule;
|
||||
@@ -30,6 +29,7 @@ import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.handlers.DecoratorFMP;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerFMP;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ProxyServer {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ProxyServer {
|
||||
/* Agriculture */
|
||||
AgricultureModule.register();
|
||||
|
||||
if (Loader.isModLoaded("ForgeMultipart")) {
|
||||
if (LoadedMods.FORGE_MULTIPART) {
|
||||
HUDHandlerFMP.register();
|
||||
DecoratorFMP.register();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public final class Constants {
|
||||
public static String CFG_WAILA_NHEARTS = "waila.cfg.heartsperline";
|
||||
public static String CFG_WAILA_MAXHP = "waila.cfg.maxhpbeforetext";
|
||||
public static String CFG_WAILA_NEWFILTERS = "waila.cfg.newfilters";
|
||||
public static String CFG_WAILA_FLUIDUNIT = "waila.cfg.fluid_unit";
|
||||
|
||||
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
|
||||
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class LoadedMods {
|
||||
|
||||
public static boolean FORGE_MULTIPART = Loader.isModLoaded("ForgeMultipart");
|
||||
public static boolean NEI = Loader.isModLoaded("NotEnoughItems");
|
||||
public static boolean GT5U = Loader.isModLoaded("gregtech_nh");
|
||||
public static boolean WAILA_PLUGINS = Loader.isModLoaded("wailaplugins");
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import gregtech.api.util.GTUtility;
|
||||
|
||||
public class NumberFormatter {
|
||||
|
||||
private static NumberFormat numberFormat = NumberFormat.getInstance(getCurrentLocale());
|
||||
|
||||
public static String format(long number) {
|
||||
if (LoadedMods.GT5U) {
|
||||
return GTUtility.formatNumbers(number);
|
||||
}
|
||||
|
||||
return numberFormat.format(number);
|
||||
}
|
||||
|
||||
public static Locale getCurrentLocale() {
|
||||
String langCode = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
|
||||
String[] parts = langCode.split("_", 2);
|
||||
String language = parts[0];
|
||||
String country = parts.length == 1 ? "" : parts[1];
|
||||
|
||||
return new Locale(language, country);
|
||||
}
|
||||
|
||||
public static void onResourcesReload() {
|
||||
numberFormat = NumberFormat.getInstance(getCurrentLocale());
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=Nenalezeno žádné využití.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Držte %s pro více informací
|
||||
|
||||
hud.msg.none=<Nic>
|
||||
hud.msg.empty=<Prázdný>
|
||||
hud.msg.empty=Prázdný
|
||||
hud.msg.output=Výstup
|
||||
hud.msg.input=Vstup
|
||||
hud.msg.out=Ven
|
||||
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=Keine Nutzung gefunden.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Halte %s für mehr Infos
|
||||
|
||||
hud.msg.none=<Nichts>
|
||||
hud.msg.empty=<Leer>
|
||||
hud.msg.empty=Leer
|
||||
hud.msg.output=Output
|
||||
hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
|
||||
@@ -42,8 +42,7 @@ client.msg.nousage=No usage found.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Hold %s for more info
|
||||
|
||||
hud.msg.none=<None>
|
||||
hud.msg.empty=<Empty>
|
||||
hud.msg.empty=Empty
|
||||
hud.msg.output=Output
|
||||
hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
|
||||
@@ -38,8 +38,7 @@ waila.keybind.testing=[Waila] Testimine
|
||||
client.msg.norecipe=Ühtegi retsepti ei leitud.
|
||||
client.msg.nousage=Ühtegi kasutust ei leitud.
|
||||
|
||||
hud.msg.none=<Mitte Ükski>
|
||||
hud.msg.empty=<Tühi>
|
||||
hud.msg.empty=Tühi
|
||||
hud.msg.output=Väljund
|
||||
hud.msg.input=Sisend
|
||||
hud.msg.out=Välja
|
||||
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=Ühtegi kasutust ei leitud.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Hoia %s lisainfo saamiseks
|
||||
|
||||
hud.msg.none=<Mitte Ükski>
|
||||
hud.msg.empty=<Tühi>
|
||||
hud.msg.empty=Tühi
|
||||
hud.msg.output=Väljund
|
||||
hud.msg.input=Sisend
|
||||
hud.msg.out=Välja
|
||||
|
||||
@@ -39,8 +39,7 @@ client.msg.nousage=Pas d'utilisation trouvée.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Maintenez %s pour plus d'infos
|
||||
|
||||
hud.msg.none=<Aucun>
|
||||
hud.msg.empty=<Vide>
|
||||
hud.msg.empty=Vide
|
||||
hud.msg.output=Sortie
|
||||
hud.msg.input=Entrée
|
||||
hud.msg.out=Sortie
|
||||
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=Nessun uso trovato.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Tieni premuto %s per più info
|
||||
|
||||
hud.msg.none=<Niente>
|
||||
hud.msg.empty=<Vuoto>
|
||||
hud.msg.empty=Vuoto
|
||||
hud.msg.output=Uscita
|
||||
hud.msg.input=Entrata
|
||||
hud.msg.out=Fuori
|
||||
|
||||
@@ -39,8 +39,7 @@ client.msg.nousage=Geen gebruik gevonden.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Houd %s ingedrukt voor meer info
|
||||
|
||||
hud.msg.none=<Geen>
|
||||
hud.msg.empty=<Leeg>
|
||||
hud.msg.empty=Leeg
|
||||
hud.msg.output=Uitvoer
|
||||
hud.msg.input=Invoer
|
||||
hud.msg.out=Uit
|
||||
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=Применений не найдено.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Удерживайте %s для подробностей
|
||||
|
||||
hud.msg.none=<Ничего>
|
||||
hud.msg.empty=<Пусто>
|
||||
hud.msg.empty=Пусто
|
||||
hud.msg.output=Вывод
|
||||
hud.msg.input=Ввод
|
||||
hud.msg.out=Из
|
||||
|
||||
@@ -41,8 +41,7 @@ client.msg.nousage=未发现可参与合成.
|
||||
|
||||
hud.msg.holdkeymoreinfo=按住 %s 查看更多信息
|
||||
|
||||
hud.msg.none=<无>
|
||||
hud.msg.empty=<空>
|
||||
hud.msg.empty=空
|
||||
hud.msg.output=输出
|
||||
hud.msg.input=输入
|
||||
hud.msg.out=输出
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 145 B |
Reference in new issue
Block a user