Compare commits

..
Author SHA1 Message Date
Mika Hensel 76406153ee Clamp delta reset state on world change and fade only the bar 2026-11-07 05:30:30 +01:00
Mika Hensel cb1b75a17b Further styling tweaks, happy with it now 2026-10-28 21:39:44 +01:00
Mika Hensel f172a0dbb0 Add Jade style block break progress 2026-10-28 20:03:10 +01:00
evgengoldwarandMartin Robertz f998f9ebfe Fix TTRenderStack (#75)
Co-authored-by: Martin Robertz <[email protected]>
2026-08-24 00:08:51 +07:00
evgengoldwar 6d0f162453 Add ColorUtils (#74) 2026-08-23 13:27:35 +02:00
evgengoldwar 9e3ef39e30 Improve progress bar (#73) 2026-08-22 23:16:21 -04:00
SuperSoupr 452fbfa47c Change progress bars lengths (#71) 2026-07-19 13:47:43 +03:00
Guillaume MercierandGuillaume Mercier d8477007c9 Add compat for fluid colors for non GT5u fluids (#69)
Co-authored-by: Guillaume Mercier <[email protected]>
2026-06-05 16:01:44 -04:00
flamingowrangler2869 bd5905dfc0 fix comparator "substractor" mode spelling (#70) 2026-05-24 00:26:01 +00:00
Algent 80e761d83f Allow Waila to handle bigger NBT packet (#68) 2026-05-12 14:12:37 +02:00
MalTeeezandgithub-actions[bot] ef0f8b5329 Prevent overflowing of bars in tooltip renderers (#66)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-11 18:50:24 +02:00
Alexdoru 65e4a773d0 [Memory-opti:fix leak] fix client leak from DataAccessorFMP (#65) 2026-05-10 20:19:36 +02:00
jackandMartin Robertz 30717912fb Added GUI config factory (#63)
Co-authored-by: Martin Robertz <[email protected]>
2026-05-03 10:05:56 +02:00
Ranzu 1421b83a5b Styling of text and buttons (#64) 2026-04-29 18:24:21 +02:00
UltraProdigy 2de1ec4235 Fix Deps (#62) 2026-04-27 23:35:30 +02:00
Martin Robertz 91f8019410 update+gradle+deps+bs 2026-04-27 12:25:53 +02:00
UltraProdigy 59157ec1e3 Optimize Images & Workflow (#61) 2026-04-26 18:20:36 +00:00
slprime b612897ddb Skip WAILA tooltip updates when GUI is open (#60) 2026-02-07 14:37:38 +01:00
Martin Robertz a5607eda00 update 2026-01-24 20:40:06 +01:00
Connor-ColensoandConnor Colenso f242cf77a9 Format numbers follow up (#59)
Co-authored-by: Connor Colenso <colen@CONNORSPC>
2026-01-24 20:37:57 +01:00
9d1840dabc Format numbers migration (#57)
Co-authored-by: Connor Colenso <[email protected]>
Co-authored-by: Connor Colenso <colen@CONNORSPC>
2026-01-23 18:55:28 +00:00
evgengoldwar 677a74dad7 Add small icon variant for TTRenderStack (#58) 2026-01-19 22:25:21 +01:00
MalTeeezandMartin Robertz 10219fd204 Allow showing empty tanks via Fluid Bars (#51)
Co-authored-by: Martin Robertz <[email protected]>
2025-11-17 00:50:29 +01:00
MalTeeezandMartin Robertz d14044c92e Use progress bars to render IEnergyInfo RF content (#55)
Co-authored-by: Martin Robertz <[email protected]>
2025-11-17 00:50:04 +01:00
danyadev 5c115d9af3 WailaPlugins compat (#54) 2025-11-15 18:17:38 +01:00
danyadev c0a119902a add a note about forking the repo in README.md (#52) 2025-11-15 09:50:17 +00:00
SuperSoupr 93485e1525 Clarify IWailaVariableWidthTooltipRenderer.getSize's documentation (#53) 2025-11-14 06:29:41 +01:00
ceb94e3e2c fix loader check (#45)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: SuperSoupr <[email protected]>
2025-11-11 18:29:45 +00:00
SuperSouprandsisyphussy 8ea26bf073 Add gradient to fluid bar to improve visibility (#49)
Co-authored-by: sisyphussy <[email protected]>
2025-11-11 18:50:58 +01:00
Worive 2aabfdb64c Rename hasAdvancedBody to hasWailaAdvancedBody (#48) 2025-10-25 14:04:28 +02:00
Martin Robertz a34460c159 update 2025-10-24 22:59:20 +02:00
SuperSouprandSuper 1f3fd64a38 Use special comma for renderer formatting (#47)
Co-authored-by: Super <[email protected]>
2025-10-24 13:29:56 +02:00
Martin Robertz 191a916896 update 2025-10-22 21:39:31 +02:00
SuperSouprandSuper ee1ed27a3a Add fancy fluid tooltip renderer (#43)
Co-authored-by: Super <[email protected]>
2025-10-22 21:33:06 +02:00
SuperSoupr 07b9d1bf92 Add documentation for IWailaVariableWidthTooltipRenderer (#44) 2025-10-20 21:47:51 +00:00
SuperSouprandSuper e82729a113 Add variable width tooltip renderer support (#42)
Co-authored-by: Super <[email protected]>
2025-10-20 21:55:03 +02:00
Dream Master c938ccf542 update 2025-10-13 14:42:49 +02:00
c2e8b44f2b Draw thaumcraft aspect icons in tooltip (#41)
Co-authored-by: Super <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2025-10-13 14:22:46 +02:00
Martin Robertz c4e3537957 update 2025-10-01 17:23:42 +02:00
EmperorSuper 9bc1e79f64 Add Gadomancy support (Thaumic Sight enchant) (#40) 2025-10-01 08:12:13 +02:00
Martin Robertz bdebd737d6 update 2025-09-21 17:20:45 +02:00
WoriveandMartin Robertz 9f04d3d029 feat(api): Add support for advanced tooltip body (#38)
Co-authored-by: Martin Robertz <[email protected]>
2025-09-21 17:19:57 +02:00
Martin Robertz ef3c4a9774 update 2025-09-17 13:52:33 +02:00
Alexdoru 3b64d21335 change log level of callbackRegistration (#39) 2025-09-16 11:26:17 +02:00
Alexdoru 72c91a3700 Fix FMLLoadCompleteEvent using wrong annotation (#37) 2025-07-14 00:22:10 +00:00
Alexdoru bf6d309038 Delete redundant registration via reflection (#36) 2025-07-13 21:58:24 +02:00
Maya 5bb7f7221a update 2025-06-28 09:59:03 -06:00
AlexdoruandMartin Robertz 6278e4d575 [Memory-opti:fix leak] Fix WorldClient leak in WailaTickHandler and RayTracing (#31)
Co-authored-by: Martin Robertz <[email protected]>
2025-06-28 09:58:51 -06:00
Martin Robertz 7a46d914db update 2025-06-14 00:28:26 +02:00
Alexdoru d30d8ba100 Add config to show icon on HUD or not (#35) 2025-06-13 12:06:54 +02:00
Alexdoru 490a176446 Make strings rendering ignore transparency (#33) 2025-06-11 04:19:57 +02:00
Nikolay S. 453a8f50a7 Re-encode cs_CZ.lang into UTF-8 (#32) 2025-06-10 20:48:42 -05:00
Dream Master d946500c0d update 2025-05-28 12:25:03 +02:00
Alexdoru 487829a16e Stop running tick events twice per tick (#30) 2025-05-28 06:28:45 +02:00
Martin Robertz f153502858 update
(cherry picked from commit 093cf20b71)
2025-05-24 22:31:15 +02:00
dibbydoda 095ea9e3c4 Remove unused EnderIO module (#29) 2025-05-24 20:08:33 +02:00
Maya c6d48b32f7 update 2025-03-20 09:41:10 -05:00
4fb3d1edaa Fix thaumcraft node aspects overflowing out of the tooltip bounding box (#28)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-03-20 09:40:58 -05:00
EmperorSuperandMaya 678bb6dd44 Add a total size counter to thaumcraft nodes (#27)
Co-authored-by: Maya <[email protected]>
2025-03-20 09:35:25 -05:00
Glease 5333808d65 add more information to help debug weird NPE (#26) 2025-03-20 09:30:06 -05:00
Martin Robertz 4750486375 update 2024-11-16 15:38:59 +01:00
Alexdoru 0f9710a9f9 Remove unnecessary reflection (#24) 2024-11-16 02:48:17 +01:00
Martin Robertz 0c0ac4fcfa update 2024-07-02 23:48:19 +02:00
AnrDaemonandQuarri6343 a189446cac fixed broken Maintained mod (#23)
Co-authored-by: Quarri6343 <[email protected]>
2024-07-01 06:43:57 +02:00
Martin Robertz 6279ef2b09 update 2024-05-20 12:35:52 +02:00
Lyfts 6cf6dafb53 Add signal strength indicator for projectred wires (#22) 2024-05-20 12:34:29 +02:00
146 changed files with 2251 additions and 3704 deletions

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
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
+2
View File
@@ -27,3 +27,5 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
layout.json
.DS_Store
+13
View File
@@ -0,0 +1,13 @@
# Waila
## Contribution
When forking this repository, make sure to uncheck the `Copy the master branch only` option.
This will copy all tags to your fork, so the build system can detect the latest mod version.
If you leave it checked, you won't be able to enter the world in a local client run because Waila [will think the mod is outdated](https://github.com/GTNewHorizons/waila/blob/master/src/main/java/mcp/mobius/waila/Waila.java#L133).
If you already forked the repository without tags, you can fetch them manually:
```
git remote add upstream https://github.com/GTNewHorizons/waila
git fetch upstream --tags
```
+18 -1
View File
@@ -1,7 +1,24 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.6.0-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.93-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")
}
+54 -8
View File
@@ -14,7 +14,7 @@ modId = Waila
modGroup = mcp.mobius.waila
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
@@ -39,9 +39,33 @@ 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 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 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 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.
@@ -80,18 +104,25 @@ apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = Waila_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -117,9 +148,15 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
@@ -140,7 +177,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
@@ -161,6 +198,12 @@ 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.
@@ -190,3 +233,6 @@ 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
+12
View File
@@ -0,0 +1,12 @@
#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
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+7 -8
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 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.
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/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/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -112,7 +114,6 @@ 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.
@@ -170,7 +171,6 @@ 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" )
@@ -203,15 +203,14 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+3 -2
View File
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -68,11 +70,10 @@ 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%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
}
+13 -37
View File
@@ -1,6 +1,5 @@
package mcp.mobius.waila;
import java.lang.reflect.Field;
import java.util.Map;
import net.minecraftforge.common.MinecraftForge;
@@ -8,24 +7,24 @@ import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.relauncher.Side;
import mcp.mobius.waila.addons.harvestability.MissingHarvestInfo;
import mcp.mobius.waila.addons.harvestability.proxy.ProxyIguanaTweaks;
import mcp.mobius.waila.addons.vanillamc.TestRegistrar;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.api.impl.elements.ModuleProbeRegistrar;
import mcp.mobius.waila.client.KeyEvent;
import mcp.mobius.waila.commands.CommandDumpHandlers;
import mcp.mobius.waila.network.NetworkHandler;
@@ -41,7 +40,8 @@ import mcp.mobius.waila.utils.ModIdentification;
name = "Waila",
version = Tags.GRADLETOKEN_VERSION,
dependencies = "after:NotEnoughItems@[1.0.4.0,)",
acceptableRemoteVersions = "*")
acceptableRemoteVersions = "*",
guiFactory = "mcp.mobius.waila.client.WailaGuiFactory")
public class Waila {
// The instance of your mod that Forge uses.
@@ -65,36 +65,21 @@ public class Waila {
@EventHandler
public void initialize(FMLInitializationEvent event) {
try {
Field eBus = FMLModContainer.class.getDeclaredField("eventBus");
eBus.setAccessible(true);
EventBus FMLbus = (EventBus) eBus.get(FMLCommonHandler.instance().findContainerFor(this));
FMLbus.register(this);
} catch (Throwable ignored) {}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
FMLCommonHandler.instance().bus().register(new KeyEvent());
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
FMLCommonHandler.instance().bus().register(new WailaTickHandler());
}
FMLCommonHandler.instance().bus().register(new NetworkHandler());
MissingHarvestInfo.init();
TestRegistrar.init();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.registerHandlers();
ModIdentification.init();
if (Loader.isModLoaded("IguanaTweaksTConstruct")) {
ProxyIguanaTweaks.init();
}
}
@Subscribe
@EventHandler
public void loadComplete(FMLLoadCompleteEvent event) {
proxy.registerMods();
proxy.registerIMCs();
@@ -131,15 +116,6 @@ public class Waila {
imcMessage.getStringValue()));
ModuleRegistrar.instance().addIMCRequest(imcMessage.getStringValue(), imcMessage.getSender());
}
if (imcMessage.key.equalsIgnoreCase("elementregister")) {
Waila.log.info(
String.format(
"Receiving registration request from [ %s ] for method %s",
imcMessage.getSender(),
imcMessage.getStringValue()));
ModuleProbeRegistrar.instance().addIMCRequest(imcMessage.getStringValue(), imcMessage.getSender());
}
}
}
@@ -1,44 +0,0 @@
package mcp.mobius.waila.addons;
import static mcp.mobius.waila.api.SpecialChars.*;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.elements.IProbeInfo;
import mcp.mobius.waila.handlers.HUDHandlerBlocks;
import mcp.mobius.waila.utils.ModIdentification;
public class DefaultProbeInfoProvider {
public static void addStandardBlockInfo(ItemStack itemStack, IProbeInfo probeInfo, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
// TODO: item icon, horizontal layout
// if (!itemStack.isEmpty()) {
// if (Tools.show(mode, config.getShowModName())) {
// probeInfo.horizontal().item(pickBlock).vertical().itemLabel(pickBlock).text(TextStyleClass.MODNAME + modid);
// } else {
// probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).item(pickBlock).itemLabel(pickBlock);
// }
// } else if (Tools.show(mode, config.getShowModName())) {
// probeInfo.vertical().text(TextStyleClass.NAME + getBlockUnlocalizedName(block)).text(TextStyleClass.MODNAME +
// modid);
// } else {
// probeInfo.vertical().text(TextStyleClass.NAME + getBlockUnlocalizedName(block));
// }
HUDHandlerBlocks hudHandlerBlocks = new HUDHandlerBlocks();
IProbeInfo row = probeInfo.horizontal();
row.item(itemStack);
IProbeInfo row_vertical = row.vertical();
row_vertical.text(hudHandlerBlocks.getWailaHead(itemStack, new ArrayList<>(), accessor, config).get(0));
String modName = ModIdentification.nameFromStack(itemStack);
if (modName != null && !modName.isEmpty()) {
row_vertical.text(BLUE + ITALIC + modName);
}
}
}
@@ -8,6 +8,7 @@ import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class BCModule {
@@ -15,21 +16,26 @@ public class BCModule {
public static Method TileTank_getTankInfo = null;
public static void register() {
if (LoadedMods.WAILA_PLUGINS) {
return;
}
try {
TileTank = Class.forName("buildcraft.factory.TileTank");
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
Waila.log.log(Level.INFO, "Buildcraft mod found.");
} catch (ClassNotFoundException | NoSuchMethodException e) {
Waila.log.log(Level.INFO, "[BC] Buildcraft mod not found.");
return;
}
Waila.log.log(Level.INFO, "Buildcraft mod found.");
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
TankFluidHandler tankFluidHandler = new TankFluidHandler();
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
}
}
@@ -1,5 +1,8 @@
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;
@@ -20,7 +23,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.cbcore.LangUtil;
public class HUDHandlerBCTanks implements IWailaDataProvider {
public class TankFluidHandler implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -30,27 +33,36 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!ConfigHandler.instance().getConfig("bc.tanktype")) {
return currenttip;
}
FluidTankInfo tank = this.getTank(accessor);
FluidStack stack = tank != null ? tank.fluid : null;
String name = currenttip.get(0);
if (stack != null && ConfigHandler.instance().getConfig("bc.tanktype"))
name = name + " (" + stack.getFluid().getName() + ")";
else if (stack == null && ConfigHandler.instance().getConfig("bc.tanktype"))
name = name + " " + LangUtil.translateG("hud.msg.empty");
currenttip.set(0, name);
String fluidName = stack == null ? LangUtil.translateG("hud.msg.empty")
: stack.getFluid().getLocalizedName(stack);
currenttip.set(0, name + " < " + fluidName + " >");
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!ConfigHandler.instance().getConfig("bc.tankamount")) {
return currenttip;
}
FluidTankInfo tank = this.getTank(accessor);
FluidStack stack = tank != null ? tank.fluid : null;
int liquidAmount = stack != null ? stack.amount : 0;
int capacity = tank != null ? tank.capacity : 0;
if (ConfigHandler.instance().getConfig("bc.tankamount")) currenttip.add(liquidAmount + "/" + capacity + " mB");
currenttip.add(String.format("%s / %s", formatNumber(liquidAmount), formatFluid(capacity)));
return currenttip;
}
@@ -1,62 +0,0 @@
package mcp.mobius.waila.addons.enderio;
import java.lang.reflect.Method;
import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class EnderIOModule {
public static Class<?> TileCapacitorBank = null;
public static Method TCB_getMaxInput = null;
public static Method TCB_getMaxOutput = null;
public static Method TCB_getEnergyStored = null;
public static Method TCB_getMaxEnergyStored = null;
public static Method TCB_getMaxIO = null;
public static Class<?> TileTesseract = null;
public static void register() {
try {
Class.forName("crazypants.enderio.EnderIO");
Waila.log.log(Level.INFO, "EnderIO mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
return;
}
try {
TileCapacitorBank = Class.forName("crazypants.enderio.machine.power.TileCapacitorBank");
TCB_getEnergyStored = TileCapacitorBank.getMethod("getEnergyStored");
TCB_getMaxInput = TileCapacitorBank.getMethod("getMaxInput");
TCB_getMaxOutput = TileCapacitorBank.getMethod("getMaxOutput");
TCB_getMaxEnergyStored = TileCapacitorBank.getMethod("getMaxEnergyStored");
TCB_getMaxIO = TileCapacitorBank.getMethod("getMaxIO");
TileTesseract = Class.forName("crazypants.enderio.machine.hypercube.TileHyperCube");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[EnderStorage] Class not found. " + e);
return;
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARN, "[EnderStorage] Method not found." + e);
return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[EnderStorage] Unhandled exception." + e);
return;
}
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.inout");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.storage");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.owner");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.channel");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCapacitorBank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCapacitor(), TileCapacitorBank);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);
}
}
@@ -1,107 +0,0 @@
package mcp.mobius.waila.addons.enderio;
import static mcp.mobius.waila.api.SpecialChars.*;
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 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 HUDHandlerCapacitor implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (accessor.getPlayer().isSneaking()) {
try {
String maxIOStr = LangUtil.translateG("hud.msg.maxio");
String inputStr = LangUtil.translateG("hud.msg.input");
String outputStr = LangUtil.translateG("hud.msg.output");
if (config.getConfig("enderio.storage")) {
Integer maxEnergyStored = (Integer) EnderIOModule.TCB_getMaxEnergyStored
.invoke(accessor.getTileEntity());
Double energyStored = (Double) EnderIOModule.TCB_getEnergyStored.invoke(accessor.getTileEntity());
currenttip.add(
String.format(
"%s%.1f%s / %s%d%s RF",
WHITE,
energyStored * 10,
RESET,
WHITE,
maxEnergyStored * 10,
RESET));
}
if (config.getConfig("enderio.inout")) {
Integer maxIO = (Integer) EnderIOModule.TCB_getMaxIO.invoke(accessor.getTileEntity());
Integer maxInput = (Integer) EnderIOModule.TCB_getMaxInput.invoke(accessor.getTileEntity());
Integer maxOutput = (Integer) EnderIOModule.TCB_getMaxOutput.invoke(accessor.getTileEntity());
currenttip.add(
String.format(
"%s : %s%d%sRF/t ",
maxIOStr,
TAB + ALIGNRIGHT + WHITE,
maxIO * 10,
TAB + ALIGNRIGHT));
currenttip.add(
String.format(
"%s : %s%d%sRF/t ",
inputStr,
TAB + ALIGNRIGHT + WHITE,
maxInput * 10,
TAB + ALIGNRIGHT));
currenttip.add(
String.format(
"%s : %s%d%sRF/t ",
outputStr,
TAB + ALIGNRIGHT + WHITE,
maxOutput * 10,
TAB + ALIGNRIGHT));
}
} catch (Exception e) {
currenttip = WailaExceptionHandler
.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
}
@@ -1,92 +0,0 @@
package mcp.mobius.waila.addons.enderio;
import static mcp.mobius.waila.api.SpecialChars.*;
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 mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.cbcore.LangUtil;
public class HUDHandlerTesseract implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (accessor.getPlayer().isSneaking()) {
String channel = "%s : %s%s%s %s";
String freq;
String frequser;
if (config.getConfig("enderio.channel")) {
if (accessor.getNBTData().hasKey("channelName")) {
freq = accessor.getNBTData().getString("channelName");
if (accessor.getNBTData().hasKey("channelUser"))
frequser = "[ " + WHITE + accessor.getNBTData().getString("channelUser") + RESET + " ]";
else frequser = "[ " + WHITE + LangUtil.translateG("hud.msg.public") + RESET + " ]";
} else {
freq = LangUtil.translateG("hud.msg.none");
frequser = "";
}
currenttip.add(
String.format(
channel,
LangUtil.translateG("hud.msg.frequency"),
TAB + WHITE,
freq,
RESET,
frequser));
}
if (config.getConfig("enderio.owner")) {
if (accessor.getNBTData().hasKey("owner")) currenttip.add(
String.format(
"%s : %s%s",
LangUtil.translateG("hud.msg.owner"),
TAB + WHITE,
accessor.getNBTData().getString("owner")));
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
}
@@ -1,5 +1,8 @@
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;
@@ -15,7 +18,7 @@ import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerDrum implements IWailaDataProvider {
public class DrumFluidHandler implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -34,18 +37,14 @@ public class HUDHandlerDrum implements IWailaDataProvider {
if (!config.getConfig("extrautilities.fluidamount")) return currenttip;
int amount = 0;
NBTTagCompound subtag = accessor.getNBTData().getCompoundTag("tank");
if (subtag.hasKey("Amount")) amount = accessor.getNBTInteger(subtag, "Amount");
IFluidHandler handler = (IFluidHandler) accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks.length != 1) return currenttip;
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
return currenttip;
}
@@ -59,7 +58,6 @@ public class HUDHandlerDrum implements IWailaDataProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
@@ -4,30 +4,26 @@ import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class ExtraUtilitiesModule {
public static Class<?> TileEntityDrum = null;
public static void register() {
if (LoadedMods.WAILA_PLUGINS) {
return;
}
try {
Class.forName("com.rwtema.extrautils.ExtraUtils");
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
return;
}
try {
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[ExtraUtilities] Class not found. " + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDrum(), TileEntityDrum);
ModuleRegistrar.instance().registerBodyProvider(new DrumFluidHandler(), TileEntityDrum);
}
}
@@ -1,14 +0,0 @@
package mcp.mobius.waila.addons.harvestability;
public class Config {
public static final String MINIMAL_SEPARATOR_STRING = " : ";
public static final String CURRENTLY_HARVESTABLE_STRING = "\u2714";
public static final String NOT_CURRENTLY_HARVESTABLE_STRING = "\u2718";
public static final String SHEARABILITY_STRING = "\u2702";
public static final String SILK_TOUCHABILITY_STRING = "\u2712";
}
@@ -1,338 +0,0 @@
package mcp.mobius.waila.addons.harvestability;
import java.util.*;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.common.config.Configuration;
import mcp.mobius.waila.addons.harvestability.helpers.*;
import mcp.mobius.waila.addons.harvestability.proxy.ProxyCreativeBlocks;
import mcp.mobius.waila.addons.harvestability.proxy.ProxyGregTech;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.ProbeMode;
import mcp.mobius.waila.api.elements.IProbeDataProvider;
import mcp.mobius.waila.api.elements.IProbeInfo;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.api.impl.elements.ModuleProbeRegistrar;
import mcp.mobius.waila.utils.Constants;
public class HUDHandlerHarvestability implements IWailaDataProvider, IProbeDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> toolTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return toolTip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> toolTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false)) {
return toolTip;
}
Block block = accessor.getBlock();
int meta = accessor.getMetadata();
if (ProxyCreativeBlocks.isCreativeBlock(block, meta)) return toolTip;
EntityPlayer player = accessor.getPlayer();
// for disguised blocks
if (itemStack.getItem() instanceof ItemBlock && !ProxyGregTech.isOreBlock(block)
&& !ProxyGregTech.isCasing(block)
&& !ProxyGregTech.isMachine(block)) {
block = Block.getBlockFromItem(itemStack.getItem());
meta = itemStack.getItemDamage();
}
boolean minimalLayout = config.getConfig("harvestability.minimal", false);
List<String> stringParts = new ArrayList<String>();
getHarvestability(stringParts, player, block, meta, accessor.getPosition(), config, minimalLayout);
if (!stringParts.isEmpty()) {
if (minimalLayout) toolTip.add(
StringHelper.concatenateStringList(
stringParts,
EnumChatFormatting.RESET + Config.MINIMAL_SEPARATOR_STRING));
else toolTip.addAll(stringParts);
}
return toolTip;
}
public void getHarvestability(List<String> stringList, EntityPlayer player, Block block, int meta,
MovingObjectPosition position, IWailaConfigHandler config, boolean minimalLayout) {
boolean isSneaking = player.isSneaking();
boolean showHarvestLevel = config.getConfig("harvestability.harvestlevel")
&& (!config.getConfig("harvestability.harvestlevel.sneakingonly") || isSneaking);
boolean showHarvestLevelNum = config.getConfig("harvestability.harvestlevelnum")
&& (!config.getConfig("harvestability.harvestlevelnum.sneakingonly") || isSneaking);
boolean showEffectiveTool = config.getConfig("harvestability.effectivetool")
&& (!config.getConfig("harvestability.effectivetool.sneakingonly") || isSneaking);
boolean showCurrentlyHarvestable = config.getConfig("harvestability.currentlyharvestable")
&& (!config.getConfig("harvestability.currentlyharvestable.sneakingonly") || isSneaking);
boolean hideWhileHarvestable = config.getConfig("harvestability.unharvestableonly", false);
boolean showOresOnly = config.getConfig("harvestability.oresonly", false);
boolean toolRequiredOnly = config.getConfig("harvestability.toolrequiredonly");
if (showHarvestLevel || showEffectiveTool || showCurrentlyHarvestable) {
if (showOresOnly && !OreHelper.isBlockAnOre(block, meta)) {
return;
}
if (!player.isCurrentToolAdventureModeExempt(position.blockX, position.blockY, position.blockZ)
|| BlockHelper.isBlockUnbreakable(
block,
player.worldObj,
position.blockX,
position.blockY,
position.blockZ)) {
String unbreakableString = ColorHelper.getBooleanColor(false) + Config.NOT_CURRENTLY_HARVESTABLE_STRING
+ (!minimalLayout
? EnumChatFormatting.RESET
+ StatCollector.translateToLocal("wailaharvestability.harvestable")
: "");
stringList.add(unbreakableString);
return;
}
// needed to stop array index out of bounds exceptions on mob spawners
// block.getHarvestLevel/getHarvestTool are only 16 elements big
if (meta >= 16) meta = 0;
int harvestLevel = block.getHarvestLevel(meta);
String effectiveTool = BlockHelper.getEffectiveToolOf(
player.worldObj,
position.blockX,
position.blockY,
position.blockZ,
block,
meta);
if (effectiveTool != null && harvestLevel < 0) harvestLevel = 0;
boolean blockHasEffectiveTools = harvestLevel >= 0 && effectiveTool != null;
String shearability = getShearabilityString(player, block, meta, position, config);
String silkTouchability = getSilkTouchabilityString(player, block, meta, position, config);
if (toolRequiredOnly && block.getMaterial().isToolNotRequired()
&& !blockHasEffectiveTools
&& shearability.isEmpty()
&& silkTouchability.isEmpty())
return;
boolean canHarvest = false;
boolean isEffective = false;
boolean isAboveMinHarvestLevel = false;
boolean isHoldingTinkersTool = false;
boolean isHoldingGTTool = false;
ItemStack itemHeld = player.getHeldItem();
if (itemHeld != null) {
isHoldingTinkersTool = ToolHelper.hasToolTag(itemHeld);
isHoldingGTTool = ProxyGregTech.isGTTool(itemHeld);
isAboveMinHarvestLevel = (showCurrentlyHarvestable || showHarvestLevel)
&& ToolHelper.canToolHarvestLevel(itemHeld, block, meta, harvestLevel);
isEffective = showEffectiveTool
&& ToolHelper.isToolEffectiveAgainst(itemHeld, block, meta, effectiveTool);
if (isHoldingGTTool) {
// GT tool don't care net.minecraft.block.material.Material#isToolNotRequired
canHarvest = itemHeld.func_150998_b(block);
} else {
canHarvest = ToolHelper.canToolHarvestBlock(itemHeld, block, meta)
|| (!isHoldingTinkersTool && block.canHarvestBlock(player, meta));
}
}
boolean isCurrentlyHarvestable = (canHarvest && isAboveMinHarvestLevel)
|| (!isHoldingTinkersTool && ForgeHooks.canHarvestBlock(block, player, meta));
if (hideWhileHarvestable && isCurrentlyHarvestable) return;
String currentlyHarvestable = showCurrentlyHarvestable
? ColorHelper.getBooleanColor(isCurrentlyHarvestable)
+ (isCurrentlyHarvestable ? Config.CURRENTLY_HARVESTABLE_STRING
: Config.NOT_CURRENTLY_HARVESTABLE_STRING)
+ (!minimalLayout
? EnumChatFormatting.RESET
+ StatCollector.translateToLocal("wailaharvestability.currentlyharvestable")
: "")
: "";
if (!currentlyHarvestable.isEmpty() || !shearability.isEmpty() || !silkTouchability.isEmpty()) {
String separator = (!shearability.isEmpty() || !silkTouchability.isEmpty() ? " " : "");
stringList.add(
currentlyHarvestable + separator
+ silkTouchability
+ (!silkTouchability.isEmpty() ? separator : "")
+ shearability);
}
if (harvestLevel != -1 && showEffectiveTool && effectiveTool != null) {
String effectiveToolString;
if (StatCollector.canTranslate("wailaharvestability.toolclass." + effectiveTool))
effectiveToolString = StatCollector
.translateToLocal("wailaharvestability.toolclass." + effectiveTool);
else effectiveToolString = effectiveTool.substring(0, 1).toUpperCase() + effectiveTool.substring(1);
stringList.add(
(!minimalLayout ? StatCollector.translateToLocal("wailaharvestability.effectivetool") : "")
+ ColorHelper.getBooleanColor(
isEffective && (!isHoldingTinkersTool || canHarvest),
isHoldingTinkersTool && isEffective && !canHarvest)
+ effectiveToolString);
}
if (harvestLevel >= 1 && (showHarvestLevel || showHarvestLevelNum)) {
String harvestLevelString = "";
String harvestLevelName = StringHelper.stripFormatting(StringHelper.getHarvestLevelName(harvestLevel));
String harvestLevelNum = String.valueOf(harvestLevel);
// only show harvest level number and name if they are different
showHarvestLevelNum = showHarvestLevelNum
&& (!showHarvestLevel || !harvestLevelName.equals(harvestLevelNum));
if (showHarvestLevel) harvestLevelString = harvestLevelName
+ (showHarvestLevelNum ? String.format(" (%d)", harvestLevel) : "");
else if (showHarvestLevelNum) harvestLevelString = harvestLevelNum;
stringList.add(
(!minimalLayout ? StatCollector.translateToLocal("wailaharvestability.harvestlevel") : "")
+ ColorHelper.getBooleanColor(isAboveMinHarvestLevel && canHarvest)
+ harvestLevelString);
}
}
}
public String getShearabilityString(EntityPlayer player, Block block, int meta, MovingObjectPosition position,
IWailaConfigHandler config) {
boolean isSneaking = player.isSneaking();
boolean showShearability = config.getConfig("harvestability.shearability")
&& (!config.getConfig("harvestability.shearability.sneakingonly") || isSneaking);
if (showShearability && (block instanceof IShearable || block == Blocks.deadbush
|| (block == Blocks.double_plant && block.getItemDropped(meta, new Random(), 0) == null))) {
ItemStack itemHeld = player.getHeldItem();
boolean isHoldingShears = itemHeld != null && itemHeld.getItem() instanceof ItemShears;
boolean isShearable = isHoldingShears && ((IShearable) block)
.isShearable(itemHeld, player.worldObj, position.blockX, position.blockY, position.blockZ);
return ColorHelper.getBooleanColor(isShearable, !isShearable && isHoldingShears)
+ Config.SHEARABILITY_STRING;
}
return "";
}
public String getSilkTouchabilityString(EntityPlayer player, Block block, int meta, MovingObjectPosition position,
IWailaConfigHandler config) {
boolean isSneaking = player.isSneaking();
boolean showSilkTouchability = config.getConfig("harvestability.silktouchability")
&& (!config.getConfig("harvestability.silktouchability.sneakingonly") || isSneaking);
if (showSilkTouchability && block
.canSilkHarvest(player.worldObj, player, position.blockX, position.blockY, position.blockZ, meta)) {
Item itemDropped = block.getItemDropped(meta, new Random(), 0);
boolean silkTouchMatters = (itemDropped instanceof ItemBlock && itemDropped != Item.getItemFromBlock(block))
|| block.quantityDropped(new Random()) <= 0;
if (silkTouchMatters) {
boolean hasSilkTouch = EnchantmentHelper.getSilkTouchModifier(player);
return ColorHelper.getBooleanColor(hasSilkTouch) + Config.SILK_TOUCHABILITY_STRING;
}
}
return "";
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> toolTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return toolTip;
}
public static HashMap<String, Boolean> configOptions = new HashMap<String, Boolean>();
static {
configOptions.put("harvestability.harvestlevel", true);
configOptions.put("harvestability.harvestlevelnum", false);
configOptions.put("harvestability.effectivetool", true);
configOptions.put("harvestability.currentlyharvestable", true);
configOptions.put("harvestability.harvestlevel.sneakingonly", false);
configOptions.put("harvestability.harvestlevelnum.sneakingonly", false);
configOptions.put("harvestability.effectivetool.sneakingonly", false);
configOptions.put("harvestability.currentlyharvestable.sneakingonly", false);
configOptions.put("harvestability.oresonly", false);
configOptions.put("harvestability.minimal", false);
configOptions.put("harvestability.unharvestableonly", false);
configOptions.put("harvestability.toolrequiredonly", true);
configOptions.put("harvestability.shearability", true);
configOptions.put("harvestability.shearability.sneakingonly", false);
configOptions.put("harvestability.silktouchability", true);
configOptions.put("harvestability.silktouchability.sneakingonly", false);
}
public void addProbeInfo(ProbeMode probeMode, ItemStack itemStack, IProbeInfo probeInfo,
IWailaDataAccessor accessor, IWailaConfigHandler config) {
Block block = accessor.getBlock();
int meta = accessor.getMetadata();
if (ProxyCreativeBlocks.isCreativeBlock(block, meta)) return;
EntityPlayer player = accessor.getPlayer();
// for disguised blocks
if (itemStack.getItem() instanceof ItemBlock && !ProxyGregTech.isOreBlock(block)
&& !ProxyGregTech.isCasing(block)
&& !ProxyGregTech.isMachine(block)) {
block = Block.getBlockFromItem(itemStack.getItem());
meta = itemStack.getItemDamage();
}
List<String> stringParts = new ArrayList<String>();
getHarvestability(stringParts, player, block, meta, accessor.getPosition(), config, true);
if (!stringParts.isEmpty()) {
probeInfo.text(
StringHelper.concatenateStringList(
stringParts,
EnumChatFormatting.RESET + Config.MINIMAL_SEPARATOR_STRING));
}
}
public static void register() {
for (Map.Entry<String, Boolean> entry : configOptions.entrySet()) {
// hacky way to set default values to anything but true
ConfigHandler.instance().getConfig(entry.getKey(), entry.getValue());
ModuleRegistrar.instance().addConfig("Harvestability", entry.getKey(), "option." + entry.getKey());
}
ModuleProbeRegistrar.instance().registerProbeProvider(new HUDHandlerHarvestability(), Block.class);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerHarvestability(), Block.class);
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
return tag;
}
}
@@ -1,14 +0,0 @@
package mcp.mobius.waila.addons.harvestability;
import net.minecraft.init.Blocks;
public class MissingHarvestInfo {
public static void init() {
vanilla();
}
public static void vanilla() {
Blocks.web.setHarvestLevel("sword", 0);
}
}
@@ -1,43 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.world.World;
public class BlockHelper {
private static final HashMap<String, ItemStack> testTools = new HashMap<String, ItemStack>();
static {
testTools.put("pickaxe", new ItemStack(Items.wooden_pickaxe));
testTools.put("shovel", new ItemStack(Items.wooden_shovel));
testTools.put("axe", new ItemStack(Items.wooden_axe));
}
public static String getEffectiveToolOf(World world, int x, int y, int z, Block block, int metadata) {
String effectiveTool = block.getHarvestTool(metadata);
if (effectiveTool == null) {
float hardness = block.getBlockHardness(world, x, y, z);
if (hardness > 0f) {
for (Map.Entry<String, ItemStack> testToolEntry : testTools.entrySet()) {
ItemStack testTool = testToolEntry.getValue();
if (testTool != null && testTool.getItem() instanceof ItemTool
&& testTool.func_150997_a(block) >= ((ItemTool) testTool.getItem()).func_150913_i()
.getEfficiencyOnProperMaterial()) {
effectiveTool = testToolEntry.getKey();
break;
}
}
}
}
return effectiveTool;
}
public static boolean isBlockUnbreakable(Block block, World world, int x, int y, int z) {
return block.getBlockHardness(world, x, y, z) == -1.0f;
}
}
@@ -1,32 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import net.minecraft.util.EnumChatFormatting;
public class ColorHelper {
private static final EnumChatFormatting colorRange[] = { EnumChatFormatting.DARK_RED, EnumChatFormatting.RED,
EnumChatFormatting.GOLD, EnumChatFormatting.YELLOW, EnumChatFormatting.DARK_GREEN, EnumChatFormatting.GREEN,
EnumChatFormatting.AQUA };
private static final EnumChatFormatting booleanColorRange[] = { EnumChatFormatting.DARK_RED, EnumChatFormatting.RED,
EnumChatFormatting.DARK_GREEN, EnumChatFormatting.GREEN };
public static String getRelativeColor(double val, double min, double max) {
if (min == max) return EnumChatFormatting.RESET.toString();
else if ((max > min && val > max) || (min > max && val < max))
return EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD;
else if ((max > min && val < min) || (min > max && val > min))
return colorRange[0].toString() + EnumChatFormatting.BOLD;
int index = (int) (((val - min) / (max - min)) * (colorRange.length - 1));
return colorRange[Math.max(0, Math.min(colorRange.length - 1, index))].toString();
}
public static String getBooleanColor(boolean val) {
return getBooleanColor(val, false);
}
public static String getBooleanColor(boolean val, boolean modified) {
return booleanColorRange[(val ? 2 : 0) + (modified ? 1 : 0)].toString();
}
}
@@ -1,22 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
public class KeyHelper {
public static boolean isCtrlKeyDown() {
// prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the
// OPTION key on Mac)
boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
if (!isCtrlKeyDown && Minecraft.isRunningOnMac)
isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA);
return isCtrlKeyDown;
}
public static boolean isShiftKeyDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
}
}
@@ -1,32 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class OreHelper {
public static boolean isBlockAnOre(Block block) {
return isBlockAnOre(block, 0);
}
public static boolean isBlockAnOre(Block block, int metadata) {
return isItemAnOre(new ItemStack(block, 1, metadata));
}
public static boolean isItemAnOre(ItemStack itemStack) {
// check the ore dictionary to see if it starts with "ore"
int[] oreIDs = OreDictionary.getOreIDs(itemStack);
for (int oreID : oreIDs) {
if (OreDictionary.getOreName(oreID).startsWith("ore")) return true;
}
// ore in the display name (but not part of another word)
if (itemStack.getDisplayName().matches(".*(^|\\s)([oO]re)($|\\s).*")) return true;
// ore as the start of the unlocalized name
if (itemStack.getUnlocalizedName().startsWith("ore")) return true;
return false;
}
}
@@ -1,52 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import java.lang.reflect.Method;
import java.util.List;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Loader;
import mcp.mobius.waila.addons.harvestability.proxy.ProxyIguanaTweaks;
public class StringHelper {
public static Class<?> HarvestLevels = null;
public static Method getHarvestLevelName = null;
static {
try {
HarvestLevels = Class.forName("tconstruct.library.util.HarvestLevels");
getHarvestLevelName = HarvestLevels.getDeclaredMethod("getHarvestLevelName", int.class);
} catch (Exception e) {}
}
public static String getHarvestLevelName(int num) {
if (getHarvestLevelName != null) {
try {
return (String) getHarvestLevelName.invoke(null, num);
} catch (Exception e) {}
}
if (Loader.isModLoaded("IguanaTweaksTConstruct")) return ProxyIguanaTweaks.getHarvestLevelName(num);
String unlocalized = "wailaharvestability.harvestlevel" + (num + 1);
if (StatCollector.canTranslate(unlocalized)) return StatCollector.translateToLocal(unlocalized);
return String.valueOf(num);
}
public static String concatenateStringList(List<String> strings, String separator) {
StringBuilder sb = new StringBuilder();
String sep = "";
for (String s : strings) {
sb.append(sep).append(s);
sep = separator;
}
return sb.toString();
}
public static String stripFormatting(String str) {
return EnumChatFormatting.getTextWithoutFormattingCodes(str);
}
}
@@ -1,115 +0,0 @@
package mcp.mobius.waila.addons.harvestability.helpers;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeHooks;
import cpw.mods.fml.common.Loader;
public class ToolHelper {
// tinkers construct
private static Class<?> HarvestTool = null;
private static Class<?> DualHarvestTool = null;
private static Method getHarvestType = null;
private static Method getSecondHarvestType = null;
public static boolean tinkersConstructLoaded = false;
public static void init() {
if (Loader.isModLoaded("TConstruct")) {
try {
HarvestTool = Class.forName("tconstruct.library.tools.HarvestTool");
DualHarvestTool = Class.forName("tconstruct.library.tools.DualHarvestTool");
getHarvestType = HarvestTool.getDeclaredMethod("getHarvestType");
getSecondHarvestType = DualHarvestTool.getDeclaredMethod("getSecondHarvestType");
getHarvestType.setAccessible(true);
getSecondHarvestType.setAccessible(true);
tinkersConstructLoaded = true;
} catch (Exception e) {
return;
}
}
}
public static boolean hasToolTag(ItemStack itemStack) {
return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("InfiTool");
}
public static NBTTagCompound getToolTag(ItemStack tool) {
NBTTagCompound tag = null;
if (tool.hasTagCompound()) tag = tool.getTagCompound().getCompoundTag("InfiTool");
return tag;
}
public static int getPrimaryHarvestLevel(NBTTagCompound toolTag) {
return toolTag.getInteger("HarvestLevel");
}
public static int getSecondaryHarvestLevel(NBTTagCompound toolTag) {
return toolTag.getInteger("HarvestLevel2");
}
public static Set<String> getToolClassesOf(ItemStack tool) {
return tool.getItem().getToolClasses(tool);
}
public static boolean isToolOfClass(ItemStack tool, String toolClass) {
return getToolClassesOf(tool).contains(toolClass);
}
public static boolean toolHasAnyToolClass(ItemStack tool) {
return !getToolClassesOf(tool).isEmpty();
}
public static boolean isToolEffectiveAgainst(ItemStack tool, Block block, int metadata, String effectiveToolClass) {
if (tinkersConstructLoaded && HarvestTool.isInstance(tool.getItem())) {
Item item = tool.getItem();
List<String> harvestTypes = new ArrayList<String>();
try {
harvestTypes.add((String) getHarvestType.invoke(item));
} catch (Exception e) {
e.printStackTrace();
tinkersConstructLoaded = false;
}
if (DualHarvestTool.isInstance(item)) {
try {
harvestTypes.add((String) getSecondHarvestType.invoke(item));
} catch (Exception e) {
e.printStackTrace();
tinkersConstructLoaded = false;
}
}
return harvestTypes.contains(effectiveToolClass);
}
return ForgeHooks.isToolEffective(tool, block, metadata)
|| (toolHasAnyToolClass(tool) ? isToolOfClass(tool, effectiveToolClass)
: tool.getItem().getDigSpeed(tool, block, metadata) > 1.5f);
}
public static boolean canToolHarvestLevel(ItemStack tool, Block block, int metadata, int harvestLevel) {
boolean canTinkersToolHarvestBlock = false;
NBTTagCompound toolTag = ToolHelper.getToolTag(tool);
if (toolTag != null) {
int toolHarvestLevel = Math
.max(ToolHelper.getPrimaryHarvestLevel(toolTag), ToolHelper.getSecondaryHarvestLevel(toolTag));
canTinkersToolHarvestBlock = toolHarvestLevel >= harvestLevel;
}
return canTinkersToolHarvestBlock || ForgeHooks.canToolHarvestBlock(block, metadata, tool);
}
public static boolean canToolHarvestBlock(ItemStack tool, Block block, int metadata) {
return block.getMaterial().isToolNotRequired() || tool.func_150998_b(block); // func_150998_b = canHarvestBlock
}
}
@@ -1,33 +0,0 @@
package mcp.mobius.waila.addons.harvestability.proxy;
import java.lang.reflect.Method;
import net.minecraft.block.Block;
import cpw.mods.fml.common.Loader;
public class ProxyCreativeBlocks {
private static Class<?> CreativeBlocks = null;
private static Method isCreativeBlock = null;
static {
if (Loader.isModLoaded("CreativeBlocks")) {
try {
CreativeBlocks = Class.forName("squeek.creativeblocks.CreativeBlocks");
isCreativeBlock = CreativeBlocks.getDeclaredMethod("isCreativeBlock", Block.class, int.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static boolean isCreativeBlock(Block block, int meta) {
if (isCreativeBlock != null) {
try {
return (Boolean) isCreativeBlock.invoke(null, block, meta);
} catch (Exception e) {}
}
return false;
}
}
@@ -1,35 +0,0 @@
package mcp.mobius.waila.addons.harvestability.proxy;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
public class ProxyGregTech {
public static final String modID = "gregtech";
public static final String oreBlockID = "gt.blockores";
public static final String oreBlockUniqueIdentifier = modID + ":" + oreBlockID;
public static final String casingID = "gt.blockcasings";
public static final String casingUniqueIdentifier = modID + ":" + casingID;
public static final String machineID = "gt.blockmachines";
public static final String machineUniqueIdentifier = modID + ":" + machineID;
public static boolean isModLoaded = Loader.isModLoaded(modID);
public static boolean isOreBlock(Block block) {
return isModLoaded && GameRegistry.findUniqueIdentifierFor(block).toString().equals(oreBlockUniqueIdentifier);
}
public static boolean isCasing(Block block) {
return isModLoaded && GameRegistry.findUniqueIdentifierFor(block).toString().equals(casingUniqueIdentifier);
}
public static boolean isMachine(Block block) {
return isModLoaded && GameRegistry.findUniqueIdentifierFor(block).toString().equals(machineUniqueIdentifier);
}
public static boolean isGTTool(ItemStack itemStack) {
return isModLoaded && itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("GT.ToolStats");
}
}
@@ -1,30 +0,0 @@
package mcp.mobius.waila.addons.harvestability.proxy;
import java.lang.reflect.Method;
public class ProxyIguanaTweaks {
private static Class<?> HarvestLevels = null;
private static Method proxyGetHarvestLevelName;
public static void init() {
try {
HarvestLevels = Class.forName("iguanaman.iguanatweakstconstruct.util.HarvestLevels");
proxyGetHarvestLevelName = HarvestLevels.getDeclaredMethod("getHarvestLevelName", int.class);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getHarvestLevelName(int num) {
String harvestLevelName = "<Unknown>";
try {
harvestLevelName = (String) proxyGetHarvestLevelName.invoke(null, num);
} catch (Exception e) {
e.printStackTrace();
}
return harvestLevelName;
}
}
@@ -4,30 +4,29 @@ import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class OpenBlocksModule {
public static Class<?> TileEntityTank = null;
public static void register() {
if (LoadedMods.WAILA_PLUGINS) {
return;
}
try {
Class.forName("openblocks.OpenBlocks");
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
return;
}
try {
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[OpenBlocks] Class not found. " + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileEntityTank);
TankFluidHandler tankFluidHandler = new TankFluidHandler();
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileEntityTank);
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileEntityTank);
}
}
@@ -1,5 +1,8 @@
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;
@@ -17,7 +20,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.cbcore.LangUtil;
public class HUDHandlerTank implements IWailaDataProvider {
public class TankFluidHandler implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -37,14 +40,10 @@ public class HUDHandlerTank implements IWailaDataProvider {
FluidStack fluid = tanks[0].fluid;
String name = currenttip.get(0);
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
: fluid.getFluid().getLocalizedName(fluid);
try {
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
} catch (NullPointerException f) {
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.set(0, name);
currenttip.set(0, name + " < " + fluidName + " >");
return currenttip;
}
@@ -60,9 +59,8 @@ public class HUDHandlerTank implements IWailaDataProvider {
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks.length != 1) return currenttip;
if (tanks[0].fluid != null)
currenttip.add(String.format("%d / %d mB", tanks[0].fluid.amount, tanks[0].capacity));
else currenttip.add(String.format("0 / %d mB", tanks[0].capacity));
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
return currenttip;
}
@@ -76,7 +74,6 @@ public class HUDHandlerTank implements IWailaDataProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
@@ -1,6 +1,9 @@
package mcp.mobius.waila.addons.projectred;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,43 +1,59 @@
package mcp.mobius.waila.addons.railcraft;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class RailcraftModule {
public static Class<?> TileTankBase = null;
public static Class<?> ITankTile = null;
public static Method ITankTile_getTank = null;
public static Method TileTankBase_getTank = null;
public static Class<?> StandardTank = null;
public static Field StandardTank_capacity = null;
public static Field StandardTank_renderData = null;
public static Field StandardTank_renderDataFluid = null;
public static Field StandardTank_renderDataAmount = null;
public static void register() {
try {
Class.forName("mods.railcraft.common.core.Railcraft");
Waila.log.log(Level.INFO, "Railcraft mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
if (LoadedMods.WAILA_PLUGINS) {
return;
}
try {
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
ITankTile_getTank = ITankTile.getMethod("getTank");
TileTankBase_getTank = TileTankBase.getMethod("getTank");
StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
StandardTank_capacity = StandardTank.getSuperclass().getDeclaredField("capacity");
StandardTank_capacity.setAccessible(true);
StandardTank_renderData = StandardTank.getField("renderData");
StandardTank_renderDataFluid = StandardTank_renderData.getType().getField("fluid");
StandardTank_renderDataAmount = StandardTank_renderData.getType().getField("amount");
Waila.log.log(Level.INFO, "Railcraft mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[Railcraft] Class not found. " + e);
return;
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARN, "[Railcraft] Method not found." + e);
return;
} catch (NoSuchFieldException e) {
Waila.log.log(Level.WARN, "[Railcraft] Field not found." + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTankBase);
TankFluidHandler tankFluidHandler = new TankFluidHandler();
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTankBase);
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTankBase);
}
}
@@ -0,0 +1,98 @@
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,8 @@
package mcp.mobius.waila.addons.statues;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.BLUE;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,11 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
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;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.ArrayList;
import java.util.List;
@@ -76,7 +81,8 @@ 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" : this.getAmount(amount) + " " + this.getAmountType(amount);
String sAmount = amount == 0 ? "All"
: formatNumber(this.getAmount(amount)) + " " + this.getAmountType(amount);
String selection = (String) StevesCartsModule.GetSelectionName
.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
@@ -1,6 +1,11 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
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;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -73,13 +78,14 @@ public class HUDLiquidManager implements IWailaDataProvider {
fluidAmount = tag.getCompoundTag("Fluid" + i).getInteger("Amount");
}
String fluidString = fluidAmount == 0 ? "<Empty>" : String.format("%s mB of %s", fluidAmount, fluidName);
String fluidString = fluidAmount == 0 ? "<Empty>"
: String.format("%s of %s", formatFluid(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" : this.getMaxAmountBuckets(amount) + " mB";
String sAmount = amount == 0 ? "All" : formatFluid(this.getMaxAmountBuckets(amount));
currenttip.add(
String.format(
@@ -1,6 +1,11 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
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;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -43,7 +48,7 @@ public class HUDMinecartModular implements IWailaEntityProvider {
return currenttip;
}
Item ItemCartModule = null;
Item ItemCartModule;
try {
ItemCartModule = (Item) StevesCartsModule.ItemCartModule.get(null);
} catch (Exception e) {
@@ -72,12 +77,11 @@ public class HUDMinecartModular implements IWailaEntityProvider {
currenttip.add(
new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB
+ ALIGNRIGHT
+ GRAY
+ " [ "
+ WHITE
+ amount
+ GRAY
+ " mB of "
+ WHITE
+ formatNumber(amount)
+ " of "
+ fluid
+ GRAY
+ " ]");
@@ -1,6 +1,9 @@
package mcp.mobius.waila.addons.thaumcraft;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.AQUA;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -17,6 +20,8 @@ import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.SpecialChars;
import mcp.mobius.waila.cbcore.LangUtil;
public class HUDHandlerIAspectContainer implements IWailaDataProvider {
@@ -43,15 +48,32 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
List<String> unknownAspects = new ArrayList<>();
int total = 0;
for (int i = 0; i < taglist.tagCount(); i++) {
NBTTagCompound subtag = taglist.getCompoundTagAt(i);
String aspect = subtag.getString("key");
String amount = String.valueOf(subtag.getInteger("value"));
int value = subtag.getInteger("value");
total += value;
String amount = String.valueOf(value);
if (!aspect.equals("???"))
currenttip.add(String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount));
else unknownAspects.add(String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount));
if (!aspect.equals("???")) currenttip.add(
SpecialChars.getRenderString("waila.tcaspect", aspect) + TAB + ALIGNRIGHT + WHITE + amount);
else unknownAspects.add(
SpecialChars.getRenderString("waila.tcaspect", aspect) + TAB + ALIGNRIGHT + WHITE + amount);
}
String id = tag.getString("WailaID");
if ((id.equals("TileNode") || id.equals("TileExtendedNode") || id.equals("TileJarNode"))
&& (taglist.tagCount() > 10 || total > 300)) {
currenttip.add(
0,
String.format(
AQUA + "%s" + TAB + ALIGNRIGHT + WHITE + "%s",
LangUtil.translateG("hud.msg.tcnodetotalsize"),
total));
}
currenttip.addAll(unknownAspects);
@@ -77,7 +99,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
ItemStack headSlot = player.inventory.armorInventory[3];
if (headSlot == null) return tag;
boolean hasReveal = ThaumcraftModule.IGoggles.isInstance(headSlot.getItem());
boolean hasReveal = ThaumcraftModule.isGoggles.apply(headSlot);
if (!hasReveal) return tag;
Map<String, ?> knownAspects = (Map<String, ?>) ThaumcraftModule.CommonProxy_getKnownAspects
@@ -98,7 +120,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
if (tileAspects.get(o) > 0) {
if (playerAspects.containsKey(o)) {
NBTTagCompound cmptag = new NBTTagCompound();
cmptag.setString("key", (String) ThaumcraftModule.Aspect_getName.invoke(o));
cmptag.setString("key", (String) ThaumcraftModule.Aspect_tag.get(o));
cmptag.setInteger("value", tileAspects.get(o));
aspects.appendTag(cmptag);
} else {
@@ -110,7 +132,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
}
}
} catch (Exception e) {
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
@@ -1,9 +1,13 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.awt.Color;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.function.Function;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.Level;
@@ -28,12 +32,19 @@ public class ThaumcraftModule {
public static Class<?> Aspect = null;
public static Field Aspect_tag = null;
public static Method Aspect_getName = null;
public static Method Aspect_getAspect = null;
public static Method Aspect_getImage = null;
public static Method Aspect_getColor = null;
public static Class<?> CommonProxy = null;
public static Method CommonProxy_getKnownAspects = null;
public static Class<?> IGoggles = null;
public static ResourceLocation unknownAspectTexture = null;
public static Color unknownAspectColor = null;
public static Function<ItemStack, Boolean> isGoggles = stack -> IGoggles.isInstance(stack.getItem());
public static void register() {
try {
Thaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
@@ -53,12 +64,18 @@ public class ThaumcraftModule {
Aspect_tag = Aspect.getDeclaredField("tag");
Aspect_tag.setAccessible(true);
Aspect_getName = Aspect.getDeclaredMethod("getName");
Aspect_getAspect = Aspect.getMethod("getAspect", java.lang.String.class);
Aspect_getImage = Aspect.getDeclaredMethod("getImage");
Aspect_getColor = Aspect.getDeclaredMethod("getColor");
CommonProxy = Class.forName("thaumcraft.common.CommonProxy");
CommonProxy_getKnownAspects = CommonProxy.getDeclaredMethod("getKnownAspects");
IGoggles = Class.forName("thaumcraft.api.IGoggles");
unknownAspectTexture = new ResourceLocation("thaumcraft", "textures/aspects/_unknown.png");
unknownAspectColor = new Color(0x654242);
ModuleRegistrar.instance().addConfigRemote("Thaumcraft", "thaumcraft.aspects");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), IAspectContainer);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), TileAlchemyFurnace);
@@ -0,0 +1,41 @@
package mcp.mobius.waila.addons.thaumcraftGadomancy;
import java.lang.reflect.Field;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
public class GadomancyModule {
public static Class<?> RegisteredEnchantments = null;
public static Field RegisteredEnchantments_revealer = null;
public static int revealerEffectId;
public static void register() {
try {
RegisteredEnchantments = Class.forName("makeo.gadomancy.common.registration.RegisteredEnchantments");
RegisteredEnchantments_revealer = RegisteredEnchantments.getDeclaredField("revealer");
Object revealer = RegisteredEnchantments_revealer.get(null);
revealerEffectId = ((Enchantment) revealer).effectId;
ThaumcraftModule.isGoggles = stack -> ThaumcraftModule.IGoggles.isInstance(stack.getItem())
|| EnchantmentHelper.getEnchantmentLevel(revealerEffectId, stack) > 0;
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Thaumcraft Gadomancy] Gadomancy mod not found.");
return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thaumcraft Gadomancy] Unhandled exception. {}", e);
return;
}
Waila.log.log(Level.INFO, "Gadomancy mod found.");
}
}
@@ -0,0 +1,108 @@
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;
}
}
@@ -4,31 +4,35 @@ import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class ThermalDynamicsModule {
public static Class<?> TileFluidDuct = null;
public static void register() {
// XXX : We register the Fluiduct
try {
TileFluidDuct = Class.forName("cofh.thermaldynamics.ducts.fluid.TileFluidDuct");
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerDuct(), TileFluidDuct);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDuct(), TileFluidDuct);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDuct(), TileFluidDuct);
} catch (Exception e) {
if (e instanceof ClassNotFoundException) {
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
} else {
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
}
if (LoadedMods.WAILA_PLUGINS) {
return;
}
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
try {
TileFluidDuct = Class.forName("cofh.thermaldynamics.duct.fluid.TileFluidDuct");
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
return;
}
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
FluiductFluidHandler fluiductFluidHandler = new FluiductFluidHandler();
ModuleRegistrar.instance().registerHeadProvider(fluiductFluidHandler, TileFluidDuct);
ModuleRegistrar.instance().registerBodyProvider(fluiductFluidHandler, TileFluidDuct);
ModuleRegistrar.instance().registerNBTProvider(fluiductFluidHandler, TileFluidDuct);
}
}
@@ -40,14 +40,17 @@ public class HUDHandlerCache implements IWailaDataProvider {
if (storedItem != null) {
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
name += String.format(
" < " + SpecialChars.getRenderString(
" < %s %s >",
SpecialChars.getRenderString(
"waila.stack",
"1",
namex,
"0",
String.valueOf(storedItem.getItemDamage())) + color + " %s >",
String.valueOf(storedItem.getItemDamage())) + color,
storedItem.getDisplayName());
} else name += " " + LangUtil.translateG("hud.msg.empty");
} else {
name += " < " + LangUtil.translateG("hud.msg.empty") + " >";
}
currenttip.set(0, name);
} catch (Exception e) {
@@ -1,5 +1,7 @@
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;
@@ -36,11 +38,11 @@ public class HUDHandlerEnergyCell implements IWailaDataProvider {
currenttip.add(
String.format(
"%s/%s : %d / %d RF/t",
"%s/%s : %s / %s RF/t",
LangUtil.translateG("hud.msg.in"),
LangUtil.translateG("hud.msg.out"),
energyReceive,
energySend));
formatNumber(energyReceive),
formatNumber(energySend)));
return currenttip;
}
@@ -1,5 +1,7 @@
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;
@@ -13,7 +15,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.utils.WailaExceptionHandler;
import mcp.mobius.waila.api.SpecialChars;
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
@@ -34,15 +36,23 @@ 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;
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");
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");
}
}
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
@@ -1,104 +0,0 @@
package mcp.mobius.waila.addons.thermalexpansion;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerTank implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("thermalexpansion.fluidtype")) return currenttip;
try {
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid
.invoke(accessor.getTileEntity());
String name = currenttip.get(0);
try {
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
} catch (NullPointerException f) {
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.set(0, name);
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
try {
if (config.getConfig("thermalexpansion.fluidamount")) {
int amount = 0;
if (accessor.getNBTData().hasKey("Amount"))
amount = accessor.getNBTInteger(accessor.getNBTData(), "Amount");
Integer capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity
.invoke(accessor.getTileEntity());
currenttip.add(String.format("%d / %d mB", amount, capacity));
}
if (config.getConfig("thermalexpansion.tankmode")) {
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
if (mode == 0) currenttip.add(
String.format(
"%s : \u00a7a%s",
LangUtil.translateG("hud.msg.mode"),
LangUtil.translateG("hud.msg.input")));
else if (mode == 1) currenttip.add(
String.format(
"%s : \u00a7c%s",
LangUtil.translateG("hud.msg.mode"),
LangUtil.translateG("hud.msg.output")));
else currenttip.add(String.format("Mode : Unknown (%d)", mode));
}
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
try {
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(te);
tag.setInteger("Amount", amount);
} catch (Exception e) {
throw new RuntimeException(e);
}
return tag;
}
}
@@ -11,6 +11,7 @@ import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.SpecialChars;
import mcp.mobius.waila.cbcore.LangUtil;
public class HUDHandlerTesseract implements IWailaDataProvider {
@@ -33,9 +34,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("\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"));
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"));
switch (accessor.getNBTInteger(accessor.getNBTData(), "Item.Mode")) {
case 0:
@@ -1,4 +1,7 @@
package mcp.mobius.waila.addons.railcraft;
package mcp.mobius.waila.addons.thermalexpansion;
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
import java.util.List;
@@ -8,7 +11,6 @@ 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;
@@ -16,7 +18,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerTank implements IWailaDataProvider {
public class TankFluidHandler implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -26,26 +28,24 @@ public class HUDHandlerTank implements IWailaDataProvider {
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
if (!config.getConfig("thermalexpansion.fluidtype")) {
return currenttip;
}
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity == null) return currenttip;
try {
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
if (tank == null) return currenttip;
FluidStack fluid = tank.getFluid();
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);
try {
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
} catch (NullPointerException f) {
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.set(0, name);
currenttip.set(0, name + " < " + fluidName + " >");
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
}
return currenttip;
@@ -54,19 +54,22 @@ public class HUDHandlerTank implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
if (!config.getConfig("thermalexpansion.fluidamount")) {
return currenttip;
}
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity == null) return currenttip;
try {
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
if (tank == null) return currenttip;
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(tileEntity);
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(tileEntity);
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));
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(capacity)));
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
}
return currenttip;
@@ -81,7 +84,6 @@ public class HUDHandlerTank implements IWailaDataProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
@@ -1,4 +1,4 @@
package mcp.mobius.waila.addons.thermaldynamics;
package mcp.mobius.waila.addons.thermalexpansion;
import java.util.List;
@@ -7,17 +7,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.SpecialChars;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
/**
* Created by Lordmau5 on 28.02.2015.
*/
public class HUDHandlerDuct implements IWailaDataProvider {
public class TankModeHandler implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -27,33 +25,33 @@ public class HUDHandlerDuct implements IWailaDataProvider {
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("thermaldynamics.fluiductsFluid")) return currenttip;
FluidStack fluid = FluidStack.loadFluidStackFromNBT(accessor.getNBTData());
String name = "";
try {
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
} catch (NullPointerException f) {
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.add(name);
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
if (!config.getConfig("thermaldynamics.fluiductsAmount")) return currenttip;
try {
if (config.getConfig("thermalexpansion.tankmode")) {
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
if (mode == 0) {
currenttip.add(
String.format(
"%s : %s",
LangUtil.translateG("hud.msg.mode"),
SpecialChars.GREEN + LangUtil.translateG("hud.msg.input")));
} else if (mode == 1) {
currenttip.add(
String.format(
"%s : %s",
LangUtil.translateG("hud.msg.mode"),
SpecialChars.RED + LangUtil.translateG("hud.msg.output")));
}
}
int amount = 0;
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("Amount")) amount = accessor.getNBTInteger(tag, "Amount");
currenttip.add(String.format(" %d / 1000 mB", amount));
} catch (Exception e) {
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@@ -67,7 +65,6 @@ public class HUDHandlerDuct implements IWailaDataProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
return tag;
}
@@ -9,6 +9,7 @@ import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.LoadedMods;
public class ThermalExpansionModule {
@@ -67,6 +68,7 @@ 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);
@@ -74,13 +76,11 @@ public class ThermalExpansionModule {
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
printedThermalExpansionNotFound = true;
} catch (Exception e) {
if (e instanceof ClassNotFoundException) {
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
printedThermalExpansionNotFound = true;
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
}
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
}
// XXX : We register the energy cell
@@ -93,41 +93,43 @@ public class ThermalExpansionModule {
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
} catch (Exception e) {
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
} catch (ClassNotFoundException e) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
}
// XXX : We register the Tank interface
try {
TileTank = Class.forName("cofh.thermalexpansion.block.tank.TileTank");
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
TileTank_mode = TileTank.getField("mode");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTank);
if (!LoadedMods.WAILA_PLUGINS) {
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
} catch (Exception e) {
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
TankFluidHandler tankFluidHandler = new TankFluidHandler();
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
}
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
ModuleRegistrar.instance().registerBodyProvider(new TankModeHandler(), TileTank);
} catch (ClassNotFoundException e) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
}
// XXX : We register the Tesseract interface
@@ -142,15 +144,13 @@ public class ThermalExpansionModule {
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);
} catch (Exception e) {
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
} catch (ClassNotFoundException e) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
}
// XXX : We register the ISecureTile interface
@@ -163,15 +163,13 @@ public class ThermalExpansionModule {
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerISecureTile(), ISecureTile);
} catch (Exception e) {
if (e instanceof ClassNotFoundException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
} catch (ClassNotFoundException e) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
}
// XXX : We register the Cache interface
@@ -186,16 +184,15 @@ public class ThermalExpansionModule {
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCache(), TileCache);
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCache(), TileCache);
} catch (Exception e) {
if (e instanceof ClassNotFoundException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
} catch (ClassNotFoundException e) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
}
if (!printedThermalExpansionNotFound) {
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
}
@@ -1,83 +0,0 @@
package mcp.mobius.waila.addons.vanillamc;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.NumberFormat;
import mcp.mobius.waila.api.ProbeMode;
import mcp.mobius.waila.api.elements.IProbeDataProvider;
import mcp.mobius.waila.api.elements.IProbeInfo;
import mcp.mobius.waila.api.elements.ITextStyle;
import mcp.mobius.waila.overlay.DisplayUtil;
/**
* Example class for testing various elements
*/
public class HUDElementHandlerFurnace implements IProbeDataProvider {
@Override
public void addProbeInfo(ProbeMode probeMode, ItemStack itemStack, IProbeInfo probeInfo, IWailaDataAccessor data,
IWailaConfigHandler config) {
int cookTime = data.getNBTData().getShort("CookTime");
if (cookTime != 0) {
cookTime = Math.round(cookTime / 20.0f);
probeInfo.vertical().progress(
cookTime,
10,
probeInfo.defaultProgressStyle().text("Smelting: " + cookTime + " / 10 s").filledColor(0xFF4CBB17)
.alternateFilledColor(0xFF4CBB17).borderColor(0xFF555555)
.numberFormat(NumberFormat.COMMAS));
}
if (probeMode != ProbeMode.EXTENDED) {
return;
}
int burnTime = data.getNBTData().getInteger("BurnTime") / 20;
if (burnTime > 0) {
probeInfo.horizontal().text("Burn")
.item(new ItemStack(Blocks.fire), probeInfo.defaultItemStyle().width(8).height(8))
.text(": " + burnTime + " " + "Seconds Remaining");
}
ItemStack[] items = new ItemStack[3];
NBTTagList itemsTag = data.getNBTData().getTagList("Items", 10);
for (int i = 0; i < itemsTag.tagCount(); i++) {
NBTTagCompound itemTag = itemsTag.getCompoundTagAt(i);
byte slot = itemTag.getByte("Slot");
if (slot >= 0 && slot < items.length) {
items[slot] = ItemStack.loadItemStackFromNBT(itemTag);
}
}
ITextStyle itemPaddedStyle = probeInfo.defaultTextStyle().vPadding(2);
IProbeInfo itemSection = probeInfo.vertical(probeInfo.defaultLayoutStyle().borderColor(0xff00ffff));
if (items[0] != null) {
itemSection.horizontal().text("In: ", itemPaddedStyle)
.item(items[0], probeInfo.defaultItemStyle().width(10).height(10)).text(
" " + DisplayUtil.itemDisplayNameShort(items[0]) + " x" + items[0].stackSize,
itemPaddedStyle);
}
if (items[2] != null) {
itemSection.horizontal().text("Out: ", itemPaddedStyle)
.item(items[2], probeInfo.defaultItemStyle().width(10).height(10)).text(
" " + DisplayUtil.itemDisplayNameShort(items[2]) + " x" + items[2].stackSize,
itemPaddedStyle);
}
if (items[1] != null) {
itemSection.horizontal().text("Fuel: ", itemPaddedStyle)
.item(items[1], probeInfo.defaultItemStyle().width(10).height(10)).text(
" " + DisplayUtil.itemDisplayNameShort(items[1]) + " x" + items[1].stackSize,
itemPaddedStyle);
}
}
}
@@ -2,21 +2,29 @@ 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.SpecialChars;
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;
public class HUDHandlerFurnace implements IWailaDataProvider {
static Block furanace = Blocks.furnace;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
@@ -31,45 +39,68 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
int cookTime = accessor.getNBTData().getShort("CookTime");
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
NBTTagCompound tag = accessor.getNBTData();
NBTTagList items = accessor.getNBTData().getTagList("Items", 10);
String itemsText = "";
ItemStack inputStack = null;
ItemStack fuelStack = null;
ItemStack outputStack = null;
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()));
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;
}
}
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 (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);
}
currenttip.add(renderStr);
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);
return currenttip;
}
@@ -83,9 +114,19 @@ 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 != null) te.writeToNBT(tag);
if (te instanceof TileEntityFurnace furnace) {
tag.setInteger("Smelt", furnace.furnaceCookTime);
tag.setInteger("Fuel", furnace.furnaceBurnTime);
tag.setInteger("MaxFuel", furnace.currentItemBurnTime);
te.writeToNBT(tag);
}
return tag;
}
public static void register() {}
public static void register() {
IWailaDataProvider provider = new HUDHandlerFurnace();
ModuleRegistrar.instance().registerBodyProvider(provider, furanace.getClass());
ModuleRegistrar.instance().registerNBTProvider(provider, furanace.getClass());
}
}
@@ -1,18 +0,0 @@
package mcp.mobius.waila.addons.vanillamc;
import net.minecraft.block.BlockFurnace;
import cpw.mods.fml.common.event.FMLInterModComms;
import mcp.mobius.waila.api.elements.IProbeRegistrar;
// example class for registering IMC
public class TestRegistrar {
public static void callbackRegister(IProbeRegistrar register) {
register.registerProbeProvider(new HUDElementHandlerFurnace(), BlockFurnace.class);
}
public static void init() {
FMLInterModComms.sendMessage("Waila", "elementregister", TestRegistrar.class.getName() + ".callbackRegister");
}
}
@@ -49,6 +49,4 @@ public interface IWailaDataAccessor {
ForgeDirection getSide();
ItemStack getStack();
float getBlockBreakDamage();
}
@@ -62,6 +62,35 @@ public interface IWailaDataProvider {
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config);
/**
* Callback used to determine if there is extended information to display for the Body section. If this returns
* true, Waila will either display the "Hold <KEY> for more info" prompt or call getWailaAdvancedBody if the key is
* being held.
*
* @param itemStack Current block scanned, in ItemStack form.
* @param accessor Contains most of the relevant information about the current environment.
* @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) {
return false; // Default to false for backward compatibility
}
/**
* Callback used to add the extended lines to the Body section of the tooltip. This method is ONLY called if
* hasAdvancedBody returns true AND the player is holding the configured key for advanced tooltips.
*
* @param itemStack Current block scanned, in ItemStack form.
* @param currenttip The current list of tooltip lines, including the normal body.
* @param accessor Contains most of the relevant information about the current environment.
* @param config Current configuration of Waila.
* @return Modified input currenttip with advanced information appended.
*/
default List<String> getWailaAdvancedBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip; // Default to returning the unmodified list
}
/**
* Callback used to add lines to one of the three sections of the tooltip (Head, Body, Tail).</br>
* Will be used if the implementing class is registered via {@link IWailaRegistrar}.{@link registerTailProvider}
@@ -1,6 +1,6 @@
package mcp.mobius.waila.api;
import java.awt.*;
import java.awt.Dimension;
public interface IWailaTooltipRenderer {
@@ -0,0 +1,42 @@
package mcp.mobius.waila.api;
import java.awt.Dimension;
/**
* Interface for tooltip renderers that adjust their width depending on the width of the rest of the tooltip.
* setMaxLineWidth is called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render to inform the
* renderer of the width of the longest line in the tooltip.
*/
public interface IWailaVariableWidthTooltipRenderer extends IWailaTooltipRenderer {
/**
* Return the size of the tooltip. for variable width renderers it is recommended to return the minimum width needed
* for the line, then draw the actual width using getMaxLineWidth(). They do not need to actually match.
*
* @param params Array of string parameters as passed to the RENDER arg in the tooltip
* ({rendername,param1,param2,...})
* @param accessor A global accessor for TileEntities and Entities
* @return Dimension of the reserved area
*/
Dimension getSize(String[] params, IWailaCommonAccessor accessor);
/**
* Informs the renderer of what the length of the longest line is.</br>
* Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.</br>
*
* @param width The width of the longest line in the tooltip.
*
*/
void setMaxLineWidth(int width);
/**
* Returns the width of the longest line in the current tooltip.</br>
* With icons disabled the tooltip's background box is always 2 pixels wider to the right of the line than it is to
* the left.</br>
*
* @return The width of the longest line in the tooltip
*
*/
int getMaxLineWidth();
}
@@ -1,11 +0,0 @@
package mcp.mobius.waila.api;
public enum NumberFormat {
FULL,
COMPACT,
COMMAS,
NONE;
private NumberFormat() {}
}
@@ -1,7 +0,0 @@
package mcp.mobius.waila.api;
public enum ProbeMode {
NORMAL, // Normal display. What a user expects to see
EXTENDED, // Extended. This is used when the player is sneaking
DEBUG // Creative only. This is used when the player holds a creative probe
}
@@ -33,6 +33,7 @@ public class SpecialChars {
public static String WailaStyle = "\u00A4";
public static String WailaIcon = "\u00A5";
public static String WailaRenderer = "\u00A6";
public static String WailaRendererComma = "\u0082";
public static String TAB = WailaStyle + WailaStyle + "a";
public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b";
public static String ALIGNCENTER = WailaStyle + WailaStyle + "c";
@@ -43,12 +44,19 @@ public class SpecialChars {
public static final Pattern patternMinecraft = Pattern.compile("(?i)" + MCStyle + "[0-9A-FK-OR]");
public static final Pattern patternWaila = Pattern.compile("(?i)(" + WailaStyle + "(?<type>..))");
public static final Pattern patternRender = Pattern
.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<args>[^}]*)\\})");
// (?i)(¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\})
public static final Pattern patternRender = Pattern.compile(
"(?i)(" + RENDER
+ "\\{(?<name>[^"
+ WailaRendererComma
+ "}]*)"
+ WailaRendererComma
+ "?(?<args>[^}]*)\\})");
public static final Pattern patternTab = Pattern.compile("(?i)" + TAB);
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9a-z]))");
// (?i)(¤¤[^¤]+|¤¥[0-9A-Z]|¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\}|[^¤]+)
public static final Pattern patternLineSplit = Pattern.compile(
"(?i)(" + WailaStyle
+ WailaStyle
@@ -60,7 +68,11 @@ public class SpecialChars {
+ "[0-9A-Z]|"
+ WailaStyle
+ WailaRenderer
+ "a\\{([^,}]*),?([^}]*)\\}|[^"
+ "a\\{(?<name>[^"
+ WailaRendererComma
+ "}]*)"
+ WailaRendererComma
+ "?(?<args>[^}]*)\\}|[^"
+ WailaStyle
+ "]+)");
@@ -71,7 +83,7 @@ public class SpecialChars {
public static String getRenderString(String name, String... params) {
StringBuilder result = new StringBuilder(RENDER + "{" + name);
for (String s : params) {
result.append(",").append(s);
result.append(WailaRendererComma).append(s);
}
result.append("}");
return result.toString();
@@ -1,7 +0,0 @@
package mcp.mobius.waila.api.elements;
public enum ElementAlignment {
ALIGN_TOPLEFT,
ALIGN_CENTER,
ALIGN_BOTTOMRIGHT
}
@@ -1,10 +0,0 @@
package mcp.mobius.waila.api.elements;
public interface IElement {
void render(int var1, int var2);
int getWidth();
int getHeight();
}
@@ -1,12 +0,0 @@
package mcp.mobius.waila.api.elements;
public interface IItemStyle {
IItemStyle width(int var1);
IItemStyle height(int var1);
int getWidth();
int getHeight();
}
@@ -1,16 +0,0 @@
package mcp.mobius.waila.api.elements;
public interface ILayoutStyle {
ILayoutStyle borderColor(Integer var1);
ILayoutStyle spacing(int var1);
ILayoutStyle alignment(ElementAlignment var1);
Integer getBorderColor();
int getSpacing();
ElementAlignment getAlignment();
}
@@ -1,23 +0,0 @@
package mcp.mobius.waila.api.elements;
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 mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.ProbeMode;
public interface IProbeDataProvider {
default void addProbeInfo(ProbeMode probeMode, ItemStack itemStack, IProbeInfo probeInfo,
IWailaDataAccessor accessor, IWailaConfigHandler config) {}
default 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,50 +0,0 @@
package mcp.mobius.waila.api.elements;
import net.minecraft.item.ItemStack;
public interface IProbeInfo {
/**
* Create a default layout style for the horizontal or vertical elements
*/
ILayoutStyle defaultLayoutStyle();
/**
* Create a default style for the progress bar
*/
IProgressStyle defaultProgressStyle();
/**
* Create a default style for the text element
*/
ITextStyle defaultTextStyle();
/**
* Create a default style for the item element
*/
IItemStyle defaultItemStyle();
IProbeInfo text(String text, ITextStyle style);
IProbeInfo text(String text);
IProbeInfo vertical(ILayoutStyle style);
IProbeInfo vertical();
IProbeInfo horizontal(ILayoutStyle style);
IProbeInfo horizontal();
IProbeInfo item(ItemStack stack, IItemStyle style);
IProbeInfo item(ItemStack stack);
IProbeInfo progress(int var1, int var2, IProgressStyle var3);
IProbeInfo progress(int var1, int var2);
IProbeInfo progress(long var1, long var3, IProgressStyle var5);
IProbeInfo progress(long var1, long var3);
}
@@ -1,6 +0,0 @@
package mcp.mobius.waila.api.elements;
public interface IProbeRegistrar {
void registerProbeProvider(IProbeDataProvider dataProvider, Class<?> block);
}
@@ -1,65 +0,0 @@
package mcp.mobius.waila.api.elements;
import mcp.mobius.waila.api.NumberFormat;
public interface IProgressStyle {
/// The color that is used for the border of the progress bar
IProgressStyle borderColor(int c);
/// The color that is used for the background of the progress bar
IProgressStyle backgroundColor(int c);
/// The color that is used for the filled part of the progress bar
IProgressStyle filledColor(int c);
/// If this is different from the filledColor then the fill color will alternate
IProgressStyle alternateFilledColor(int c);
/// If true then text is shown inside the progress bar
IProgressStyle showText(boolean b);
/// The number format to use for the text inside the progress bar
IProgressStyle numberFormat(NumberFormat f);
IProgressStyle text(String text);
IProgressStyle textColor(int color);
IProgressStyle textShadow(boolean b);
/// If the progressbar is a lifebar then this is the maximum width
IProgressStyle width(int w);
IProgressStyle height(int h);
IProgressStyle lifeBar(boolean b);
IProgressStyle armorBar(boolean b);
int getBorderColor();
int getBackgroundColor();
int getFilledColor();
int getAlternatefilledColor();
boolean isShowText();
NumberFormat getNumberFormat();
String getText();
int getTextColor();
boolean isTextShadow();
int getWidth();
int getHeight();
boolean isLifeBar();
boolean isArmorBar();
}
@@ -1,61 +0,0 @@
package mcp.mobius.waila.api.elements;
import mcp.mobius.waila.api.impl.elements.TextStyle;
public interface ITextStyle {
/// Allows copying the state for easier template creation
ITextStyle copy();
default ITextStyle padding(int padding) {
return topPadding(padding).bottomPadding(padding).leftPadding(padding).rightPadding(padding);
}
default ITextStyle vPadding(int padding) {
return topPadding(padding).bottomPadding(padding);
}
default ITextStyle hPadding(int padding) {
return leftPadding(padding).rightPadding(padding);
}
ITextStyle topPadding(int padding);
ITextStyle bottomPadding(int padding);
ITextStyle leftPadding(int padding);
ITextStyle rightPadding(int padding);
default ITextStyle bounds(Integer width, Integer height) {
return width(width).height(height);
}
ITextStyle width(Integer width);
ITextStyle height(Integer height);
ITextStyle alignment(ElementAlignment align);
TextStyle color(int color);
TextStyle shadow(boolean shadow);
int getLeftPadding();
int getRightPadding();
int getTopPadding();
int getBottomPadding();
Integer getWidth();
Integer getHeight();
ElementAlignment getAlignment();
int getColor();
boolean getShadow();
}
@@ -134,6 +134,10 @@ public class ConfigHandler implements IWailaConfigHandler {
return getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
}
public boolean showIcon() {
return getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOWICON, true);
}
/* Default config loading */
public void loadDefaultConfig(FMLPreInitializationEvent event) {
@@ -145,7 +149,7 @@ public class ConfigHandler implements IWailaConfigHandler {
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NEWFILTERS, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOWICON, true);
OverlayConfig.posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
@@ -1,7 +1,6 @@
package mcp.mobius.waila.api.impl;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -22,8 +21,6 @@ import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor {
private static final Minecraft mc = Minecraft.getMinecraft();
public World world;
public EntityPlayer player;
public MovingObjectPosition mop;
@@ -40,7 +37,6 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
public ItemStack stack;
public static DataAccessorCommon instance = new DataAccessorCommon();
public float blockBreakDamage;
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
this.set(_world, _player, _mop, null, 0.0);
@@ -59,7 +55,6 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
this.entity = null;
this.blockID = Block.getIdFromBlock(this.block);
this.blockResource = GameData.getBlockRegistry().getNameForObject(this.block);
this.blockBreakDamage = mc.playerController.curBlockDamageMP;
try {
this.stack = new ItemStack(this.block, 1, this.metadata);
} catch (Exception ignored) {}
@@ -205,11 +200,6 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
return this.stack;
}
@Override
public float getBlockBreakDamage() {
return this.blockBreakDamage;
}
public boolean isTimeElapsed(long time) {
return System.currentTimeMillis() - this.timeLastUpdate >= time;
}
@@ -12,18 +12,18 @@ import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorFMP implements IWailaFMPAccessor {
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;
public static final DataAccessorFMP instance = new DataAccessorFMP();
public static DataAccessorFMP instance = new DataAccessorFMP();
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 void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT,
String id) {
@@ -35,13 +35,24 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
this.tileEntity = 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;
@@ -54,7 +65,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
@Override
public TileEntity getTileEntity() {
return this.entity;
return this.tileEntity;
}
@Override
@@ -69,12 +80,9 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
@Override
public NBTTagCompound getFullNBTData() {
if (this.entity == null) return null;
if (this.isTagCorrect(this.remoteNBT)) return this.remoteNBT;
if (this.tileEntity == null) return null;
NBTTagCompound tag = new NBTTagCompound();
this.entity.writeToNBT(tag);
this.tileEntity.writeToNBT(tag);
return tag;
}
@@ -98,20 +106,4 @@ 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;
}
}
}
@@ -6,23 +6,24 @@ import java.util.Map;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.cbcore.Layout;
import mcp.mobius.waila.client.KeyEvent;
import mcp.mobius.waila.network.Message0x01TERequest;
import mcp.mobius.waila.network.Message0x03EntRequest;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class MetaDataProvider {
@@ -68,9 +69,7 @@ public class MetaDataProvider {
if (accessor.getTileEntity() != null && Waila.instance.serverPresent
&& accessor.isTimeElapsed(250)
&& ConfigHandler.instance().showTooltip()
&& ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false)) {
&& ConfigHandler.instance().showTooltip()) {
accessor.resetTimer();
HashSet<String> keys = new HashSet<>();
@@ -82,8 +81,7 @@ public class MetaDataProvider {
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTProviders(block)
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
WailaPacketHandler.INSTANCE
.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys, false));
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent
&& accessor.isTimeElapsed(250)
@@ -151,11 +149,29 @@ public class MetaDataProvider {
}
if (layout == Layout.BODY) for (List<IWailaDataProvider> providersList : bodyBlockProviders.values()) {
boolean hasAdvancedBodyAvailable = false;
final boolean isAdvancedKeyDown = KeyEvent.key_show_advanced.getIsKeyPressed();
for (IWailaDataProvider dataProvider : providersList) try {
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
if (dataProvider.hasWailaAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
hasAdvancedBodyAvailable = true;
if (isAdvancedKeyDown) {
currenttip = dataProvider
.getWailaAdvancedBody(itemStack, currenttip, accessor, ConfigHandler.instance());
}
}
} catch (Throwable e) {
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (hasAdvancedBodyAvailable && !isAdvancedKeyDown) {
String keyName = GameSettings.getKeyDisplayString(KeyEvent.key_show_advanced.getKeyCode());
currenttip.add(LangUtil.translateG("hud.msg.holdkeymoreinfo", keyName));
}
}
if (layout == Layout.FOOTER) for (List<IWailaDataProvider> providersList : tailBlockProviders.values()) {
for (IWailaDataProvider dataProvider : providersList) try {
@@ -4,11 +4,24 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import au.com.bytecode.opencsv.CSVReader;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.*;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.api.IWailaFMPDecorator;
import mcp.mobius.waila.api.IWailaFMPProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.api.IWailaTooltipRenderer;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.Constants;
@@ -1,7 +1,12 @@
package mcp.mobius.waila.api.impl;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import mcp.mobius.waila.api.ITaggedList;
@@ -1,126 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.Gui;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.elements.*;
public abstract class AbstractElementPanel implements IElement, IProbeInfo {
protected List<IElement> children = new ArrayList();
protected Integer borderColor;
protected int spacing;
protected ElementAlignment alignment;
public void render(int x, int y) {
if (this.borderColor != null) {
int w = this.getWidth();
int h = this.getHeight();
drawHorizontalLine(x, y, x + w - 1, this.borderColor);
drawHorizontalLine(x, y + h - 1, x + w - 1, this.borderColor);
drawVerticalLine(x, y, y + h - 1, this.borderColor);
drawVerticalLine(x + w - 1, y, y + h, this.borderColor);
}
}
public AbstractElementPanel(Integer borderColor, int spacing, ElementAlignment alignment) {
this.borderColor = borderColor;
this.spacing = spacing;
this.alignment = alignment;
}
public IProbeInfo text(String text, ITextStyle style) {
this.children.add(new ElementText(text, style));
return this;
}
public IProbeInfo text(String text) {
this.children.add(new ElementText(text));
return this;
}
public IProbeInfo vertical(ILayoutStyle style) {
ElementVertical e = new ElementVertical(style.getBorderColor(), style.getSpacing(), style.getAlignment());
this.children.add(e);
return e;
}
public IProbeInfo vertical() {
ElementVertical e = new ElementVertical(null, 2, ElementAlignment.ALIGN_TOPLEFT);
this.children.add(e);
return e;
}
public IProbeInfo horizontal(ILayoutStyle style) {
ElementHorizontal e = new ElementHorizontal(style.getBorderColor(), style.getSpacing(), style.getAlignment());
this.children.add(e);
return e;
}
public IProbeInfo horizontal() {
ElementHorizontal e = new ElementHorizontal((Integer) null, this.spacing, ElementAlignment.ALIGN_TOPLEFT);
this.children.add(e);
return e;
}
public IProbeInfo item(ItemStack stack, IItemStyle style) {
this.children.add(new ElementItemStack(stack, style));
return this;
}
public IProbeInfo item(ItemStack stack) {
return this.item(stack, new ItemStyle());
}
public IProbeInfo progress(int current, int max) {
return this.progress(current, max, new ProgressStyle());
}
public IProbeInfo progress(int current, int max, IProgressStyle style) {
this.children.add(new ElementProgress((long) current, (long) max, style));
return this;
}
public IProbeInfo progress(long current, long max) {
return this.progress(current, max, new ProgressStyle());
}
public IProbeInfo progress(long current, long max, IProgressStyle style) {
this.children.add(new ElementProgress(current, max, style));
return this;
}
// tmp
public static void drawHorizontalLine(int x1, int y1, int x2, int color) {
Gui.drawRect(x1, y1, x2, y1 + 1, color);
}
// tmp
public static void drawVerticalLine(int x1, int y1, int y2, int color) {
Gui.drawRect(x1, y1, x1 + 1, y2, color);
}
@Override
public ILayoutStyle defaultLayoutStyle() {
return new LayoutStyle();
}
@Override
public IProgressStyle defaultProgressStyle() {
return new ProgressStyle();
}
@Override
public ITextStyle defaultTextStyle() {
return new TextStyle();
}
@Override
public IItemStyle defaultItemStyle() {
return new ItemStyle();
}
}
@@ -1,64 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import mcp.mobius.waila.api.elements.ElementAlignment;
import mcp.mobius.waila.api.elements.IElement;
public class ElementHorizontal extends AbstractElementPanel {
public static final int SPACING = 5;
public ElementHorizontal(Integer borderColor, int spacing, ElementAlignment alignment) {
super(borderColor, spacing, alignment);
}
@Override
public void render(int x, int y) {
super.render(x, y);
if (borderColor != null) {
x += 3;
y += 3;
}
int totHeight = getHeight();
for (IElement element : children) {
int h = element.getHeight();
int cy = y;
switch (alignment) {
case ALIGN_TOPLEFT:
break;
case ALIGN_CENTER:
cy = y + (totHeight - h) / 2;
break;
case ALIGN_BOTTOMRIGHT:
cy = y + totHeight - h;
break;
}
element.render(x, cy);
x += element.getWidth() + spacing;
}
}
private int getBorderSpacing() {
return borderColor == null ? 0 : 6;
}
@Override
public int getWidth() {
int w = 0;
for (IElement element : children) {
w += element.getWidth();
}
return w + spacing * (children.size() - 1) + getBorderSpacing();
}
@Override
public int getHeight() {
int h = 0;
for (IElement element : children) {
int hh = element.getHeight();
if (hh > h) {
h = hh;
}
}
return h + getBorderSpacing();
}
}
@@ -1,37 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import mcp.mobius.waila.api.elements.IElement;
import mcp.mobius.waila.api.elements.IItemStyle;
import mcp.mobius.waila.overlay.DisplayUtil;
public class ElementItemStack implements IElement {
private final ItemStack itemStack;
private final IItemStyle style;
public ElementItemStack(ItemStack itemStack, IItemStyle style) {
this.itemStack = itemStack;
this.style = style;
}
@Override
public void render(int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
DisplayUtil.elementRenderStack(x, y, itemStack, style);
}
@Override
public int getWidth() {
return style.getWidth();
}
@Override
public int getHeight() {
return style.getHeight();
}
}
@@ -1,117 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.text.DecimalFormat;
import mcp.mobius.waila.api.NumberFormat;
import mcp.mobius.waila.api.elements.IElement;
import mcp.mobius.waila.api.elements.IProgressStyle;
import mcp.mobius.waila.overlay.DisplayUtil;
public class ElementProgress implements IElement {
private final long current;
private final long max;
private final IProgressStyle style;
public ElementProgress(long current, long max, IProgressStyle style) {
this.current = current;
this.max = max;
this.style = style;
}
private static DecimalFormat dfCommas = new DecimalFormat("###,###");
/**
* If the suffix starts with 'm' we can possibly drop that
*/
public static String format(long in, NumberFormat style, String suffix) {
switch (style) {
case FULL:
return Long.toString(in) + suffix;
case COMPACT: {
int unit = 1000;
if (in < unit) {
return Long.toString(in) + " " + suffix;
}
int exp = (int) (Math.log(in) / Math.log(unit));
char pre;
if (suffix.startsWith("m")) {
suffix = suffix.substring(1);
if (exp - 2 >= 0) {
pre = "kMGTPE".charAt(exp - 2);
return String.format("%.1f %s", in / Math.pow(unit, exp), pre) + suffix;
} else {
return String.format("%.1f %s", in / Math.pow(unit, exp), suffix);
}
} else {
pre = "kMGTPE".charAt(exp - 1);
return String.format("%.1f %s", in / Math.pow(unit, exp), pre) + suffix;
}
}
case COMMAS:
return dfCommas.format(in) + suffix;
case NONE:
return suffix;
}
return Long.toString(in);
}
@Override
public void render(int x, int y) {
render(style, current, max, x, y, getWidth(), getHeight());
}
private static void render(IProgressStyle style, long current, long max, int x, int y, int w, int h) {
DisplayUtil.drawThickBeveledBox(
x,
y,
x + w,
y + h,
1,
style.getBorderColor(),
style.getBorderColor(),
style.getBackgroundColor());
if (current > 0L && max > 0L) {
int dx = (int) Math.min(current * (long) (w - 2) / max, (long) (w - 2));
if (style.getFilledColor() == style.getAlternatefilledColor()) {
if (dx > 0) {
DisplayUtil.drawThickBeveledBox(
x + 1,
y + 1,
x + dx + 1,
y + h - 1,
1,
style.getFilledColor(),
style.getFilledColor(),
style.getFilledColor());
}
} else {
for (int xx = x + 1; xx <= x + dx + 1; ++xx) {
int color = (xx & 1) == 0 ? style.getFilledColor() : style.getAlternatefilledColor();
DisplayUtil.drawVerticalLine(xx, y + 1, y + h - 1, color);
}
}
}
if (style.isShowText()) {
DisplayUtil.drawString(style.getText(), x + 3, y + 2, style.getTextColor(), style.isTextShadow());
}
}
@Override
public int getWidth() {
if (style.isLifeBar()) {
if (current * 4 >= style.getWidth()) {
return 100;
} else {
return (int) (current * 4 + 2);
}
}
return style.getWidth();
}
@Override
public int getHeight() {
return style.getHeight();
}
}
@@ -1,68 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import net.minecraft.client.Minecraft;
import mcp.mobius.waila.api.elements.IElement;
import mcp.mobius.waila.api.elements.ITextStyle;
import mcp.mobius.waila.overlay.DisplayUtil;
public class ElementText implements IElement {
private final String text;
private final ITextStyle style;
private static final int DEFAULT_HEIGHT = 10;
public ElementText(String text) {
this(text, new TextStyle());
}
public ElementText(String text, ITextStyle style) {
this.text = text;
this.style = style;
}
public void render(int x, int y) {
int width = getTextWidth();
switch (style.getAlignment()) {
case ALIGN_BOTTOMRIGHT -> DisplayUtil.drawString(
text,
(x + getInternalWidth() - width) + style.getLeftPadding(),
y + style.getTopPadding(),
style.getColor(),
style.getShadow());
case ALIGN_CENTER -> DisplayUtil.drawString(
text,
((x + (getInternalWidth() / 2)) - (width / 2)) + style.getLeftPadding(),
y + style.getTopPadding(),
style.getColor(),
style.getShadow());
case ALIGN_TOPLEFT -> DisplayUtil.drawString(
text,
x + style.getLeftPadding(),
y + style.getTopPadding(),
style.getColor(),
style.getShadow());
}
}
public int getTextWidth() {
return Minecraft.getMinecraft().fontRenderer.getStringWidth(text);
}
protected int getInternalWidth() {
return (style.getWidth() != null ? style.getWidth() : getTextWidth());
}
@Override
public int getWidth() {
return style.getLeftPadding() + (style.getWidth() != null ? style.getWidth() : getTextWidth())
+ style.getRightPadding();
}
@Override
public int getHeight() {
return style.getTopPadding() + (style.getHeight() != null ? style.getHeight() : DEFAULT_HEIGHT)
+ style.getBottomPadding();
}
}
@@ -1,73 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.util.Iterator;
import mcp.mobius.waila.api.elements.ElementAlignment;
import mcp.mobius.waila.api.elements.IElement;
public class ElementVertical extends AbstractElementPanel {
public ElementVertical(Integer borderColor, int spacing, ElementAlignment alignment) {
super(borderColor, spacing, alignment);
}
public void render(int x, int y) {
super.render(x, y);
if (this.borderColor != null) {
x += 3;
y += 3;
}
int totWidth = this.getWidth();
IElement element;
for (Iterator var4 = this.children.iterator(); var4.hasNext(); y += element.getHeight() + this.spacing) {
element = (IElement) var4.next();
int w = element.getWidth();
int cx = x;
switch (this.alignment) {
case ALIGN_TOPLEFT:
default:
break;
case ALIGN_CENTER:
cx = x + (totWidth - w) / 2;
break;
case ALIGN_BOTTOMRIGHT:
cx = x + totWidth - w;
}
element.render(cx, y);
}
}
private int getBorderSpacing() {
return this.borderColor == null ? 0 : 6;
}
public int getHeight() {
int h = 0;
IElement element;
for (Iterator var2 = this.children.iterator(); var2.hasNext(); h += element.getHeight()) {
element = (IElement) var2.next();
}
return h + this.spacing * (this.children.size() - 1) + this.getBorderSpacing();
}
public int getWidth() {
int w = 0;
Iterator var2 = this.children.iterator();
while (var2.hasNext()) {
IElement element = (IElement) var2.next();
int ww = element.getWidth();
if (ww > w) {
w = ww;
}
}
return w + this.getBorderSpacing();
}
}
@@ -1,34 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import mcp.mobius.waila.api.elements.IItemStyle;
public class ItemStyle implements IItemStyle {
private int width = 20;
private int height = 20;
public ItemStyle(int w, int h) {
width = w;
height = h;
}
public ItemStyle() {}
public IItemStyle width(int w) {
this.width = w;
return this;
}
public IItemStyle height(int h) {
this.height = h;
return this;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
}
@@ -1,43 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import mcp.mobius.waila.api.elements.ElementAlignment;
import mcp.mobius.waila.api.elements.ILayoutStyle;
public class LayoutStyle implements ILayoutStyle {
private Integer borderColor = null;
private ElementAlignment alignment;
private int spacing;
public LayoutStyle() {
this.alignment = ElementAlignment.ALIGN_TOPLEFT;
this.spacing = -1;
}
public ILayoutStyle alignment(ElementAlignment alignment) {
this.alignment = alignment;
return this;
}
public ElementAlignment getAlignment() {
return this.alignment;
}
public LayoutStyle borderColor(Integer c) {
this.borderColor = c;
return this;
}
public LayoutStyle spacing(int f) {
this.spacing = f;
return this;
}
public Integer getBorderColor() {
return this.borderColor;
}
public int getSpacing() {
return this.spacing;
}
}
@@ -1,99 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.util.HashSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.addons.DefaultProbeInfoProvider;
import mcp.mobius.waila.api.ProbeMode;
import mcp.mobius.waila.api.elements.IProbeDataProvider;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.DataAccessorCommon;
import mcp.mobius.waila.network.Message0x01TERequest;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class MetaProbeDataProvider {
public ProbeInfo handleBlockElementData(ItemStack itemStack, World world, EntityPlayer player,
MovingObjectPosition mop, DataAccessorCommon accessor) {
Block block = accessor.getBlock();
ProbeInfo probeInfo = new ProbeInfo();
DefaultProbeInfoProvider.addStandardBlockInfo(itemStack, probeInfo, accessor, ConfigHandler.instance());
if (!ModuleProbeRegistrar.instance().hasProviders(block)
&& !ModuleProbeRegistrar.instance().hasProviders(accessor.getTileEntity())) {
return probeInfo;
}
ProbeMode probeMode = player.isSneaking() ? ProbeMode.EXTENDED
: player.capabilities.isCreativeMode ? ProbeMode.DEBUG : ProbeMode.NORMAL;
if (accessor.getTileEntity() != null && Waila.instance.serverPresent
&& accessor.isTimeElapsed(250)
&& ConfigHandler.instance().showTooltip()
&& !ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false)) {
accessor.resetTimer();
HashSet<String> keys = new HashSet<>();
if (ModuleProbeRegistrar.instance().hasProviders(block)
|| ModuleProbeRegistrar.instance().hasProviders(accessor.getTileEntity()))
WailaPacketHandler.INSTANCE
.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys, true));
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent
&& accessor.isTimeElapsed(250)
&& ConfigHandler.instance().showTooltip()) {
try {
NBTTagCompound tag = new NBTTagCompound();
accessor.getTileEntity().writeToNBT(tag);
accessor.setNBTData(tag);
} catch (Exception e) {
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
}
}
/* Lookup by class (for blocks) */
if (ModuleProbeRegistrar.instance().hasProviders(block)) {
List<IProbeDataProvider> probeDataProviders = ModuleProbeRegistrar.instance().getProviders(block);
for (IProbeDataProvider probeDataProvider : probeDataProviders) {
probeDataProvider.addProbeInfo(probeMode, itemStack, probeInfo, accessor, ConfigHandler.instance());
}
}
/* Lookup by class (for tileentities) */
if (ModuleProbeRegistrar.instance().hasProviders(accessor.getTileEntity())) {
List<IProbeDataProvider> probeDataProviders = ModuleProbeRegistrar.instance()
.getProviders(accessor.getTileEntity());
for (IProbeDataProvider probeDataProvider : probeDataProviders) {
probeDataProvider.addProbeInfo(probeMode, itemStack, probeInfo, accessor, ConfigHandler.instance());
}
}
return probeInfo;
}
// append legacy Tooltip into new ProbeInfo if possible
public ProbeInfo appendTooltipData(ProbeInfo probeInfo, List<String> tooltip, ItemStack itemStack,
DataAccessorCommon accessor) {
if (tooltip.isEmpty()) {
return probeInfo;
}
for (String s : tooltip) {
probeInfo.text(s);
}
return probeInfo;
}
}
@@ -1,64 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import mcp.mobius.waila.api.elements.IProbeDataProvider;
import mcp.mobius.waila.api.elements.IProbeRegistrar;
public class ModuleProbeRegistrar implements IProbeRegistrar {
private static ModuleProbeRegistrar instance = null;
public LinkedHashMap<Class<?>, ArrayList<IProbeDataProvider>> probeProviders = new LinkedHashMap<>();;
public LinkedHashMap<String, String> IMCRequests = new LinkedHashMap<>();
private ModuleProbeRegistrar() {
instance = this;
}
public static ModuleProbeRegistrar instance() {
if (ModuleProbeRegistrar.instance == null) ModuleProbeRegistrar.instance = new ModuleProbeRegistrar();
return ModuleProbeRegistrar.instance;
}
/* IMC HANDLING */
public void addIMCRequest(String method, String modname) {
this.IMCRequests.put(method, modname);
}
@Override
public void registerProbeProvider(IProbeDataProvider dataProvider, Class<?> block) {
this.registerProvider(dataProvider, block, this.probeProviders);
}
private void registerProvider(IProbeDataProvider dataProvider, Class<?> clazz,
LinkedHashMap<Class<?>, ArrayList<IProbeDataProvider>> target) {
if (clazz == null || dataProvider == null) throw new RuntimeException(
"Trying to register a null provider or null block ! Please check the stacktrace to know what was the original registration method.");
if (!target.containsKey(clazz)) target.put(clazz, new ArrayList<>());
ArrayList<IProbeDataProvider> providers = target.get(clazz);
if (providers.contains(dataProvider)) return;
target.get(clazz).add(dataProvider);
}
public boolean hasProviders(Object obj) {
for (Class clazz : probeProviders.keySet()) if (clazz.isInstance(obj)) return true;
return false;
}
public List<IProbeDataProvider> getProviders(Object obj) {
List<IProbeDataProvider> returnList = new ArrayList<>();
for (Class clazz : probeProviders.keySet()) {
if (clazz.isInstance(obj)) returnList.addAll(probeProviders.get(clazz));
}
return returnList;
}
}
@@ -1,21 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import java.util.List;
import mcp.mobius.waila.api.elements.ElementAlignment;
import mcp.mobius.waila.api.elements.IElement;
public class ProbeInfo extends ElementVertical {
public List<IElement> getElements() {
return this.children;
}
public ProbeInfo() {
super(null, 2, ElementAlignment.ALIGN_TOPLEFT);
}
public void removeElement(IElement element) {
this.getElements().remove(element);
}
}
@@ -1,142 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import mcp.mobius.waila.api.NumberFormat;
import mcp.mobius.waila.api.elements.IProgressStyle;
public class ProgressStyle implements IProgressStyle {
private int borderColor = -1;
private int backgroundColor = -16777216;
private int filledColor = -5592406;
private int alternatefilledColor = -5592406;
private boolean showText = true;
private String text;
private int textColor = 0xffffffff;
private boolean textShadow = true;
private int width = 100;
private int height = 12;
private boolean lifeBar = false;
private boolean armorBar = false;
private NumberFormat numberFormat;
public ProgressStyle() {
this.numberFormat = NumberFormat.COMPACT;
}
public ProgressStyle borderColor(int c) {
this.borderColor = c;
return this;
}
public ProgressStyle backgroundColor(int c) {
this.backgroundColor = c;
return this;
}
public ProgressStyle filledColor(int c) {
this.filledColor = c;
return this;
}
public ProgressStyle alternateFilledColor(int c) {
this.alternatefilledColor = c;
return this;
}
public ProgressStyle showText(boolean b) {
this.showText = b;
return this;
}
public ProgressStyle numberFormat(NumberFormat f) {
this.numberFormat = f;
return this;
}
public ProgressStyle text(String text) {
this.text = text;
return this;
}
public ProgressStyle textColor(int color) {
this.textColor = color;
return this;
}
public ProgressStyle textShadow(boolean b) {
this.textShadow = b;
return this;
}
public ProgressStyle width(int w) {
this.width = w;
return this;
}
public ProgressStyle height(int h) {
this.height = h;
return this;
}
public IProgressStyle lifeBar(boolean b) {
this.lifeBar = b;
return this;
}
public IProgressStyle armorBar(boolean b) {
this.armorBar = b;
return this;
}
public int getBorderColor() {
return this.borderColor;
}
public int getBackgroundColor() {
return this.backgroundColor;
}
public int getFilledColor() {
return this.filledColor;
}
public int getAlternatefilledColor() {
return this.alternatefilledColor;
}
public boolean isShowText() {
return this.showText;
}
public NumberFormat getNumberFormat() {
return this.numberFormat;
}
public String getText() {
return this.text;
}
public int getTextColor() {
return this.textColor;
}
public boolean isTextShadow() {
return this.textShadow;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public boolean isLifeBar() {
return this.lifeBar;
}
public boolean isArmorBar() {
return this.armorBar;
}
}
@@ -1,123 +0,0 @@
package mcp.mobius.waila.api.impl.elements;
import mcp.mobius.waila.api.elements.ElementAlignment;
import mcp.mobius.waila.api.elements.ITextStyle;
import mcp.mobius.waila.overlay.OverlayConfig;
public class TextStyle implements ITextStyle {
int top = 0;
int bottom = 0;
int left = 0;
int right = 0;
Integer width = null;
Integer height = null;
ElementAlignment align = ElementAlignment.ALIGN_TOPLEFT;
int color = OverlayConfig.fontcolor;
boolean shadow = false;
@Override
public ITextStyle copy() {
return new TextStyle().bottomPadding(bottom).leftPadding(left).rightPadding(right).topPadding(top)
.bounds(width, height).alignment(align);
}
@Override
public TextStyle topPadding(int padding) {
top = padding;
return this;
}
@Override
public TextStyle bottomPadding(int padding) {
bottom = padding;
return this;
}
@Override
public TextStyle leftPadding(int padding) {
left = padding;
return this;
}
@Override
public TextStyle rightPadding(int padding) {
right = padding;
return this;
}
@Override
public TextStyle alignment(ElementAlignment align) {
this.align = align;
return this;
}
@Override
public TextStyle width(Integer width) {
this.width = width;
return this;
}
@Override
public TextStyle height(Integer height) {
this.height = height;
return this;
}
@Override
public TextStyle color(int color) {
this.color = color;
return this;
}
@Override
public TextStyle shadow(boolean shadow) {
this.shadow = shadow;
return this;
}
@Override
public int getLeftPadding() {
return left;
}
@Override
public int getRightPadding() {
return right;
}
@Override
public int getTopPadding() {
return top;
}
@Override
public int getBottomPadding() {
return bottom;
}
@Override
public ElementAlignment getAlignment() {
return align;
}
@Override
public Integer getWidth() {
return width;
}
@Override
public Integer getHeight() {
return height;
}
@Override
public int getColor() {
return color;
}
@Override
public boolean getShadow() {
return shadow;
}
}
@@ -7,12 +7,14 @@ 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;
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 {
@@ -21,6 +23,7 @@ public class KeyEvent {
public static KeyBinding key_liquid;
public static KeyBinding key_recipe;
public static KeyBinding key_usage;
public static KeyBinding key_show_advanced;
public KeyEvent() {
ClientRegistry
@@ -33,6 +36,8 @@ public class KeyEvent {
key_recipe = new KeyBinding(Constants.BIND_WAILA_RECIPE, Keyboard.KEY_NUMPAD3, "Waila"));
ClientRegistry.registerKeyBinding(
key_usage = new KeyBinding(Constants.BIND_WAILA_USAGE, Keyboard.KEY_NUMPAD4, "Waila"));
ClientRegistry.registerKeyBinding(
key_show_advanced = new KeyBinding(Constants.BIND_WAILA_SHOW_ADVANCED, Keyboard.KEY_LSHIFT, "Waila"));
}
@SubscribeEvent
@@ -43,38 +48,37 @@ public class KeyEvent {
if (mc.currentScreen == null) {
mc.displayGuiScreen(new ScreenConfig(null));
}
} else if (showKey && ConfigHandler.instance()
return;
}
if (showKey && ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)) {
boolean status = ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
ConfigHandler.instance()
.setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, !status);
boolean status = ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, !status);
} else if (showKey && !ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)) {
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
} else
if (showKey && !ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)) {
ConfigHandler.instance()
.setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
} else
if (key_liquid.isPressed()) {
boolean status = ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true);
ConfigHandler.instance()
.setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, !status);
} else if (key_recipe.isPressed()) {
if (Loader.isModLoaded("NotEnoughItems")) {
try {
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler")
.getDeclaredMethod("openRecipeGUI", boolean.class).invoke(null, true);
} catch (Exception ignored) {}
}
} else if (key_usage.isPressed()) {
if (Loader.isModLoaded("NotEnoughItems")) {
try {
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler")
.getDeclaredMethod("openRecipeGUI", boolean.class).invoke(null, false);
} catch (Exception ignored) {}
}
}
if (key_liquid.isPressed()) {
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);
}
}
@SubscribeEvent
public void tickClient(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.START) return;
if (!KeyEvent.key_show.getIsKeyPressed()
&& !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)
&& ConfigHandler.instance()
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false)) {
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
}
}
}
@@ -6,9 +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.Waila;
import mcp.mobius.waila.api.impl.DataAccessorCommon;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.cbcore.LangUtil;
@@ -17,10 +15,17 @@ import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
import mcp.mobius.waila.handlers.HUDHandlerBlocks;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
import mcp.mobius.waila.handlers.nei.NEIHandler;
import mcp.mobius.waila.overlay.BreakProgressRenderer;
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 {
@@ -33,13 +38,8 @@ public class ProxyClient extends ProxyServer {
LangUtil.loadLangDir("waila");
if (Loader.isModLoaded("NotEnoughItems")) {
try {
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler").getDeclaredMethod("register").invoke(null);
} catch (Exception e) {
Waila.log.error("Failed to hook into NEI properly. Reverting to Vanilla tooltip handler");
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
}
if (LoadedMods.NEI) {
NEIHandler.register();
} else {
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
}
@@ -54,10 +54,17 @@ public class ProxyClient extends ProxyServer {
ModuleRegistrar.instance().addConfig("General", "general.showents");
ModuleRegistrar.instance().addConfig("General", "general.showhp");
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
ModuleRegistrar.instance().addConfig("General", BreakProgressRenderer.CFG_ENABLED, true);
ModuleRegistrar.instance().addConfig("General", BreakProgressRenderer.CFG_TOP, false);
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());
MinecraftForge.EVENT_BUS.register(new WorldUnloadEventHandler());
}
@@ -73,7 +80,9 @@ public class ProxyClient extends ProxyServer {
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
DataAccessorCommon.instance = new DataAccessorCommon();
if (event.world.isRemote) {
DataAccessorCommon.instance = new DataAccessorCommon();
}
}
}
}
@@ -0,0 +1,30 @@
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;
}
}
@@ -5,7 +5,11 @@ import net.minecraftforge.common.config.Configuration;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.*;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.RenderPriority;
import mcp.mobius.waila.gui.interfaces.Signal;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
@@ -2,10 +2,7 @@ package mcp.mobius.waila.gui.screens.config;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.util.Point;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
@@ -22,27 +19,9 @@ public class ScreenModuleConfig extends ScreenBase {
public ScreenModuleConfig(GuiScreen parent, String modname) {
super(parent);
this.getRoot().addWidget("ButtonContainer", new ButtonContainerLabel(this.getRoot(), 2, 100, 25.0) {
protected int scrollValue = 0;
@Override
public void onMouseWheel(MouseEvent event) {
scrollValue += event.z * 4;
if (scrollValue > 0) {
scrollValue = 0;
}
}
@Override
public void draw(Point pos) {
if (scrollValue <= 0) {
geom.setPos(0, 20.0 + scrollValue, true, true);
}
}
});
this.getRoot().addWidget("ButtonContainer", new ButtonContainerLabel(this.getRoot(), 2, 100, 25.0));
this.getRoot().getWidget("ButtonContainer").setGeometry(
new WidgetGeometry(0.0, 20.0, 100.0, 200.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
new WidgetGeometry(0.0, 20.0, 100.0, 60.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel) this.getRoot().getWidget("ButtonContainer"));
@@ -88,12 +88,12 @@ public class ScreenWailaConfig extends ScreenBase {
new ButtonBooleanConfig(
this.getRoot(),
Configuration.CATEGORY_GENERAL,
Constants.CFG_WAILA_FORCE_LEGACY_MODE,
Constants.CFG_WAILA_SHOWICON,
true,
false,
"screen.button.no",
"screen.button.yes"),
"choice.forcelegacymode");
"choice.showicon");
this.getRoot().addWidget("LayoutConfigPos", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutConfigPos")
@@ -7,7 +7,11 @@ import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.*;
import mcp.mobius.waila.gui.widgets.ItemStackDisplay;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.ViewTable;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
public class ScreenEnchants extends ScreenBase {
@@ -14,7 +14,7 @@ package mcp.mobius.waila.gui.truetyper;
* <http://www.gnu.org/licenses/>.
*/
import java.awt.*;
import java.awt.Font;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff. Show more