Compare commits

..
7 Commits
354 changed files with 5442 additions and 28584 deletions

No files matched your search

-2
View File
@@ -1,2 +0,0 @@
# Ignore spotlessApply reformat
4ee7d7396c8a27b994d49169140edbf9adfdc2dc
-44
View File
@@ -1,44 +0,0 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
-13
View File
@@ -1,13 +0,0 @@
name: Build and test
on:
pull_request:
branches: [ master, main, release/** ]
push:
branches: [ master, main, release/** ]
jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
-17
View File
@@ -1,17 +0,0 @@
name: Optimize images
on:
pull_request:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
push:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
jobs:
optimize-images:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
secrets: inherit
-14
View File
@@ -1,14 +0,0 @@
name: Release tagged build
on:
push:
tags: [ '*' ]
permissions:
contents: write
jobs:
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
-31
View File
@@ -1,31 +0,0 @@
.gradle
.settings
/.idea/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
*.bat
layout.json
.DS_Store
-3
View File
@@ -1,3 +0,0 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
-437
View File
@@ -1,437 +0,0 @@
Attribution-NonCommercial-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International Public License
("Public License"). To the extent this Public License may be
interpreted as a contract, You are granted the Licensed Rights in
consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the
Licensor receives from making the Licensed Material available under
these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-NC-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution, NonCommercial, and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. NonCommercial means not primarily intended for or directed towards
commercial advantage or monetary compensation. For purposes of
this Public License, the exchange of the Licensed Material for
other material subject to Copyright and Similar Rights by digital
file-sharing or similar means is NonCommercial provided there is
no payment of monetary compensation in connection with the
exchange.
l. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
m. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
n. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part, for NonCommercial purposes only; and
b. produce, reproduce, and Share Adapted Material for
NonCommercial purposes only.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties, including when
the Licensed Material is used other than for NonCommercial
purposes.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-NC-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database for NonCommercial purposes
only;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.
-13
View File
@@ -1,13 +0,0 @@
# Waila
## Contribution
When forking this repository, make sure to uncheck the `Copy the master branch only` option.
This will copy all tags to your fork, so the build system can detect the latest mod version.
If you leave it checked, you won't be able to enter the world in a local client run because Waila [will think the mod is outdated](https://github.com/GTNewHorizons/waila/blob/master/src/main/java/mcp/mobius/waila/Waila.java#L133).
If you already forked the repository without tags, you can fetch them manually:
```
git remote add upstream https://github.com/GTNewHorizons/waila
git fetch upstream --tags
```
-5
View File
@@ -1,5 +0,0 @@
//version: 1707058017
plugins {
id 'com.gtnewhorizons.gtnhconvention'
}
-24
View File
@@ -1,24 +0,0 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev')
shadowImplementation('au.com.bytecode:opencsv:2.4')
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.463:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:WAILAPlugins:0.7.2:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'waila'
}
runtimeOnlyNonPublishable("com.github.GTNewHorizons:EnderCore:0.5.12:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:BuildCraft:7.1.57:dev")
runtimeOnlyNonPublishable(deobfCurse("cofh-lib-220333:2388748"))
runtimeOnlyNonPublishable(deobfCurse("extrautils-225561:2264383"))
runtimeOnlyNonPublishable("com.github.GTNewHorizons:OpenBlocks:1.12.12-GTNH:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Railcraft:9.17.26:dev")
runtimeOnlyNonPublishable(deobfCurse('thermal-foundation-222880:2388753'))
runtimeOnlyNonPublishable(deobfCurse('thermal-expansion-69163:2388759'))
runtimeOnlyNonPublishable(deobfCurse('thermal-dynamics-227443:2388756'))
implementation(deobfCurse('cofh-core-69162:2388751'))
api("com.github.GTNewHorizons:GTNHLib:0.11.37:dev")
}
-238
View File
@@ -1,238 +0,0 @@
# 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
# 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
# Whether to use modGroup as the maven publishing group.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# 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
# 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
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
# 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 = mcp.mobius.waila.Tags
# 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 =
# [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 =
# 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
apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
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
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
# 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
# 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 CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
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: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# 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 customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# 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
# Non-GTNH properties
org.gradle.configuration-cache = true
org.gradle.parallel = true
-12
View File
@@ -1,12 +0,0 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
toolchainVersion=25
Binary file not shown.
-7
View File
@@ -1,7 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
-248
View File
@@ -1,248 +0,0 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
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.
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=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# 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, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
-93
View File
@@ -1,93 +0,0 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
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
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
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
:execute
@rem Setup the command line
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
-2
View File
@@ -1,2 +0,0 @@
before_install:
- ./gradlew setupCIWorkspace
+14
View File
@@ -0,0 +1,14 @@
package mcp.mobius.waila;
public final class Constants {
public static String BIND_SCREEN_WIKI = "showwiki";
public static String BIND_SCREEN_TECH = "showtechtree";
public static String BIND_SCREEN_ENCH = "showenchant";
public static String BIND_WAILA_CFG = "key.wailaconfig";
public static String BIND_WAILA_SHOW = "key.wailadisplay";
public static String CFG_NEI_SHOW = "options.inworld tooltips";
}
+87
View File
@@ -0,0 +1,87 @@
package mcp.mobius.waila;
import net.minecraft.item.Item;
import org.lwjgl.input.Keyboard;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.forge.GuiContainerManager;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.addons.appeng.AppEngModule;
import mcp.mobius.waila.addons.betterbarrels.BetterBarrelsModule;
import mcp.mobius.waila.addons.buildcraft.BCModule;
import mcp.mobius.waila.addons.enderstorage.EnderStorageModule;
import mcp.mobius.waila.addons.gravestone.GravestoneModule;
import mcp.mobius.waila.addons.ic2.IC2Module;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
import mcp.mobius.waila.gui.ConfigKeyHandler;
import mcp.mobius.waila.handlers.HUDHandlerExternal;
import mcp.mobius.waila.handlers.HUDHandlerWaila;
import mcp.mobius.waila.handlers.HandlerEnchantment;
import mcp.mobius.waila.handlers.SummaryProviderDefault;
import mcp.mobius.waila.handlers.HandlerTechTree;
import mcp.mobius.waila.handlers.TooltipHandlerWaila;
import mcp.mobius.waila.handlers.HandlerWiki;
import mcp.mobius.waila.server.ProxyServer;
public class ProxyClient extends ProxyServer {
public ProxyClient() {}
@Override
public void registerHandlers(){
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.HEADER);
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.BODY);
API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.FOOTER);
API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.HEADER);
KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
ExternalModulesHandler.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
//GuiContainerManager.addInputHandler(new HandlerEnchantment());
//GuiContainerManager.addInputHandler(new HandlerWiki());
//GuiContainerManager.addInputHandler(new HandlerTechTree());
//API.addKeyBind(Constants.BIND_SCREEN_ENCH, "Display enchantements", Keyboard.KEY_NUMPAD7);
//API.addKeyBind(Constants.BIND_SCREEN_WIKI, "Display wiki", Keyboard.KEY_NUMPAD8);
//API.addKeyBind(Constants.BIND_SCREEN_TECH, "Display techtree", Keyboard.KEY_NUMPAD9);
this.registerMods();
}
public void registerMods(){
HUDHandlerVanilla.register();
/*BETTER BARRELS*/
//BetterBarrelsModule.register();
/* BUILDCRAFT */
BCModule.register();
/* INDUSTRIALCRAFT2 */
IC2Module.register();
/*Thaumcraft*/
ThaumcraftModule.register();
/*EnderStorage*/
EnderStorageModule.register();
/*Gravestone*/
GravestoneModule.register();
/*Twilight forest*/
TwilightForestModule.register();
/* Applied Energetics */
AppEngModule.register();
}
}
@@ -0,0 +1,24 @@
package mcp.mobius.waila;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class WailaExceptionHandler {
public WailaExceptionHandler() {}
private static ArrayList<String> errs = new ArrayList<String>();
public static List<String> handleErr(Throwable e, String className, List<String> currenttip){
if (!errs.contains(className)){
errs.add(className);
mod_Waila.log.log(Level.WARNING, String.format("Catched unhandled exception : [%s] %s",className,e));
}
if (currenttip != null)
currenttip.add("<ERROR>");
return currenttip;
}
}
@@ -0,0 +1,84 @@
package mcp.mobius.waila.addons;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
public class ConfigHandler implements IWailaConfigHandler {
private static ConfigHandler instance = null;
private LinkedHashMap<String, ConfigModule> modules = new LinkedHashMap<String, ConfigModule>();
private ArrayList<String> serverconfigs = new ArrayList<String>();
private ConfigHandler() {
instance = this;
}
public static ConfigHandler instance(){
if (ConfigHandler.instance == null)
ConfigHandler.instance = new ConfigHandler();
return ConfigHandler.instance;
}
public void addModule(String modName, HashMap<String, String> options){
this.addModule(modName, new ConfigModule(modName, options));
}
public void addModule(String modName, ConfigModule options){
this.modules.put(modName, options);
}
@Override
public Set<String> getModuleNames(){
return this.modules.keySet();
}
@Override
public HashMap<String, String> getConfigKeys(String modName){
if (this.modules.containsKey(modName))
return this.modules.get(modName).options;
else
return null;
}
public void addConfig(String modName, String key, String name){
if (!this.modules.containsKey(modName))
this.modules.put(modName, new ConfigModule(modName));
this.modules.get(modName).addOption(key, name);
}
public void addConfigServer(String modName, String key, String name){
if (!this.modules.containsKey(modName))
this.modules.put(modName, new ConfigModule(modName));
this.modules.get(modName).addOption(key, name);
this.serverconfigs.add(key);
}
@Override
public boolean getConfig(String key, boolean defvalue){
mod_Waila.instance.config.load();
if (this.serverconfigs.contains(key) && !mod_Waila.instance.serverPresent)
return false;
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, defvalue);
return prop.getBoolean(defvalue);
}
public boolean isServerRequired(String key){
return this.serverconfigs.contains(key);
}
@Override
public boolean getConfig(String key){
return this.getConfig(key, true);
}
}
+24
View File
@@ -0,0 +1,24 @@
package mcp.mobius.waila.addons;
import java.util.HashMap;
public class ConfigModule {
String modName;
HashMap<String, String> options;
public ConfigModule(String _modName){
this.modName = _modName;
this.options = new HashMap<String, String>();
}
public ConfigModule(String _modName, HashMap<String, String> _options) {
this.modName = _modName;
this.options = _options;
}
public void addOption(String key, String name){
this.options.put(key,name);
}
}
@@ -0,0 +1,344 @@
package mcp.mobius.waila.addons;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import au.com.bytecode.opencsv.CSVReader;
import net.minecraft.block.Block;
import codechicken.nei.api.API;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.handlers.HUDHandlerExternal;
public class ExternalModulesHandler implements IWailaRegistrar {
private static ExternalModulesHandler instance = null;
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> headProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> bodyProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> tailProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Integer, ArrayList<IWailaDataProvider>> stackProviders = new LinkedHashMap<Integer, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> headBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> bodyBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> tailBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaDataProvider>> stackBlockProviders = new LinkedHashMap<Class, ArrayList<IWailaDataProvider>>();
public LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>> wikiDescriptions = new LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>>();
public LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>> summaryProviders = new LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>>();
private ExternalModulesHandler() {
instance = this;
}
public static ExternalModulesHandler instance(){
if (ExternalModulesHandler.instance == null)
ExternalModulesHandler.instance = new ExternalModulesHandler();
return ExternalModulesHandler.instance;
}
@Override
public void addConfig(String modname, String key, String configname) {
ConfigHandler.instance().addConfig(modname, key, configname);
}
@Override
public void addConfigRemote(String modname, String key, String configname) {
ConfigHandler.instance().addConfigServer(modname, key, configname);
}
@Override
public void registerHeadProvider(IWailaDataProvider dataProvider, int blockID) {
if (!this.headProviders.containsKey(blockID))
this.headProviders.put(blockID, new ArrayList<IWailaDataProvider>());
this.headProviders.get(blockID).add(dataProvider);
}
@Override
public void registerHeadProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.headBlockProviders.containsKey(block))
this.headBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
this.headBlockProviders.get(block).add(dataProvider);
}
@Override
public void registerBodyProvider(IWailaDataProvider dataProvider, int blockID) {
if (!this.bodyProviders.containsKey(blockID))
this.bodyProviders.put(blockID, new ArrayList<IWailaDataProvider>());
this.bodyProviders.get(blockID).add(dataProvider);
}
@Override
public void registerBodyProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.bodyBlockProviders.containsKey(block))
this.bodyBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
this.bodyBlockProviders.get(block).add(dataProvider);
}
public void registerTailProvider(IWailaDataProvider dataProvider, int blockID) {
if (!this.tailProviders.containsKey(blockID))
this.tailProviders.put(blockID, new ArrayList<IWailaDataProvider>());
this.tailProviders.get(blockID).add(dataProvider);
}
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.tailBlockProviders.containsKey(block))
this.tailBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
this.tailBlockProviders.get(block).add(dataProvider);
}
@Override
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID) {
if (!this.stackProviders.containsKey(blockID))
this.stackProviders.put(blockID, new ArrayList<IWailaDataProvider>());
this.stackProviders.get(blockID).add(dataProvider);
API.registerHighlightIdentifier(blockID, new HUDHandlerExternal());
}
@Override
public void registerStackProvider(IWailaDataProvider dataProvider, Class block) {
for (int i = 0; i < Block.blocksList.length; i++)
if (block.isInstance(Block.blocksList[i])){
this.registerStackProvider(dataProvider, i);
}
}
@Override
public void registerShortDataProvider(IWailaSummaryProvider dataProvider, Class item) {
if (!this.summaryProviders.containsKey(item))
this.summaryProviders.put(item, new ArrayList<IWailaSummaryProvider>());
this.summaryProviders.get(item).add(dataProvider);
}
/* Arrays getters */
public ArrayList<IWailaDataProvider> getHeadProviders(int blockID) {
return this.headProviders.get(blockID);
}
public ArrayList<IWailaDataProvider> getBodyProviders(int blockID) {
return this.bodyProviders.get(blockID);
}
public ArrayList<IWailaDataProvider> getTailProviders(int blockID) {
return this.tailProviders.get(blockID);
}
public ArrayList<IWailaDataProvider> getHeadProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.headBlockProviders.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.headBlockProviders.get(clazz));
return returnList;
}
public ArrayList<IWailaDataProvider> getBodyProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.bodyBlockProviders.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.bodyBlockProviders.get(clazz));
return returnList;
}
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.bodyBlockProviders.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.bodyBlockProviders.get(clazz));
return returnList;
}
public ArrayList<IWailaDataProvider> getStackProviders(int blockID) {
return this.stackProviders.get(blockID);
}
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
ArrayList<IWailaSummaryProvider> returnList = new ArrayList<IWailaSummaryProvider>();
for (Class clazz : this.summaryProviders.keySet())
if (clazz.isInstance(item))
returnList.addAll(this.summaryProviders.get(clazz));
return returnList;
}
/* Providers querry methods */
public boolean hasHeadProviders(int blockID){
return this.headProviders.containsKey(blockID);
}
public boolean hasBodyProviders(int blockID){
return this.bodyProviders.containsKey(blockID);
}
public boolean hasTailProviders(int blockID){
return this.tailProviders.containsKey(blockID);
}
public boolean hasStackProviders(int blockID){
return this.stackProviders.containsKey(blockID);
}
public boolean hasHeadProviders(Object block){
for (Class clazz : this.headBlockProviders.keySet())
if (clazz.isInstance(block))
return true;
return false;
}
public boolean hasBodyProviders(Object block){
for (Class clazz : this.bodyBlockProviders.keySet())
if (clazz.isInstance(block))
return true;
return false;
}
public boolean hasTailProviders(Object block){
for (Class clazz : this.tailBlockProviders.keySet())
if (clazz.isInstance(block))
return true;
return false;
}
public boolean hasSummaryProvider(Class item){
return this.summaryProviders.containsKey(item);
}
@Override
public void registerDocTextFile(String filename) {
List<String[]> docData = null;
int nentries = 0;
try{
docData = this.readFileAsString(filename);
} catch (IOException e){
mod_Waila.log.log(Level.WARNING, String.format("Error while accessing file %s : %s", filename, e));
return;
}
for (String[] ss : docData){
String modid = ss[0];
String name = ss[1];
String meta = ss[2];
String desc = ss[5].replace('$', '\n');
if (!(desc.trim().equals(""))){
if (!this.wikiDescriptions.containsKey(modid))
this.wikiDescriptions.put(modid, new LinkedHashMap <String, LinkedHashMap <String, String>>());
if (!this.wikiDescriptions.get(modid).containsKey(name))
this.wikiDescriptions.get(modid).put(name, new LinkedHashMap<String, String>());
this.wikiDescriptions.get(modid).get(name).put(meta, desc);
System.out.printf("Registered %s %s %s\n", modid, name, meta);
nentries += 1;
}
}
/*
String[] sections = docData.split(">>>>");
for (String s : sections){
s.trim();
if (!s.equals("")){
try{
String name = s.split("\r?\n",2)[0].trim();
String desc = s.split("\r?\n",2)[1].trim();
if (!this.wikiDescriptions.containsKey(modid))
this.wikiDescriptions.put(modid, new LinkedHashMap <String, String>());
this.wikiDescriptions.get(modid).put(name, desc);
nentries += 1;
}catch (Exception e){
System.out.printf("%s\n", e);
}
}
}
*/
mod_Waila.log.log(Level.INFO, String.format("Registered %s entries from %s", nentries, filename));
}
public boolean hasDocTextModID(String modid){
return this.wikiDescriptions.containsKey(modid);
}
public boolean hasDocTextItem(String modid, String item){
if (this.hasDocTextModID(modid))
return this.wikiDescriptions.get(modid).containsKey(item);
return false;
}
public boolean hasDocTextMeta(String modid, String item, String meta){
if (this.hasDocTextItem(modid, item))
return this.wikiDescriptions.get(modid).get(item).containsKey(meta);
return false;
}
public LinkedHashMap<String, String> getDocText(String modid, String name){
return this.wikiDescriptions.get(modid).get(name);
}
public String getDocText(String modid, String name, String meta){
return this.wikiDescriptions.get(modid).get(name).get(meta);
}
public boolean hasDocTextSpecificMeta(String modid, String name, String meta){
for (String s : this.getDocText(modid, name).keySet())
if (s.equals(meta))
return true;
return false;
}
public String getDoxTextWildcardMatch(String modid, String name){
Set<String> keys = this.wikiDescriptions.get(modid).keySet();
for (String s : keys){
String regexed = s;
regexed = regexed.replace(".", "\\.");
regexed = regexed.replace("*", ".*");
if (name.matches(s))
return s;
}
return null;
}
private List<String[]> readFileAsString(String filePath) throws IOException {
// URL fileURL = this.getClass().getResource(filePath);
// File filedata = new File(fileURL);
// Reader paramReader = new InputStreamReader(this.getClass().getResourceAsStream(filePath));
InputStream in = getClass().getResourceAsStream(filePath);
BufferedReader input = new BufferedReader(new InputStreamReader(in));
CSVReader reader = new CSVReader(input);
List<String[]> myEntries = reader.readAll();
reader.close();
return myEntries;
/*
StringBuffer fileData = new StringBuffer();
//BufferedReader reader = new BufferedReader(paramReader);
char[] buf = new char[1024];
int numRead=0;
while((numRead=input.read(buf)) != -1){
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
}
input.close();
return fileData.toString();
*/
}
}
@@ -0,0 +1,42 @@
package mcp.mobius.waila.addons.appeng;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
public class AppEngModule {
public static Class TileStorageMonitor = null;
public static Class IAEItemStack = null;
public static Method TileStorageMonitor_getItem = null;
public static Method IAEItemStack_getItemStack = null;
public static void register(){
try{
TileStorageMonitor = Class.forName("appeng.me.tile.TileStorageMonitor");
IAEItemStack = Class.forName("appeng.api.IAEItemStack");
TileStorageMonitor_getItem = TileStorageMonitor.getMethod("getItem");
IAEItemStack_getItemStack = IAEItemStack.getMethod("getItemStack");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[AppEng] Class not found. " + e);
return;
} catch (SecurityException e) {
mod_Waila.log.log(Level.WARNING, "[AppEng] Security Exception. " + e);
return;
} catch (NoSuchMethodException e) {
mod_Waila.log.log(Level.WARNING, "[AppEng] Method not found. " + e);
return;
}
mod_Waila.log.log(Level.WARNING, "Waila module AppEng succefully hooked.");
ExternalModulesHandler.instance().addConfig("Applied Energetic", "appeng.monitorcontent", "Monitor's content");
ExternalModulesHandler.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
}
}
@@ -0,0 +1,44 @@
package mcp.mobius.waila.addons.appeng;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDAppEngMonitor 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) {
TileEntity entity = accessor.getTileEntity();
if (entity != null){
if (config.getConfig("appeng.monitorcontent")){
try {
ItemStack stack = (ItemStack)AppEngModule.IAEItemStack_getItemStack.invoke(AppEngModule.IAEItemStack.cast(AppEngModule.TileStorageMonitor_getItem.invoke(entity)));
if (stack != null)
currenttip.add(stack.getDisplayName());
else
currenttip.add("<None>");
} catch (Exception e) {
System.out.printf("%s\n", e);
}
}
}
return currenttip;
}
}
@@ -0,0 +1,41 @@
package mcp.mobius.waila.addons.betterbarrels;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.addons.buildcraft.HUDHandlerBCPipes;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
public class BetterBarrelsModule {
public static Class TileEntityBarrel = null;
public static Class IBarrelStorage = null;
public static Field TileEntityBarrel_Storage = null;
public static Method IBarrelStorage_getItem = null;
public static void register(){
try{
TileEntityBarrel = Class.forName("mcp.mobius.betterbarrels.common.TileEntityBarrel");
IBarrelStorage = Class.forName("mcp.mobius.betterbarrels.common.IBarrelStorage");
TileEntityBarrel_Storage = TileEntityBarrel.getField("storage");
IBarrelStorage_getItem = IBarrelStorage.getMethod("getItem");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[BB] BetterBarrel classes not found.");
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[BB] Storage field not found.");
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[BB] getItem() not found.");
}
if (IBarrelStorage_getItem != null){
mod_Waila.log.log(Level.INFO, "Waila module BetterBarrel succefully hooked.");
ExternalModulesHandler.instance().addConfig("BetterBarrels", "bb.content", "Barrel's content");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBBContent(), TileEntityBarrel);
}
}
}
@@ -0,0 +1,59 @@
package mcp.mobius.waila.addons.betterbarrels;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
//import mcp.mobius.betterbarrels.common.TileEntityBarrel;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.api.ItemInfo.Layout;
import codechicken.nei.api.IHighlightHandler;
public class HUDHandlerBBContent 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) {
TileEntity entity = accessor.getTileEntity();
if (!config.getConfig("bb.content")) return currenttip;
if ((entity != null) && (BetterBarrelsModule.TileEntityBarrel.isInstance(entity))){
ItemStack stack = null;
try {
stack = (ItemStack) BetterBarrelsModule.IBarrelStorage_getItem.invoke(BetterBarrelsModule.TileEntityBarrel_Storage.get(entity));
} catch (Exception e){
mod_Waila.log.log(Level.SEVERE, "[BB] Unhandled exception trying to access a barrel storage for display !.\n" + String.valueOf(e));
currenttip.add("<ERROR!>");
return currenttip;
}
if (stack != null){
currenttip.add(stack.getDisplayName());
} else {
currenttip.add("<Empty>");
}
}
return currenttip;
}
}
@@ -0,0 +1,58 @@
package mcp.mobius.waila.addons.buildcraft;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import net.minecraftforge.common.ForgeDirection;
public class BCModule {
public static Class TileTank = null;
public static Class IPowerReceptor = null;
public static Class PipeTransportPower = null;
public static Class TileGenericPipe = null;
public static Class TileEngine = null;
public static Method TileTank_GetTanks = null;
public static Method IPowerReceptor_PowerRequest = null;
public static void register(){
try {
Class ModBuildcraftFactory = Class.forName("buildcraft.BuildCraftFactory");
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
return;
}
try{
TileTank = Class.forName("buildcraft.factory.TileTank");
IPowerReceptor = Class.forName("buildcraft.api.power.IPowerReceptor");
PipeTransportPower = Class.forName("buildcraft.transport.PipeTransportPower");
TileGenericPipe = Class.forName("buildcraft.transport.TileGenericPipe");
TileEngine = Class.forName("buildcraft.energy.TileEngine");
TileTank_GetTanks = TileTank.getMethod("getTanks", ForgeDirection.class);
IPowerReceptor_PowerRequest = IPowerReceptor.getMethod("powerRequest", ForgeDirection.class);
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[BC] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[BC] Method not found." + e);
return;
}
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tankamount", "Liquid amount");
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tanktype", "Liquid type");
ExternalModulesHandler.instance().addConfigRemote("Buildcraft", "bc.powerpipe", "Power pipes");
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCPipes(), TileGenericPipe);
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCEngine(), TileEngine);
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCIPowerReceptor(), PipeTransportPower);
}
}
@@ -0,0 +1,38 @@
package mcp.mobius.waila.addons.buildcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerBCEngine 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) {
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("energyF")){
//float output = tag.getFloat("energyF")*tag.getFloat("progress");
float output = tag.getFloat("energyF");
if (output > 1.0F)
currenttip.add(String.format("Output : %.1f MJ",output));
else
currenttip.add(String.format("Output : %.2f MJ",output));
}
return currenttip;
}
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.addons.buildcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerBCIPowerReceptor implements IWailaDataProvider {
public HUDHandlerBCIPowerReceptor() {
// TODO Auto-generated constructor stub
}
@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) {
// int powerRequest = 0;
// try{
// powerRequest = (Integer)BCModule.IPowerReceptor_PowerRequest.invoke(BCModule.IPowerReceptor.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN);
// }
// catch (Exception e){
// mod_Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
// return currenttip;
// }
// currenttip.add(String.valueOf(powerRequest));
NBTTagCompound tag = accessor.getNBTData();
return currenttip;
}
}
@@ -0,0 +1,47 @@
package mcp.mobius.waila.addons.buildcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerBCPipes 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) {
NBTTagCompound tag = accessor.getNBTData();
if (this.hasPartialKey(tag, "internalNextPower") && config.getConfig("bc.powerpipe")){
double power = Math.max(0, this.getPartialKeySum(tag, "internalNextPower"));
currenttip.add(String.format("Power : %.1f MJ", power));
}
return currenttip;
}
public boolean hasPartialKey(NBTTagCompound tag, String key){
for (Object k : tag.tagMap.keySet())
if (((String)k).contains(key))
return true;
return false;
}
public double getPartialKeySum(NBTTagCompound tag, String key){
double retVal = 0;
for (Object k : tag.tagMap.keySet())
if (((String)k).contains(key))
retVal += tag.getDouble((String)k);
return retVal;
}
}
@@ -0,0 +1,63 @@
package mcp.mobius.waila.addons.buildcraft;
import java.util.List;
import java.util.logging.Level;
//import buildcraft.factory.TileTank;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.LiquidStack;
public class HUDHandlerBCTanks 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) {
ILiquidTank tank = this.getTank(accessor);
LiquidStack stack = tank != null ? tank.getLiquid() : null;
String name = currenttip.get(0);
if (stack != null && ConfigHandler.instance().getConfig("bc.tanktype"))
name = name + " (" + stack.asItemStack().getDisplayName() + ")";
else if (stack == null && ConfigHandler.instance().getConfig("bc.tanktype"))
name = name + " <Empty>";
currenttip.set(0, name);
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
ILiquidTank tank = this.getTank(accessor);
LiquidStack stack = tank != null ? tank.getLiquid() : null;
int liquidAmount = stack != null ? stack.amount:0;
int capacity = tank != null ? tank.getCapacity() : 0;
if (ConfigHandler.instance().getConfig("bc.tankamount"))
currenttip.add(String.valueOf(liquidAmount) + "/" + String.valueOf(capacity) + " mB");
return currenttip;
}
public ILiquidTank getTank(IWailaDataAccessor accessor){
ILiquidTank tank = null;
try{
tank = ((ILiquidTank[])BCModule.TileTank_GetTanks.invoke(BCModule.TileTank.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN))[0];
} catch (Exception e){
mod_Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
return null;
}
return tank;
}
}
@@ -0,0 +1,52 @@
package mcp.mobius.waila.addons.enderstorage;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
public class EnderStorageModule {
public static Class TileFrequencyOwner = null;
public static Field TileFrequencyOwner_Freq = null;
public static Class EnderStorageManager = null;
public static Method GetColourFromFreq = null;
public static void register(){
try{
Class EnderStorage = Class.forName("codechicken.enderstorage.EnderStorage");
mod_Waila.log.log(Level.INFO, "EnderStorage mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
return;
}
try{
TileFrequencyOwner = Class.forName("codechicken.enderstorage.common.TileFrequencyOwner");
TileFrequencyOwner_Freq = TileFrequencyOwner.getField("freq");
EnderStorageManager = Class.forName("codechicken.enderstorage.api.EnderStorageManager");
GetColourFromFreq = EnderStorageManager.getDeclaredMethod("getColourFromFreq", Integer.TYPE, Integer.TYPE);
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Method not found." + e);
return;
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
return;
} catch (Exception e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfig("EnderStorage", "enderstorage.colors", "Colors");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerStorage(), TileFrequencyOwner);
}
}
@@ -0,0 +1,44 @@
package mcp.mobius.waila.addons.enderstorage;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerStorage implements IWailaDataProvider {
private static String[] colors = {"White", "Orange", "Magenta", "LBlue", "Yellow", "Lime", "Pink", "Gray", "LGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
@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(config.getConfig("enderstorage.colors")){
try{
int freq = EnderStorageModule.TileFrequencyOwner_Freq.getInt(accessor.getTileEntity());
int freqLeft = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 0);
int freqCenter = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 1);
int freqRight = (Integer)EnderStorageModule.GetColourFromFreq.invoke(null, freq, 2);
currenttip.add(String.format("%s/%s/%s", colors[freqLeft], colors[freqCenter], colors[freqRight]));
} catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
}
return currenttip;
}
}
@@ -0,0 +1,32 @@
package mcp.mobius.waila.addons.gravestone;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
public class GravestoneModule {
public static Class BlockGraveStone = null;
public static void register(){
try{
Class ModGravestone = Class.forName("GraveStone.ModGraveStone");
mod_Waila.log.log(Level.INFO, "GraveStone mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[GraveStone] GraveStone mod not found.");
return;
}
try {
BlockGraveStone = Class.forName("GraveStone.block.BlockGSGraveStone");
} catch (ClassNotFoundException e) {
mod_Waila.log.log(Level.WARNING, "[GraveStone] Class not found. " + e);
}
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
}
}
@@ -0,0 +1,27 @@
package mcp.mobius.waila.addons.gravestone;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerGravestone implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
}
@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) {
return currenttip;
}
}
@@ -0,0 +1,29 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerDoor implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return IC2Module.ReinforcedDoorStack;
}
@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) {
return currenttip;
}
}
@@ -0,0 +1,83 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class HUDHandlerIC2IEnergySink implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
int maxinput = -1;
try{
if (IC2Module.IEnergySink.isInstance(accessor.getTileEntity()))
maxinput = (Integer)(IC2Module.IEnergySink_GetInput.invoke(IC2Module.IEnergySink.cast(accessor.getTileEntity())));
} catch (Exception e){
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySink for display !.\n" + String.valueOf(e));
return currenttip;
}
int ntransformers = this.getTransformerUpgrades(accessor);
if (ntransformers > 0){
maxinput = maxinput * (int)Math.pow(4.0D, Math.min(3, ntransformers));
}
if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput > 4096))
currenttip.add("IN : ANY");
else if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput != -1) && !this.canUpgrade(accessor.getNBTData()))
currenttip.add(String.format("IN : %s EU/t", maxinput));
else if (ConfigHandler.instance().getConfig("ic2.inputeumach") && (maxinput != -1) && this.canUpgrade(accessor.getNBTData()))
currenttip.add(String.format("IN : %s EU/t", maxinput));
if (config.getConfig("ic2.storage"))
if (accessor.getNBTData().hasKey("energy") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
currenttip.add(String.format("Storage : %s EU", accessor.getNBTInteger(accessor.getNBTData(), "energy")));
return currenttip;
}
public boolean canUpgrade(NBTTagCompound tag){
if (tag.hasKey("InvSlots"))
if (tag.getCompoundTag("InvSlots").hasKey("upgrade"))
return true;
return false;
}
public int getTransformerUpgrades(IWailaDataAccessor accessor){
NBTTagCompound tag = accessor.getNBTData();
if (!canUpgrade(tag)) return -1;
int ntransformers = 0;
NBTTagList contents = tag.getCompoundTag("InvSlots").getCompoundTag("upgrade").getTagList("Contents");
for (NBTTagCompound subtag : (List<NBTTagCompound>)contents.tagList){
ItemStack currentSlot = new ItemStack(accessor.getNBTInteger(subtag, "id"),accessor.getNBTInteger(subtag, "Count"),accessor.getNBTInteger(subtag, "Damage"));
if (IC2Module.TransformerUpgradeStack.isItemEqual(currentSlot)){
ntransformers += currentSlot.stackSize;
}
}
return ntransformers;
}
}
@@ -0,0 +1,47 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
public class HUDHandlerIC2IEnergySource implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
int output = -1;
try{
if (IC2Module.IEnergySource.isInstance(accessor.getTileEntity()))
output = (Integer)(IC2Module.IEnergySource_GetOutput.invoke(IC2Module.IEnergySource.cast(accessor.getTileEntity())));
} catch (Exception e){
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySource for display !.\n" + String.valueOf(e));
return currenttip;
}
if (ConfigHandler.instance().getConfig("ic2.outputeu") && (output != -1))
currenttip.add(String.format("OUT : %s EU/t", output));
if (config.getConfig("ic2.storage"))
if (accessor.getNBTData().hasKey("storage") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
currenttip.add(String.format("Storage : %s EU", accessor.getNBTInteger(accessor.getNBTData(), "storage")));
return currenttip;
}
}
@@ -0,0 +1,47 @@
package mcp.mobius.waila.addons.ic2;
import java.util.List;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
public class HUDHandlerIC2IEnergyStorage 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 (!config.getConfig("ic2.storage"))
return currenttip;
int stored = -1;
int capacity = -1;
try{
if (IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
capacity = (Integer)(IC2Module.IEnergyStorage_GetCapacity.invoke(IC2Module.IEnergyStorage.cast(accessor.getTileEntity())));
} catch (Exception e){
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergyStorage for display !.\n" + String.valueOf(e));
return currenttip;
}
if (accessor.getNBTData().hasKey("energy"))
stored = accessor.getNBTInteger(accessor.getNBTData(), "energy");
if ((capacity != -1) && (stored != -1))
currenttip.add(String.format("%s/%s EU", stored, capacity));
return currenttip;
}
}
@@ -0,0 +1,91 @@
package mcp.mobius.waila.addons.ic2;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import net.minecraft.item.ItemStack;
public class IC2Module {
/* Our interfaces */
public static Class IEnergyStorage = null;
public static Class IEnergySink = null;
public static Class IEnergySource = null;
/* Methods interfaces */
public static Method IEnergyStorage_GetCapacity = null;
public static Method IEnergySink_GetInput = null;
public static Method IEnergySource_GetOutput = 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;
/* Fix for doors */
public static Class BlockIC2Door = null;
public static Field ReinforcedDoor = null;
public static ItemStack ReinforcedDoorStack = null;
public static void register(){
try{
Class ModIndustrialCraft = Class.forName("ic2.core.IC2");
mod_Waila.log.log(Level.INFO, "Industrialcraft2 mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[IC2] Industrialcraft2 mod not found.");
return;
}
try{
IEnergyStorage = Class.forName("ic2.api.tile.IEnergyStorage");
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
IEnergySource = Class.forName("ic2.api.energy.tile.IEnergySource");
IEnergySink_GetInput = IEnergySink.getMethod("getMaxSafeInput");
IEnergySource_GetOutput = IEnergySource.getMethod("getMaxEnergyOutput");
IEnergyStorage_GetCapacity = IEnergyStorage.getMethod("getCapacity");
IC2Items = Class.forName("ic2.core.Ic2Items");
TransformerUpgrade = IC2Items.getDeclaredField("transformerUpgrade");
EnergyStorageUpgrade = IC2Items.getDeclaredField("energyStorageUpgrade");
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
BlockIC2Door = Class.forName("ic2.core.block.BlockIC2Door");
ReinforcedDoor = IC2Items.getDeclaredField("reinforcedDoor");
ReinforcedDoorStack = (ItemStack)ReinforcedDoor.get(null);
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
return;
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
return;
} catch (Exception e){
mod_Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeumach", "Max EU input [Machines]");
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.inputeuother", "Max EU input [Other]");
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.outputeu", "Max EU output");
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.storage", "Energy stored");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySink(), IEnergySink);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySource(), IEnergySource);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergyStorage(), IEnergyStorage);
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerDoor(), BlockIC2Door);
}
}
@@ -0,0 +1,38 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
public class HUDHandlerCapacitor implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (config.getConfig("thaumcraft.storedvis")){
try{
short storedVis = ThaumcraftModule.TileCrystalCapacitor_StoredVis.getShort(accessor.getTileEntity());
short maxVis = ThaumcraftModule.TileCrystalCapacitor_MaxVis.getShort(accessor.getTileEntity());
currenttip.add(String.format("%s/%s vis", storedVis, maxVis));
}catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getClass().getName(), currenttip);
}
}
return currenttip;
}
}
@@ -0,0 +1,27 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerLeaves implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
}
@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) {
return currenttip;
}
}
@@ -0,0 +1,26 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerPlants implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
}
@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) {
return currenttip;
}
}
@@ -0,0 +1,57 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.lang.reflect.Field;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
public class ThaumcraftModule {
public static Class BlockMagicalLeaves = null;
public static Class BlockCustomPlant = null;
public static Class TileCrystalCapacitor = null;
public static Field TileCrystalCapacitor_StoredVis = null;
public static Field TileCrystalCapacitor_MaxVis = null;
public static void register(){
try{
Class ModThaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
mod_Waila.log.log(Level.INFO, "Thaumcraft mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
return;
}
try{
BlockMagicalLeaves = Class.forName("thaumcraft.common.world.BlockMagicalLeaves");
BlockCustomPlant = Class.forName("thaumcraft.common.world.BlockCustomPlant");
TileCrystalCapacitor = Class.forName("thaumcraft.common.tiles.TileCrystalCapacitor");
TileCrystalCapacitor_StoredVis = TileCrystalCapacitor.getField("storedVis");
TileCrystalCapacitor_MaxVis = TileCrystalCapacitor.getField("maxVis");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Class not found. " + e);
return;
// } catch (NoSuchMethodException e){
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Method not found." + e);
// return;
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Field not found." + e);
return;
// } catch (Exception e){
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
// return;
}
ExternalModulesHandler.instance().addConfig("Thaumcraft", "thaumcraft.storedvis", "Capacitor storage");
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerLeaves(), BlockMagicalLeaves);
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
}
}
@@ -0,0 +1,27 @@
package mcp.mobius.waila.addons.twilightforest;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class TwilightForestGenericOverride implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
}
@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) {
return currenttip;
}
}
@@ -0,0 +1,38 @@
package mcp.mobius.waila.addons.twilightforest;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
public class TwilightForestModule {
public static Class BlockTFRoots = null;
public static Class BlockTFPlant = null;
public static Class BlockTFSapling = null;
public static void register(){
try{
Class TwilightForestMod = Class.forName("twilightforest.TwilightForestMod");
mod_Waila.log.log(Level.INFO, "TwilightForestMod mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[TwilightForestMod] TwilightForestMod mod not found.");
return;
}
try {
BlockTFRoots = Class.forName("twilightforest.block.BlockTFRoots");
BlockTFPlant = Class.forName("twilightforest.block.BlockTFPlant");
BlockTFSapling = Class.forName("twilightforest.block.BlockTFSapling");
} catch (ClassNotFoundException e) {
mod_Waila.log.log(Level.WARNING, "[TwilightForestMod] Class not found. " + e);
}
ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFRoots);
ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFPlant);
//ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFSapling);
}
}
@@ -0,0 +1,146 @@
package mcp.mobius.waila.addons.vanillamc;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityMobSpawner;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerVanilla implements IWailaDataProvider {
static int mobSpawnerID = Block.mobSpawner.blockID;
static int cropsID = Block.crops.blockID;
static int melonStemID = Block.melonStem.blockID;
static int pumpkinStemID = Block.pumpkinStem.blockID;
static int carrotID = Block.carrot.blockID;
static int potatoID = Block.potato.blockID;
static int leverID = Block.lever.blockID;
static int repeaterIdle = Block.redstoneRepeaterIdle.blockID;
static int repeaterActv = Block.redstoneRepeaterActive.blockID;
static int comparatorIdl = Block.redstoneComparatorIdle.blockID;
static int comparatorAct = Block.redstoneComparatorActive.blockID;
static int redstone = Block.redstoneWire.blockID;
static int jukebox = Block.jukebox.blockID;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
int blockID = accessor.getBlockID();
/* Mob spawner handler */
if (blockID == mobSpawnerID && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
String name = currenttip.get(0);
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).func_98049_a().getEntityNameToSpawn();
currenttip.set(0, String.format("%s (%s)", name, mobname));
}
if (blockID == redstone){
String name = currenttip.get(0).replaceFirst(String.format(" %s", accessor.getMetadata()), "");
currenttip.set(0, name);
}
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
int blockID = accessor.getBlockID();
/* Crops */
if (config.getConfig("vanilla.growthvalue"))
if (blockID == cropsID || blockID == melonStemID || blockID == pumpkinStemID || blockID == carrotID || blockID == potatoID){
float growthValue = (accessor.getMetadata() / 7.0F) * 100.0F;
if (growthValue != 100.0)
currenttip.add(String.format("Growth : %.0f %%", growthValue));
else
currenttip.add("Growth : Mature");
return currenttip;
}
if (config.getConfig("vanilla.leverstate"))
if (blockID == leverID){
String redstoneOn = (accessor.getMetadata() & 8) == 0 ? "Off" : "On";
currenttip.add("State : " + redstoneOn);
return currenttip;
}
if (config.getConfig("vanilla.repeater"))
if ((blockID == repeaterIdle) ||(blockID == repeaterActv)){
int tick = (accessor.getMetadata() >> 2) + 1 ;
if (tick == 1)
currenttip.add(String.format("Delay : %s tick", tick));
else
currenttip.add(String.format("Delay : %s ticks", tick));
return currenttip;
}
if (config.getConfig("vanilla.comparator"))
if ((blockID == comparatorIdl) ||(blockID == comparatorAct)){
String mode = ((accessor.getMetadata() >> 2) & 1) == 0 ? "Comparator" : "Subtractor";
//int outputSignal = ((TileEntityComparator)entity).func_96100_a();
currenttip.add("Mode : " + mode);
//currenttip.add(String.format("Out : %s", outputSignal));
return currenttip;
}
if (config.getConfig("vanilla.redstone"))
if (blockID == redstone){
currenttip.add(String.format("Power : %s" , accessor.getMetadata()));
return currenttip;
}
if (config.getConfig("vanilla.jukebox"))
if (blockID == jukebox){
NBTTagCompound tag = accessor.getNBTData();
Item record = null;
if (tag.hasKey("Record")){
record = Item.itemsList[accessor.getNBTInteger(tag, "Record")];
currenttip.add(((ItemRecord)record).getRecordTitle());
} else {
currenttip.add("<Empty>");
}
}
return currenttip;
}
public static void register(){
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.spawntype", "Spawner type");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.growthvalue", "Growth value");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.leverstate", "Lever state");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.repeater", "Repeater delay");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.comparator", "Comparator mode");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.redstone", "Redstone power");
ExternalModulesHandler.instance().addConfigRemote("VanillaMC", "vanilla.jukebox", "Jukebox disk");
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), mobSpawnerID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), cropsID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), melonStemID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), pumpkinStemID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), carrotID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), potatoID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), leverID);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterIdle);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterActv);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorIdl);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorAct);
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), redstone);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), redstone);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), jukebox);
ExternalModulesHandler.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
}
}
+32
View File
@@ -0,0 +1,32 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaBlock {
/*
* Use this method to return an item stack in case the default lookup system fails.
* Return null if you want to use the default lookup system.
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
*/
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config);
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
* body to where you mostly want to put informations, and I reserve the tail for modname display
*/
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD.
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack().
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info.
* currenttip represents the current list of text lines in the tooltip zone.
* For example, getWailaHead() will have the current item name as currenttip.
* You can modify the tips, add more, remove some, etc.
* When you are done, just returns the currenttip and it will display in Waila.
*
* Always return the currenttip is you don't want to modify the current zone.
*/
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}
@@ -0,0 +1,26 @@
package mcp.mobius.waila.api;
import java.util.HashMap;
import java.util.Set;
public interface IWailaConfigHandler {
/* Returns a set of all the currently loaded modules in the config handler */
public Set<String> getModuleNames();
/* Returns all the currently available options for a given module */
public HashMap<String, String> getConfigKeys(String modName);
/* Add a new option to a given module
*
* modName is the name of the module to add the option to (ie : Buildcraft, IndustrialCraft2, etc)
* key is the config key (ie : bc.tankcontent, ic2.inputvalue)
* name is the human readable name of the option (ie : "Tank content", "Max EU Input")
* */
//public void addConfig(String modName, String key, String name);
/* Returns the current value of an option (true/false) with a default value defvalue if not set*/
public boolean getConfig(String key, boolean defvalue);
/* Returns the current value of an option (true/false) with a default value true if not set*/
public boolean getConfig(String key);
}
@@ -0,0 +1,20 @@
package mcp.mobius.waila.api;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IWailaDataAccessor {
World getWorld();
EntityPlayer getPlayer();
Block getBlock();
int getBlockID();
int getMetadata();
TileEntity getTileEntity();
MovingObjectPosition getPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
}
@@ -0,0 +1,4 @@
package mcp.mobius.waila.api;
public interface IWailaDataProvider extends IWailaBlock{
}
+24
View File
@@ -0,0 +1,24 @@
package mcp.mobius.waila.api;
public interface IWailaRegistrar {
/* Add a config option in the section modname with displayed text configtext and access key keyname */
public void addConfig(String modname, String keyname, String configtext);
public void addConfigRemote(String modname, String keyname, String configtext);
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
/* Register a stack overrider for the given blockID */
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
/* Same thing, but works on a class hierarchy instead */
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
public void registerDocTextFile (String filename);
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
}
@@ -0,0 +1,21 @@
package mcp.mobius.waila.api;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
public interface IWailaSummaryProvider {
/* This interface is used to control the display data in the description screen */
/* BASIC TOOLS & ITEMS DATA */
//EnumToolMaterial getMaterial(ItemStack stack);
//String getMaterialName(ItemStack stack);
//String getEffectiveBlock(ItemStack stack);
//int getHarvestLevel(ItemStack stack);
//float getEfficiencyOnProperMaterial(ItemStack stack);
//int getEnchantability(ItemStack stack);
//int getDamageVsEntity(ItemStack stack);
//int getDurability(ItemStack stack);
LinkedHashMap<String, String> getSummary(ItemStack stack, LinkedHashMap<String, String> currentSummary, IWailaConfigHandler config);
}
+235
View File
@@ -0,0 +1,235 @@
package mcp.mobius.waila.gui;
import java.util.Collection;
import java.util.HashMap;
import org.lwjgl.input.Mouse;
import mcp.mobius.waila.gui.widget.IWidget;
import mcp.mobius.waila.gui.widget_old.Button2States;
import mcp.mobius.waila.gui.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;
}
}
@@ -0,0 +1,72 @@
package mcp.mobius.waila.gui;
import java.util.EnumSet;
import org.lwjgl.input.Keyboard;
import codechicken.nei.NEIClientConfig;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ConfigHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class ConfigKeyHandler extends KeyHandler {
public ConfigKeyHandler()
{
super(new KeyBinding[]{
new KeyBinding(Constants.BIND_WAILA_CFG, Keyboard.KEY_NUMPAD0),
new KeyBinding(Constants.BIND_WAILA_SHOW, Keyboard.KEY_NUMPAD1),
//new KeyBinding("key.wailatedump", Keyboard.KEY_NUMPAD1),
}, new boolean[]{
false,
false,
//false
});
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_CFG, "[Waila] Config screen");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_SHOW, "[Waila] Show/Hide");
//LanguageRegistry.instance().addStringLocalization("key.wailatedump", "[Waila] Dump server TE");
}
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if (!tickEnd) return;
Minecraft mc = Minecraft.getMinecraft();
if (kb.keyDescription == Constants.BIND_WAILA_CFG){
if(mc.currentScreen == null)
mc.displayGuiScreen(new GuiConfigScreen(mc.currentScreen));
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig("waila.showmode")){
boolean status = NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).getBooleanValue();
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(!status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig("waila.showmode")){
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(true);
}
}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
if (!tickEnd) return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig("waila.showmode")){
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(false);
}
}
@Override
public EnumSet<TickType> ticks() {
return EnumSet.of(TickType.CLIENT);
}
@Override
public String getLabel() {
return "Waila Config Screen Keybind";
}
}
+23
View File
@@ -0,0 +1,23 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiConfigScreen extends BaseWailaScreen {
public GuiConfigScreen(GuiScreen _parentGui) {
super(_parentGui);
}
@Override
/* We init the GUI data here (buttons, etc) */
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Done", null));
ContainerButtons container = new ContainerButtons(this, 5, height/2-10, width - 10, height);
container.addButton(new ButtonChangeScreen(201, "Waila", new GuiWailaConfig(this) ));
container.addButton(new ButtonChangeScreen(202, "Modules", new GuiModules(this)));
}
}
@@ -0,0 +1,57 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.gui.widget.ContainerTable;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui.widget.StackDisplay;
import net.minecraft.client.gui.GuiScreen;
public class GuiEnchantScreen extends BaseWailaScreen {
public ContainerTable widTable;
public StackDisplay widStackDisplay;
public Label widStackName;
public Label widStackEnchantability;
public GuiEnchantScreen(GuiScreen _parentGui) {
super(_parentGui);
this.zLevel = -1.0F;
this.widTable = new ContainerTable(this);
this.widStackDisplay = new StackDisplay(this);
this.widStackName = new Label(this);
this.widStackEnchantability = new Label(this);
this.widTable.setColumns(8, "\u00a7a\u00a7oName", "\u00a7a\u00a7oMin lvl", "\u00a7a\u00a7oMax lvl", "\u00a7a\u00a7oMod");
this.widTable.setHeight(this.res.getScaledHeight() - 16 - 32);
this.addWidget("datatable", this.widTable);
this.addWidget("stackdisplay", this.widStackDisplay);
this.addWidget("stackname", this.widStackName);
this.addWidget("stackenchant", this.widStackEnchantability);
}
@Override
/* Here we draw anything special, and super takes care of the buttons for us */
public void drawScreen(int i, int j, float f)
{
//this.parentGui.drawScreen(i, j, f);
//this.parentGui.allowUserInput = false;
super.drawScreen(i, j, f);
widTable.draw(this.getXCentered(widTable.getWidth()), 32, 0);
widStackDisplay.draw(this.getXCentered(widTable.getWidth()), 0, 0);
widStackName.draw(this.getXCentered(widTable.getWidth())+32, 0, 0);
widStackEnchantability.draw(this.getXCentered(widTable.getWidth())+32, 8, 0);
}
@Override
public void initGui()
{
}
@Override
public void drawDefaultBackground()
{
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
}
}
+62
View File
@@ -0,0 +1,62 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.gui.widget.ContainerTable;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui.widget.StackDisplay;
import mcp.mobius.waila.gui.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);
}
}
@@ -0,0 +1,33 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui.widget_old.ButtonConfigRemote;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiModuleOptions extends BaseWailaScreen {
private String modName;
public GuiModuleOptions(GuiScreen _parentGui, String _modName) {
super(_parentGui);
this.modName = _modName;
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
for (String key:ConfigHandler.instance().getConfigKeys(this.modName).keySet()){
if (ConfigHandler.instance().isServerRequired(key))
container.addButton(new ButtonConfigRemote(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
else
container.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
}
}
}
+31
View File
@@ -0,0 +1,31 @@
package mcp.mobius.waila.gui;
import java.util.HashMap;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiModules extends BaseWailaScreen {
private HashMap<String, GuiScreen> screens = new HashMap<String, GuiScreen>();
public GuiModules(GuiScreen _parentGui) {
super(_parentGui);
for (String key : ConfigHandler.instance().getModuleNames())
screens.put(key, new GuiModuleOptions(this, key));
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
for (String key : ConfigHandler.instance().getModuleNames())
container.addButton(new ButtonChangeScreen(-1, key, screens.get(key)));
}
}
+42
View File
@@ -0,0 +1,42 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.gui.widget.DraggableViewport;
import mcp.mobius.waila.gui.widget.StackDisplay;
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);
}
}
+29
View File
@@ -0,0 +1,29 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ButtonConfigNEI;
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiWailaConfig extends BaseWailaScreen {
public GuiWailaConfig(GuiScreen _parentGui) {
super(_parentGui);
// TODO Auto-generated constructor stub
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
container.addButton(new ButtonConfigNEI(-1, "Hidden", "Shown", "Show/Hide Waila", Constants.CFG_NEI_SHOW ));
container.addButton(new ButtonConfigOption(-1, "Maintained", "Toggled", "Toggle/Maintained", "waila.showmode" ));
container.addButton(new ButtonConfigOption(-1, "Hidden", "Visible", "Show ID:Metadata", "waila.showmetadata", false ));
}
}
+215
View File
@@ -0,0 +1,215 @@
package mcp.mobius.waila.gui.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.RenderEngine;
import net.minecraft.client.renderer.Tessellator;
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 RenderEngine 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);
}
}
@@ -0,0 +1,75 @@
package mcp.mobius.waila.gui.widget;
import java.util.ArrayList;
import mcp.mobius.waila.handlers.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;
}
}
}
@@ -0,0 +1,191 @@
package mcp.mobius.waila.gui.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;
}
}
@@ -0,0 +1,112 @@
package mcp.mobius.waila.gui.widget;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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;
}
}
+34
View File
@@ -0,0 +1,34 @@
package mcp.mobius.waila.gui.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);
}
+67
View File
@@ -0,0 +1,67 @@
package mcp.mobius.waila.gui.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;
}
}
@@ -0,0 +1,74 @@
package mcp.mobius.waila.gui.widget;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
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;
this.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;
}
}
@@ -0,0 +1,109 @@
package mcp.mobius.waila.gui.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;
}
}
+127
View File
@@ -0,0 +1,127 @@
package mcp.mobius.waila.gui.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);
}
}
@@ -0,0 +1,112 @@
package mcp.mobius.waila.gui.widget_old;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
public class Button2States extends GuiButton {
boolean state;
String label;
int labelSize;
String stateFalse;
String stateTrue;
public Button2States(int par1, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state) {
super(par1, 0, 0, 80, 20, _stateFalse);
state = _state;
label = _label;
stateFalse = _stateFalse;
stateTrue = _stateTrue;
labelSize = _labelSize;
this.displayString = state ? stateTrue:stateFalse;
}
public Button2States(int par1, int par2, int par3, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state) {
super(par1, par2, par3, _stateFalse);
state = _state;
label = _label;
stateFalse = _stateFalse;
stateTrue = _stateTrue;
labelSize = _labelSize;
this.displayString = state ? stateTrue:stateFalse;
}
public Button2States(int par1, int par2, int par3, int par4, int par5, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state) {
super(par1, par2, par3, par4, par5, _stateFalse);
state = _state;
label = _label;
stateFalse = _stateFalse;
stateTrue = _stateTrue;
labelSize = _labelSize;
this.displayString = state ? stateTrue:stateFalse;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if (this.drawButton)
{
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
par1Minecraft.renderEngine.bindTexture("/gui/gui.png");
if (this.labelSize == -1)
labelSize = fontrenderer.getStringWidth(this.label) + 5;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_82253_i = par2 >= this.xPosition + this.labelSize && par3 >= this.yPosition && par2 < this.xPosition + this.width + this.labelSize && par3 < this.yPosition + this.height;
int k = this.getHoverState(this.field_82253_i);
this.drawTexturedModalRect(this.xPosition + this.labelSize, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.labelSize + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(par1Minecraft, par2, par3);
int l = 14737632;
if (!this.enabled)
{
l = -6250336;
}
else if (this.field_82253_i)
{
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.labelSize + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
this.drawCenteredString(fontrenderer, this.label, this.xPosition + this.labelSize/2, this.yPosition + (this.height - 8) / 2, 14737632);
}
}
public void pressButton(){
state = state?false:true;
this.displayString = state ? stateTrue:stateFalse;
}
public boolean getState(){
return state;
}
@Override
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3)
{
return this.enabled && this.drawButton && par2 >= this.xPosition + this.labelSize && par3 >= this.yPosition && par2 < this.xPosition + this.labelSize + this.width && par3 < this.yPosition + this.height;
}
public int getHeight(){
return this.height;
}
public int getWidth(){
return this.width + this.labelSize;
}
public void setHeight(int value){
this.height = value;
}
public void setWidth(int value){
this.width = value;
}
}
@@ -0,0 +1,46 @@
package mcp.mobius.waila.gui.widget_old;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
public class ButtonChangeScreen extends GuiButton {
GuiScreen linkedScreen;
public ButtonChangeScreen(int par1, String par4Str, GuiScreen _linkedScreen) {
super(par1, 0, 0, 80, 20, par4Str);
this.linkedScreen = _linkedScreen;
}
public ButtonChangeScreen(int par1, int par2, int par3, String par4Str, GuiScreen _linkedScreen) {
super(par1, par2, par3, par4Str);
this.linkedScreen = _linkedScreen;
}
public ButtonChangeScreen(int par1, int par2, int par3, int par4, int par5, String par6Str, GuiScreen _linkedScreen) {
super(par1, par2, par3, par4, par5, par6Str);
this.linkedScreen = _linkedScreen;
}
public void pressButton(){
Minecraft mc = Minecraft.getMinecraft();
mc.displayGuiScreen(this.linkedScreen);
}
public int getHeight(){
return this.height;
}
public int getWidth(){
return this.width;
}
public void setHeight(int value){
this.height = value;
}
public void setWidth(int value){
this.width = value;
}
}
@@ -0,0 +1,39 @@
package mcp.mobius.waila.gui.widget_old;
import codechicken.nei.NEIClientConfig;
public class ButtonConfigNEI extends ButtonConfigOption {
public ButtonConfigNEI(int par1, String _stateFalse, String _stateTrue,
String _label, String _configKey) {
super(par1, _stateFalse, _stateTrue, _label, _configKey);
}
public ButtonConfigNEI(int par1, int par2, int par3, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state,
String _configKey) {
super(par1, par2, par3, _stateFalse, _stateTrue, _label, _labelSize,
_state, _configKey);
}
public ButtonConfigNEI(int par1, int par2, int par3, int par4, int par5,
String _stateFalse, String _stateTrue, String _label,
int _labelSize, boolean _state, String _configKey) {
super(par1, par2, par3, par4, par5, _stateFalse, _stateTrue, _label,
_labelSize, _state, _configKey);
}
@Override
public void setupInitialState(String _configKey, boolean _state){
this.configKey = _configKey;
this.state = NEIClientConfig.getSetting(this.configKey).getBooleanValue();
this.displayString = state ? stateTrue:stateFalse;
}
@Override
public void pressButton(){
super.pressButton();
this.state = !NEIClientConfig.getSetting(this.configKey).getBooleanValue();
NEIClientConfig.getSetting(this.configKey).setBooleanValue(this.state);
}
}
@@ -0,0 +1,54 @@
package mcp.mobius.waila.gui.widget_old;
import mcp.mobius.waila.mod_Waila;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
public class ButtonConfigOption extends Button2States {
String configKey;
public ButtonConfigOption(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey) {
super(par1, 0, 0, 80, 20, _stateFalse, _stateTrue, _label, -1, false);
this.setupInitialState(_configKey, true);
}
public ButtonConfigOption(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey, boolean _state) {
super(par1, 0, 0, 80, 20, _stateFalse, _stateTrue, _label, -1, _state);
this.setupInitialState(_configKey, _state);
}
public ButtonConfigOption(int par1, int par2, int par3, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
super(par1, par2, par3, _stateFalse, _stateTrue, _label, _labelSize, _state);
this.setupInitialState(_configKey, true);
}
public ButtonConfigOption(int par1, int par2, int par3, int par4, int par5, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
super(par1, par2, par3, par4, par5, _stateFalse, _stateTrue, _label, _labelSize, _state);
this.setupInitialState(_configKey, true);
}
public void setupInitialState(String _configKey, boolean _state){
this.configKey = _configKey;
this.state = this.readConfigKey(this.configKey, _state);
this.displayString = state ? stateTrue:stateFalse;
}
@Override
public void pressButton(){
super.pressButton();
this.writeConfigKey(this.configKey, this.state);
}
protected void writeConfigKey(String keyname, boolean value){
mod_Waila.instance.config.getCategory(Configuration.CATEGORY_GENERAL).put(keyname, new Property(keyname,String.valueOf(value),Property.Type.BOOLEAN));
mod_Waila.instance.config.save();
}
protected boolean readConfigKey(String keyname, boolean _state){
mod_Waila.instance.config.load();
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, keyname, _state);
return prop.getBoolean(_state);
}
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.gui.widget_old;
import mcp.mobius.waila.mod_Waila;
import net.minecraft.client.Minecraft;
public class ButtonConfigRemote extends ButtonConfigOption {
public ButtonConfigRemote(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey) {
super(par1, _stateFalse, _stateTrue, _label, _configKey);
}
public ButtonConfigRemote(int par1, String _stateFalse, String _stateTrue, String _label, String _configKey, boolean _state) {
super(par1, _stateFalse, _stateTrue, _label, _configKey, _state);
}
public ButtonConfigRemote(int par1, int par2, int par3, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
super(par1, par2, par3, _stateFalse, _stateTrue, _label, _labelSize, _state, _configKey);
}
public ButtonConfigRemote(int par1, int par2, int par3, int par4, int par5, String _stateFalse, String _stateTrue, String _label, int _labelSize, boolean _state, String _configKey) {
super(par1, par2, par3, par4, par5, _stateFalse, _stateTrue, _label, _labelSize, _state, _configKey);
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
this.enabled = mod_Waila.instance.serverPresent;
super.drawButton(par1Minecraft, par2, par3);
}
@Override
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3)
{
this.enabled = mod_Waila.instance.serverPresent;
return super.mousePressed(par1Minecraft, par2, par3);
}
@Override
protected int getHoverState(boolean par1)
{
this.enabled = mod_Waila.instance.serverPresent;
return super.getHoverState(par1);
}
}
@@ -0,0 +1,68 @@
package mcp.mobius.waila.gui.widget_old;
import java.util.ArrayList;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
public class ContainerButtons {
GuiScreen parentScreen;
int posX, posY, width, height;
int maxLabelSize = 0;
int maxColumnWidth = 0;
ArrayList<GuiButton> buttons = new ArrayList<GuiButton>();
public ContainerButtons(GuiScreen _parentScreen, int _posX, int _posY, int _width, int _height) {
this.parentScreen = _parentScreen;
this.posX = _posX; this.posY = _posY;
this.width = _width; this.height = _height;
this.maxColumnWidth = this.width/2;
}
public void addButton(GuiButton button){
this.buttons.add(button);
/*
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
if (button instanceof Button2States){
maxLabelSize = Math.max(maxLabelSize, fontrenderer.getStringWidth(((Button2States)button).label) + 5);
((Button2States)button).labelSize = maxLabelSize;
maxColumnWidth = Math.max(maxColumnWidth, ((Button2States)button).getWidth());
}
*/
/*
for (GuiButton other : this.buttons){
if (other instanceof Button2States)
((Button2States) other).labelSize = this.maxLabelSize;
if (other instanceof ButtonChangeScreen)
((ButtonChangeScreen) other).setWidth(maxColumnWidth);
}
*/
if (button instanceof Button2States){
((Button2States) button).setWidth(80);
((Button2States) button).labelSize = this.width/2 - 80;
button.xPosition = (this.buttons.size() - 1)%2 * this.width / 2 + this.posX;
button.yPosition = (this.buttons.size() - 1)/2 * 20 + this.posY;
}
if (button instanceof ButtonChangeScreen){
//((ButtonChangeScreen) button).setWidth(this.width/2);
((ButtonChangeScreen) button).setWidth(120);
button.xPosition = (this.buttons.size() - 1)%2 * this.width / 2 + this.posX + (this.width / 2 - ((ButtonChangeScreen) button).getWidth())/2;
button.yPosition = (this.buttons.size() - 1)/2 * 20 + this.posY;
}
this.parentScreen.buttonList.add(button);
}
}
@@ -0,0 +1,175 @@
package mcp.mobius.waila.handlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
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.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
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;
}
public String toString(){
return this.elements.toString();
}
}
+117
View File
@@ -0,0 +1,117 @@
package mcp.mobius.waila.handlers;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaDataAccessor;
public class DataAccessor implements IWailaDataAccessor {
public World world;
public EntityPlayer player;
public MovingObjectPosition mop;
public Block block;
public int blockID;
public int metadata;
public TileEntity entity;
public NBTTagCompound remoteNbt = null;
public long timeLastUpdate = System.currentTimeMillis();
public static DataAccessor instance = new DataAccessor();
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ);
this.block = Block.blocksList[this.blockID];
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
this.entity = world.getBlockTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
}
@Override
public World getWorld() {
return this.world;
}
@Override
public EntityPlayer getPlayer() {
return this.player;
}
@Override
public Block getBlock() {
return this.block;
}
@Override
public int getMetadata() {
return this.metadata;
}
@Override
public TileEntity getTileEntity() {
return this.entity;
}
@Override
public MovingObjectPosition getPosition() {
return this.mop;
}
@Override
public NBTTagCompound getNBTData() {
if (this.entity == null) return null;
if (this.isTagCorrect(this.remoteNbt))
return this.remoteNbt;
NBTTagCompound tag = new NBTTagCompound();
this.entity.writeToNBT(tag);
return tag;
}
@Override
public int getNBTInteger(NBTTagCompound tag, String keyname){
NBTBase subtag = tag.getTag(keyname);
if (subtag instanceof NBTTagInt)
return tag.getInteger(keyname);
if (subtag instanceof NBTTagShort)
return tag.getShort(keyname);
if (subtag instanceof NBTTagByte)
return tag.getByte(keyname);
return 0;
}
@Override
public int getBlockID() {
return this.blockID;
}
private boolean isTagCorrect(NBTTagCompound tag){
if (tag == null){
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
int x = tag.getInteger("x");
int y = tag.getInteger("y");
int z = tag.getInteger("z");
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
return true;
else {
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
}
}
@@ -0,0 +1,137 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.network.Packet0x01TERequest;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.IHighlightHandler;
import codechicken.nei.api.ItemInfo.Layout;
import cpw.mods.fml.common.network.PacketDispatcher;
public class HUDHandlerExternal implements IHighlightHandler {
@Override
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
DataAccessor accessor = DataAccessor.instance;
accessor.set(world, player, mop);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (IWailaBlock.class.isInstance(block)){
try{
return ((IWailaBlock)block).getWailaStack(accessor, ConfigHandler.instance());
}catch (Throwable e){
WailaExceptionHandler.handleErr(e, block.getClass().toString(), null);
}
}
if(ExternalModulesHandler.instance().hasStackProviders(blockID)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
try{
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
if (retval != null)
return retval;
}catch (Throwable e){
WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), null);
}
}
}
return null;
}
@Override
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
DataAccessor accessor = DataAccessor.instance;
accessor.set(world, player, mop);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent && (System.currentTimeMillis() - accessor.timeLastUpdate >= 250) ){
accessor.timeLastUpdate = System.currentTimeMillis();
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
}
if (IWailaBlock.class.isInstance(block)){
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (layout == Layout.HEADER)
try{
return ((IWailaBlock)block).getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
else if (layout == Layout.BODY)
try{
return ((IWailaBlock)block).getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(blockID))
try{
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(blockID))
try{
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(block)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(block))
try{
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(block)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(block))
try{
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(accessor.getTileEntity())){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(accessor.getTileEntity()))
try{
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(accessor.getTileEntity())){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(accessor.getTileEntity()))
try{
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
return currenttip;
}
}
@@ -0,0 +1,38 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.ItemInfo.Layout;
import codechicken.nei.api.IHighlightHandler;
public class HUDHandlerWaila implements IHighlightHandler {
@Override
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
return null;
}
@Override
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
if (layout == Layout.FOOTER){
String modName = mod_Waila.instance.getModName(itemStack);
if (modName != null && !modName.equals(""))
currenttip.add("\u00a79\u00a7o" + modName);
} else if (layout == Layout.HEADER && ConfigHandler.instance().getConfig("waila.showmetadata", false)){
if (currenttip.size() == 0)
currenttip.add("< Unnamed >");
else{
String name = currenttip.get(0);
currenttip.set(0, name + String.format(" %s:%s", world.getBlockId(mop.blockX, mop.blockY, mop.blockZ), world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ)));
}
}
return currenttip;
};
}
@@ -0,0 +1,171 @@
package mcp.mobius.waila.handlers;
import java.lang.reflect.Method;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.GuiEnchantScreen;
import mcp.mobius.waila.gui.widget.Label;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.forge.IContainerInputHandler;
public class HandlerEnchantment implements IContainerInputHandler {
static Class EplusApi;
static Method Tooltip;
@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_ENCH)){
//try{
int itemEnchantability = stackover.getItem().getItemEnchantability();
if (itemEnchantability == 0){return false;}
Minecraft mc = Minecraft.getMinecraft();
GuiEnchantScreen enchantScreen = new GuiEnchantScreen(mc.currentScreen);
enchantScreen.widStackDisplay.setStack(stackover);
enchantScreen.widStackName.setLabel("\u00a7f" + stackover.getDisplayName());
enchantScreen.widStackEnchantability.setLabel(String.format("\u00a7fEnchantability : %s", itemEnchantability));
Enchantment[] enchants = null;
if (stackover.getItem() == Item.book)
enchants = Enchantment.field_92090_c;
else
enchants = Enchantment.enchantmentsList;
for(Enchantment enchant : enchants){
if (enchant == null){continue;}
if (enchant.canApplyAtEnchantingTable(stackover) || stackover.getItem() == Item.book){
for (int lvl = enchant.getMinLevel(); lvl <= enchant.getMaxLevel(); lvl++){
int minEnchantEnchantability = enchant.getMinEnchantability(lvl);
int maxEnchantEnchantability = enchant.getMaxEnchantability(lvl);
int minItemEnchantability = 1;
int meanItemEnchantability = 1 + itemEnchantability/4;
int maxItemEnchantability = 1 + itemEnchantability/2;
int minModifiedEnchantability = (int)(0.85*minItemEnchantability + 0.5);
int meanModifiedEnchantability = (int)(1.00*meanItemEnchantability + 0.5);
int maxModifiedEnchantability = (int)(1.15*maxItemEnchantability + 0.5);
int minLevel = (int) ((minEnchantEnchantability - minModifiedEnchantability)/1.15);
int maxLevel = (int) ((maxEnchantEnchantability - maxModifiedEnchantability)/0.85);
int meanMinLevel = (int) ((minEnchantEnchantability - meanModifiedEnchantability)/1.0);
int meanMaxLevel = (int) ((maxEnchantEnchantability - meanModifiedEnchantability)/1.0);
enchantScreen.widTable.addRow(new Label(enchant.getTranslatedName(lvl)),
new Label(String.valueOf(minLevel)),
new Label(String.valueOf(maxLevel)),
//new Label(String.valueOf(meanMinLevel)),
//new Label(String.valueOf(meanMaxLevel)),
new Label("\u00a79\u00a7o"+ this.getEnchantModName(enchant))
);
//String description = this.getEnchantmentToolTip(enchant);
}
}
}
mc.displayGuiScreen(enchantScreen);
//}
//catch (NullPointerException e){
// System.out.printf("%s\n", e);
//}
}
return false;
}
public String getEnchantModName(Enchantment enchant){
String enchantPath = enchant.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
String enchantModName = "<Unknown>";
for (String s: mod_Waila.instance.modSourceList.keySet())
if (enchantPath.contains(s))
enchantModName = mod_Waila.instance.modSourceList.get(s);
if (enchantModName.equals("Minecraft Coder Pack"))
enchantModName = "Minecraft";
return enchantModName;
}
@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
}
private String getEnchantmentToolTip(Enchantment enchantment) {
try {
if (EplusApi == null) {
EplusApi = Class.forName("eplus.api.EplusApi");
}
if (Tooltip == null) {
Tooltip = EplusApi.getMethod("getEnchantmentToolTip", Enchantment.class);
}
return String.valueOf(Tooltip.invoke(null, enchantment));
} catch (Exception e) {
return "";
}
}
}
@@ -0,0 +1,77 @@
package mcp.mobius.waila.handlers;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.GuiIngameWiki;
import mcp.mobius.waila.gui.GuiTechTree;
import mcp.mobius.waila.gui.widget.ComponentDisplay;
import mcp.mobius.waila.gui.widget.StackDisplay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.forge.IContainerInputHandler;
public class HandlerTechTree implements IContainerInputHandler {
public HandlerTechTree() {}
@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);
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 keyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; }
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { }
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { return false; }
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; }
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { }
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { }
}
+101
View File
@@ -0,0 +1,101 @@
package mcp.mobius.waila.handlers;
import java.util.LinkedHashMap;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.gui.GuiIngameWiki;
import mcp.mobius.waila.gui.widget.Label;
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 (ExternalModulesHandler.instance().hasDocTextModID(modid)){
//Do we have an direct entry for this item ?
if (ExternalModulesHandler.instance().hasDocTextItem(modid, name)){
//We check if we have an exact match, a wildcard match and finally, an meta 0 match
if (ExternalModulesHandler.instance().hasDocTextMeta(modid, name, meta)){
return ExternalModulesHandler.instance().getDocText(modid, name, meta);
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, name, "*")){
return ExternalModulesHandler.instance().getDocText(modid, name, "*");
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, name, "0")){
return ExternalModulesHandler.instance().getDocText(modid, name, "0");
}
} else if (ExternalModulesHandler.instance().getDoxTextWildcardMatch(modid, name) != null) {
String key = ExternalModulesHandler.instance().getDoxTextWildcardMatch(modid, name);
if (ExternalModulesHandler.instance().hasDocTextMeta(modid, key, meta)){
return ExternalModulesHandler.instance().getDocText(modid, key, meta);
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, key, "*")){
return ExternalModulesHandler.instance().getDocText(modid, key, "*");
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, key, "0")){
return ExternalModulesHandler.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(mod_Waila.instance.getModID(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) { return false; }
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { }
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { return false; }
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; }
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { }
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { }
}
@@ -0,0 +1,32 @@
package mcp.mobius.waila.handlers;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaSummaryProvider;
public class SummaryProvider {
private static SummaryProvider instance = null;
private SummaryProvider() {
instance = this;
}
public static SummaryProvider instance(){
if (SummaryProvider.instance == null)
SummaryProvider.instance = new SummaryProvider();
return SummaryProvider.instance;
}
public LinkedHashMap<String, String> getSummary(ItemStack stack, IWailaConfigHandler config) {
LinkedHashMap<String, String> currentSummary = new LinkedHashMap<String, String>();
for (IWailaSummaryProvider provider : ExternalModulesHandler.instance().getSummaryProvider(stack.getItem())){
currentSummary = provider.getSummary(stack, currentSummary, config);
}
return currentSummary;
}
}
@@ -0,0 +1,213 @@
package mcp.mobius.waila.handlers;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IShearable;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaSummaryProvider;
public class SummaryProviderDefault implements IWailaSummaryProvider {
public SummaryProviderDefault() {
// TODO Auto-generated constructor stub
}
@Override
public LinkedHashMap<String, String> getSummary(ItemStack stack, LinkedHashMap<String, String> currentSummary, IWailaConfigHandler config) {
if (!(stack.getItem() instanceof ItemBlock)){
//For now, we have either a basic item or a tool/weapon/armor
if (this.getToolMaterialName(stack) != null){
currentSummary.put("Material", this.getToolMaterialName(stack));
currentSummary.put("Tier", this.getHarvestLevel(stack) != null?String.valueOf(this.getHarvestLevel(stack)):null);
currentSummary.put("Durability", this.getItemDurability(stack) != null?String.valueOf(this.getItemDurability(stack)):null);
currentSummary.put("Harvest", this.getEffectiveBlock(stack));
if (this.getEffectiveBlock(stack) != null)
currentSummary.put("Efficiency", this.getEfficiencyOnProperMaterial(stack) != null?String.valueOf(this.getEfficiencyOnProperMaterial(stack)):null);
currentSummary.put("Enchant", this.getToolEnchantability(stack) != null?String.valueOf(this.getToolEnchantability(stack)):null);
currentSummary.put("Damage", this.getDamageVsEntity(stack) != null?String.valueOf(this.getDamageVsEntity(stack)):null);
}
else if (this.getArmorMaterialName(stack) != null){
currentSummary.put("Material", this.getArmorMaterialName(stack));
currentSummary.put("Durability", this.getItemDurability(stack) != null?String.valueOf(this.getItemDurability(stack)):null);
currentSummary.put("Armor Value", this.getDamageReduction(stack) != null?String.valueOf(this.getDamageReduction(stack)):null);
currentSummary.put("Enchant", this.getArmorEnchantability(stack) != null?String.valueOf(this.getArmorEnchantability(stack)):null);
}
} else {
//We have an ItemBlock
ItemBlock itemBlock = (ItemBlock)stack.getItem();
Block block = Block.blocksList[itemBlock.getBlockID()];
try{currentSummary.put("Hardness", String.valueOf(block.getBlockHardness(Minecraft.getMinecraft().theWorld, 0, 0, 0)));} catch (Exception e){};
try{currentSummary.put("Resistance", String.valueOf(block.getExplosionResistance(null)));} catch (Exception e){};
try{
ArrayList<ItemStack> droppedStacks = block.getBlockDropped(Minecraft.getMinecraft().theWorld, 0, 0, 0, stack.getItemDamage(), 3);
if (droppedStacks.size() == 1)
currentSummary.put("Drop", droppedStacks.get(0).getDisplayName());
else
for (int i=0; i < droppedStacks.size(); i++)
currentSummary.put(String.format("Drop %s", i), droppedStacks.get(i).getDisplayName());
}catch (Exception e){System.out.printf("%s\n",e);};
try{
if (block instanceof IShearable){
IShearable shearable = (IShearable)block;
ArrayList<ItemStack> droppedStacks = shearable.onSheared(null, Minecraft.getMinecraft().theWorld, 0, 0, 0, 3);
if (droppedStacks.size() == 1)
currentSummary.put("Sheared", droppedStacks.get(0).getDisplayName());
else
for (int i=0; i < droppedStacks.size(); i++)
currentSummary.put(String.format("Sheared %s", i), droppedStacks.get(i).getDisplayName());
}
}catch (Exception e){System.out.printf("%s\n",e);};
}
return currentSummary;
}
public EnumToolMaterial getToolMaterial(ItemStack stack){
Class itemClass = stack.getItem().getClass();
EnumToolMaterial material = null;
try{
Field getMaterial = this.findField(itemClass, "toolMaterial");
if (getMaterial != null){
getMaterial.setAccessible(true);
material = (EnumToolMaterial)(getMaterial.get(stack.getItem()));
}
} catch (Exception e){}
return material;
}
public EnumArmorMaterial getArmorMaterial(ItemStack stack){
Class itemClass = stack.getItem().getClass();
EnumArmorMaterial material = null;
try{
Field getMaterial = this.findField(itemClass, "material");
if (getMaterial != null){
getMaterial.setAccessible(true);
material = (EnumArmorMaterial)(getMaterial.get(stack.getItem()));
}
} catch (Exception e){}
return material;
}
public String getToolMaterialName(ItemStack stack){
EnumToolMaterial material = this.getToolMaterial(stack);
if (material == null)
return null;
HashMap<String, String> matName = new HashMap<String, String>();
matName.put("WOOD", "Wood");
matName.put("STONE", "Stone");
matName.put("IRON", "Iron");
matName.put("EMERALD", "Diamond");
matName.put("GOLD", "Gold");
String materialName = material.toString();
materialName = matName.containsKey(materialName)?matName.get(materialName):materialName;
return materialName;
}
public String getArmorMaterialName(ItemStack stack){
EnumArmorMaterial material = this.getArmorMaterial(stack);
if (material == null)
return null;
HashMap<String, String> matName = new HashMap<String, String>();
matName.put("CLOTH", "Cloth");
matName.put("CHAIN", "Chain");
matName.put("IRON", "Iron");
matName.put("DIAMOND", "Diamond");
matName.put("GOLD", "Gold");
String materialName = material.toString();
materialName = matName.containsKey(materialName)?matName.get(materialName):materialName;
return materialName;
}
public String getEffectiveBlock(ItemStack stack){
Class itemClass = stack.getItem().getClass();
try{
Field blocksEffectiveField = itemClass.getField("blocksEffectiveAgainst");
Block[] effectiveBlocksArray = (Block[])(blocksEffectiveField.get(stack.getItem()));
ArrayList<Block> effectiveBlocks = new ArrayList<Block>();
Collections.addAll(effectiveBlocks, effectiveBlocksArray);
String effectiveAgainst = "";
if (effectiveBlocks.contains(Block.obsidian))
effectiveAgainst = Block.obsidian.getLocalizedName();
else if (effectiveBlocks.contains(Block.stone))
effectiveAgainst = Block.stone.getLocalizedName();
else if (effectiveBlocks.contains(Block.dirt))
effectiveAgainst = Block.dirt.getLocalizedName();
else if (effectiveBlocks.contains(Block.wood))
effectiveAgainst = Block.wood.getLocalizedName();
return effectiveAgainst.equals("")?null:effectiveAgainst;
}catch (Exception e){}
return null;
}
public Integer getHarvestLevel(ItemStack stack){
EnumToolMaterial material = this.getToolMaterial(stack);
return material!=null?material.getHarvestLevel():null;
}
public Float getEfficiencyOnProperMaterial(ItemStack stack){
EnumToolMaterial material = this.getToolMaterial(stack);
return material!=null?material.getEfficiencyOnProperMaterial():null;
}
public Integer getToolEnchantability(ItemStack stack){
EnumToolMaterial material = this.getToolMaterial(stack);
return material!=null?material.getEnchantability():null;
}
public Integer getDamageVsEntity(ItemStack stack){
EnumToolMaterial material = this.getToolMaterial(stack);
return material!=null?material.getDamageVsEntity():null;
}
public Integer getItemDurability(ItemStack stack){
return stack.getMaxDamage() > 0?stack.getMaxDamage():null;
}
public Integer getDamageReduction(ItemStack stack){
if (stack.getItem() instanceof ItemArmor){
ItemArmor armor = (ItemArmor)stack.getItem();
return armor.damageReduceAmount;
}
return null;
}
public Integer getArmorEnchantability(ItemStack stack){
EnumArmorMaterial material = this.getArmorMaterial(stack);
return material!=null?material.getEnchantability():null;
}
public Field findField(Class lookup, String name){
Field retField = null;
try{
retField = lookup.getDeclaredField(name);
} catch (Exception e){
if (lookup.getSuperclass() == null)
retField = null;
else
retField = findField(lookup.getSuperclass(), name);
}
return retField;
}
}
@@ -0,0 +1,26 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import mcp.mobius.waila.mod_Waila;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.forge.IContainerTooltipHandler;
public class TooltipHandlerWaila implements IContainerTooltipHandler {
private mod_Waila waila = mod_Waila.instance;
@Override
public List<String> handleTooltipFirst(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
return currenttip;
}
@Override
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
String canonicalName = waila.getModName(itemstack);
if (canonicalName != null && !canonicalName.equals(""))
currenttip.add("\u00a79\u00a7o" + canonicalName);
return currenttip;
}
}
+159
View File
@@ -0,0 +1,159 @@
package mcp.mobius.waila;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.logging.Logger;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.network.WailaConnectionHandler;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.server.ProxyServer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.Configuration;
import codechicken.core.CommonUtils;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.IMCCallback;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.ItemData;
@Mod(modid="Waila", name="Waila", version="1.3.9")
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false,
connectionHandler = WailaConnectionHandler.class, packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
public class mod_Waila {
// The instance of your mod that Forge uses.
@Instance("Waila")
public static mod_Waila instance;
@SidedProxy(clientSide="mcp.mobius.waila.ProxyClient", serverSide="mcp.mobius.waila.server.ProxyServer")
public static ProxyServer proxy;
public static Logger log = Logger.getLogger("Waila");
private HashMap<Integer, String> itemMap = new HashMap<Integer, String>();
public Configuration config = null;
public boolean serverPresent = false;
public HashMap<String, String> modSourceList = new HashMap<String, String>();
@PreInit
public void preInit(FMLPreInitializationEvent event) {
config = new Configuration(event.getSuggestedConfigurationFile());
}
@Init
public void load(FMLInitializationEvent event) {
proxy.registerHandlers();
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
/* This section is about preloading the name/modid of the items in a table, so we don't look it up at every cycle */
NBTTagList itemDataList = new NBTTagList();
GameData.writeItemData(itemDataList);
for(int i = 0; i < itemDataList.tagCount(); i++)
{
ItemData itemData = new ItemData((NBTTagCompound) itemDataList.tagAt(i));
this.itemMap.put(itemData.getItemId(), itemData.getModId());
}
for (ModContainer mod : Loader.instance().getModList()) {
this.modSourceList.put(mod.getSource().getName(), mod.getName());
System.out.printf("%s\n", mod.getSource().getName());
}
// for (String s : this.modSourceList.keySet())
// if (this.modSourceList.get(s) == "Minecraft Coder Pack")
// this.modSourceList.put(s, "Minecraft");
}
@IMCCallback
public void processIMC(FMLInterModComms.IMCEvent event)
{
for (IMCMessage imcMessage : event.getMessages()){
if (!imcMessage.isStringMessage()) continue;
if (imcMessage.key.equalsIgnoreCase("addconfig")){
String[] params = imcMessage.getStringValue().split("\\$\\$");
if (params.length != 3){
mod_Waila.log.warning(String.format("Error while parsing config option from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
continue;
}
mod_Waila.log.info(String.format("Receiving config request from [ %s ] for %s", imcMessage.getSender(), imcMessage.getStringValue()));
ConfigHandler.instance().addConfig(params[0], params[1], params[2]);
}
if (imcMessage.key.equalsIgnoreCase("register")){
mod_Waila.log.info(String.format("Receiving registration request from [ %s ] for method %s", imcMessage.getSender(), imcMessage.getStringValue()));
this.callbackRegistration(imcMessage.getStringValue(), imcMessage.getSender());
}
}
}
public void callbackRegistration(String method, String modname){
String[] splitName = method.split("\\.");
String methodName = splitName[splitName.length-1];
String className = method.substring(0, method.length()-methodName.length()-1);
mod_Waila.log.info(String.format("Trying to reflect %s %s", className, methodName));
try{
Class reflectClass = Class.forName(className);
Method reflectMethod = reflectClass.getDeclaredMethod(methodName, IWailaRegistrar.class);
reflectMethod.invoke(null, (IWailaRegistrar)ExternalModulesHandler.instance());
mod_Waila.log.info(String.format("Success in registering %s", modname));
} catch (ClassNotFoundException e){
mod_Waila.log.warning(String.format("Could not find class %s", className));
} catch (NoSuchMethodException e){
mod_Waila.log.warning(String.format("Could not find method %s", methodName));
} catch (Exception e){
mod_Waila.log.warning(String.format("Exception while trying to access the method : %s", e.toString()));
}
}
public String getModName(ItemStack itemstack){
try{
String modID = this.itemMap.get(itemstack.itemID);
ModContainer mod = CommonUtils.findModContainer(modID);
String modname = mod == null ? modID : mod.getName();
return modname;
} catch (NullPointerException e){
//System.out.printf("NPE : %s\n",itemstack.toString());
return "";
}
}
public String getModID(ItemStack itemstack){
try{
String modID = this.itemMap.get(itemstack.itemID);
return modID;
} catch (NullPointerException e){
//System.out.printf("NPE : %s\n",itemstack.toString());
return "";
}
}
}
@@ -0,0 +1,39 @@
package mcp.mobius.waila.network;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.network.packet.Packet250CustomPayload;
public class Packet0x00ServerPing {
public byte header;
public Packet0x00ServerPing(Packet250CustomPayload packet){
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
try{
this.header = inputStream.readByte();
} catch (IOException e){}
}
public static Packet250CustomPayload create(){
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream bos = new ByteArrayOutputStream(1);
DataOutputStream outputStream = new DataOutputStream(bos);
try{
outputStream.writeByte(0x00);
}catch(IOException e){}
packet.channel = "Waila";
packet.data = bos.toByteArray();
packet.length = bos.size();
return packet;
}
}
@@ -0,0 +1,51 @@
package mcp.mobius.waila.network;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class Packet0x01TERequest {
public byte header;
public int worldID;
public int posX;
public int posY;
public int posZ;
public Packet0x01TERequest(Packet250CustomPayload packet){
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
try{
this.header = inputStream.readByte();
this.worldID = inputStream.readInt();
this.posX = inputStream.readInt();
this.posY = inputStream.readInt();
this.posZ = inputStream.readInt();
} catch (IOException e){}
}
public static Packet250CustomPayload create(World world, MovingObjectPosition mop){
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
DataOutputStream outputStream = new DataOutputStream(bos);
try{
outputStream.writeByte(0x01);
outputStream.writeInt(world.getWorldInfo().getDimension());
outputStream.writeInt(mop.blockX);
outputStream.writeInt(mop.blockY);
outputStream.writeInt(mop.blockZ);
}catch(IOException e){}
packet.channel = "Waila";
packet.data = bos.toByteArray();
packet.length = bos.size();
return packet;
}
}
@@ -0,0 +1,72 @@
package mcp.mobius.waila.network;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
public class Packet0x02TENBTData {
public byte header;
public NBTTagCompound tag;
public Packet0x02TENBTData(Packet250CustomPayload packet){
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
try{
this.header = inputStream.readByte();
this.tag = Packet0x02TENBTData.readNBTTagCompound(inputStream);
} catch (IOException e){}
}
public static Packet250CustomPayload create(NBTTagCompound tag){
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream bos = new ByteArrayOutputStream(1 + 4 + 4 + 4 + 4);
DataOutputStream outputStream = new DataOutputStream(bos);
try{
outputStream.writeByte(0x02);
Packet0x02TENBTData.writeNBTTagCompound(tag, outputStream);
}catch(IOException e){}
packet.channel = "Waila";
packet.data = bos.toByteArray();
packet.length = bos.size();
return packet;
}
public static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutputStream par1DataOutputStream) throws IOException
{
if (par0NBTTagCompound == null)
{
par1DataOutputStream.writeShort(-1);
}
else
{
byte[] abyte = CompressedStreamTools.compress(par0NBTTagCompound);
par1DataOutputStream.writeShort((short)abyte.length);
par1DataOutputStream.write(abyte);
}
}
public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream) throws IOException
{
short short1 = par0DataInputStream.readShort();
if (short1 < 0)
{
return null;
}
else
{
byte[] abyte = new byte[short1];
par0DataInputStream.readFully(abyte);
return CompressedStreamTools.decompress(abyte);
}
}
}
@@ -0,0 +1,40 @@
package mcp.mobius.waila.network;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class WailaConnectionHandler implements IConnectionHandler {
@Override
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
PacketDispatcher.sendPacketToPlayer(Packet0x00ServerPing.create(), player);
}
@Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) {
return null;
}
@Override
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {
}
@Override
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {
}
@Override
public void connectionClosed(INetworkManager manager) {
}
@Override
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {
}
}
@@ -0,0 +1,63 @@
package mcp.mobius.waila.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.handlers.DataAccessor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class WailaPacketHandler implements IPacketHandler {
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player){
if (packet.channel.equals("Waila")) {
byte header = this.getHeader(packet);
if (header == 0x00){
mod_Waila.log.info("Received server authentication msg. Remote sync will be activated");
mod_Waila.instance.serverPresent = true;
}
else if (header == 0x01){
Packet0x01TERequest castedPacket = new Packet0x01TERequest(packet);
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
TileEntity entity = DimensionManager.getWorld(castedPacket.worldID).getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
//TileEntity entity = server.worldServers[castedPacket.worldID].getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
if (entity != null){
try{
NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBT(tag);
PacketDispatcher.sendPacketToPlayer(Packet0x02TENBTData.create(tag), player);
}catch(Throwable e){
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
}
}
}
else if (header == 0x02){
Packet0x02TENBTData castedPacket = new Packet0x02TENBTData(packet);
DataAccessor.instance.remoteNbt = castedPacket.tag;
}
}
}
public byte getHeader(Packet250CustomPayload packet){
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
try{
return inputStream.readByte();
} catch (IOException e){
return -1;
}
}
}
+9
View File
@@ -0,0 +1,9 @@
package mcp.mobius.waila.server;
public class ProxyServer {
public ProxyServer() {}
public void registerHandlers(){}
}
Loaded 100 of 354 files, more files were not shown because too many files have changed in this diff. Show more