mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-14 17:14:51 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1071a6e611 | ||
|
|
acf75bf118 | ||
|
|
8594e628f4 |
No files matched your search
@@ -3,9 +3,9 @@ name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
name: Optimize images
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
jobs:
|
||||
optimize-images:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
||||
secrets: inherit
|
||||
@@ -28,4 +28,3 @@ whitelist.json
|
||||
src/main/resources/mixins.*.json
|
||||
*.bat
|
||||
layout.json
|
||||
.DS_Store
|
||||
@@ -1,13 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
+1
-18
@@ -1,24 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.91-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.463:dev") { transitive = false }
|
||||
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:WAILAPlugins:0.7.2:dev") {
|
||||
exclude group: 'com.github.GTNewHorizons', module: 'waila'
|
||||
}
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderCore:0.5.12:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:BuildCraft:7.1.57:dev")
|
||||
runtimeOnlyNonPublishable(deobfCurse("cofh-lib-220333:2388748"))
|
||||
runtimeOnlyNonPublishable(deobfCurse("extrautils-225561:2264383"))
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:OpenBlocks:1.12.12-GTNH:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Railcraft:9.17.26:dev")
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-foundation-222880:2388753'))
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-expansion-69163:2388759'))
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-dynamics-227443:2388756'))
|
||||
implementation(deobfCurse('cofh-core-69162:2388751'))
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.11.37:dev")
|
||||
}
|
||||
+4
-39
@@ -39,33 +39,9 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = jabel
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
||||
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
# jvmDowngraderStubsProvider =
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -120,9 +96,7 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# 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.
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -198,12 +172,6 @@ curseForgeRelations =
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
@@ -233,6 +201,3 @@ curseForgeRelations =
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
org.gradle.configuration-cache = true
|
||||
org.gradle.parallel = true
|
||||
@@ -1,12 +0,0 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
|
||||
toolchainVersion=25
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -114,6 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -171,6 +172,7 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -210,7 +212,8 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+2
-1
@@ -70,10 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ import mcp.mobius.waila.utils.ModIdentification;
|
||||
name = "Waila",
|
||||
version = Tags.GRADLETOKEN_VERSION,
|
||||
dependencies = "after:NotEnoughItems@[1.0.4.0,)",
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "mcp.mobius.waila.client.WailaGuiFactory")
|
||||
acceptableRemoteVersions = "*")
|
||||
public class Waila {
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
|
||||
@@ -8,7 +8,6 @@ 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 {
|
||||
|
||||
@@ -16,26 +15,21 @@ 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);
|
||||
|
||||
Waila.log.log(Level.INFO, "Buildcraft mod found.");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
||||
+8
-20
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -23,7 +20,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -33,36 +30,27 @@ public class TankFluidHandler 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);
|
||||
String fluidName = stack == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: stack.getFluid().getLocalizedName(stack);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(liquidAmount), formatFluid(capacity)));
|
||||
if (ConfigHandler.instance().getConfig("bc.tankamount")) currenttip.add(liquidAmount + "/" + capacity + " mB");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -4,26 +4,30 @@ 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 {
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
Class.forName("com.rwtema.extrautils.ExtraUtils");
|
||||
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 DrumFluidHandler(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.exu;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -18,7 +15,7 @@ import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class DrumFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -37,14 +34,18 @@ public class DrumFluidHandler 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;
|
||||
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
|
||||
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -58,6 +59,7 @@ public class DrumFluidHandler 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;
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.openblocks;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -20,7 +17,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -40,10 +37,14 @@ public class TankFluidHandler 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);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -59,8 +60,9 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
|
||||
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));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -74,6 +76,7 @@ public class TankFluidHandler 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,29 +4,30 @@ 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 {
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
Class.forName("openblocks.OpenBlocks");
|
||||
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
try {
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[OpenBlocks] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileEntityTank);
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
}
|
||||
}
|
||||
+28
-30
@@ -1,7 +1,4 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,6 +8,7 @@ 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;
|
||||
@@ -18,7 +16,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -28,24 +26,26 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@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;
|
||||
|
||||
if (!config.getConfig("railcraft.fluidamount")) 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);
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
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) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -54,22 +54,19 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@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;
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(tileEntity);
|
||||
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(tileEntity);
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(capacity)));
|
||||
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) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -84,6 +81,7 @@ public class TankFluidHandler 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,59 +1,43 @@
|
||||
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 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 Class<?> ITankTile = null;
|
||||
public static Method ITankTile_getTank = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
|
||||
TileTankBase_getTank = TileTankBase.getMethod("getTank");
|
||||
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
|
||||
ITankTile_getTank = ITankTile.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");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTankBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTankBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTankBase);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
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.cbcore.LangUtil;
|
||||
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", formatNumber(amount), formatFluid(tank.getCapacity())));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
@@ -81,8 +80,7 @@ public class HUDCargoManager implements IWailaDataProvider {
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All"
|
||||
: formatNumber(this.getAmount(amount)) + " " + this.getAmountType(amount);
|
||||
String sAmount = amount == 0 ? "All" : this.getAmount(amount) + " " + this.getAmountType(amount);
|
||||
|
||||
String selection = (String) StevesCartsModule.GetSelectionName
|
||||
.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
@@ -78,14 +77,13 @@ public class HUDLiquidManager implements IWailaDataProvider {
|
||||
fluidAmount = tag.getCompoundTag("Fluid" + i).getInteger("Amount");
|
||||
}
|
||||
|
||||
String fluidString = fluidAmount == 0 ? "<Empty>"
|
||||
: String.format("%s of %s", formatFluid(fluidAmount), fluidName);
|
||||
String fluidString = fluidAmount == 0 ? "<Empty>" : String.format("%s mB of %s", fluidAmount, fluidName);
|
||||
|
||||
if (color == 5) continue;
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All" : formatFluid(this.getMaxAmountBuckets(amount));
|
||||
String sAmount = amount == 0 ? "All" : this.getMaxAmountBuckets(amount) + " mB";
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
@@ -48,7 +47,7 @@ public class HUDMinecartModular implements IWailaEntityProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
Item ItemCartModule;
|
||||
Item ItemCartModule = null;
|
||||
try {
|
||||
ItemCartModule = (Item) StevesCartsModule.ItemCartModule.get(null);
|
||||
} catch (Exception e) {
|
||||
@@ -77,11 +76,12 @@ public class HUDMinecartModular implements IWailaEntityProvider {
|
||||
currenttip.add(
|
||||
new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB
|
||||
+ ALIGNRIGHT
|
||||
+ GRAY
|
||||
+ " [ "
|
||||
+ WHITE
|
||||
+ formatNumber(amount)
|
||||
+ " of "
|
||||
+ amount
|
||||
+ GRAY
|
||||
+ " mB of "
|
||||
+ WHITE
|
||||
+ fluid
|
||||
+ GRAY
|
||||
+ " ]");
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
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.cbcore.LangUtil;
|
||||
|
||||
/**
|
||||
* 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", formatNumber(amount), formatFluid(capacity)));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+27
-24
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,15 +7,17 @@ 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;
|
||||
|
||||
public class TankModeHandler implements IWailaDataProvider {
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class HUDHandlerDuct implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -25,33 +27,33 @@ public class TankModeHandler 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) {
|
||||
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")));
|
||||
}
|
||||
}
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) return currenttip;
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Amount")) amount = accessor.getNBTInteger(tag, "Amount");
|
||||
|
||||
currenttip.add(String.format(" %d / 1000 mB", amount));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ public class TankModeHandler 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,35 +4,31 @@ 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() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX : We register the Fluiduct
|
||||
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;
|
||||
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) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", 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);
|
||||
}
|
||||
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);
|
||||
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,17 +40,14 @@ public class HUDHandlerCache implements IWailaDataProvider {
|
||||
if (storedItem != null) {
|
||||
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
|
||||
name += String.format(
|
||||
" < %s %s >",
|
||||
SpecialChars.getRenderString(
|
||||
" < " + SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
namex,
|
||||
"0",
|
||||
String.valueOf(storedItem.getItemDamage())) + color,
|
||||
String.valueOf(storedItem.getItemDamage())) + color + " %s >",
|
||||
storedItem.getDisplayName());
|
||||
} else {
|
||||
name += " < " + LangUtil.translateG("hud.msg.empty") + " >";
|
||||
}
|
||||
} else name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
|
||||
currenttip.set(0, name);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -38,11 +36,11 @@ public class HUDHandlerEnergyCell implements IWailaDataProvider {
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s/%s : %s / %s RF/t",
|
||||
"%s/%s : %d / %d RF/t",
|
||||
LangUtil.translateG("hud.msg.in"),
|
||||
LangUtil.translateG("hud.msg.out"),
|
||||
formatNumber(energyReceive),
|
||||
formatNumber(energySend)));
|
||||
energyReceive,
|
||||
energySend));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
+8
-18
@@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -15,7 +13,7 @@ import mcp.mobius.waila.api.ITaggedList;
|
||||
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.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
@@ -36,23 +34,15 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.energyhandler")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("Energy")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("MaxStorage")) return currenttip;
|
||||
|
||||
if (currenttip instanceof ITaggedList taggedTips) {
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
|
||||
if (maxEnergy > 0 && taggedTips.getEntries("RFEnergyStorage").isEmpty()) {
|
||||
if (config.getConfig("thermalexpansion.rfenergybar")) {
|
||||
taggedTips.add(
|
||||
SpecialChars.getRenderString("waila.rfenergy", energy + "", maxEnergy + ""),
|
||||
"RFEnergyStorage");
|
||||
} else {
|
||||
taggedTips.add(
|
||||
String.format("%s / %s RF", formatNumber(energy), formatNumber(maxEnergy)),
|
||||
"RFEnergyStorage");
|
||||
}
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
try {
|
||||
if ((maxEnergy != 0) && (((ITaggedList) currenttip).getEntries("RFEnergyStorage").size() == 0)) {
|
||||
((ITaggedList) currenttip).add(String.format("%d / %d RF", energy, maxEnergy), "RFEnergyStorage");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ 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 HUDHandlerTesseract implements IWailaDataProvider {
|
||||
@@ -34,9 +33,9 @@ public class HUDHandlerTesseract implements IWailaDataProvider {
|
||||
if (config.getConfig("thermalexpansion.tesssendrecv")) {
|
||||
String send = String.format("%s : ", LangUtil.translateG("hud.msg.send"));
|
||||
String recv = String.format("%s : ", LangUtil.translateG("hud.msg.recv"));
|
||||
String item = String.format("%s ", SpecialChars.GREEN + LangUtil.translateG("hud.msg.item"));
|
||||
String fluid = String.format("%s ", SpecialChars.BLUE + LangUtil.translateG("hud.msg.fluid"));
|
||||
String energ = String.format("%s ", SpecialChars.RED + LangUtil.translateG("hud.msg.energ"));
|
||||
String item = String.format("\u00a7a%s ", LangUtil.translateG("hud.msg.item"));
|
||||
String fluid = String.format("\u00a79%s ", LangUtil.translateG("hud.msg.fluid"));
|
||||
String energ = String.format("\u00a7c%s ", LangUtil.translateG("hud.msg.energ"));
|
||||
|
||||
switch (accessor.getNBTInteger(accessor.getNBTData(), "Item.Mode")) {
|
||||
case 0:
|
||||
|
||||
+54
-51
@@ -9,7 +9,6 @@ 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 {
|
||||
|
||||
@@ -68,7 +67,6 @@ public class ThermalExpansionModule {
|
||||
IEnergyInfo_getCurStorage = IEnergyInfo.getMethod("getInfoEnergyStored");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.rfenergybar");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyReceiver);
|
||||
@@ -76,11 +74,13 @@ 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) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", 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);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the energy cell
|
||||
@@ -93,43 +93,41 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
|
||||
} 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
||||
if (!LoadedMods.WAILA_PLUGINS) {
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
|
||||
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().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new TankModeHandler(), TileTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the Tesseract interface
|
||||
@@ -144,13 +142,15 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
|
||||
} 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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the ISecureTile interface
|
||||
@@ -163,13 +163,15 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
|
||||
} 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the Cache interface
|
||||
@@ -184,15 +186,16 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCache(), TileCache);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCache(), TileCache);
|
||||
|
||||
} 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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
|
||||
}
|
||||
|
||||
@@ -2,29 +2,21 @@ package mcp.mobius.waila.addons.vanillamc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.utils.ColorUtils;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
|
||||
public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
|
||||
static Block furanace = Blocks.furnace;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
@@ -39,68 +31,45 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
NBTTagList items = accessor.getNBTData().getTagList("Items", 10);
|
||||
String itemsText = "";
|
||||
ItemStack inputStack = null;
|
||||
ItemStack fuelStack = null;
|
||||
ItemStack outputStack = null;
|
||||
int cookTime = accessor.getNBTData().getShort("CookTime");
|
||||
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
|
||||
|
||||
int smeltTime = tag.getInteger("Smelt");
|
||||
int fuelTime = tag.getInteger("Fuel");
|
||||
int maxFuelTime = tag.getInteger("MaxFuel");
|
||||
|
||||
double smeltProgress = (double) smeltTime / 200;
|
||||
double fuelProgress = (double) fuelTime / maxFuelTime;
|
||||
|
||||
for (int i = 0; i < items.tagCount(); i++) {
|
||||
NBTTagCompound itemTag = items.getCompoundTagAt(i);
|
||||
byte slot = itemTag.getByte("Slot");
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag);
|
||||
|
||||
if (slot == 0) {
|
||||
inputStack = stack;
|
||||
} else if (slot == 1) {
|
||||
fuelStack = stack;
|
||||
} else if (slot == 2) {
|
||||
outputStack = stack;
|
||||
}
|
||||
String renderStr = "";
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(1));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
if (fuelProgress > 0) {
|
||||
String fuelBar = TTRenderBar.create(
|
||||
String.format("Fuel %ds / %ds", (maxFuelTime - fuelTime) / 20, maxFuelTime / 20),
|
||||
ColorUtils.fuelFurnaceBarTop.getColor(),
|
||||
ColorUtils.fuelFurnaceBarBottom.getColor(),
|
||||
1.0 - fuelProgress);
|
||||
currenttip.add(fuelBar);
|
||||
renderStr += SpecialChars.getRenderString("waila.progress", String.valueOf(cookTime), String.valueOf(200));
|
||||
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
if (smeltProgress > 0) {
|
||||
String cookBar = TTRenderBar.create(
|
||||
String.format("Smelt %ds / %ds", smeltTime / 20, 200 / 20),
|
||||
ColorUtils.progressBarTop.getColor(),
|
||||
ColorUtils.progressBarBottom.getColor(),
|
||||
smeltProgress);
|
||||
currenttip.add(cookBar);
|
||||
}
|
||||
|
||||
if (inputStack != null) {
|
||||
itemsText += TTRenderStack.create(inputStack, inputStack.stackSize);
|
||||
}
|
||||
|
||||
if (fuelStack != null) {
|
||||
itemsText += TTRenderStack.create(fuelStack, fuelStack.stackSize);
|
||||
}
|
||||
|
||||
if (outputStack != null) {
|
||||
if (inputStack != null || fuelStack != null) {
|
||||
itemsText += TTRenderProgressBar.create(0, 1);
|
||||
}
|
||||
itemsText += TTRenderStack.create(outputStack, outputStack.stackSize);
|
||||
}
|
||||
|
||||
currenttip.add(itemsText);
|
||||
currenttip.add(renderStr);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -114,19 +83,9 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te instanceof TileEntityFurnace furnace) {
|
||||
tag.setInteger("Smelt", furnace.furnaceCookTime);
|
||||
tag.setInteger("Fuel", furnace.furnaceBurnTime);
|
||||
tag.setInteger("MaxFuel", furnace.currentItemBurnTime);
|
||||
te.writeToNBT(tag);
|
||||
}
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
IWailaDataProvider provider = new HUDHandlerFurnace();
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, furanace.getClass());
|
||||
ModuleRegistrar.instance().registerNBTProvider(provider, furanace.getClass());
|
||||
}
|
||||
public static void register() {}
|
||||
}
|
||||
@@ -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 hasWailaAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
default boolean hasAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return false; // Default to false for backward compatibility
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
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,7 +33,6 @@ 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";
|
||||
@@ -44,19 +43,12 @@ 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>..))");
|
||||
// (?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 patternRender = Pattern
|
||||
.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<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
|
||||
@@ -68,11 +60,7 @@ public class SpecialChars {
|
||||
+ "[0-9A-Z]|"
|
||||
+ WailaStyle
|
||||
+ WailaRenderer
|
||||
+ "a\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\}|[^"
|
||||
+ "a\\{([^,}]*),?([^}]*)\\}|[^"
|
||||
+ WailaStyle
|
||||
+ "]+)");
|
||||
|
||||
@@ -83,7 +71,7 @@ public class SpecialChars {
|
||||
public static String getRenderString(String name, String... params) {
|
||||
StringBuilder result = new StringBuilder(RENDER + "{" + name);
|
||||
for (String s : params) {
|
||||
result.append(WailaRendererComma).append(s);
|
||||
result.append(",").append(s);
|
||||
}
|
||||
result.append("}");
|
||||
return result.toString();
|
||||
|
||||
@@ -12,18 +12,18 @@ import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
public static final DataAccessorFMP instance = new DataAccessorFMP();
|
||||
String id;
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
TileEntity entity;
|
||||
NBTTagCompound partialNBT = null;
|
||||
NBTTagCompound remoteNBT = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
|
||||
private String id;
|
||||
private World world;
|
||||
private EntityPlayer player;
|
||||
private MovingObjectPosition mop;
|
||||
private Vec3 renderingvec;
|
||||
private TileEntity tileEntity;
|
||||
private NBTTagCompound partialNBT;
|
||||
private double partialFrame;
|
||||
|
||||
private DataAccessorFMP() {}
|
||||
public static DataAccessorFMP instance = new DataAccessorFMP();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT,
|
||||
String id) {
|
||||
@@ -35,24 +35,13 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.partialNBT = _partialNBT;
|
||||
this.id = id;
|
||||
this.renderingvec = renderVec;
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
id = null;
|
||||
world = null;
|
||||
player = null;
|
||||
mop = null;
|
||||
renderingvec = null;
|
||||
tileEntity = null;
|
||||
partialNBT = null;
|
||||
partialFrame = 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
@@ -65,7 +54,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.tileEntity;
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,9 +69,12 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getFullNBTData() {
|
||||
if (this.tileEntity == null) return null;
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNBT)) return this.remoteNBT;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -106,4 +98,20 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag) {
|
||||
if (tag == null) {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class MetaDataProvider {
|
||||
for (IWailaDataProvider dataProvider : providersList) try {
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
|
||||
if (dataProvider.hasWailaAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
if (dataProvider.hasAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
|
||||
hasAdvancedBodyAvailable = true;
|
||||
|
||||
if (isAdvancedKeyDown) {
|
||||
|
||||
@@ -7,6 +7,7 @@ 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;
|
||||
@@ -14,7 +15,6 @@ 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,10 +63,14 @@ 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 (LoadedMods.NEI && key_recipe.isPressed()) {
|
||||
NEIHandler.openRecipeGUI(true);
|
||||
} else if (LoadedMods.NEI && key_usage.isPressed()) {
|
||||
NEIHandler.openRecipeGUI(false);
|
||||
} else if (key_recipe.isPressed()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
NEIHandler.openRecipeGUI(true);
|
||||
}
|
||||
} else if (key_usage.isPressed()) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
NEIHandler.openRecipeGUI(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ 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,14 +18,10 @@ 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.TTRenderBar;
|
||||
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.TTRenderRFBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ProxyClient extends ProxyServer {
|
||||
|
||||
@@ -37,7 +34,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
LangUtil.loadLangDir("waila");
|
||||
|
||||
if (LoadedMods.NEI) {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
NEIHandler.register();
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
|
||||
@@ -56,10 +53,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.bar", new TTRenderBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.rfenergy", new TTRenderRFBar());
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.tcaspect", new TTRenderAspectString());
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
|
||||
public class WailaGuiFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return ScreenConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,17 @@ public class LabelFixedFont extends WidgetBase {
|
||||
|
||||
protected String text = "";
|
||||
protected int color;
|
||||
protected boolean shadow;
|
||||
|
||||
public LabelFixedFont(IWidget parent, String text) {
|
||||
super(parent);
|
||||
this.setText(text);
|
||||
this.color = 0xFFFFFF;
|
||||
this.shadow = false;
|
||||
}
|
||||
|
||||
public LabelFixedFont(IWidget parent, String text, int color) {
|
||||
super(parent);
|
||||
this.setText(text);
|
||||
this.color = color;
|
||||
this.shadow = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,10 +39,6 @@ public class LabelFixedFont extends WidgetBase {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setShadow(boolean shadow) {
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
private void updateGeometry() {
|
||||
if (this.geom == null) this.geom = new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY);
|
||||
|
||||
@@ -63,8 +56,7 @@ public class LabelFixedFont extends WidgetBase {
|
||||
@Override
|
||||
public void draw(Point pos) {
|
||||
this.saveGLState();
|
||||
if (this.shadow) this.mc.fontRenderer.drawStringWithShadow(this.text, pos.getX(), pos.getY(), this.color);
|
||||
else this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
|
||||
this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
@@ -15,17 +15,8 @@ import mcp.mobius.waila.gui.widgets.WidgetBase;
|
||||
|
||||
public abstract class ButtonBase extends WidgetBase {
|
||||
|
||||
protected static final int BUTTON_TEX_U = 0;
|
||||
protected static final int BUTTON_TEX_V_BASE = 66;
|
||||
protected static final int BUTTON_TEX_V_STEP = 20;
|
||||
protected static final int BUTTON_TEX_W = 200;
|
||||
protected static final int BUTTON_TEX_H = 20;
|
||||
protected static final int BUTTON_BORDER = 2;
|
||||
protected static final int COLOR_TEXT = 0xffffff;
|
||||
protected static final int COLOR_TEXT_HOVER = 0xffffa0;
|
||||
|
||||
protected boolean mouseOver = false;
|
||||
protected static final ResourceLocation widgetsTexture = new ResourceLocation("textures/gui/widgets.png");
|
||||
protected static ResourceLocation widgetsTexture = new ResourceLocation("textures/gui/widgets.png");
|
||||
|
||||
public ButtonBase(IWidget parent) {
|
||||
super(parent);
|
||||
@@ -34,14 +25,10 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int textColor = this.mouseOver ? COLOR_TEXT_HOVER : COLOR_TEXT;
|
||||
|
||||
for (IWidget widget : this.widgets.values()) {
|
||||
if (!(widget instanceof LabelFixedFont)) continue;
|
||||
LabelFixedFont label = (LabelFixedFont) widget;
|
||||
label.setShadow(true);
|
||||
label.setColor(textColor);
|
||||
}
|
||||
for (IWidget widget : this.widgets.values())
|
||||
if (widget instanceof LabelFixedFont) if (this.mouseOver) ((LabelFixedFont) widget).setColor(0xffffa0);
|
||||
else((LabelFixedFont) widget).setColor(0xffffff);
|
||||
|
||||
super.draw();
|
||||
}
|
||||
@@ -53,108 +40,20 @@ public abstract class ButtonBase extends WidgetBase {
|
||||
|
||||
if (this.mouseOver) texOffset = 1;
|
||||
|
||||
this.drawVanillaButton(texOffset);
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
|
||||
this.loadGLState();
|
||||
}
|
||||
|
||||
protected void drawVanillaButton(int texOffset) {
|
||||
int x = this.getPos().getX();
|
||||
int y = this.getPos().getY();
|
||||
int width = this.getSize().getX();
|
||||
int height = this.getSize().getY();
|
||||
int v = BUTTON_TEX_V_BASE + texOffset * BUTTON_TEX_V_STEP;
|
||||
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
if (width <= 0 || height <= 0) return;
|
||||
|
||||
int borderX = Math.min(BUTTON_BORDER, width / 2);
|
||||
int borderY = Math.min(BUTTON_BORDER, height / 2);
|
||||
int midW = width - borderX * 2;
|
||||
int midH = height - borderY * 2;
|
||||
int srcMidW = BUTTON_TEX_W - BUTTON_BORDER * 2;
|
||||
int srcMidH = BUTTON_TEX_H - BUTTON_BORDER * 2;
|
||||
|
||||
// Corners
|
||||
UIHelper.drawTexture(x, y, borderX, borderY, BUTTON_TEX_U, v, BUTTON_BORDER, BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x,
|
||||
y + height - borderY,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_U,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y + height - borderY,
|
||||
borderX,
|
||||
borderY,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
BUTTON_BORDER);
|
||||
|
||||
if (midW > 0) {
|
||||
// Top + bottom edges
|
||||
UIHelper.drawTexture(x + borderX, y, midW, borderY, BUTTON_BORDER, v, srcMidW, BUTTON_BORDER);
|
||||
UIHelper.drawTexture(
|
||||
x + borderX,
|
||||
y + height - borderY,
|
||||
midW,
|
||||
borderY,
|
||||
BUTTON_BORDER,
|
||||
v + BUTTON_TEX_H - BUTTON_BORDER,
|
||||
srcMidW,
|
||||
BUTTON_BORDER);
|
||||
}
|
||||
|
||||
if (midH > 0) {
|
||||
// Left + right edges
|
||||
UIHelper.drawTexture(
|
||||
x,
|
||||
y + borderY,
|
||||
borderX,
|
||||
midH,
|
||||
BUTTON_TEX_U,
|
||||
v + BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
srcMidH);
|
||||
UIHelper.drawTexture(
|
||||
x + width - borderX,
|
||||
y + borderY,
|
||||
borderX,
|
||||
midH,
|
||||
BUTTON_TEX_W - BUTTON_BORDER,
|
||||
v + BUTTON_BORDER,
|
||||
BUTTON_BORDER,
|
||||
srcMidH);
|
||||
}
|
||||
|
||||
if (midW > 0 && midH > 0) {
|
||||
// Center
|
||||
UIHelper.drawTexture(
|
||||
x + borderX,
|
||||
y + borderY,
|
||||
midW,
|
||||
midH,
|
||||
BUTTON_BORDER,
|
||||
v + BUTTON_BORDER,
|
||||
srcMidW,
|
||||
srcMidH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseEnter(MouseEvent event) {
|
||||
mouseOver = true;
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.lwjgl.util.Point;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
|
||||
public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
@@ -46,7 +47,17 @@ public class ButtonBooleanConfig extends ButtonBoolean {
|
||||
if (!ConfigHandler.instance().forcedConfigs.containsKey(this.configKey)) super.draw(pos);
|
||||
else {
|
||||
this.saveGLState();
|
||||
this.drawVanillaButton(-1);
|
||||
int texOffset = -1;
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.lwjgl.util.Point;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.gui.events.MouseEvent;
|
||||
import mcp.mobius.waila.gui.helpers.UIHelper;
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
|
||||
public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
@@ -40,7 +41,17 @@ public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
|
||||
super.draw(pos);
|
||||
else {
|
||||
this.saveGLState();
|
||||
this.drawVanillaButton(-1);
|
||||
int texOffset = -1;
|
||||
this.mc.getTextureManager().bindTexture(widgetsTexture);
|
||||
UIHelper.drawTexture(
|
||||
this.getPos().getX(),
|
||||
this.getPos().getY(),
|
||||
this.getSize().getX(),
|
||||
this.getSize().getY(),
|
||||
0,
|
||||
66 + texOffset * 20,
|
||||
200,
|
||||
20);
|
||||
this.loadGLState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,9 @@ public class DecoratorFMP implements IWailaBlockDecorator {
|
||||
accessor.getRenderingPosition(),
|
||||
accessor.getPartialFrame());
|
||||
|
||||
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id)
|
||||
.values()) {
|
||||
for (IWailaFMPDecorator provider : providersList) {
|
||||
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id).values())
|
||||
for (IWailaFMPDecorator provider : providersList)
|
||||
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
|
||||
@@ -71,7 +72,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()) {
|
||||
|
||||
@@ -41,11 +41,9 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getHeadFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +64,9 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getBodyFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,11 +87,9 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getTailFMPProviders(id)
|
||||
.values()) {
|
||||
for (IWailaFMPProvider provider : providersList) {
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
DataAccessorFMP.instance.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,20 +90,20 @@ public enum WailaPacketHandler {
|
||||
}
|
||||
|
||||
public void writeNBT(ByteBuf target, NBTTagCompound tag) throws IOException {
|
||||
if (tag == null) target.writeInt(-1);
|
||||
if (tag == null) target.writeShort(-1);
|
||||
else {
|
||||
byte[] abyte = CompressedStreamTools.compress(tag);
|
||||
target.writeInt(abyte.length);
|
||||
target.writeShort((short) abyte.length);
|
||||
target.writeBytes(abyte);
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound readNBT(ByteBuf dat) throws IOException {
|
||||
int val = dat.readInt();
|
||||
short short1 = dat.readShort();
|
||||
|
||||
if (val < 0) return null;
|
||||
if (short1 < 0) return null;
|
||||
else {
|
||||
byte[] abyte = new byte[val];
|
||||
byte[] abyte = new byte[short1];
|
||||
dat.readBytes(abyte);
|
||||
return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ 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;
|
||||
@@ -42,9 +41,8 @@ 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(SpecialChars.WailaRendererComma),
|
||||
DataAccessorCommon.instance).width;
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
}
|
||||
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
@@ -179,23 +177,4 @@ public class DisplayUtil {
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,16 +15,14 @@ public class OverlayRenderer {
|
||||
private static boolean hasDepthTest;
|
||||
private static int boundTexIndex;
|
||||
|
||||
public static boolean isOverlayVisible() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
return (mc.currentScreen == null && mc.theWorld != null
|
||||
public static void renderOverlay(Tooltip tooltip) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (!(mc.currentScreen == null && mc.theWorld != null
|
||||
&& Minecraft.isGuiEnabled()
|
||||
&& !mc.gameSettings.keyBindPlayerList.getIsKeyPressed()
|
||||
&& ConfigHandler.instance().showTooltip());
|
||||
}
|
||||
|
||||
public static void renderOverlay(Tooltip tooltip) {
|
||||
if (!isOverlayVisible() || RayTracing.instance().getTarget() == null) return;
|
||||
&& ConfigHandler.instance().showTooltip()
|
||||
&& RayTracing.instance().getTarget() != null))
|
||||
return;
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK
|
||||
&& RayTracing.instance().getTargetStack() != null) {
|
||||
|
||||
@@ -21,8 +21,6 @@ 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;
|
||||
@@ -182,10 +180,7 @@ public class Tooltip {
|
||||
renderable = new Renderable(
|
||||
renderer,
|
||||
new Point(offsetX, offsetY),
|
||||
renderMatcher.group("args").split(SpecialChars.WailaRendererComma));
|
||||
if (renderer instanceof IWailaVariableWidthTooltipRenderer variableWidthRenderer) {
|
||||
variableWidthRenderer.setMaxLineWidth(maxStringW);
|
||||
}
|
||||
renderMatcher.group("args").split(","));
|
||||
this.elements2nd.add(renderable);
|
||||
}
|
||||
} else if (iconMatcher.find()) {
|
||||
|
||||
@@ -35,9 +35,13 @@ public class WailaTickHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickClient(TickEvent.ClientTickEvent event) {
|
||||
|
||||
if (event.phase == TickEvent.Phase.START) return;
|
||||
|
||||
if (!OverlayRenderer.isOverlayVisible()) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
World world = mc.theWorld;
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
if (world == null || player == null) {
|
||||
this.tooltip = null;
|
||||
RayTracing.instance().clear();
|
||||
return;
|
||||
@@ -45,9 +49,6 @@ public class WailaTickHandler {
|
||||
|
||||
RayTracing.instance().fire();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
World world = mc.theWorld;
|
||||
|
||||
List<String> currenttip;
|
||||
List<String> currenttipHead;
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
private int maxStringW;
|
||||
private static final int HEIGHT = 12;
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
String text = params[0];
|
||||
|
||||
int displayWidth = DisplayUtil.getDisplayWidth(text);
|
||||
|
||||
return new Dimension(displayWidth + 4, HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
String text = params[0];
|
||||
int topColor = 0xFFFFEE55;
|
||||
int bottomColor = 0xFFFFA500;
|
||||
int fillWidth = maxStringW - 2;
|
||||
|
||||
if (params.length > 2) {
|
||||
try {
|
||||
topColor = Integer.parseInt(params[1]);
|
||||
bottomColor = Integer.parseInt(params[2]);
|
||||
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
|
||||
if (params.length > 3) {
|
||||
try {
|
||||
double ratio = Double.parseDouble(params[3]);
|
||||
ratio = Math.max(0.0, Math.min(1.0, ratio));
|
||||
fillWidth = (int) ((maxStringW - 2) * ratio);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
|
||||
drawVerticalGradient(maxStringW - 1, 0xFF2A2A2A, 0xFF111111);
|
||||
|
||||
if (fillWidth > 0) {
|
||||
drawVerticalGradient(1 + fillWidth, topColor, bottomColor);
|
||||
}
|
||||
|
||||
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, HEIGHT, 1, 0xFF505050, 0xFF505050, -1);
|
||||
DisplayUtil.drawString(text, 2, 2, 0xFFFFFFFF, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
|
||||
private void drawVerticalGradient(int x2, int topColor, int bottomColor) {
|
||||
int h = 11;
|
||||
if (x2 <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < h; i++) {
|
||||
float ratio = (float) i / (float) h;
|
||||
int color = blendColors(topColor, bottomColor, ratio);
|
||||
Gui.drawRect(1, i, x2, i + 1, color);
|
||||
}
|
||||
}
|
||||
|
||||
private int blendColors(int c1, int c2, float ratio) {
|
||||
int a1 = (c1 >> 24 & 0xFF), r1 = (c1 >> 16 & 0xFF), g1 = (c1 >> 8 & 0xFF), b1 = (c1 & 0xFF);
|
||||
int a2 = (c2 >> 24 & 0xFF), r2 = (c2 >> 16 & 0xFF), g2 = (c2 >> 8 & 0xFF), b2 = (c2 & 0xFF);
|
||||
|
||||
int a = (int) (a1 + (a2 - a1) * ratio);
|
||||
int r = (int) (r1 + (r2 - r1) * ratio);
|
||||
int g = (int) (g1 + (g2 - g1) * ratio);
|
||||
int b = (int) (b1 + (b2 - b1) * ratio);
|
||||
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public static String create(String text, int topColor, int bottomColor, double progress) {
|
||||
return SpecialChars.getRenderString(
|
||||
"waila.bar",
|
||||
text,
|
||||
String.valueOf(topColor),
|
||||
String.valueOf(bottomColor),
|
||||
String.valueOf(progress));
|
||||
}
|
||||
|
||||
public static String create(String text, int color, double progress) {
|
||||
return create(text, color, color, progress);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
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.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import gtPlusPlus.core.util.minecraft.FluidUtils;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
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 tFStack = FluidUtils.getWildcardFluidStack(fluidName, 1000);
|
||||
if (tFStack == null) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
Fluid tFluid = tFStack.getFluid();
|
||||
if (tFluid == null) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
// duplicate code to prevent extra stack allocations
|
||||
int tColor = tFluid.getColor();
|
||||
float r = ((tColor >>> 16) & 0xFF) / (float) 0xFF;
|
||||
float g = ((tColor >>> 8) & 0xFF) / (float) 0xFF;
|
||||
float b = (tColor & 0xFF) / (float) 0xFF;
|
||||
GL11.glColor4f(r, g, b, 1.0F);
|
||||
};
|
||||
} else {
|
||||
bindColor = (fluidName) -> {
|
||||
Fluid tFluid = FluidRegistry.getFluid(fluidName);
|
||||
if (tFluid == null) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
// duplicate code to prevent extra stack allocations
|
||||
int tColor = tFluid.getColor();
|
||||
float r = ((tColor >>> 16) & 0xFF) / (float) 0xFF;
|
||||
float g = ((tColor >>> 8) & 0xFF) / (float) 0xFF;
|
||||
float b = (tColor & 0xFF) / (float) 0xFF;
|
||||
GL11.glColor4f(r, g, b, 1.0F);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
boolean isEmpty = (params[0].equals("EMPTYFLUID") && params[1].equals("EMPTYFLUID"));
|
||||
int displayWidth = DisplayUtil.getDisplayWidth(
|
||||
buildDisplayText(
|
||||
isEmpty ? 0 : Double.parseDouble(params[2]),
|
||||
Double.parseDouble(params[3]),
|
||||
params[1],
|
||||
isEmpty));
|
||||
|
||||
return new Dimension(displayWidth + 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;
|
||||
boolean isEmpty = fluidName.equals("EMPTYFLUID") && localizedName.equals("EMPTYFLUID");
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (!isEmpty) {
|
||||
IIcon icon = FluidRegistry.getFluid(fluidName).getIcon();
|
||||
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 / Math.max(capacity, amount)));
|
||||
int j = 0;
|
||||
for (; i > height; i = i - height) {
|
||||
drawRectFromIcon(tessellator, 1 + (j * height), 0, 0, icon, height, height);
|
||||
j++;
|
||||
}
|
||||
if (i > 0) DisplayUtil.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();
|
||||
}
|
||||
|
||||
if (!isEmpty) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.70F);
|
||||
mc.getTextureManager().bindTexture(gradient);
|
||||
tessellator.startDrawingQuads();
|
||||
DisplayUtil.drawRect(tessellator, 1, 0, 0, maxStringW - 2, height - 1, 0, 0, 1, 1);
|
||||
tessellator.draw();
|
||||
} else {
|
||||
Gui.drawRect(1, 0, maxStringW - 1, height - 1, 0x1A575656);
|
||||
}
|
||||
|
||||
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
|
||||
|
||||
DisplayUtil.drawString(
|
||||
buildDisplayText(amount, capacity, localizedName, isEmpty),
|
||||
2,
|
||||
2,
|
||||
isEmpty ? 0xFFDDDDDD : 0xFFFFFFFF,
|
||||
true);
|
||||
}
|
||||
|
||||
public String buildDisplayText(double amount, double capacity, String fluidName, boolean isEmpty) {
|
||||
return isEmpty ? String.format("%s / %s", LangUtil.translateG("hud.msg.empty"), formatFluid(capacity))
|
||||
: String.format("%s / %s %s", formatNumber(amount), formatFluid(capacity), fluidName);
|
||||
}
|
||||
|
||||
public static void drawRectFromIcon(Tessellator tessellator, int x, int y, double z, IIcon icon, int width,
|
||||
int height) {
|
||||
DisplayUtil.drawRect(
|
||||
tessellator,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
width,
|
||||
height,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMaxU(),
|
||||
icon.getMaxV());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderProgressBar implements IWailaTooltipRenderer {
|
||||
@@ -34,8 +33,4 @@ public class TTRenderProgressBar implements IWailaTooltipRenderer {
|
||||
|
||||
}
|
||||
|
||||
public static String create(int currentValue, int maxValue) {
|
||||
return SpecialChars.getRenderString("waila.progress", String.valueOf(currentValue), String.valueOf(maxValue));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
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.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
int maxStringW;
|
||||
|
||||
private static final int height = 12;
|
||||
private static final int width = 2;
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return new Dimension(
|
||||
DisplayUtil.getDisplayWidth(buildDisplayText(Integer.parseInt(params[0]), Integer.parseInt(params[1])))
|
||||
+ 4,
|
||||
height);
|
||||
}
|
||||
|
||||
public static final ResourceLocation barTexture = new ResourceLocation("waila", "textures/rf_energy_bar.png");
|
||||
public static final ResourceLocation gradientTexture = new ResourceLocation("waila", "textures/gradient.png");
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
int amount = Integer.parseInt(params[0]);
|
||||
int capacity = Integer.parseInt(params[1]);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getTextureManager().bindTexture(barTexture);
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
// Draw dark (uncharged) background for whole bar first
|
||||
for (int i = 0; i < (maxStringW - 2); i += width) {
|
||||
DisplayUtil.drawRect(tessellator, 1 + i, 0, 0, width, height, 0.0, 0.0, 0.5, 1.0);
|
||||
}
|
||||
|
||||
double i = (double) (maxStringW - 2) * ((double) amount / Math.max(capacity, amount));
|
||||
int drawnRects = 0;
|
||||
for (; i > width; i -= width) {
|
||||
DisplayUtil.drawRect(tessellator, 1 + (drawnRects * width), 0, 0, width, height, 0.5, 0.0, 1.0, 1.0);
|
||||
drawnRects++;
|
||||
}
|
||||
// Do less than full increments just as much as they take up on the scaled texture
|
||||
drawRectD(tessellator, 1 + (drawnRects * width), 0, 0, i, height, 0.5, 0.0, 0.5 + 0.25 * i, 1.0);
|
||||
tessellator.draw();
|
||||
|
||||
// Border
|
||||
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
|
||||
|
||||
// Gradient
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.5F);
|
||||
mc.getTextureManager().bindTexture(gradientTexture);
|
||||
tessellator.startDrawingQuads();
|
||||
DisplayUtil.drawRect(tessellator, 1, 1, 0, maxStringW - 2, height - 2, 0, 0, 1, 1);
|
||||
tessellator.draw();
|
||||
|
||||
DisplayUtil.drawString(buildDisplayText(amount, capacity), 2, 2, 0xFFFFFFFF, true);
|
||||
}
|
||||
|
||||
public String buildDisplayText(int amount, int capacity) {
|
||||
return String.format("%s / %s RF", formatNumber(amount), formatNumber(capacity));
|
||||
}
|
||||
|
||||
public static void drawRectD(Tessellator tessellator, double x, double y, double z, double width, double 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
}
|
||||
@@ -7,21 +7,15 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderStack implements IWailaTooltipRenderer {
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
boolean small = Boolean.parseBoolean(params.length > 4 ? params[4] : "false");
|
||||
return small ? new Dimension(10, 8) : new Dimension(16, 16);
|
||||
return new Dimension(16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,51 +24,14 @@ public class TTRenderStack implements IWailaTooltipRenderer {
|
||||
String name = params[1]; // Fully qualified name
|
||||
int amount = Integer.parseInt(params[2]);
|
||||
int meta = Integer.parseInt(params[3]);
|
||||
boolean small = Boolean.parseBoolean(params.length > 4 ? params[4] : "false");
|
||||
final float scale = 0.5f;
|
||||
|
||||
ItemStack stack = null;
|
||||
if (type == 0) stack = new ItemStack((Block) Block.blockRegistry.getObject(name), amount, meta);
|
||||
if (type == 1) stack = new ItemStack((Item) Item.itemRegistry.getObject(name), amount, meta);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
if (small) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glScaled(scale, scale, 1.0f);
|
||||
|
||||
DisplayUtil.renderStack(0, -1, stack);
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
DisplayUtil.renderStack(0, 0, stack);
|
||||
}
|
||||
DisplayUtil.renderStack(0, 0, stack);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack, int amount, boolean small) {
|
||||
String name = GameData.getItemRegistry().getNameForObject(itemStack.getItem());
|
||||
int meta = itemStack.getItemDamage();
|
||||
return SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
String.valueOf(1),
|
||||
name,
|
||||
String.valueOf(amount),
|
||||
String.valueOf(meta),
|
||||
String.valueOf(small));
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack, boolean small) {
|
||||
return create(itemStack, 1, small);
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack) {
|
||||
return create(itemStack, false);
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack, int amount) {
|
||||
return create(itemStack, amount, false);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -29,7 +30,6 @@ 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 (LoadedMods.FORGE_MULTIPART) {
|
||||
if (Loader.isModLoaded("ForgeMultipart")) {
|
||||
HUDHandlerFMP.register();
|
||||
DecoratorFMP.register();
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.color.ColorResource;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
private static final ColorResource.Factory color = new ColorResource.Factory("waila");
|
||||
|
||||
public static final ColorResource
|
||||
// spotless:off
|
||||
fuelFurnaceBarTop = color.argb("fuelFurnaceBarTop", "0xFFFF8800"),
|
||||
fuelFurnaceBarBottom = color.argb("fuelFurnaceBarBottom", "0xFFFFCC00"),
|
||||
progressBarTop = color.argb("progressBarTop", "0xFFFF0000"),
|
||||
progressBarBottom = color.argb("progressBarBottom", "0xFF8B0000");
|
||||
// spotless:on
|
||||
|
||||
}
|
||||
@@ -29,7 +29,6 @@ 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";
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
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");
|
||||
}
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=Nenalezeno žádné využití.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Držte %s pro více informací
|
||||
|
||||
hud.msg.empty=Prázdný
|
||||
hud.msg.none=<Nic>
|
||||
hud.msg.empty=<Prázdný>
|
||||
hud.msg.output=Výstup
|
||||
hud.msg.input=Vstup
|
||||
hud.msg.out=Ven
|
||||
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=Keine Nutzung gefunden.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Halte %s für mehr Infos
|
||||
|
||||
hud.msg.empty=Leer
|
||||
hud.msg.none=<Nichts>
|
||||
hud.msg.empty=<Leer>
|
||||
hud.msg.output=Output
|
||||
hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
|
||||
@@ -42,7 +42,8 @@ client.msg.nousage=No usage found.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Hold %s for more info
|
||||
|
||||
hud.msg.empty=Empty
|
||||
hud.msg.none=<None>
|
||||
hud.msg.empty=<Empty>
|
||||
hud.msg.output=Output
|
||||
hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
@@ -92,7 +93,7 @@ hud.msg.on=On
|
||||
hud.msg.state=State
|
||||
hud.msg.delay=Delay
|
||||
hud.msg.comparator=Comparator
|
||||
hud.msg.substractor=Subtractor
|
||||
hud.msg.substractor=Substractor
|
||||
hud.msg.record=Record
|
||||
|
||||
hud.msg.offers=Offers
|
||||
@@ -114,7 +115,6 @@ option.ic2.consump=Show consumption
|
||||
option.ic2.tradeomat=Show Trade-O-Mat request
|
||||
option.thaumcraft.storedvis=Capacitor storage
|
||||
option.thermalexpansion.energyhandler=Show RF storage
|
||||
option.thermalexpansion.rfenergybar=Use Progress Bar for RF
|
||||
option.thermalexpansion.energycell=Show ECell IN/OUT
|
||||
option.thermalexpansion.fluidtype=Show fluid type
|
||||
option.thermalexpansion.fluidamount=Show fluid amount
|
||||
@@ -155,4 +155,4 @@ option.general.showhp=Show entities health
|
||||
option.general.showcrop=Show crop growth
|
||||
option.thaumcraft.aspects=Show aspects
|
||||
|
||||
nei.options.keys.showenchant=Show enchanting values
|
||||
nei.options.keys.showenchant=Show enchanting values
|
||||
@@ -38,7 +38,8 @@ waila.keybind.testing=[Waila] Testimine
|
||||
client.msg.norecipe=Ühtegi retsepti ei leitud.
|
||||
client.msg.nousage=Ühtegi kasutust ei leitud.
|
||||
|
||||
hud.msg.empty=Tühi
|
||||
hud.msg.none=<Mitte Ükski>
|
||||
hud.msg.empty=<Tühi>
|
||||
hud.msg.output=Väljund
|
||||
hud.msg.input=Sisend
|
||||
hud.msg.out=Välja
|
||||
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=Ühtegi kasutust ei leitud.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Hoia %s lisainfo saamiseks
|
||||
|
||||
hud.msg.empty=Tühi
|
||||
hud.msg.none=<Mitte Ükski>
|
||||
hud.msg.empty=<Tühi>
|
||||
hud.msg.output=Väljund
|
||||
hud.msg.input=Sisend
|
||||
hud.msg.out=Välja
|
||||
|
||||
@@ -39,7 +39,8 @@ client.msg.nousage=Pas d'utilisation trouvée.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Maintenez %s pour plus d'infos
|
||||
|
||||
hud.msg.empty=Vide
|
||||
hud.msg.none=<Aucun>
|
||||
hud.msg.empty=<Vide>
|
||||
hud.msg.output=Sortie
|
||||
hud.msg.input=Entrée
|
||||
hud.msg.out=Sortie
|
||||
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=Nessun uso trovato.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Tieni premuto %s per più info
|
||||
|
||||
hud.msg.empty=Vuoto
|
||||
hud.msg.none=<Niente>
|
||||
hud.msg.empty=<Vuoto>
|
||||
hud.msg.output=Uscita
|
||||
hud.msg.input=Entrata
|
||||
hud.msg.out=Fuori
|
||||
|
||||
@@ -39,7 +39,8 @@ client.msg.nousage=Geen gebruik gevonden.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Houd %s ingedrukt voor meer info
|
||||
|
||||
hud.msg.empty=Leeg
|
||||
hud.msg.none=<Geen>
|
||||
hud.msg.empty=<Leeg>
|
||||
hud.msg.output=Uitvoer
|
||||
hud.msg.input=Invoer
|
||||
hud.msg.out=Uit
|
||||
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=Применений не найдено.
|
||||
|
||||
hud.msg.holdkeymoreinfo=Удерживайте %s для подробностей
|
||||
|
||||
hud.msg.empty=Пусто
|
||||
hud.msg.none=<Ничего>
|
||||
hud.msg.empty=<Пусто>
|
||||
hud.msg.output=Вывод
|
||||
hud.msg.input=Ввод
|
||||
hud.msg.out=Из
|
||||
|
||||
@@ -41,7 +41,8 @@ client.msg.nousage=未发现可参与合成.
|
||||
|
||||
hud.msg.holdkeymoreinfo=按住 %s 查看更多信息
|
||||
|
||||
hud.msg.empty=空
|
||||
hud.msg.none=<无>
|
||||
hud.msg.empty=<空>
|
||||
hud.msg.output=输出
|
||||
hud.msg.input=输入
|
||||
hud.msg.out=输出
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 138 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 606 B |
Reference in new issue
Block a user