Compare commits

...
11 Commits
Author SHA1 Message Date
Martin Robertz a767b0f922 update 2024-02-22 13:21:43 +01:00
connor135246 61f8fbe1ce Fix vanilla Anvils, Saplings, and Slabs (#18)
* Fix Anvil display

* Fix growth stage 1 Saplings

* Fix top slabs and "smooth" double slabs

* comment on modded anvils

* spotless apply

* Only fix vanilla anvil

modded anvils can do it themselves

* Simplify

Thinking about this, I don't think there's a need to worry about the smooth double slabs.
There's a few reasons:
These blocks can only be obtained with commands. The only one this actually matters for is the sandstone one (43:9), since that's the only one that is visually different as well as has the wrong name. Holding 43:9 in your inventory will still have the wrong name anyway. Mods that add the modern minecraft ways of accessing these blocks create their own versions instead of using the old ones.
2024-02-22 11:33:30 +01:00
Raven Szewczyk a8a49f2b6e [ci skip] upgraded build system 2024-02-04 20:02:54 +00:00
Martin Robertz bf7cc86247 update bs+deps 2024-01-12 21:23:08 +01:00
Raven Szewczyk d6650f6cc4 [ci skip] upgraded build system 2024-01-08 21:30:25 +00:00
tth05 bc46b8840d Convert world unload event handler to public inner class (#17) 2023-11-17 20:39:34 +01:00
tth05 7d72e0680e Clear DataAccessorCommon instance when leaving world (#16) 2023-11-17 15:43:10 +01:00
Martin Robertz ee237c3a44 update deps+bs 2023-11-16 11:03:17 +01:00
tth05 4c4cb95782 Remove unnecessary targetStack and targetEntity fields in RayTracing class 2023-11-16 10:01:36 +01:00
Martin Robertz 9698692020 Cleanup (#14)
* update gradle+deps

* remove bak file
clean wci

* add back

* sa
2023-10-18 18:34:53 +02:00
ghostflyby e7524e80f1 Move font init to getter with guard if (#13)
* Move font init to getter with guard if

* update bs
2023-10-18 13:50:55 +02:00
49 changed files with 291 additions and 3902 deletions

No files matched your search

+2 -1492
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.48-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.19-GTNH:dev')
shadowImplementation('au.com.bytecode:opencsv:2.4')
}
+153 -24
View File
@@ -1,63 +1,192 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Waila
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = Waila
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = mcp.mobius.waila
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = Waila.java
gradleTokenModId =
gradleTokenModName =
# 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 = false
# 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.
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = Waila.java
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# 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.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# 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.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+17 -12
View File
@@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# 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" \
Vendored
+10 -10
View File
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
+5 -10
View File
@@ -4,10 +4,10 @@ pluginManagement {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
@@ -17,12 +17,7 @@ pluginManagement {
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
@@ -1,6 +1,9 @@
package mcp.mobius.waila.addons.enderio;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.RESET;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,8 @@
package mcp.mobius.waila.addons.enderio;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.RESET;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,87 +0,0 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import mcp.mobius.waila.cbcore.LangUtil;
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.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEBaseGenerator 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) {
try{
int storage = -1;
int production = -1;
if (IC2Module.TileEntityBaseGenerator.isInstance(accessor.getTileEntity())){
storage = IC2Module.TEBG_MaxStorage.getShort(accessor.getTileEntity());
production = IC2Module.TEBG_Production.getInt(accessor.getTileEntity());
}
else if (IC2Module.TileEntityGeoGenerator.isInstance(accessor.getTileEntity())){
storage = IC2Module.TEGG_MaxStorage.getShort(accessor.getTileEntity());
production = IC2Module.TEGG_Production.getInt(accessor.getTileEntity());
}
else if (IC2Module.TileEntitySemifluidGenerator.isInstance(accessor.getTileEntity())){
storage = IC2Module.TESG_MaxStorage.getShort(accessor.getTileEntity());
production = (int)IC2Module.TESG_Production.getDouble(accessor.getTileEntity());
}
String storedStr = LangUtil.translateG("hud.msg.stored");
String outputStr = LangUtil.translateG("hud.msg.output");
/* EU Storage */
if (ConfigHandler.instance().getConfig("ic2.storage")){
double stored = IC2Module.getStoredEnergy(accessor);
if ( stored >= 0.0 && storage > 0)
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
//else if (stored >= 0.0)
// currenttip.add(String.format("Stored : %d EU", stored));
}
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
if ( production > 0)
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
}
} 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(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te != null)
te.writeToNBT(tag);
return tag;
}
}
@@ -1,72 +0,0 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import mcp.mobius.waila.cbcore.LangUtil;
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.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor,
IWailaConfigHandler config) {
// TODO Auto-generated method stub
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) {
try{
String storedStr = LangUtil.translateG("hud.msg.stored");
String outputStr = LangUtil.translateG("hud.msg.output");
/* EU Storage */
if (ConfigHandler.instance().getConfig("ic2.storage")){
double stored = IC2Module.getStoredEnergy(accessor);
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
if ( stored >= 0.0 )
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
}
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
if ( production > 0)
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
}
} 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(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te != null)
te.writeToNBT(tag);
return tag;
}
}
@@ -1,6 +1,7 @@
package mcp.mobius.waila.addons.ic2;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import java.util.List;
@@ -1,92 +0,0 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import mcp.mobius.waila.cbcore.LangUtil;
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.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor,
IWailaConfigHandler config) {
// TODO Auto-generated method stub
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) {
try{
IC2Upgrades upgrades = IC2Module.getUpgrades(accessor);
int baseConsumption = IC2Module.TESM_DefaultEnergyConsume.getInt(accessor.getTileEntity());
int baseOpTime = IC2Module.TESM_DefaultOperationLength.getInt(accessor.getTileEntity());
int baseStorage = IC2Module.TESM_DefaultEnergyStorage.getInt(accessor.getTileEntity());
long consumption = Math.round(Math.min(baseConsumption * Math.pow(1.6D, upgrades.overclocker), 2147483647));
double stackOpLen = baseOpTime * 64.0D * Math.pow(0.7D, upgrades.overclocker);
int opPerTick = ((int)Math.min(Math.ceil(64.0D / stackOpLen), 2147483647.0D));
int opTime = ((int)Math.round(stackOpLen * opPerTick / 64.0D));
int storage = Math.round(Math.min(baseStorage + 10000 * upgrades.storage + opTime * consumption, 2147483647));;
int maxinput = (Integer)IC2Module.IES_GetMaxSafeInput.invoke(accessor.getTileEntity()) * (int)Math.pow(4.0D, Math.min(4, upgrades.transform));
double stored = IC2Module.getStoredEnergy(accessor);
String storedStr = LangUtil.translateG("hud.msg.stored");
String powerStr = LangUtil.translateG("hud.msg.power");
String maxPowerStr = LangUtil.translateG("hud.msg.maxpower");
/* EU Storage */
if (ConfigHandler.instance().getConfig("ic2.storage")){
if ( stored >= 0.0 )
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
}
if (ConfigHandler.instance().getConfig("ic2.consump")){
if ( consumption > 0)
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", powerStr, TAB + ALIGNRIGHT, consumption ));
}
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
if ( maxinput > 0)
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", maxPowerStr, TAB + ALIGNRIGHT, maxinput ));
}
} 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(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te != null)
te.writeToNBT(tag);
return tag;
}
}
@@ -1,68 +0,0 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import mcp.mobius.waila.cbcore.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
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.api.impl.ConfigHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTETradeOMat 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 (!ConfigHandler.instance().getConfig("ic2.tradeomat")) return currenttip;
NBTTagCompound slots = accessor.getNBTData().getCompoundTag("InvSlots");
NBTTagList offer = slots.getCompoundTag("offer").getTagList("Contents");
NBTTagList demand = slots.getCompoundTag("demand").getTagList("Contents");
String offersStr = LangUtil.translateG("hud.msg.offers");
String demandsStr = LangUtil.translateG("hud.msg.demands");
if (offer.tagCount() == 1){
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
}
if (demand.tagCount() == 1){
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
}
*/
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
if (te != null)
te.writeToNBT(tag);
return tag;
}
}
@@ -1,186 +0,0 @@
package mcp.mobius.waila.addons.ic2;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.logging.Level;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.AccessHelper;
public class IC2Module {
public static Class TileEntityStandardMachine = null;
public static Field TESM_DefaultEnergyStorage = null;
public static Field TESM_DefaultEnergyConsume = null;
public static Field TESM_DefaultOperationLength = null;
public static Field TESM_MaxEnergy = null;
public static Class TileEntityBaseGenerator = null;
public static Field TEBG_MaxStorage = null;
public static Field TEBG_Production = null;
public static Class TileEntitySemifluidGenerator = null;
public static Field TESG_MaxStorage = null;
public static Field TESG_Production = null;
public static Class TileEntityGeoGenerator = null;
public static Field TEGG_MaxStorage = null;
public static Field TEGG_Production = null;
public static Class TileEntityElectricBlock = null;
public static Field TEEB_MaxStorage = null;
public static Field TEEB_Output = null;
public static Class IEnergySink = null;
public static Method IES_GetMaxSafeInput = null;
public static Class TileEntityTradeOMat = null;
/* Some required items */
public static Class IC2Items = null;
public static Field TransformerUpgrade = null;
public static ItemStack TransformerUpgradeStack = null;
public static Field EnergyStorageUpgrade = null;
public static ItemStack EnergyStorageUpgradeStack = null;
public static Field OverclockerUpgrade = null;
public static ItemStack OverclockerUpgradeStack = null;
public static void register(){
/*
try{
TileEntityStandardMachine = Class.forName("ic2.core.block.machine.tileentity.TileEntityStandardMachine");
TESM_DefaultEnergyStorage = TileEntityStandardMachine.getField("defaultEnergyStorage");
TESM_DefaultEnergyConsume = TileEntityStandardMachine.getField("defaultEnergyConsume");
TESM_DefaultOperationLength = TileEntityStandardMachine.getField("defaultOperationLength");
TESM_MaxEnergy = TileEntityStandardMachine.getField("maxEnergy");
TileEntityBaseGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityBaseGenerator");
TEBG_MaxStorage = TileEntityBaseGenerator.getField("maxStorage");
TEBG_Production = TileEntityBaseGenerator.getField("production");
TileEntitySemifluidGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator");
TESG_MaxStorage = TileEntitySemifluidGenerator.getDeclaredField("maxStorage");
TESG_Production = TileEntitySemifluidGenerator.getDeclaredField("production");
TESG_MaxStorage.setAccessible(true);
TESG_Production.setAccessible(true);
TileEntityGeoGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityGeoGenerator");
TEGG_MaxStorage = TileEntityGeoGenerator.getField("maxStorage");
TEGG_Production = TileEntityGeoGenerator.getField("production");
TileEntityElectricBlock = Class.forName("ic2.core.block.wiring.TileEntityElectricBlock");
TEEB_MaxStorage = TileEntityElectricBlock.getField("maxStorage");
TEEB_Output = TileEntityElectricBlock.getField("output");
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
IES_GetMaxSafeInput = IEnergySink.getMethod("getMaxSafeInput");
IC2Items = Class.forName("ic2.core.Ic2Items");
TransformerUpgrade = IC2Items.getField("transformerUpgrade");
EnergyStorageUpgrade = IC2Items.getField("energyStorageUpgrade");
OverclockerUpgrade = IC2Items.getField("overclockerUpgrade");
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
OverclockerUpgradeStack = (ItemStack)OverclockerUpgrade.get(null);
TileEntityTradeOMat = Class.forName("ic2.core.block.personal.TileEntityTradeOMat");
} catch (ClassNotFoundException e){
//e.printStackTrace();
Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
//e.printStackTrace();
Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
return;
} catch (NoSuchFieldException e){
//e.printStackTrace();
Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
return;
} catch (Exception e){
//e.printStackTrace();
Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
ModuleRegistrar.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStandardMachine);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityBaseGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntitySemifluidGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityGeoGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityElectricBlock);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTradeOMat);
*/
}
/* Retuns the current stored energy if available in the nbt and config is true */
public static double getStoredEnergy(IWailaDataAccessor accessor){
/*
if (ConfigHandler.instance().getConfig("ic2.storage")){
if (accessor.getNBTData().hasKey("energy"))
return accessor.getNBTData().getDouble("energy");
else if (accessor.getNBTData().hasKey("storage"))
return accessor.getNBTData().getDouble("storage");
}
*/
return -1.0;
}
public static IC2Upgrades getUpgrades(IWailaDataAccessor accessor){
NBTTagCompound nbt = accessor.getNBTData();
IC2Upgrades upgrades = new IC2Upgrades();
/*
if (!nbt.hasKey("InvSlots")) return null;
NBTTagCompound inventory = nbt.getCompoundTag("InvSlots");
if (!inventory.hasKey("upgrade")) return null;
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
for (Object subobj : tagList){
NBTTagCompound subtag = (NBTTagCompound)subobj;
int id = subtag.getShort("id");
int meta = subtag.getShort("Damage");
int count = subtag.getByte("Count");
//ItemStack is = new ItemStack(id, 1, count);
if (TransformerUpgradeStack.getItemDamage() == meta && TransformerUpgradeStack.itemID == id)
upgrades.transform += count;
if (EnergyStorageUpgradeStack.getItemDamage() == meta && EnergyStorageUpgradeStack.itemID == id)
upgrades.storage += count;
if (OverclockerUpgradeStack.getItemDamage() == meta && OverclockerUpgradeStack.itemID == id)
upgrades.overclocker += count;
}
*/
return upgrades;
}
}
@@ -1,7 +0,0 @@
package mcp.mobius.waila.addons.ic2;
public class IC2Upgrades {
public int transform = 0;
public int storage = 0;
public int overclocker = 0;
}
@@ -1,6 +1,9 @@
package mcp.mobius.waila.addons.projectred;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,8 @@
package mcp.mobius.waila.addons.statues;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.BLUE;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,10 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.ArrayList;
import java.util.List;
@@ -1,6 +1,10 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,10 @@
package mcp.mobius.waila.addons.stevescarts;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.List;
@@ -1,6 +1,8 @@
package mcp.mobius.waila.addons.thaumcraft;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.TAB;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -4,6 +4,8 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneOre;
import net.minecraft.block.BlockStoneSlab;
import net.minecraft.block.BlockWoodSlab;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -44,6 +46,8 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
static Block log = Blocks.log;
static Block log2 = Blocks.log2;
static Block quartz = Blocks.quartz_block;
static Block anvil = Blocks.anvil;
static Block sapling = Blocks.sapling;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -96,6 +100,18 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return new ItemStack(block, 1, 2);
}
if (block == anvil) {
return new ItemStack(block, 1, block.damageDropped(accessor.getMetadata()));
}
if (block == sapling) {
return new ItemStack(block, 1, block.damageDropped(accessor.getMetadata()));
}
if (block instanceof BlockStoneSlab || block instanceof BlockWoodSlab) {
return new ItemStack(block, 1, block.damageDropped(accessor.getMetadata()));
}
return null;
}
@@ -245,6 +261,10 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
ModuleRegistrar.instance().registerStackProvider(provider, log.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, log2.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, quartz.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, anvil.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, sapling.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, BlockStoneSlab.class);
ModuleRegistrar.instance().registerStackProvider(provider, BlockWoodSlab.class);
// ModuleRegistrar.instance().registerStackProvider(provider, Block.class);
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawner.getClass());
@@ -1,8 +1,5 @@
package mcp.mobius.waila.api;
import static mcp.mobius.waila.api.SpecialChars.RENDER;
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
import java.util.regex.Pattern;
public class SpecialChars {
@@ -212,5 +212,4 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
public String getBlockQualifiedName() {
return this.blockResource;
}
}
@@ -4,9 +4,12 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.DataAccessorCommon;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.gui.truetyper.FontLoader;
@@ -32,8 +35,6 @@ public class ProxyClient extends ProxyServer {
LangUtil.loadLangDir("waila");
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
// TickRegistry.registerTickHandler(WailaTickHandler.instance(), Side.CLIENT);
if (Loader.isModLoaded("NotEnoughItems")) {
@@ -63,11 +64,22 @@ public class ProxyClient extends ProxyServer {
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
MinecraftForge.EVENT_BUS.register(new WorldUnloadEventHandler());
}
@Override
public Object getFont() {
if (minecraftiaFont == null)
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
return this.minecraftiaFont;
}
public static class WorldUnloadEventHandler {
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
DataAccessorCommon.instance = new DataAccessorCommon();
}
}
}
@@ -1,235 +0,0 @@
package mcp.mobius.waila.gui_old;
import java.util.Collection;
import java.util.HashMap;
import org.lwjgl.input.Mouse;
import mcp.mobius.waila.gui_old.widget.IWidget;
import mcp.mobius.waila.gui_old.widget_old.Button2States;
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
public class BaseWailaScreen extends GuiScreen{
protected GuiScreen parentGui; // GUI we will return to in the case we are call from a GUI
public ScaledResolution res;
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
/* Custom mouse handling */
private int lastMouseButton = -1;
private long lastMouseEvent = -1;
private int lastMousePosX = -1;
private int lastMousePosY = -1;
private static int buttonCount = Mouse.getButtonCount();
private boolean[] lastButtonStates = new boolean[buttonCount];
private IWidget[] focusWidget = new IWidget[buttonCount];
private IWidget mainFocusWidget = null;
public BaseWailaScreen(GuiScreen _parentGui) {
this.parentGui = _parentGui;
res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
Minecraft.getMinecraft().displayWidth,
Minecraft.getMinecraft().displayHeight);
Mouse.getDWheel();
}
@Override
/* Here we draw anything special, and super takes care of the buttons for us */
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
super.drawScreen(i, j, f);
}
@Override
/* Here we handle key presses. Super will just close the gui on ESC, and we like it like that */
public void keyTyped(char keyChar, int keyID)
{
if (keyID == 1)
{
if (this.parentGui == null){
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
} else {
this.mc.displayGuiScreen(this.parentGui);
}
}
}
@Override
protected void actionPerformed(GuiButton guibutton)
{
if (guibutton instanceof ButtonChangeScreen)
((ButtonChangeScreen)guibutton).pressButton();
else if (guibutton instanceof Button2States)
((Button2States)guibutton).pressButton();
}
protected int getXCentered(int width){
return (this.res.getScaledWidth() - width)/ 2;
}
public void addWidget(String name, IWidget widget){
this.widgets.put(name, widget);
}
public Collection<IWidget> getWidgets(){
return this.widgets.values();
}
public IWidget getWidget(String name){
return this.widgets.get(name);
}
@Override
public void mouseClicked(int mouseX, int mouseY, int buttonID)
{
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null && widget.mouseClicked(mouseX, mouseY, buttonID)){
if (buttonID == 0)
this.mainFocusWidget = widget;
this.focusWidget[buttonID] = widget;
}
else
super.mouseClicked(mouseX, mouseY, buttonID);
}
@Override
public void mouseMovedOrUp(int mouseX, int mouseY, int buttonID)
{
if (buttonID == 0)
this.mainFocusWidget = null;
if (this.focusWidget[buttonID] != null){
this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
this.focusWidget[buttonID] = null;
} else {
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget == null || !widget.mouseReleased(mouseX, mouseY, buttonID))
super.mouseMovedOrUp(mouseX, mouseY, buttonID);
}
}
public void mouseWheel(int mouseX, int mouseY, int mouseZ){
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
widget.mouseWheel(mouseX, mouseY, mouseZ);
}
public void mouseMoved(int mouseX, int mouseY){
if (this.mainFocusWidget != null)
this.mainFocusWidget.mouseMoved(mouseX, mouseY);
else{
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
widget.mouseMoved(mouseX, mouseY);
}
}
/*
public void mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
}
*/
@Override
public void handleMouseInput()
{
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int mouseZ = Mouse.getEventDWheel();
boolean[] buttonChanged = new boolean[buttonCount];
if (mouseZ != 0)
this.mouseWheel(mouseX, mouseY, mouseZ);
int changedButton = -1;
boolean hasStateChanged = false;
if (Mouse.getEventButtonState()){
hasStateChanged = true;
changedButton = Mouse.getEventButton();
}
for (int i = 0; i < buttonCount; i++){
buttonChanged[i] = Mouse.isButtonDown(i) != this.lastButtonStates[i];
this.lastButtonStates[i] = Mouse.isButtonDown(i);
if (buttonChanged[i] && Mouse.isButtonDown(i))
this.mouseClicked(mouseX, mouseY, i);
else if (buttonChanged[i] && !Mouse.isButtonDown(i))
this.mouseMovedOrUp(mouseX, mouseY, i);
}
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
this.mouseMoved(mouseX, mouseY);
this.lastMousePosX = mouseX;
this.lastMousePosY = mouseY;
}
/*
if (changedButton != -1){
if (Mouse.isButtonDown(changedButton)){
this.mouseClicked(mouseX, mouseY, changedButton);
this.lastMouseButton = changedButton;
}
else if (!Mouse.isButtonDown(changedButton)){
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
this.lastMouseButton = -1;
}
}
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
this.mouseMoved(mouseX, mouseY);
this.lastMousePosX = mouseX;
this.lastMousePosY = mouseY;
}
*/
/*
if (hasStateChanged)
{
this.lastMouseButton = changedButton;
this.lastMouseEvent = Minecraft.getSystemTime();
this.mouseClicked(mouseX, mouseY, this.lastMouseButton);
}
else if (changedButton != -1)
{
this.lastMouseButton = -1;
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
}
*/
/*
else if (this.lastMouseButton != -1 && this.lastMouseEvent > 0L)
{
long deltaTime = Minecraft.getSystemTime() - this.lastMouseEvent;
this.mouseDragged(mouseX, mouseY, this.lastMouseButton, deltaTime);
}
*/
/*
else if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
this.mouseMoved(mouseX, mouseY);
this.lastMousePosX = mouseX;
this.lastMousePosY = mouseY;
}
*/
}
private IWidget getWidgetAtCoordinates(int posX, int posY){
for (IWidget widget : this.getWidgets())
if ((posX >= widget.getPosX()) &&
(posX <= widget.getPosX() + widget.getWidth()) &&
(posY >= widget.getPosY()) &&
(posY <= widget.getPosY() + widget.getHeight()))
return widget;
return null;
}
}
@@ -1,62 +0,0 @@
package mcp.mobius.waila.gui_old;
import mcp.mobius.waila.gui_old.widget.ContainerTable;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.gui_old.widget.StackDisplay;
import mcp.mobius.waila.gui_old.widget.WikiReader;
import net.minecraft.client.gui.GuiScreen;
public class GuiIngameWiki extends BaseWailaScreen {
public WikiReader widReader = null;
public StackDisplay widStack = null;
public ContainerTable widTable = null;
public Label widItemName = null;
public GuiIngameWiki(GuiScreen _parentGui) {
super(_parentGui);
this.widReader = new WikiReader(this);
this.widStack = new StackDisplay(this);
this.widTable = new ContainerTable(this);
this.widItemName = new Label("");
this.widReader.setWidth(this.res.getScaledWidth()-this.res.getScaledWidth()/3 - 16);
this.widReader.setHeight(this.res.getScaledHeight() - 24);
this.widReader.setBackgroundColor(0x66888888);
this.widStack.setScale(4.0f);
this.widTable.setAutosize(false);
this.widTable.setWidth(this.res.getScaledWidth()/3 - 8);
this.widTable.setHeight(this.res.getScaledHeight() - 16 - this.widStack.getHeight());
this.widTable.setColumns(8, "\u00a7a\u00a7oEntry", "\u00a7a\u00a7oValue");
this.addWidget("wikireader", this.widReader);
this.addWidget("stackdisplay", this.widStack);
this.addWidget("datatable", this.widTable);
}
@Override
public void drawScreen(int i, int j, float f)
{
super.drawScreen(i, j, f);
widTable.draw(4, this.widStack.getHeight() + 16, 1000);
widItemName.draw(this.res.getScaledWidth()/6-widItemName.getWidth()/2, this.widStack.getHeight(), 0);
widReader.draw(this.res.getScaledWidth()/3 + 8, 8, 0);
widStack.draw(this.res.getScaledWidth()/6-widStack.getWidth()/2, 0, 0);
}
@Override
public void initGui()
{
}
@Override
public void drawDefaultBackground()
{
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
}
}
@@ -1,41 +0,0 @@
package mcp.mobius.waila.gui_old;
import mcp.mobius.waila.gui_old.widget.DraggableViewport;
import net.minecraft.client.gui.GuiScreen;
public class GuiTechTree extends BaseWailaScreen {
public DraggableViewport widViewport = null;
public int topOffset = 16;
public GuiTechTree(GuiScreen _parentGui) {
super(_parentGui);
this.widViewport = new DraggableViewport(this);
this.widViewport.setWidth(this.res.getScaledWidth() - 32);
this.widViewport.setHeight(this.res.getScaledHeight() - 32);
this.widViewport.setBackgroundColor(0x66888888);
this.addWidget("viewport", this.widViewport);
}
@Override
public void drawScreen(int i, int j, float f)
{
super.drawScreen(i, j, f);
this.widViewport.draw(16,topOffset,0);
}
@Override
public void initGui()
{
}
@Override
public void drawDefaultBackground()
{
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
}
}
@@ -1,168 +0,0 @@
package mcp.mobius.waila.gui_old.NEI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import codechicken.core.ReflectionManager;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.FuelRecipeHandler;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class CraftingTreeNode {
CraftingTreeNode topNode = null;
LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>> bottomNodes = new LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>>();
//Item stacks we have in the node.
public ArrayList<ItemStack> elements = new ArrayList<ItemStack>();
//Item stacks we are filtering the recipes with. (Previous stacks in the tree)
ArrayList<CachedRecipe> excRecipes = new ArrayList<CachedRecipe>();
//List of recipes available for a given stack
HashMap<ItemStack, ArrayList<CachedRecipe>> recipesMap = new HashMap<ItemStack, ArrayList<CachedRecipe>>();
//Components sorted by recipes for a given item stack
HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>> componentsMap = new HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>>();
int layer;
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers;
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
this.topNode = topNode;
this.layer = layer;
this.layers = layers;
this.addSelfToLayers();
this.setElements(elements);
System.out.printf("%s\n", this.toString());
}
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, ArrayList<CachedRecipe> excluded, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
this.topNode = topNode;
this.layer = layer;
this.layers = layers;
this.addSelfToLayers();
this.excRecipes = excluded;
this.setElements(elements);
System.out.printf("%s\n", this.toString());
}
public CraftingTreeNode(CraftingTreeNode topNode, ItemStack stack, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
this.topNode = topNode;
this.layer = layer;
this.layers = layers;
this.addSelfToLayers();
this.addElement(stack);
System.out.printf("%s\n", this.toString());
}
public void addSelfToLayers(){
if (!(this.layers.containsKey(layer)))
this.layers.put(this.layer, new ArrayList<CraftingTreeNode>());
this.layers.get(this.layer).add(this);
}
public void addElement(ItemStack stack){
this.elements.add(stack);
this.recipesMap.put(stack, this.getRecipes(stack, this.excRecipes));
this.componentsMap.put(stack, new ArrayList<ArrayList<ItemStack>>());
for (CachedRecipe recipe: this.recipesMap.get(stack)){
this.excRecipes.add(recipe);
ArrayList<ItemStack> subComposants = new ArrayList<ItemStack>();
for (PositionedStack substack : recipe.getIngredients())
subComposants.add(substack.item);
if (subComposants.size() > 0){
if (!this.bottomNodes.containsKey(stack))
this.bottomNodes.put(stack, new ArrayList<CraftingTreeNode>());
this.bottomNodes.get(stack).add(new CraftingTreeNode(this, this.cleanupRecipe(subComposants), this.excRecipes, this.layer+1, this.layers));
}
}
}
public void setElements(ArrayList<ItemStack> elements){
for (ItemStack is : elements)
this.addElement(is);
}
public ArrayList<CachedRecipe> getRecipes(ItemStack stack, ArrayList<CachedRecipe> excluded){
ArrayList<ICraftingHandler> craftinghandlers = ReflectionManager.getField(GuiCraftingRecipe.class, ArrayList.class, null, "craftinghandlers");
ArrayList<CachedRecipe> cachedRecipes = new ArrayList<CachedRecipe>();
for (ICraftingHandler handler : craftinghandlers)
if (handler instanceof TemplateRecipeHandler && !(handler instanceof FuelRecipeHandler)){
((TemplateRecipeHandler) handler).arecipes = new ArrayList<CachedRecipe>();
((TemplateRecipeHandler) handler).loadCraftingRecipes(stack);
for (CachedRecipe recipe : ((TemplateRecipeHandler)handler).arecipes){
boolean found = false;
for (CachedRecipe exc : excluded)
if (this.areRecipesIdentical(recipe, exc))
found = true;
if (found)
continue;
cachedRecipes.add(recipe);
}
}
return cachedRecipes;
}
public boolean areRecipesIdentical(CachedRecipe recipe1, CachedRecipe recipe2){
if (recipe1.getResult().items.length != recipe2.getResult().items.length)
return false;
if (recipe1.getIngredients().size() != recipe1.getIngredients().size())
return false;
for (int i = 0; i < recipe1.getResult().items.length; i++)
if (!recipe1.getResult().items[i].isItemEqual(recipe2.getResult().items[i]))
return false;
for (int i = 0; i < recipe1.getIngredients().size(); i++)
for (int j = 0; j < recipe1.getIngredients().get(i).items.length; j++)
if (!recipe1.getIngredients().get(i).items[j].isItemEqual(recipe2.getIngredients().get(i).items[j]))
return false;
return true;
}
public ArrayList<ItemStack> cleanupRecipe(ArrayList<ItemStack> stacks){
ArrayList<ItemStack> curratedStacks = new ArrayList<ItemStack>();
for (ItemStack is : stacks){
boolean found = false;
for (ItemStack isc : curratedStacks){
//if (OreDictionary.itemMatches(is, isc, false)){
if ((isc.isItemEqual(is)) ||
((OreDictionary.getOreID(isc) != -1) &&
(OreDictionary.getOreID(is) != -1) &&
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
)){
found = true;
break;
}
}
if (!found){
ItemStack isc = is.copy();
isc.stackSize = 0;
curratedStacks.add(isc);
}
}
for (ItemStack is : stacks)
for (ItemStack isc : curratedStacks)
if ((isc.isItemEqual(is)) ||
((OreDictionary.getOreID(isc) != -1) &&
(OreDictionary.getOreID(is) != -1) &&
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
))
//if (isc.isItemEqual(is) || OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
isc.stackSize += is.stackSize;
return curratedStacks;
}
@Override
public String toString(){
return this.elements.toString();
}
}
@@ -1,141 +0,0 @@
package mcp.mobius.waila.gui_old.NEI;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui_old.GuiTechTree;
import mcp.mobius.waila.gui_old.widget.ComponentDisplay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.forge.IContainerInputHandler;
public class HandlerTechTree implements IContainerInputHandler {
public HandlerTechTree() {
// TODO Auto-generated constructor stub
}
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
// TODO Auto-generated method stub
}
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
ItemStack stackover = gui.manager.getStackMouseOver();
if(stackover == null)
return false;
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_TECH)){
Minecraft mc = Minecraft.getMinecraft();
GuiTechTree techScreen = new GuiTechTree(mc.currentScreen);
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
CraftingTreeNode tree = new CraftingTreeNode(null, stackover, 0, layers);
/*
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> curratedLayers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
for (int layer : layers.keySet())
curratedLayers.put(layer, new ArrayList<CraftingTreeNode>());
for (int i = 0; i < (layers.size() - 1) ; i++)
for (CraftingTreeNode node : layers.get(i)){
if (node.bottomNodes.size() != 0){
curratedLayers.get(i).add(node);
}
else{
node.layer += 1;
layers.get(i+1).add(node);
}
}
for (CraftingTreeNode node : layers.get(layers.keySet().size()-1))
curratedLayers.get(layers.keySet().size()-1).add(node);
System.out.printf("%s\n", curratedLayers);
*/
/*
for (int layer = curratedLayers.keySet().size() - 1; layer >= 0; layer--){
int offsetX = 0;
for (int icompo = 0; icompo < curratedLayers.get(layer).size(); icompo++){
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, curratedLayers.get(layer).get(icompo));
componentDisplay.setBackgroundColor(0xddeeeed1);
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
offsetX += componentDisplay.getWidth() + 8;
}
}
*/
for (int layer = layers.keySet().size() - 1; layer >= 0; layer--){
int offsetX = 0;
for (int icompo = 0; icompo < layers.get(layer).size(); icompo++){
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, layers.get(layer).get(icompo));
componentDisplay.setBackgroundColor(0xddeeeed1);
if (layer != 0)
componentDisplay.setDrawOverlay(true);
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
offsetX += componentDisplay.getWidth() + 8;
}
}
mc.displayGuiScreen(techScreen);
}
return false;
}
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
int button) {
// TODO Auto-generated method stub
}
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
// TODO Auto-generated method stub
}
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
int scrolled) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
int scrolled) {
// TODO Auto-generated method stub
}
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
int button, long heldTime) {
// TODO Auto-generated method stub
}
}
@@ -1,138 +0,0 @@
package mcp.mobius.waila.gui_old.NEI;
import java.util.LinkedHashMap;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.gui_old.GuiIngameWiki;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.handlers.SummaryProvider;
import mcp.mobius.waila.tools.ModIdentification;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.forge.IContainerInputHandler;
public class HandlerWiki implements IContainerInputHandler {
public String getDescriptionString(String modid, String name, String meta){
if (ModuleRegistrar.instance().hasDocTextModID(modid)){
//Do we have an direct entry for this item ?
if (ModuleRegistrar.instance().hasDocTextItem(modid, name)){
//We check if we have an exact match, a wildcard match and finally, an meta 0 match
if (ModuleRegistrar.instance().hasDocTextMeta(modid, name, meta)){
return ModuleRegistrar.instance().getDocText(modid, name, meta);
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "*")){
return ModuleRegistrar.instance().getDocText(modid, name, "*");
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "0")){
return ModuleRegistrar.instance().getDocText(modid, name, "0");
}
} else if (ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name) != null) {
String key = ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name);
if (ModuleRegistrar.instance().hasDocTextMeta(modid, key, meta)){
return ModuleRegistrar.instance().getDocText(modid, key, meta);
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "*")){
return ModuleRegistrar.instance().getDocText(modid, key, "*");
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "0")){
return ModuleRegistrar.instance().getDocText(modid, key, "0");
}
}
}
return String.format("No description for %s$$%s",modid, name);
}
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
ItemStack stackover = gui.manager.getStackMouseOver();
if(stackover == null)
return false;
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_WIKI)){
Minecraft mc = Minecraft.getMinecraft();
GuiIngameWiki wikiScreen = new GuiIngameWiki(mc.currentScreen);
wikiScreen.widReader.setText(this.getDescriptionString(ModIdentification.idFromStack(stackover), stackover.getItemName(), String.valueOf(stackover.getItemDamage())));
wikiScreen.widStack.setStack(stackover);
wikiScreen.widItemName.setLabel(stackover.getDisplayName());
LinkedHashMap<String, String> entries = SummaryProvider.instance().getSummary(stackover, (ConfigHandler.instance()));
int nvalidentries = 0;
for (String s : entries.keySet())
if (entries.get(s) != null)
nvalidentries += 1;
if (nvalidentries == 0)
for (int i = 0; i < 6; i++)
wikiScreen.widTable.addRow(new Label(""), new Label(entries.get("")));
else
for (String s : entries.keySet())
if (entries.get(s) != null)
wikiScreen.widTable.addRow(new Label(s), new Label(entries.get(s)));
mc.displayGuiScreen(wikiScreen);
}
return false;
}
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
// TODO Auto-generated method stub
}
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
int button) {
// TODO Auto-generated method stub
}
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
// TODO Auto-generated method stub
}
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
int scrolled) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
int scrolled) {
// TODO Auto-generated method stub
}
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
int button, long heldTime) {
// TODO Auto-generated method stub
}
}
@@ -1,215 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import java.util.Collection;
import java.util.HashMap;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
public abstract class BaseWidget implements IWidget {
protected int width, height;
protected String label;
protected int posX, posY, posZ;
protected GuiScreen parent;
protected FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;;
protected TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
protected IWidget[] focusWidget = new IWidget[Mouse.getButtonCount()];
protected IWidget mainFocusWidget = null;
protected int backgroundColor = 0;
public BaseWidget(){}
@Override
public abstract int getWidth();
@Override
public abstract int getHeight();
@Override
public void setWidth(int width) { this.width = width; }
@Override
public void setHeight(int height) { this.height = height; }
@Override
public void setPos (int posX, int posY, int posZ){
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
@Override
public int getPosX(){return this.posX;}
@Override
public int getPosY(){return this.posY;}
@Override
public String getLabel(){ return this.label;}
@Override
public void setLabel(String label){ this.label = label; }
@Override
public abstract void draw();
@Override
public void draw(int x, int y, int z){
this.posX = x;
this.posY = y;
this.posZ = z;
GL11.glPushMatrix();
GL11.glTranslatef(0.0f,0.0f, this.posZ);
this.draw();
GL11.glPopMatrix();
}
@Override
public void draw(float scale){
int oldX = this.posX;
int oldY = this.posY;
this.posX /= scale;
this.posY /= scale;
GL11.glPushMatrix();
GL11.glTranslatef(0.0f,0.0f, this.posZ);
this.draw();
GL11.glPopMatrix();
this.posX = oldX;
this.posY = oldY;
}
@Override
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null){
if (buttonID == 0)
this.mainFocusWidget = widget;
this.focusWidget[buttonID] = widget;
return widget.mouseClicked(mouseX, mouseY, buttonID);
} else
return false;
}
@Override
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
if (buttonID == 0)
this.mainFocusWidget = null;
if (this.focusWidget[buttonID] != null){
boolean retval = this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
this.focusWidget[buttonID] = null;
return retval;
}
this.focusWidget[buttonID] = null;
return false;
}
@Override
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
return widget.mouseWheel(mouseX, mouseY, mouseZ);
return false;
}
@Override
public boolean mouseMoved(int mouseX, int mouseY){
if (this.mainFocusWidget != null)
return this.mainFocusWidget.mouseMoved(mouseX, mouseY);
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
return widget.mouseMoved(mouseX, mouseY);
return false;
}
/*
@Override
public boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
if (widget != null)
return widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
return false;
}
*/
public void startScissorFilter(int posX, int posY, int width, int height){
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
Minecraft.getMinecraft().displayWidth,
Minecraft.getMinecraft().displayHeight);
int scaleFactor = res.getScaleFactor();
int glLeft = posX * scaleFactor;
int glBottom = (res.getScaledHeight() - (posY + height)) * scaleFactor;
GL11.glScissor(posX*scaleFactor, glBottom, width*scaleFactor, height*scaleFactor);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
}
public void stopScissorFilter(){
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
@Override
public IWidget getWidgetAtCoordinates(int posX, int posY){
for (IWidget widget : this.getWidgets())
if ((posX >= widget.getPosX()) &&
(posX <= widget.getPosX() + widget.getWidth()) &&
(posY >= widget.getPosY()) &&
(posY <= widget.getPosY() + widget.getHeight()))
return widget;
return null;
}
@Override
public void addWidget(String name, IWidget widget){
this.widgets.put(name, widget);
}
@Override
public Collection<IWidget> getWidgets(){
return this.widgets.values();
}
@Override
public IWidget getWidget(String name){
return this.widgets.get(name);
}
@Override
public void setBackgroundColor(int color){
this.backgroundColor = color;
}
@Override
public void drawBackground(){
if (this.backgroundColor != 0)
this.drawGradientRect(this.posX, this.posY, this.posX+this.getWidth(), this.posY+this.getHeight(), 0.0, this.backgroundColor, this.backgroundColor);
}
public void drawGradientRect(int left, int top, int right, int bottom, double zlevel, int colorStart, int colorStop)
{
float f = (colorStart >> 24 & 255) / 255.0F;
float f1 = (colorStart >> 16 & 255) / 255.0F;
float f2 = (colorStart >> 8 & 255) / 255.0F;
float f3 = (colorStart & 255) / 255.0F;
float f4 = (colorStop >> 24 & 255) / 255.0F;
float f5 = (colorStop >> 16 & 255) / 255.0F;
float f6 = (colorStop >> 8 & 255) / 255.0F;
float f7 = (colorStop & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f1, f2, f3, f);
tessellator.addVertex(right, top, zlevel);
tessellator.addVertex(left, top, zlevel);
tessellator.setColorRGBA_F(f5, f6, f7, f4);
tessellator.addVertex(left, bottom, zlevel);
tessellator.addVertex(right, bottom, zlevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
}
@@ -1,75 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
import mcp.mobius.waila.gui_old.NEI.CraftingTreeNode;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
public class ComponentDisplay extends BaseWidget {
ArrayList<ItemStack> components = null;
CraftingTreeNode node = null;
int spacingX = 4;
int spacingY = 4;
int stackDisplayWidth = 0;
boolean drawOverlay = false;
public ComponentDisplay(GuiScreen parent){
this.parent = parent;
this.components = new ArrayList<ItemStack>();
};
public ComponentDisplay(GuiScreen parent, CraftingTreeNode node){
this.parent = parent;
this.node = node;
this.setComponents(node.elements);
};
public void setDrawOverlay(boolean value){
for(IWidget widget : this.getWidgets())
if(widget instanceof StackDisplay)
((StackDisplay)widget).setDrawOverlay(value);
}
public void setComponents(ArrayList<ItemStack> components){
this.components = components;
this.stackDisplayWidth = 0;
for (ItemStack component : components)
this.addWidget(String.format("widget_%03d", this.getWidgets().size()), new StackDisplay(this.parent, component));
for (IWidget widget:this.getWidgets())
this.stackDisplayWidth = Math.max(this.stackDisplayWidth, widget.getWidth());
}
@Override
public int getWidth() {
int width = 0;
for (IWidget widget:this.getWidgets())
width += widget.getWidth();
width += (this.getWidgets().size() + 1) * this.spacingX;
return width;
}
@Override
public int getHeight() {
int height = 0;
for (IWidget widget:this.getWidgets())
height = Math.max(widget.getHeight(), height);
height += this.spacingY * 2;
return height;
}
@Override
public void draw() {
//this.drawBackground();
int index = 0;
for (IWidget widget: this.getWidgets()){
widget.setPos(this.posX + (this.spacingX * (index + 1)) + ( index * this.stackDisplayWidth ), this.posY + this.spacingY, 0);
widget.draw();
index += 1;
}
}
}
@@ -1,191 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
public class ContainerTable extends BaseWidget{
int rowHeight;
int ncolumns;
//int viewportYPos = 0;
int tableHeight = 0;
int tableWidth = 0;
int scrollWidth = 8;
int scrollButtonHeight = 16;
boolean isScrollActive = false;
FontRenderer fontRender;
int[] columnPos;
int[] columnWidth;
ArrayList<IWidget[]> table = new ArrayList<IWidget[]>();
VerticalScrollBar scrollbar = new VerticalScrollBar();
Label[] columnnames;
boolean autosize = true;
public ContainerTable(GuiScreen parent){
this.parent = parent;
this.addWidget("VScrollBar", this.scrollbar);
};
public ContainerTable( GuiScreen parent, int height, int ncolumns, String[] columnnames) {
this.parent = parent;
this.height = height;
this.rowHeight = 8;
this.fontRender = Minecraft.getMinecraft().fontRenderer;
this.ncolumns = ncolumns;
this.columnPos = new int[this.ncolumns];
this.columnWidth = new int[this.ncolumns];
this.columnnames = new Label[this.ncolumns];
for (int i = 0; i < this.ncolumns; i++){
Label labelHeader = new Label(columnnames[i]);
this.columnnames[i] = labelHeader;
this.addWidget(String.format("header_%s", i), labelHeader);
}
this.addWidget("VScrollBar", this.scrollbar);
}
public void setAutosize(boolean value){
this.autosize = value;
}
public void setColumns(int rowHeight, String... header){
this.rowHeight = rowHeight;
this.ncolumns = header.length;
this.columnPos = new int[this.ncolumns];
this.columnWidth = new int[this.ncolumns];
this.columnnames = new Label[this.ncolumns];
for (int i = 0; i < this.ncolumns; i++){
Label labelHeader = new Label(header[i]);
this.columnnames[i] = labelHeader;
this.addWidget(String.format("header_%s", i), labelHeader);
this.columnWidth[i] = Math.max(labelHeader.getWidth() + 8, this.columnWidth[i]);
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
}
this.columnPos[0] = 0;
for (int i = 1; i < this.ncolumns; i++)
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
}
public int getSize() {
return this.table.size();
}
public void addRow(IWidget... data){
this.table.add(data);
for (int i = 0; i < data.length; i++)
this.addWidget(String.format("row_%s_%s", this.table.size(), i), data[i]);
for (int i = 0; i < ncolumns; i++){
this.columnWidth[i] = Math.max(data[i].getWidth() + 8, this.columnWidth[i]);
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
}
this.columnPos[0] = 0;
for (int i = 1; i < this.ncolumns; i++)
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
}
@Override
public void draw() {
GL11.glPushMatrix();
GL11.glTranslatef(1.0f, 1.0f, this.posZ);
this.drawBackground();
this.drawTitle(this.posX, this.posY);
GL11.glPushMatrix();
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
this.startScissorFilter(this.posX, this.posY + this.rowHeight, this.getWidth(), this.getViewportHeight());
for (int i = 0; i < this.table.size(); i++)
this.drawRow(i, this.posX, this.posY+(i+1)*this.rowHeight);
this.stopScissorFilter();
GL11.glPopMatrix();
if (this.isScrollActive){
this.updateScrollBar();
this.scrollbar.draw();
}
GL11.glPopMatrix();
}
public void updateScrollBar(){
int scrollbarX = this.posX + this.getWidth() - this.scrollWidth;
int scrollbarY = this.posY + this.rowHeight;
int scrollbarW = this.scrollWidth;
int scrollbarH = this.getViewportHeight();
int maxvalue = this.getTableHeight() - this.getViewportHeight();
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
}
@Override
public int getWidth(){
if (!autosize)
return this.width;
int width = 0;
for (int i: this.columnWidth)
width += i;
if (this.isScrollActive)
width += this.scrollWidth;
return width;
}
public int getTableHeight(){
return this.rowHeight * this.getSize();
}
public int getViewportHeight(){
return this.getHeight() - this.rowHeight;
}
@Override
public int getHeight(){
return this.height;
}
@Override
public void setHeight(int height){
this.height = height;
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
}
public void drawTitle(int rowleft, int rowtop)
{
for (int j = 0; j < this.ncolumns; j++){
this.columnnames[j].setWidth(this.columnWidth[j]);
this.columnnames[j].draw(rowleft + this.columnPos[j], rowtop, 0);
}
}
public void drawRow(int index, int rowleft, int rowtop)
{
if (index%2 == 0)
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff333333, 0xff333333);
else
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff000000, 0xff000000);
IWidget[] data = this.table.get(index);
for (int j = 0; j < this.ncolumns; j++){
data[j].setWidth(this.columnWidth[j]);
data[j].draw(rowleft + this.columnPos[j], rowtop, 0);
}
}
@Override
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
return true;
}
}
@@ -1,110 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiScreen;
public class DraggableViewport extends BaseWidget {
//public StackDisplay widStack = null;;
private int offsetX = 0;
private int offsetY = 0;
private int prevMouseX = 0;
private int prevMouseY = 0;
private float scale = 1.0f;
private boolean dragging = false;
public DraggableViewport(GuiScreen parent){
this.parent = parent;
/*
widStack = new StackDisplay(parent);
widStack.setStack(new ItemStack(Item.axeDiamond));
widStack.setPos(80, 80, 0);
this.addWidget("stackdisplay", this.widStack);
*/
}
public void addWidget(IWidget widget, int posX, int posY, int posZ){
this.addWidget(String.format("widget_%s", this.widgets.size()), widget);
widget.setPos(posX, posY, posZ);
}
@Override
public int getWidth() {
return this.width;
}
@Override
public int getHeight() {
return this.height;
}
@Override
public void draw() {
this.drawBackground();
this.drawBackground();
GL11.glPushMatrix();
GL11.glTranslatef(offsetX, offsetY, 0);
GL11.glScalef(this.scale, this.scale, 1.0f);
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getHeight());
for (IWidget widget : this.getWidgets())
widget.drawBackground();
for (IWidget widget : this.getWidgets())
//widget.draw(this.scale);
widget.draw();
this.stopScissorFilter();
GL11.glPopMatrix();
}
@Override
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
if (buttonID == 0){
this.dragging = true;
this.prevMouseX = mouseX;
this.prevMouseY = mouseY;
return true;
}
else
return false;
}
@Override
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
if (buttonID == 0)
this.dragging = false;
else
return false;
return true;
}
@Override
public boolean mouseMoved(int mouseX, int mouseY){
if (this.dragging){
this.offsetX -= (this.prevMouseX - mouseX);
this.offsetY -= (this.prevMouseY - mouseY);
this.prevMouseX = mouseX;
this.prevMouseY = mouseY;
return true;
}
return false;
}
@Override
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
if (mouseZ > 0)
this.scale *= Math.abs((mouseZ / -120)*2);
else
this.scale /= Math.abs((mouseZ / -120)*2);
return true;
}
}
@@ -1,34 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import java.util.Collection;
public interface IWidget {
int getWidth();
int getHeight();
String getLabel();
int getPosX();
int getPosY();
void setWidth(int width);
void setHeight(int height);
void setLabel(String label);
void setPos(int posX, int posY, int posZ);
boolean mouseClicked(int mouseX, int mouseY, int buttonID);
boolean mouseReleased(int mouseX, int mouseY, int buttonID);
boolean mouseWheel(int mouseX, int mouseY, int mouseZ);
boolean mouseMoved(int mouseX, int mouseY);
//boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime);
void draw();
void draw(int x, int y, int z);
void draw(float scale);
IWidget getWidgetAtCoordinates(int posX, int posY);
public void addWidget(String name, IWidget widget);
public Collection<IWidget> getWidgets();
public IWidget getWidget(String name);
void drawBackground();
void setBackgroundColor(int color);
}
@@ -1,67 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import net.minecraft.client.gui.GuiScreen;
public class Label extends BaseWidget {
public Label(GuiScreen parent){
this.parent = parent;
}
public Label(GuiScreen parent, String label){
this.parent = parent;
this.setLabel(label);
}
public Label(String label){
this.parent = null;
this.setLabel(label);
}
public Label(int label){
this.parent = null;
this.setLabel(String.valueOf(label));
}
public Label(float label){
this.parent = null;
this.setLabel(String.valueOf(label));
}
public int getCharWidth(){
return this.fontRenderer.getCharWidth((char)32);
}
@Override
public void draw() {
this.drawBackground();
this.renderString(this.posX, this.posY, 0, 0xffffffff);
}
public String getTrimLabel(){
int maxchars = this.width / this.getCharWidth();
return this.label.substring(0, Math.min(this.label.length(), maxchars));
}
@Override
public int getWidth(){
return this.fontRenderer.getStringWidth(this.label);
}
@Override
public void setLabel(String label){
this.label = label;
this.width = this.fontRenderer.getStringWidth(this.label);
}
public void renderString(int x, int y, int z, int color){
//this.fontrender.drawString(this.getTrimLabel(), x, y, color);
this.fontRenderer.drawString(this.getLabel(), x, y, color);
}
@Override
public int getHeight() {
return 8;
}
}
@@ -1,71 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
public class StackDisplay extends BaseWidget {
protected static RenderItem drawItems = new RenderItem();
protected ItemStack stack;
protected Icon icon;
protected float scale = 1.0F;
protected boolean drawOverlay = false;
public StackDisplay(GuiScreen parent){
this.parent = parent;
StackDisplay.drawItems.zLevel = 500.0f;
};
public StackDisplay(GuiScreen parent, ItemStack stack){
this.parent = parent;
this.setStack(stack);
};
public void setDrawOverlay(boolean value){
this.drawOverlay = value;
}
public void setStack(ItemStack stack){
this.stack = stack;
this.icon = stack.getIconIndex();
}
@Override
public void draw() {
this.drawBackground();
GL11.glPushMatrix();
GL11.glScalef(scale, scale, 1.0f);
RenderHelper.disableStandardItemLighting();
drawItems.renderItemAndEffectIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale));
if (this.drawOverlay)
drawItems.renderItemOverlayIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale), String.valueOf(stack.stackSize));
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
}
@Override
public int getWidth(){
return (int)(16 * this.scale);
}
@Override
public int getHeight(){
return (int)(16 * this.scale);
}
public void setScale(float scale_){
this.scale = scale_;
}
public float getScale(){
return this.scale;
}
}
@@ -1,109 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import net.minecraft.client.gui.GuiScreen;
public class VerticalScrollBar extends BaseWidget {
private int maxvalue;
private int currvalue = 0;
private int buttonH;
private int buttonTop;
private int step = 6;
public boolean dragging = false;
public VerticalScrollBar(){};
public void setup(GuiScreen parent, int posX, int posY, int width, int height, int buttonH, int maxvalue) {
this.parent = parent;
this.posX = posX;
this.posY = posY;
this.width = width;
this.height = height;
this.maxvalue = maxvalue;
this.buttonH = buttonH;
}
@Override
public int getWidth() {
return this.width;
}
@Override
public int getHeight() {
return this.height;
}
@Override
public void draw() {
this.drawBackground();
this.parent.drawGradientRect(this.posX,
this.posY,
this.posX + this.getWidth(),
this.posY + this.getHeight(),
0xff999999, 0xff999999);
float currentRatio = (float)(this.currvalue) / (float)(this.maxvalue);
this.buttonTop = (int)((this.getHeight() - this.buttonH) * currentRatio) + this.posY;
this.parent.drawGradientRect(this.posX,
buttonTop,
this.posX + this.getWidth(),
buttonTop + this.buttonH,
0xffffffff, 0xffffffff);
}
public void setCurrentValue(int currvalue){
this.currvalue = currvalue;
this.currvalue = Math.max(0, this.currvalue);
this.currvalue = Math.min(this.maxvalue, this.currvalue);
}
public void addCurrentValue(int value){
this.currvalue += value;
this.currvalue = Math.max(0, this.currvalue);
this.currvalue = Math.min(this.maxvalue, this.currvalue);
}
public int getCurrentValue(){
return this.currvalue;
}
public int getStep(){
return this.step;
}
@Override
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
if(mouseY < this.buttonTop)
this.addCurrentValue(-1 * this.step);
else if (mouseY > this.buttonTop + this.buttonH)
this.addCurrentValue(this.step);
else if (buttonID == 0)
this.dragging = true;
else
return false;
return true;
}
@Override
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
if (buttonID == 0)
this.dragging = false;
else
return false;
return true;
}
@Override
public boolean mouseMoved(int mouseX, int mouseY){
if (this.dragging){
int value = (int)((float)((mouseY - this.buttonH/2) - this.posY)/(float)(this.getHeight()-this.buttonH)*this.maxvalue);
this.setCurrentValue(value);
return true;
}
return false;
}
}
@@ -1,127 +0,0 @@
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiScreen;
public class WikiReader extends BaseWidget {
private VerticalScrollBar scrollbar = new VerticalScrollBar();
private String text = "";
int textHeight = 0;
int lineHeight = 8;
int scrollWidth = 8;
int scrollButtonHeight = 16;
boolean isScrollActive = false;
public WikiReader(GuiScreen parent){
this.parent = parent;
this.addWidget("VScrollBar", this.scrollbar);
}
@Override
public int getWidth() {
if (!this.isScrollActive)
return this.width;
else
return this.width - this.scrollWidth;
}
@Override
public int getHeight() {
return this.height;
}
@Override
public void draw() {
this.drawBackground();
GL11.glPushMatrix();
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getViewportHeight());
int offset = this.posY;
for (String s : this.getTailoredText()){
this.fontRenderer.drawString(s, this.posX, offset, 0xFFFFFFFF);
offset += this.lineHeight;
}
this.stopScissorFilter();
GL11.glPopMatrix();
if (this.isScrollActive){
this.updateScrollBar();
this.scrollbar.draw();
}
}
public void setText(String text){
this.text = text;
this.textHeight = this.getTailoredText().size() * this.lineHeight;
if (this.textHeight > this.getHeight()){
this.isScrollActive = true;
//this.setWidth(this.getWidth() - this.scrollWidth);
this.textHeight = this.getTailoredText().size() * this.lineHeight;
}
}
public int getTextHeight(){
return this.getTailoredText().size() * this.lineHeight;
}
public String getText(){
return this.text;
}
public ArrayList<String> getTailoredText(){
String[] splittedText = this.text.split("\r?\n");
ArrayList<String> lines = new ArrayList<String>();
for (String s : splittedText){
ArrayList<Integer> whiteSpaces = this.getWhiteSpaces(s);
int lastCutIndex = 0;
for (int i = 0; i < whiteSpaces.size(); i++){
String substring = s.substring(lastCutIndex, whiteSpaces.get(i));
if (this.fontRenderer.getStringWidth(substring) > this.getWidth()){
lines.add(s.substring(lastCutIndex, whiteSpaces.get(i-1)));
lastCutIndex = whiteSpaces.get(i-1) + 1;
}
}
lines.add(s.substring(lastCutIndex));
}
return lines;
}
private ArrayList<Integer> getWhiteSpaces(String input){
ArrayList<Integer> indexes = new ArrayList<Integer>();
int index = 0;
while (index != -1){
index = input.indexOf(" ", index + 1);
if (index != -1)
indexes.add(index);
}
return indexes;
}
@Override
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
return true;
}
public int getViewportHeight(){
return this.getHeight();
}
public void updateScrollBar(){
int scrollbarX = this.posX + this.getWidth();
int scrollbarY = this.posY;
int scrollbarW = this.scrollWidth;
int scrollbarH = this.getViewportHeight();
int maxvalue = this.getTextHeight() - this.getViewportHeight();
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
}
}
@@ -1,6 +1,8 @@
package mcp.mobius.waila.handlers;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.BLUE;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.RENDER;
import java.util.List;
@@ -1,6 +1,10 @@
package mcp.mobius.waila.handlers;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.BLUE;
import static mcp.mobius.waila.api.SpecialChars.GRAY;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import static mcp.mobius.waila.api.SpecialChars.WHITE;
import static mcp.mobius.waila.api.SpecialChars.getRenderString;
import java.util.List;
@@ -1,6 +1,9 @@
package mcp.mobius.waila.overlay;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
import static mcp.mobius.waila.api.SpecialChars.patternMinecraft;
import static mcp.mobius.waila.api.SpecialChars.patternRender;
import static mcp.mobius.waila.api.SpecialChars.patternWaila;
import java.awt.Dimension;
import java.util.ArrayList;
@@ -1,6 +1,7 @@
package mcp.mobius.waila.overlay;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
import java.util.HashMap;
@@ -1,15 +1,12 @@
package mcp.mobius.waila.overlay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
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;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -38,15 +35,12 @@ public class RayTracing {
}
private MovingObjectPosition target = null;
private ItemStack targetStack = null;
private Entity targetEntity = null;
private Minecraft mc = Minecraft.getMinecraft();
private final Minecraft mc = Minecraft.getMinecraft();
public void fire() {
if (mc.objectMouseOver != null
&& mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
this.target = mc.objectMouseOver;
this.targetStack = null;
return;
}
@@ -54,8 +48,6 @@ public class RayTracing {
if (viewpoint == null) return;
this.target = this.rayTrace(viewpoint, mc.playerController.getBlockReachDistance(), 0);
if (this.target == null) return;
}
public MovingObjectPosition getTarget() {
@@ -63,19 +55,12 @@ public class RayTracing {
}
public ItemStack getTargetStack() {
if (this.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
this.targetStack = this.getIdentifierStack();
else this.targetStack = null;
return this.targetStack;
return this.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK ? this.getIdentifierStack() : null;
}
public Entity getTargetEntity() {
if (this.target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY)
this.targetEntity = this.getIdentifierEntity();
else this.targetEntity = null;
return this.targetEntity;
return this.target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY ? this.getIdentifierEntity()
: null;
}
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3) {
@@ -90,24 +75,17 @@ public class RayTracing {
}
public ItemStack getIdentifierStack() {
World world = mc.theWorld;
ArrayList<ItemStack> items = this.getIdentifierItems();
if (items.isEmpty()) return null;
Collections.sort(items, new Comparator<ItemStack>() {
@Override
public int compare(ItemStack stack0, ItemStack stack1) {
return stack1.getItemDamage() - stack0.getItemDamage();
}
});
items.sort((stack0, stack1) -> stack1.getItemDamage() - stack0.getItemDamage());
return items.get(0);
}
public Entity getIdentifierEntity() {
ArrayList<Entity> ents = new ArrayList<Entity>();
ArrayList<Entity> ents = new ArrayList<>();
if (this.target == null) return null;
@@ -120,16 +98,15 @@ public class RayTracing {
}
}
if (ents.size() > 0) return ents.get(0);
if (!ents.isEmpty()) return ents.get(0);
else return this.target.entityHit;
}
public ArrayList<ItemStack> getIdentifierItems() {
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
ArrayList<ItemStack> items = new ArrayList<>();
if (this.target == null) return items;
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
int x = this.target.blockX;
@@ -174,7 +151,7 @@ public class RayTracing {
}
}
if (items.size() > 0) return items;
if (!items.isEmpty()) return items;
if (world.getTileEntity(x, y, z) == null) {
try {
@@ -191,14 +168,14 @@ public class RayTracing {
} catch (Exception e) {}
}
if (items.size() > 0) return items;
if (!items.isEmpty()) return items;
try {
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, x, y, z);
if (pick != null) items.add(pick);
} catch (Exception e) {}
if (items.size() > 0) return items;
if (!items.isEmpty()) return items;
/*
* try { items.addAll(mouseoverBlock.getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0)); }
@@ -212,7 +189,7 @@ public class RayTracing {
}
}
if (items.size() == 0) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
if (items.isEmpty()) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
return items;
}
@@ -1,6 +1,11 @@
package mcp.mobius.waila.overlay;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ALIGNCENTER;
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
import static mcp.mobius.waila.api.SpecialChars.patternLineSplit;
import static mcp.mobius.waila.api.SpecialChars.patternRender;
import static mcp.mobius.waila.api.SpecialChars.patternTab;
import java.awt.Dimension;
import java.awt.Point;
@@ -1,6 +1,6 @@
package mcp.mobius.waila.overlay;
import static mcp.mobius.waila.api.SpecialChars.*;
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
import java.util.List;