mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-14 17:14:51 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
152d446d87 | ||
|
|
6bdc0776d6 | ||
|
|
051a7a3154 | ||
|
|
2089056dd8 | ||
|
|
408f47115d | ||
|
|
df80d81c2b | ||
|
|
9af4543135 | ||
|
|
4384079fe2 | ||
|
|
6589f1abc0 | ||
|
|
a585652bab | ||
|
|
123e0eb902 | ||
|
|
0de14a79a4 | ||
|
|
b3c662ee3a | ||
|
|
fff19357bc | ||
|
|
07e733b548 | ||
|
|
320561c7bf |
No files matched your search
@@ -3,9 +3,9 @@ name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
name: Optimize images
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
jobs:
|
||||
optimize-images:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
||||
secrets: inherit
|
||||
@@ -27,5 +27,3 @@ whitelist.json
|
||||
*.iws
|
||||
src/main/resources/mixins.*.json
|
||||
*.bat
|
||||
layout.json
|
||||
.DS_Store
|
||||
@@ -1,13 +0,0 @@
|
||||
# Waila
|
||||
|
||||
## Contribution
|
||||
|
||||
When forking this repository, make sure to uncheck the `Copy the master branch only` option.
|
||||
This will copy all tags to your fork, so the build system can detect the latest mod version.
|
||||
If you leave it checked, you won't be able to enter the world in a local client run because Waila [will think the mod is outdated](https://github.com/GTNewHorizons/waila/blob/master/src/main/java/mcp/mobius/waila/Waila.java#L133).
|
||||
|
||||
If you already forked the repository without tags, you can fetch them manually:
|
||||
```
|
||||
git remote add upstream https://github.com/GTNewHorizons/waila
|
||||
git fetch upstream --tags
|
||||
```
|
||||
+1
-18
@@ -1,24 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.25-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")
|
||||
}
|
||||
+8
-54
@@ -14,7 +14,7 @@ modId = Waila
|
||||
modGroup = mcp.mobius.waila
|
||||
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# When false, com.github.GTNewHorizons is used.
|
||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
@@ -39,33 +39,9 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = jabel
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
||||
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
# jvmDowngraderStubsProvider =
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -104,25 +80,18 @@ 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 =
|
||||
accessTransformersFile = Waila_at.cfg
|
||||
|
||||
# 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. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -148,15 +117,9 @@ minimizeShadowedDependencies = true
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
# Adds the GTNH maven, 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.
|
||||
@@ -177,7 +140,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: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
# Note: GTNH Mixins 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.
|
||||
@@ -198,12 +161,6 @@ curseForgeRelations =
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
@@ -233,6 +190,3 @@ curseForgeRelations =
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
org.gradle.configuration-cache = true
|
||||
org.gradle.parallel = true
|
||||
@@ -1,12 +0,0 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
|
||||
toolchainVersion=25
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -86,7 +84,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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -114,6 +112,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -171,6 +170,7 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -203,14 +203,15 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_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" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+2
-3
@@ -13,8 +13,6 @@
|
||||
@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 ##########################################################################
|
||||
@@ -70,10 +68,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.21'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mcp.mobius.waila;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -7,24 +8,24 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
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.*;
|
||||
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;
|
||||
@@ -40,8 +41,7 @@ import mcp.mobius.waila.utils.ModIdentification;
|
||||
name = "Waila",
|
||||
version = Tags.GRADLETOKEN_VERSION,
|
||||
dependencies = "after:NotEnoughItems@[1.0.4.0,)",
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "mcp.mobius.waila.client.WailaGuiFactory")
|
||||
acceptableRemoteVersions = "*")
|
||||
public class Waila {
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
@@ -65,21 +65,36 @@ 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(new WailaTickHandler());
|
||||
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
|
||||
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Subscribe
|
||||
public void loadComplete(FMLLoadCompleteEvent event) {
|
||||
proxy.registerMods();
|
||||
proxy.registerIMCs();
|
||||
@@ -116,6 +131,15 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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,7 +8,6 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class BCModule {
|
||||
|
||||
@@ -16,26 +15,21 @@ public class BCModule {
|
||||
public static Method TileTank_getTankInfo = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileTank = Class.forName("buildcraft.factory.TileTank");
|
||||
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
|
||||
|
||||
Waila.log.log(Level.INFO, "Buildcraft mod found.");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
|
||||
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
Waila.log.log(Level.INFO, "[BC] Buildcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
Waila.log.log(Level.INFO, "Buildcraft mod found.");
|
||||
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
|
||||
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
|
||||
}
|
||||
|
||||
}
|
||||
+8
-20
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.buildcraft;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -23,7 +20,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerBCTanks implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -33,36 +30,27 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!ConfigHandler.instance().getConfig("bc.tanktype")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
FluidTankInfo tank = this.getTank(accessor);
|
||||
FluidStack stack = tank != null ? tank.fluid : null;
|
||||
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = stack == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: stack.getFluid().getLocalizedName(stack);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
if (stack != null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " (" + stack.getFluid().getName() + ")";
|
||||
else if (stack == null && ConfigHandler.instance().getConfig("bc.tanktype"))
|
||||
name = name + " " + LangUtil.translateG("hud.msg.empty");
|
||||
currenttip.set(0, name);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!ConfigHandler.instance().getConfig("bc.tankamount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
FluidTankInfo tank = this.getTank(accessor);
|
||||
FluidStack stack = tank != null ? tank.fluid : null;
|
||||
int liquidAmount = stack != null ? stack.amount : 0;
|
||||
int capacity = tank != null ? tank.capacity : 0;
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(liquidAmount), formatFluid(capacity)));
|
||||
if (ConfigHandler.instance().getConfig("bc.tankamount")) currenttip.add(liquidAmount + "/" + capacity + " mB");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,26 +4,30 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ExtraUtilitiesModule {
|
||||
|
||||
public static Class<?> TileEntityDrum = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
Class.forName("com.rwtema.extrautils.ExtraUtils");
|
||||
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[ExtraUtilities] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new DrumFluidHandler(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.exu;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -18,7 +15,7 @@ import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class DrumFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -37,14 +34,18 @@ public class DrumFluidHandler implements IWailaDataProvider {
|
||||
|
||||
if (!config.getConfig("extrautilities.fluidamount")) return currenttip;
|
||||
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound subtag = accessor.getNBTData().getCompoundTag("tank");
|
||||
if (subtag.hasKey("Amount")) amount = accessor.getNBTInteger(subtag, "Amount");
|
||||
|
||||
IFluidHandler handler = (IFluidHandler) accessor.getTileEntity();
|
||||
if (handler == null) return currenttip;
|
||||
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
|
||||
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -58,6 +59,7 @@ public class DrumFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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";
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
+12
-9
@@ -1,8 +1,5 @@
|
||||
package mcp.mobius.waila.addons.openblocks;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -20,7 +17,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -40,10 +37,14 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
|
||||
FluidStack fluid = tanks[0].fluid;
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -59,8 +60,9 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
int amount = tanks[0].fluid == null ? 0 : tanks[0].fluid.amount;
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tanks[0].capacity)));
|
||||
if (tanks[0].fluid != null)
|
||||
currenttip.add(String.format("%d / %d mB", tanks[0].fluid.amount, tanks[0].capacity));
|
||||
else currenttip.add(String.format("0 / %d mB", tanks[0].capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -74,6 +76,7 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -4,29 +4,30 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class OpenBlocksModule {
|
||||
|
||||
public static Class<?> TileEntityTank = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
Class.forName("openblocks.OpenBlocks");
|
||||
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
try {
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[OpenBlocks] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileEntityTank);
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
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 static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class HUDFMPWires implements IWailaFMPProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("pr.showsignal")) return currenttip;
|
||||
|
||||
ITaggedList<String, String> tagList = (ITaggedList<String, String>) currenttip;
|
||||
int signal = ((NBTUtil.getNBTInteger(accessor.getNBTData(), "signal") & 0xff) + 16) / 17;
|
||||
if (tagList.getEntries("signal").isEmpty()) {
|
||||
tagList.add(String.format("%s : %s", LangUtil.translateG("hud.msg.power"), signal), "signal");
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public class ProjectRedModule {
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showio");
|
||||
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showdata");
|
||||
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showsignal");
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_sgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_igate");
|
||||
@@ -26,10 +25,6 @@ public class ProjectRedModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_bgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_agate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_rgate");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_redwire");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_insulated");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_fredwire");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPWires(), "pr_finsulated");
|
||||
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_sgate");
|
||||
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_igate");
|
||||
|
||||
+28
-30
@@ -1,7 +1,4 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
@@ -18,7 +16,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -28,24 +26,26 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.fluidtype")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
try {
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid.invoke(tileEntity);
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
FluidStack fluid = tank.getFluid();
|
||||
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -54,22 +54,19 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.fluidamount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(tileEntity);
|
||||
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(tileEntity);
|
||||
IFluidTank tank = (IFluidTank) RailcraftModule.ITankTile_getTank
|
||||
.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(capacity)));
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid != null) currenttip.add(String.format("%d / %d mB", fluid.amount, tank.getInfo().capacity));
|
||||
else currenttip.add(String.format("0 / %d mB", tank.getInfo().capacity));
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -84,6 +81,7 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,43 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class RailcraftModule {
|
||||
|
||||
public static Class<?> TileTankBase = null;
|
||||
public static Method TileTankBase_getTank = null;
|
||||
|
||||
public static Class<?> StandardTank = null;
|
||||
public static Field StandardTank_capacity = null;
|
||||
public static Field StandardTank_renderData = null;
|
||||
|
||||
public static Field StandardTank_renderDataFluid = null;
|
||||
public static Field StandardTank_renderDataAmount = null;
|
||||
public static Class<?> ITankTile = null;
|
||||
public static Method ITankTile_getTank = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
try {
|
||||
Class.forName("mods.railcraft.common.core.Railcraft");
|
||||
Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
|
||||
TileTankBase_getTank = TileTankBase.getMethod("getTank");
|
||||
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
|
||||
ITankTile_getTank = ITankTile.getMethod("getTank");
|
||||
|
||||
StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
|
||||
StandardTank_capacity = StandardTank.getSuperclass().getDeclaredField("capacity");
|
||||
StandardTank_capacity.setAccessible(true);
|
||||
StandardTank_renderData = StandardTank.getField("renderData");
|
||||
|
||||
StandardTank_renderDataFluid = StandardTank_renderData.getType().getField("fluid");
|
||||
StandardTank_renderDataAmount = StandardTank_renderData.getType().getField("amount");
|
||||
|
||||
Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e) {
|
||||
Waila.log.log(Level.WARN, "[Railcraft] Field not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTankBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTankBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTankBase);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankFluidHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
IFluidTank tank = this.getTank(accessor.getTileEntity());
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
IFluidTank tank = this.getTank(accessor.getTileEntity());
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
int amount = fluid == null ? 0 : fluid.amount;
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(tank.getCapacity())));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
private FluidTank getTank(TileEntity tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Object tank = RailcraftModule.TileTankBase_getTank.invoke(tileEntity);
|
||||
|
||||
int capacity = RailcraftModule.StandardTank_capacity.getInt(tank);
|
||||
Object renderData = RailcraftModule.StandardTank_renderData.get(tank);
|
||||
|
||||
Fluid fluid = (Fluid) RailcraftModule.StandardTank_renderDataFluid.get(renderData);
|
||||
int amount = RailcraftModule.StandardTank_renderDataAmount.getInt(renderData);
|
||||
|
||||
return new FluidTank(fluid, amount, capacity);
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package mcp.mobius.waila.addons.statues;
|
||||
|
||||
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 static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -81,8 +76,7 @@ public class HUDCargoManager implements IWailaDataProvider {
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All"
|
||||
: formatNumber(this.getAmount(amount)) + " " + this.getAmountType(amount);
|
||||
String sAmount = amount == 0 ? "All" : this.getAmount(amount) + " " + this.getAmountType(amount);
|
||||
|
||||
String selection = (String) StevesCartsModule.GetSelectionName
|
||||
.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -78,14 +73,13 @@ public class HUDLiquidManager implements IWailaDataProvider {
|
||||
fluidAmount = tag.getCompoundTag("Fluid" + i).getInteger("Amount");
|
||||
}
|
||||
|
||||
String fluidString = fluidAmount == 0 ? "<Empty>"
|
||||
: String.format("%s of %s", formatFluid(fluidAmount), fluidName);
|
||||
String fluidString = fluidAmount == 0 ? "<Empty>" : String.format("%s mB of %s", fluidAmount, fluidName);
|
||||
|
||||
if (color == 5) continue;
|
||||
|
||||
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
|
||||
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
|
||||
String sAmount = amount == 0 ? "All" : formatFluid(this.getMaxAmountBuckets(amount));
|
||||
String sAmount = amount == 0 ? "All" : this.getMaxAmountBuckets(amount) + " mB";
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -48,7 +43,7 @@ public class HUDMinecartModular implements IWailaEntityProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
Item ItemCartModule;
|
||||
Item ItemCartModule = null;
|
||||
try {
|
||||
ItemCartModule = (Item) StevesCartsModule.ItemCartModule.get(null);
|
||||
} catch (Exception e) {
|
||||
@@ -77,11 +72,12 @@ public class HUDMinecartModular implements IWailaEntityProvider {
|
||||
currenttip.add(
|
||||
new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB
|
||||
+ ALIGNRIGHT
|
||||
+ GRAY
|
||||
+ " [ "
|
||||
+ WHITE
|
||||
+ formatNumber(amount)
|
||||
+ " of "
|
||||
+ amount
|
||||
+ GRAY
|
||||
+ " mB of "
|
||||
+ WHITE
|
||||
+ fluid
|
||||
+ GRAY
|
||||
+ " ]");
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
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 static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -20,8 +17,6 @@ import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
|
||||
@@ -48,32 +43,15 @@ 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");
|
||||
int value = subtag.getInteger("value");
|
||||
total += value;
|
||||
String amount = String.valueOf(value);
|
||||
String amount = String.valueOf(subtag.getInteger("value"));
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
currenttip.addAll(unknownAspects);
|
||||
@@ -99,7 +77,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
|
||||
ItemStack headSlot = player.inventory.armorInventory[3];
|
||||
if (headSlot == null) return tag;
|
||||
boolean hasReveal = ThaumcraftModule.isGoggles.apply(headSlot);
|
||||
boolean hasReveal = ThaumcraftModule.IGoggles.isInstance(headSlot.getItem());
|
||||
if (!hasReveal) return tag;
|
||||
|
||||
Map<String, ?> knownAspects = (Map<String, ?>) ThaumcraftModule.CommonProxy_getKnownAspects
|
||||
@@ -120,7 +98,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_tag.get(o));
|
||||
cmptag.setString("key", (String) ThaumcraftModule.Aspect_getName.invoke(o));
|
||||
cmptag.setInteger("value", tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
} else {
|
||||
@@ -132,7 +110,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ReflectiveOperationException e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
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;
|
||||
|
||||
@@ -32,19 +28,12 @@ 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");
|
||||
@@ -64,18 +53,12 @@ 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);
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
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.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatFluid;
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class FluiductFluidHandler implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermaldynamics.fluiductsFluid")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluid"));
|
||||
int capacity = tag.getInteger("capacity");
|
||||
|
||||
if (capacity == 0) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluid"));
|
||||
int amount = fluid == null ? 0 : fluid.amount;
|
||||
int capacity = tag.getInteger("capacity");
|
||||
|
||||
if (capacity == 0) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
currenttip.add(String.format("%s / %s", formatNumber(amount), formatFluid(capacity)));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te instanceof IFluidHandler fluidHandler) {
|
||||
FluidTankInfo[] infos = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (infos.length != 1) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
FluidTankInfo info = infos[0];
|
||||
|
||||
if (info.fluid != null) {
|
||||
NBTTagCompound fluidNBT = info.fluid.writeToNBT(new NBTTagCompound());
|
||||
tag.setTag("fluid", fluidNBT);
|
||||
}
|
||||
|
||||
tag.setInteger("capacity", info.capacity);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
+27
-24
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,15 +7,17 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class TankModeHandler implements IWailaDataProvider {
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class HUDHandlerDuct implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -25,33 +27,33 @@ public class TankModeHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermaldynamics.fluiductsFluid")) return currenttip;
|
||||
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(accessor.getNBTData());
|
||||
|
||||
String name = "";
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.add(name);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
try {
|
||||
if (config.getConfig("thermalexpansion.tankmode")) {
|
||||
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
|
||||
if (mode == 0) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.GREEN + LangUtil.translateG("hud.msg.input")));
|
||||
} else if (mode == 1) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.RED + LangUtil.translateG("hud.msg.output")));
|
||||
}
|
||||
}
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) return currenttip;
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Amount")) amount = accessor.getNBTInteger(tag, "Amount");
|
||||
|
||||
currenttip.add(String.format(" %d / 1000 mB", amount));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ public class TankModeHandler implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -4,35 +4,31 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ThermalDynamicsModule {
|
||||
|
||||
public static Class<?> TileFluidDuct = null;
|
||||
|
||||
public static void register() {
|
||||
if (LoadedMods.WAILA_PLUGINS) {
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX : We register the Fluiduct
|
||||
try {
|
||||
TileFluidDuct = Class.forName("cofh.thermaldynamics.duct.fluid.TileFluidDuct");
|
||||
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
|
||||
return;
|
||||
TileFluidDuct = Class.forName("cofh.thermaldynamics.ducts.fluid.TileFluidDuct");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
|
||||
|
||||
FluiductFluidHandler fluiductFluidHandler = new FluiductFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerBodyProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerNBTProvider(fluiductFluidHandler, TileFluidDuct);
|
||||
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,17 +40,14 @@ public class HUDHandlerCache implements IWailaDataProvider {
|
||||
if (storedItem != null) {
|
||||
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
|
||||
name += String.format(
|
||||
" < %s %s >",
|
||||
SpecialChars.getRenderString(
|
||||
" < " + SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
namex,
|
||||
"0",
|
||||
String.valueOf(storedItem.getItemDamage())) + color,
|
||||
String.valueOf(storedItem.getItemDamage())) + color + " %s >",
|
||||
storedItem.getDisplayName());
|
||||
} else {
|
||||
name += " < " + LangUtil.translateG("hud.msg.empty") + " >";
|
||||
}
|
||||
} else name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
|
||||
currenttip.set(0, name);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -38,11 +36,11 @@ public class HUDHandlerEnergyCell implements IWailaDataProvider {
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s/%s : %s / %s RF/t",
|
||||
"%s/%s : %d / %d RF/t",
|
||||
LangUtil.translateG("hud.msg.in"),
|
||||
LangUtil.translateG("hud.msg.out"),
|
||||
formatNumber(energyReceive),
|
||||
formatNumber(energySend)));
|
||||
energyReceive,
|
||||
energySend));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
+8
-18
@@ -1,7 +1,5 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -15,7 +13,7 @@ import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
@@ -36,23 +34,15 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.energyhandler")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("Energy")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("MaxStorage")) return currenttip;
|
||||
|
||||
if (currenttip instanceof ITaggedList taggedTips) {
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
|
||||
if (maxEnergy > 0 && taggedTips.getEntries("RFEnergyStorage").isEmpty()) {
|
||||
if (config.getConfig("thermalexpansion.rfenergybar")) {
|
||||
taggedTips.add(
|
||||
SpecialChars.getRenderString("waila.rfenergy", energy + "", maxEnergy + ""),
|
||||
"RFEnergyStorage");
|
||||
} else {
|
||||
taggedTips.add(
|
||||
String.format("%s / %s RF", formatNumber(energy), formatNumber(maxEnergy)),
|
||||
"RFEnergyStorage");
|
||||
}
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
try {
|
||||
if ((maxEnergy != 0) && (((ITaggedList) currenttip).getEntries("RFEnergyStorage").size() == 0)) {
|
||||
((ITaggedList) currenttip).add(String.format("%d / %d RF", energy, maxEnergy), "RFEnergyStorage");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermalexpansion.fluidtype")) return currenttip;
|
||||
|
||||
try {
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid
|
||||
.invoke(accessor.getTileEntity());
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try {
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f) {
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
try {
|
||||
if (config.getConfig("thermalexpansion.fluidamount")) {
|
||||
int amount = 0;
|
||||
if (accessor.getNBTData().hasKey("Amount"))
|
||||
amount = accessor.getNBTInteger(accessor.getNBTData(), "Amount");
|
||||
|
||||
Integer capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity
|
||||
.invoke(accessor.getTileEntity());
|
||||
|
||||
currenttip.add(String.format("%d / %d mB", amount, capacity));
|
||||
}
|
||||
|
||||
if (config.getConfig("thermalexpansion.tankmode")) {
|
||||
Byte mode = (Byte) ThermalExpansionModule.TileTank_mode.get(accessor.getTileEntity());
|
||||
if (mode == 0) currenttip.add(
|
||||
String.format(
|
||||
"%s : \u00a7a%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
LangUtil.translateG("hud.msg.input")));
|
||||
else if (mode == 1) currenttip.add(
|
||||
String.format(
|
||||
"%s : \u00a7c%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
LangUtil.translateG("hud.msg.output")));
|
||||
else currenttip.add(String.format("Mode : Unknown (%d)", mode));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(te);
|
||||
tag.setInteger("Amount", amount);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class HUDHandlerTesseract implements IWailaDataProvider {
|
||||
@@ -34,9 +33,9 @@ public class HUDHandlerTesseract implements IWailaDataProvider {
|
||||
if (config.getConfig("thermalexpansion.tesssendrecv")) {
|
||||
String send = String.format("%s : ", LangUtil.translateG("hud.msg.send"));
|
||||
String recv = String.format("%s : ", LangUtil.translateG("hud.msg.recv"));
|
||||
String item = String.format("%s ", SpecialChars.GREEN + LangUtil.translateG("hud.msg.item"));
|
||||
String fluid = String.format("%s ", SpecialChars.BLUE + LangUtil.translateG("hud.msg.fluid"));
|
||||
String energ = String.format("%s ", SpecialChars.RED + LangUtil.translateG("hud.msg.energ"));
|
||||
String item = String.format("\u00a7a%s ", LangUtil.translateG("hud.msg.item"));
|
||||
String fluid = String.format("\u00a79%s ", LangUtil.translateG("hud.msg.fluid"));
|
||||
String energ = String.format("\u00a7c%s ", LangUtil.translateG("hud.msg.energ"));
|
||||
|
||||
switch (accessor.getNBTInteger(accessor.getNBTData(), "Item.Mode")) {
|
||||
case 0:
|
||||
|
||||
+54
-51
@@ -9,7 +9,6 @@ import org.apache.logging.log4j.Level;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ThermalExpansionModule {
|
||||
|
||||
@@ -68,7 +67,6 @@ public class ThermalExpansionModule {
|
||||
IEnergyInfo_getCurStorage = IEnergyInfo.getMethod("getInfoEnergyStored");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.rfenergybar");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyReceiver);
|
||||
@@ -76,11 +74,13 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
printedThermalExpansionNotFound = true;
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
printedThermalExpansionNotFound = true;
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the energy cell
|
||||
@@ -93,43 +93,41 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the Tank interface
|
||||
try {
|
||||
TileTank = Class.forName("cofh.thermalexpansion.block.tank.TileTank");
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
TileTank_mode = TileTank.getField("mode");
|
||||
|
||||
if (!LoadedMods.WAILA_PLUGINS) {
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
|
||||
TankFluidHandler tankFluidHandler = new TankFluidHandler();
|
||||
ModuleRegistrar.instance().registerHeadProvider(tankFluidHandler, TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(tankFluidHandler, TileTank);
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new TankModeHandler(), TileTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTank);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the Tesseract interface
|
||||
@@ -144,13 +142,15 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the ISecureTile interface
|
||||
@@ -163,13 +163,15 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the Cache interface
|
||||
@@ -184,15 +186,16 @@ public class ThermalExpansionModule {
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCache(), TileCache);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCache(), TileCache);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
if (e instanceof ClassNotFoundException) {
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
printedThermalExpansionNotFound = true;
|
||||
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
|
||||
}
|
||||
} else {
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!printedThermalExpansionNotFound) {
|
||||
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
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,29 +2,21 @@ package mcp.mobius.waila.addons.vanillamc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.utils.ColorUtils;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
|
||||
public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
|
||||
static Block furanace = Blocks.furnace;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
@@ -39,68 +31,45 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
NBTTagList items = accessor.getNBTData().getTagList("Items", 10);
|
||||
String itemsText = "";
|
||||
ItemStack inputStack = null;
|
||||
ItemStack fuelStack = null;
|
||||
ItemStack outputStack = null;
|
||||
int cookTime = accessor.getNBTData().getShort("CookTime");
|
||||
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
|
||||
|
||||
int smeltTime = tag.getInteger("Smelt");
|
||||
int fuelTime = tag.getInteger("Fuel");
|
||||
int maxFuelTime = tag.getInteger("MaxFuel");
|
||||
|
||||
double smeltProgress = (double) smeltTime / 200;
|
||||
double fuelProgress = (double) fuelTime / maxFuelTime;
|
||||
|
||||
for (int i = 0; i < items.tagCount(); i++) {
|
||||
NBTTagCompound itemTag = items.getCompoundTagAt(i);
|
||||
byte slot = itemTag.getByte("Slot");
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag);
|
||||
|
||||
if (slot == 0) {
|
||||
inputStack = stack;
|
||||
} else if (slot == 1) {
|
||||
fuelStack = stack;
|
||||
} else if (slot == 2) {
|
||||
outputStack = stack;
|
||||
}
|
||||
String renderStr = "";
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(1));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
if (fuelProgress > 0) {
|
||||
String fuelBar = TTRenderBar.create(
|
||||
String.format("Fuel %ds / %ds", (maxFuelTime - fuelTime) / 20, maxFuelTime / 20),
|
||||
ColorUtils.fuelFurnaceBarTop.getColor(),
|
||||
ColorUtils.fuelFurnaceBarBottom.getColor(),
|
||||
1.0 - fuelProgress);
|
||||
currenttip.add(fuelBar);
|
||||
renderStr += SpecialChars.getRenderString("waila.progress", String.valueOf(cookTime), String.valueOf(200));
|
||||
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
if (smeltProgress > 0) {
|
||||
String cookBar = TTRenderBar.create(
|
||||
String.format("Smelt %ds / %ds", smeltTime / 20, 200 / 20),
|
||||
ColorUtils.progressBarTop.getColor(),
|
||||
ColorUtils.progressBarBottom.getColor(),
|
||||
smeltProgress);
|
||||
currenttip.add(cookBar);
|
||||
}
|
||||
|
||||
if (inputStack != null) {
|
||||
itemsText += TTRenderStack.create(inputStack, inputStack.stackSize);
|
||||
}
|
||||
|
||||
if (fuelStack != null) {
|
||||
itemsText += TTRenderStack.create(fuelStack, fuelStack.stackSize);
|
||||
}
|
||||
|
||||
if (outputStack != null) {
|
||||
if (inputStack != null || fuelStack != null) {
|
||||
itemsText += TTRenderProgressBar.create(0, 1);
|
||||
}
|
||||
itemsText += TTRenderStack.create(outputStack, outputStack.stackSize);
|
||||
}
|
||||
|
||||
currenttip.add(itemsText);
|
||||
currenttip.add(renderStr);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -114,19 +83,9 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te instanceof TileEntityFurnace furnace) {
|
||||
tag.setInteger("Smelt", furnace.furnaceCookTime);
|
||||
tag.setInteger("Fuel", furnace.furnaceBurnTime);
|
||||
tag.setInteger("MaxFuel", furnace.currentItemBurnTime);
|
||||
te.writeToNBT(tag);
|
||||
}
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
IWailaDataProvider provider = new HUDHandlerFurnace();
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, furanace.getClass());
|
||||
ModuleRegistrar.instance().registerNBTProvider(provider, furanace.getClass());
|
||||
}
|
||||
public static void register() {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
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,4 +49,6 @@ public interface IWailaDataAccessor {
|
||||
ForgeDirection getSide();
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
float getBlockBreakDamage();
|
||||
}
|
||||
@@ -62,35 +62,6 @@ 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.Dimension;
|
||||
import java.awt.*;
|
||||
|
||||
public interface IWailaTooltipRenderer {
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
/**
|
||||
* Interface for tooltip renderers that adjust their width depending on the width of the rest of the tooltip.
|
||||
* setMaxLineWidth is called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render to inform the
|
||||
* renderer of the width of the longest line in the tooltip.
|
||||
*/
|
||||
public interface IWailaVariableWidthTooltipRenderer extends IWailaTooltipRenderer {
|
||||
|
||||
/**
|
||||
* Return the size of the tooltip. for variable width renderers it is recommended to return the minimum width needed
|
||||
* for the line, then draw the actual width using getMaxLineWidth(). They do not need to actually match.
|
||||
*
|
||||
* @param params Array of string parameters as passed to the RENDER arg in the tooltip
|
||||
* ({rendername,param1,param2,...})
|
||||
* @param accessor A global accessor for TileEntities and Entities
|
||||
* @return Dimension of the reserved area
|
||||
*/
|
||||
Dimension getSize(String[] params, IWailaCommonAccessor accessor);
|
||||
|
||||
/**
|
||||
* Informs the renderer of what the length of the longest line is.</br>
|
||||
* Called by {@link mcp.mobius.waila.overlay.Tooltip} before every tooltip render.</br>
|
||||
*
|
||||
* @param width The width of the longest line in the tooltip.
|
||||
*
|
||||
*/
|
||||
void setMaxLineWidth(int width);
|
||||
|
||||
/**
|
||||
* Returns the width of the longest line in the current tooltip.</br>
|
||||
* With icons disabled the tooltip's background box is always 2 pixels wider to the right of the line than it is to
|
||||
* the left.</br>
|
||||
*
|
||||
* @return The width of the longest line in the tooltip
|
||||
*
|
||||
*/
|
||||
int getMaxLineWidth();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
public enum NumberFormat {
|
||||
|
||||
FULL,
|
||||
COMPACT,
|
||||
COMMAS,
|
||||
NONE;
|
||||
|
||||
private NumberFormat() {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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,7 +33,6 @@ public class SpecialChars {
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
public static String WailaRenderer = "\u00A6";
|
||||
public static String WailaRendererComma = "\u0082";
|
||||
public static String TAB = WailaStyle + WailaStyle + "a";
|
||||
public static String ALIGNRIGHT = WailaStyle + WailaStyle + "b";
|
||||
public static String ALIGNCENTER = WailaStyle + WailaStyle + "c";
|
||||
@@ -44,19 +43,12 @@ public class SpecialChars {
|
||||
|
||||
public static final Pattern patternMinecraft = Pattern.compile("(?i)" + MCStyle + "[0-9A-FK-OR]");
|
||||
public static final Pattern patternWaila = Pattern.compile("(?i)(" + WailaStyle + "(?<type>..))");
|
||||
// (?i)(¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\})
|
||||
public static final Pattern patternRender = Pattern.compile(
|
||||
"(?i)(" + RENDER
|
||||
+ "\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\})");
|
||||
public static final Pattern patternRender = Pattern
|
||||
.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<args>[^}]*)\\})");
|
||||
public static final Pattern patternTab = Pattern.compile("(?i)" + TAB);
|
||||
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
|
||||
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
|
||||
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9a-z]))");
|
||||
// (?i)(¤¤[^¤]+|¤¥[0-9A-Z]|¤¦a\{(?<name>[^U+0082}]*)U+0082?(?<args>[^}]*)\}|[^¤]+)
|
||||
public static final Pattern patternLineSplit = Pattern.compile(
|
||||
"(?i)(" + WailaStyle
|
||||
+ WailaStyle
|
||||
@@ -68,11 +60,7 @@ public class SpecialChars {
|
||||
+ "[0-9A-Z]|"
|
||||
+ WailaStyle
|
||||
+ WailaRenderer
|
||||
+ "a\\{(?<name>[^"
|
||||
+ WailaRendererComma
|
||||
+ "}]*)"
|
||||
+ WailaRendererComma
|
||||
+ "?(?<args>[^}]*)\\}|[^"
|
||||
+ "a\\{([^,}]*),?([^}]*)\\}|[^"
|
||||
+ WailaStyle
|
||||
+ "]+)");
|
||||
|
||||
@@ -83,7 +71,7 @@ public class SpecialChars {
|
||||
public static String getRenderString(String name, String... params) {
|
||||
StringBuilder result = new StringBuilder(RENDER + "{" + name);
|
||||
for (String s : params) {
|
||||
result.append(WailaRendererComma).append(s);
|
||||
result.append(",").append(s);
|
||||
}
|
||||
result.append("}");
|
||||
return result.toString();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package mcp.mobius.waila.api.elements;
|
||||
|
||||
public enum ElementAlignment {
|
||||
ALIGN_TOPLEFT,
|
||||
ALIGN_CENTER,
|
||||
ALIGN_BOTTOMRIGHT
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package mcp.mobius.waila.api.elements;
|
||||
|
||||
public interface IElement {
|
||||
|
||||
void render(int var1, int var2);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package mcp.mobius.waila.api.elements;
|
||||
|
||||
public interface IItemStyle {
|
||||
|
||||
IItemStyle width(int var1);
|
||||
|
||||
IItemStyle height(int var1);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package mcp.mobius.waila.api.elements;
|
||||
|
||||
public interface IProbeRegistrar {
|
||||
|
||||
void registerProbeProvider(IProbeDataProvider dataProvider, Class<?> block);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
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,10 +134,6 @@ 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) {
|
||||
@@ -149,7 +145,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_SHOWICON, true);
|
||||
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false);
|
||||
|
||||
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,6 +1,7 @@
|
||||
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;
|
||||
@@ -21,6 +22,8 @@ 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;
|
||||
@@ -37,6 +40,7 @@ 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);
|
||||
@@ -55,6 +59,7 @@ 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) {}
|
||||
@@ -200,6 +205,11 @@ 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 {
|
||||
|
||||
public static final DataAccessorFMP instance = new DataAccessorFMP();
|
||||
String id;
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
TileEntity entity;
|
||||
NBTTagCompound partialNBT = null;
|
||||
NBTTagCompound remoteNBT = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
|
||||
private String id;
|
||||
private World world;
|
||||
private EntityPlayer player;
|
||||
private MovingObjectPosition mop;
|
||||
private Vec3 renderingvec;
|
||||
private TileEntity tileEntity;
|
||||
private NBTTagCompound partialNBT;
|
||||
private double partialFrame;
|
||||
|
||||
private DataAccessorFMP() {}
|
||||
public static DataAccessorFMP instance = new DataAccessorFMP();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT,
|
||||
String id) {
|
||||
@@ -35,24 +35,13 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.partialNBT = _partialNBT;
|
||||
this.id = id;
|
||||
this.renderingvec = renderVec;
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
id = null;
|
||||
world = null;
|
||||
player = null;
|
||||
mop = null;
|
||||
renderingvec = null;
|
||||
tileEntity = null;
|
||||
partialNBT = null;
|
||||
partialFrame = 0.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
@@ -65,7 +54,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.tileEntity;
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,9 +69,12 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getFullNBTData() {
|
||||
if (this.tileEntity == null) return null;
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNBT)) return this.remoteNBT;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -106,4 +98,20 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag) {
|
||||
if (tag == null) {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,23 @@ 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 {
|
||||
@@ -69,7 +68,9 @@ public class MetaDataProvider {
|
||||
|
||||
if (accessor.getTileEntity() != null && Waila.instance.serverPresent
|
||||
&& accessor.isTimeElapsed(250)
|
||||
&& ConfigHandler.instance().showTooltip()) {
|
||||
&& ConfigHandler.instance().showTooltip()
|
||||
&& ConfigHandler.instance()
|
||||
.getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FORCE_LEGACY_MODE, false)) {
|
||||
accessor.resetTimer();
|
||||
HashSet<String> keys = new HashSet<>();
|
||||
|
||||
@@ -81,7 +82,8 @@ public class MetaDataProvider {
|
||||
|
||||
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTProviders(block)
|
||||
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
|
||||
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
|
||||
WailaPacketHandler.INSTANCE
|
||||
.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys, false));
|
||||
|
||||
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent
|
||||
&& accessor.isTimeElapsed(250)
|
||||
@@ -149,29 +151,11 @@ 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,24 +4,11 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
|
||||
import au.com.bytecode.opencsv.CSVReader;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.IWailaFMPDecorator;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.IWailaSummaryProvider;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.*;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
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,14 +7,12 @@ 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 {
|
||||
|
||||
@@ -23,7 +21,6 @@ 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
|
||||
@@ -36,49 +33,47 @@ 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
|
||||
public void onKeyEvent(KeyInputEvent event) {
|
||||
boolean showKey = key_show.isPressed();
|
||||
if (key_cfg.isPressed()) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.currentScreen == null) {
|
||||
mc.displayGuiScreen(new ScreenConfig(null));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (showKey && ConfigHandler.instance()
|
||||
} else if (key_show.isPressed() && 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);
|
||||
} 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);
|
||||
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 (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);
|
||||
}
|
||||
if (key_show.isPressed() && !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) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,9 @@ 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;
|
||||
@@ -15,16 +17,10 @@ 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.tooltiprenderers.TTRenderAspectString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderRFBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ProxyClient extends ProxyServer {
|
||||
|
||||
@@ -37,8 +33,13 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
LangUtil.loadLangDir("waila");
|
||||
|
||||
if (LoadedMods.NEI) {
|
||||
NEIHandler.register();
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
|
||||
}
|
||||
@@ -56,12 +57,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.bar", new TTRenderBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.rfenergy", new TTRenderRFBar());
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.tcaspect", new TTRenderAspectString());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new WorldUnloadEventHandler());
|
||||
}
|
||||
@@ -77,9 +73,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
if (event.world.isRemote) {
|
||||
DataAccessorCommon.instance = new DataAccessorCommon();
|
||||
}
|
||||
DataAccessorCommon.instance = new DataAccessorCommon();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
|
||||
public class WailaGuiFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return ScreenConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,7 @@ 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.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.interfaces.*;
|
||||
import mcp.mobius.waila.gui.screens.ScreenBase;
|
||||
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
|
||||
import mcp.mobius.waila.gui.widgets.LayoutBase;
|
||||
|
||||
@@ -2,7 +2,10 @@ 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;
|
||||
@@ -19,9 +22,27 @@ 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));
|
||||
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().getWidget("ButtonContainer").setGeometry(
|
||||
new WidgetGeometry(0.0, 20.0, 100.0, 60.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
|
||||
new WidgetGeometry(0.0, 20.0, 100.0, 200.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
|
||||
|
||||
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel) this.getRoot().getWidget("ButtonContainer"));
|
||||
|
||||
|
||||
Loaded 100 of 148 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user