Compare commits

...
109 Commits
Author SHA1 Message Date
Thomas Guimbretiere 9b3cf62785 check for NEK and version bump. 2014-03-30 19:53:19 +02:00
Thomas Guimbretiere 0bb6caf334 Cleanup of TC module and addition of TT helmets handling. 2014-02-23 18:56:46 +01:00
Thomas Guimbretiere 5ac5f7956c Fixed Thaumcraft module. 2014-02-23 18:29:19 +01:00
Thomas Guimbretiere d00c17b3bb Fixed double registration of crops. 2014-02-23 17:34:36 +01:00
Thomas Guimbretiere 52ac40a10e Workaround for Morph eye height. 2014-02-23 17:29:09 +01:00
Thomas Guimbretiere 40facdda4b Added config option for Thaumcraft 2014-02-20 01:22:52 +01:00
Thomas Guimbretiere 3505888a82 Added new module section called "General".
Growth value and entity health are now config options there.
2014-02-20 00:34:09 +01:00
Thomas Guimbretiere 7eb35b7544 Max hp before text is now a config option 2014-02-20 00:24:22 +01:00
Thomas Guimbretiere 78039db017 Added support for Agriculture crop 2014-02-20 00:02:27 +01:00
Thomas Guimbretiere 17b5cbead9 Added tag Waila_1.5.0 for changeset ad46f8b41bbe 2014-02-19 23:44:28 +01:00
Thomas Guimbretiere d355ec28bb Added try/catch around NBT dumping client side. 2014-02-19 23:44:13 +01:00
Thomas Guimbretiere bd675cee28 Max hearts per line can be changed.
HP turns to text when max > 40
2014-02-19 23:21:42 +01:00
Thomas Guimbretiere 7c74db3640 Added lookup for known aspects. 2014-02-19 22:42:55 +01:00
Thomas Guimbretiere b65dc58fc6 Fixed tooltip size when name is bigger than tabbed display data. 2014-02-19 21:54:42 +01:00
Thomas Guimbretiere 1438d6a701 First fix for Entity hp display
Thaumcraft module will show aspects if the player is wearing googles of revealing.
2014-02-19 21:36:42 +01:00
Thomas Guimbretiere 223e2c7da6 Stopped bleeding gl constants at the end of rendering. 2014-02-19 18:52:27 +01:00
Thomas Guimbretiere 1aed35a2b5 Version bump
Local NBT is used if server sync is not available
Moved the "shift to see" handling to the tick handler directly
Fixed Steve's cart tank display
Both hide options for carpenter & secret rooms are not remote anymore.
2014-02-19 01:23:28 +01:00
Thomas Guimbretiere 96a0d27778 Added support for Statues. 2014-02-18 22:22:07 +01:00
Thomas Guimbretiere aecf8c0330 Moved the SpecialChars to the API
Deprecated the old IWailaBlock
2014-02-18 11:18:01 +01:00
Thomas Guimbretiere 4c1803accf Try at making a somewhat broken billboard code. 2014-02-18 10:46:59 +01:00
Thomas Guimbretiere 3ce45461eb Version bump 2014-02-18 02:43:42 +01:00
Thomas Guimbretiere 90dd086cc3 Added tag Waila_1.5.0_dev2 for changeset 1066f782daed 2014-02-18 02:43:32 +01:00
Thomas Guimbretiere fb9de99f39 Moved all the Vanilla module from ID to Block identification.
Fixed inheriting crop discovery
Added magical crops module.
2014-02-18 01:37:37 +01:00
Thomas Guimbretiere 1580296a2c Added Harvestcraft growth display 2014-02-18 01:04:20 +01:00
Thomas Guimbretiere 9d272f2e34 Fixed orientation of plates with alternate shapes. 2014-02-18 00:47:21 +01:00
Thomas Guimbretiere 2259e27f60 Ignore update 2014-02-17 22:44:13 +01:00
Thomas Guimbretiere 716498256b Added full FMP decorator support.
P:R decorator ported.
2014-02-17 22:41:00 +01:00
Thomas Guimbretiere bcd36dd638 Cleanup 2014-02-17 22:16:57 +01:00
Thomas Guimbretiere f790ac948d Replaced Project:Red old block registration with shiny new FMP registration.
Added DataAccessorFMP
2014-02-17 22:14:12 +01:00
Thomas Guimbretiere f282be75f4 FMPHandler registers itself properly when FMP is found. 2014-02-17 21:10:45 +01:00
Thomas Guimbretiere ec1ab8e548 Added registration for FMP data providers.
Moved getNBTInt to NBTUtil.
2014-02-17 20:36:02 +01:00
Thomas Guimbretiere add57cbd6b Spring cleaning on the registrar by abusing generics. 2014-02-17 20:09:28 +01:00
Thomas Guimbretiere ce249c806e Switched to generics for the registration. 2014-02-17 19:08:32 +01:00
Thomas Guimbretiere 3f6da9018c Tooltip cleanup works for entities too now. 2014-02-17 18:36:47 +01:00
Thomas Guimbretiere 2b7f3866a5 Separate config for blocks & entities 2014-02-17 18:32:50 +01:00
Thomas Guimbretiere b83d5bd297 Added shift toggled data display.
Will default to false, can be turned on in the config.
2014-02-17 18:02:45 +01:00
Thomas Guimbretiere 4e7e32fba7 Added config options for Steve's carts module.
Added toggle shift view.
2014-02-17 17:13:53 +01:00
Thomas Guimbretiere 2346ffd559 Steve's carts cargo and liquid managers done.
TODO : Add config options for EVERYTHING
2014-02-17 04:54:16 +01:00
Thomas Guimbretiere 49a2a32a77 Restricted synced keys for Carpenter's and SecretDoors. 2014-02-17 02:07:44 +01:00
Thomas Guimbretiere 47fb4c55a8 Carpenter's block module added 2014-02-17 02:05:08 +01:00
Thomas Guimbretiere b6b5404440 Added torches and trapdoors to the override. 2014-02-17 01:29:37 +01:00
Thomas Guimbretiere 89fc1c8ce7 Added secret room module.
Added lookup by TileEntity for override stack to the Raytracing routine.
2014-02-17 00:40:46 +01:00
Thomas Guimbretiere 79107209d9 Added option in the VanillaMC module to hide/show silverfishes.
It will default to true (Hide silverfishes).
2014-02-17 00:10:01 +01:00
Thomas Guimbretiere 3533ea2d23 Added comments to the accessors. 2014-02-16 23:45:24 +01:00
Thomas Guimbretiere f1a4056431 Try/Catch the creation of the stack in the Accessor (it does fail sometimes with some mods.) 2014-02-16 23:35:32 +01:00
Thomas Guimbretiere dcc35737be Added liquid display to Steve's carts.
Added getStack to the accessor to get the none overriden stack.
ID:Meta is now based on the override stack instead of the accessor.
Fixed a NPE when a stack provider returns a null stack.
Version bump.
2014-02-16 23:33:53 +01:00
Thomas Guimbretiere 4a3015eb21 Steve's carts first module test. 2014-02-15 21:13:27 +01:00
Thomas Guimbretiere d3a317e3dd All modules are now registering a full NBT sync request (just because it would be a pita to track down the keys). 2014-02-15 17:16:19 +01:00
Thomas Guimbretiere 9d1045333a Entity data is now synced too. 2014-02-15 17:01:14 +01:00
Thomas Guimbretiere 80e30abec3 Added partial NBT syncing to the protocol.
TEs will NOT be synced by default anymore. You actually have to either request "*" to get the whole NBT,
or request specific keys using "aaa.bbb", etc.
2014-02-15 16:41:38 +01:00
Thomas Guimbretiere 2dd88b9c13 Added synced NBT Key registration and retrieval. 2014-02-15 12:24:04 +01:00
Thomas Guimbretiere f46d9393b5 Refactoring & Cleanup 2014-02-15 11:43:12 +01:00
Thomas Guimbretiere d2f8911797 Right justification.
Fixed tooltip size prb.
2014-02-15 03:13:21 +01:00
Thomas Guimbretiere a1365b2db3 Tabulated display of IC2 tooltips. 2014-02-15 02:24:34 +01:00
Thomas Guimbretiere 0988ee744e Added Empty Heart to the icon list.
Fixed light prb (tesselator color reset)
Added life display to EntityLivingBase
2014-02-15 02:07:01 +01:00
Thomas Guimbretiere 537c3dc1af Icon rendering and handling is almost done. 2014-02-15 01:35:49 +01:00
Thomas Guimbretiere 5f7bf6cc5c Generic icon rendering method based on an enum with u,v,su,sv
Also handles adding a backgroup icon (for hearts for example).
2014-02-15 00:18:59 +01:00
Thomas Guimbretiere 904fe472b8 Code cleanup, basic icon rendering support. 2014-02-15 00:07:14 +01:00
Thomas Guimbretiere 0ef5f65067 Support for columns is now added. Inserting SpecialChars.TAB in a tooltip will create a new column.
Text in the columns is aligned properly when rendering.
2014-02-14 22:36:11 +01:00
Thomas Guimbretiere b6d529575d Basic line splitting
This will be redone and put here as reference.
2014-02-14 22:04:12 +01:00
Thomas Guimbretiere 669435f153 Moved string rendering to the Tooltip itself to allow for more complex stuff. 2014-02-14 18:42:54 +01:00
Thomas Guimbretiere f1c484d390 Moved more data to the Tooltip class for precomputation.
Only one overlay renderer now with offsets and data precomputed in the ClientTick (not more Entity vs Stack).
2014-02-14 18:32:32 +01:00
Thomas Guimbretiere ef20dcc4c6 Tooltip position & size computation moved out of the RenderTick into the ClientTick.
Will allow for more flexibility on how to render it too since more can be computed there.
2014-02-14 17:55:48 +01:00
Thomas Guimbretiere 1bbf3e8747 Server => Client config key syncing is operational. 2014-02-13 19:50:11 +01:00
Thomas Guimbretiere 3bc29dd907 Key forcing is now send over the network upon login. 2014-02-13 19:29:22 +01:00
Thomas Guimbretiere 23bbd2ceb4 Moved Overlay data to a separate class (OverlayConfig)
Moved default config file to ConfigHandler.
2014-02-13 19:00:37 +01:00
Thomas Guimbretiere d0e2932257 Server forcing config keys are generated.
The whole file is now loaded only once on startup.
2014-02-13 18:51:40 +01:00
Thomas Guimbretiere cf6ecd55e5 First pass at reworking the config system to handle multiple categories (General and modules for now) 2014-02-13 18:34:53 +01:00
Thomas Guimbretiere bfc2e5dec6 Declared Waila API as an API so it doesn't get messed up by other mods.
Fixes issue #22
2014-02-13 00:10:51 +01:00
Thomas Guimbretiere d6589ec1c1 Config options are added to the config file when the option is registered. 2014-02-12 23:51:01 +01:00
Thomas Guimbretiere 1cadab1320 Clean up
Added commented HP display for demonstration.
2014-02-12 22:57:21 +01:00
Thomas Guimbretiere 91aea326c7 Override for entities is in. 2014-02-12 22:27:10 +01:00
Thomas Guimbretiere d2c6d95e75 Entity tooltip is now handled by the API (registration, lookup, etc).
TODO : Add icon handling and overriding.
2014-02-12 22:12:32 +01:00
Thomas Guimbretiere 5a8673d322 Added & registered default empty module for Entities. 2014-02-12 18:57:59 +01:00
Thomas Guimbretiere 917eaab8be Added tag 1.4.5a for changeset 5dd753fa7c80 2014-02-12 18:20:19 +01:00
Thomas Guimbretiere 198d0c7079 Removed some logging
Reflection is now done with FML utilities
Fixes issue #17
Version bump
2014-02-12 18:20:11 +01:00
Thomas Guimbretiere 03f4bed4fe Added missing registrar methods for entities. 2014-02-11 21:10:46 +01:00
Thomas Guimbretiere 1bfcc07e1f Fixed getSide()
Fix for issue #21
2014-02-11 20:38:33 +01:00
Thomas Guimbretiere ef9a1bedfc Basic IWailaEntityProvider registration process implemented.
Removed duplicated stackProviders & decoratorProviders methods based on IDs
Deprecated ID based registration (in plan for 1.7)
2014-02-11 20:09:12 +01:00
Thomas Guimbretiere 4121e689fd Readded missing config call for ID:Meta display 2014-02-04 13:59:42 +01:00
Thomas Guimbretiere 0b1911b711 Added tag 1.4.5 for changeset 7ff010d0fad8 2014-02-04 13:59:22 +01:00
Thomas Guimbretiere ac73b6b537 Enable the rendering of the UI only is the UI is visible.
Might fix issue #11
2014-02-03 22:31:34 +01:00
Thomas Guimbretiere 4188ec37b2 Added override for redstone wires.
Fixes Issue #12
2014-02-03 22:24:54 +01:00
Thomas Guimbretiere 6cefb32520 Added safeguard if the NBT len > 32k to prevent client side crash.
Fixes Issue #9
2014-02-03 21:59:59 +01:00
Thomas Guimbretiere 7ba3a2b7e8 Removed depricated annotation. 2014-01-25 04:57:30 +01:00
Thomas Guimbretiere 3d7c3f0726 Update for 965 2014-01-25 04:45:56 +01:00
Thomas Guimbretiere 74cdb0fa1e New branch for forge_965 2014-01-12 14:56:22 +01:00
Thomas Guimbretiere dc07947ccf Merge with current 2014-01-12 14:53:07 +01:00
Thomas Guimbretiere 3b1f35e7a8 Updated default to 1.4.4b 2014-01-12 14:52:40 +01:00
Thomas Guimbretiere dbd06b2552 Removed MJ wrong handling of some internals. 2014-01-12 14:49:28 +01:00
Thomas Guimbretiere 9c121fb5c8 Added color constants. 2013-12-24 19:33:56 +01:00
Thomas Guimbretiere 28d19ef015 Clean up
Added setters for the IAccessor.
2013-12-24 18:28:01 +01:00
Thomas Guimbretiere 3843fd9815 Refactoring 2013-12-24 18:17:00 +01:00
Thomas Guimbretiere 2777e0ea80 Custom identifiers are now considered properly in the Tick handler 2013-12-24 15:45:25 +01:00
Thomas Guimbretiere e62f26a0ee The whole tooltip is now produced completly in Waila.
No more dependencies on NEI API for that.
2013-12-24 08:03:08 +01:00
Thomas Guimbretiere 403e2aad57 Tooltip rendering is not dependent on NEI API no more. 2013-12-24 07:48:36 +01:00
Thomas Guimbretiere c171d33e8c Some cleanup & added support for Footer. 2013-12-24 00:20:52 +01:00
Thomas Guimbretiere b1f7f2f2df Moved string gather to CLIENT tick for caching. 2013-12-24 00:01:18 +01:00
Thomas Guimbretiere a49d359656 Reworked the raytracing to make it cleaner and leaner. 2013-12-23 22:42:09 +01:00
Thomas Guimbretiere 03ec8ac17b Added code to call upon HUDHandlerExternal in the tick handler (commented)
TickHandler is now a singleton
2013-12-23 21:23:15 +01:00
Thomas Guimbretiere 75f3618424 Raytracing is now done in the CLIENT tick 2013-12-23 21:02:15 +01:00
Thomas Guimbretiere e400edb92f New Branch 2013-12-23 20:53:28 +01:00
Thomas Guimbretiere 42170ca050 Fixed wrong msgs on empty and microblocks. 2013-12-23 13:40:21 +01:00
Thomas Guimbretiere f9868afde1 Added support for Railcraft tanks. 2013-12-21 00:09:53 +01:00
Thomas Guimbretiere 4e79797cd1 Added support for OpenBlocks tanks. 2013-12-20 23:16:11 +01:00
Thomas Guimbretiere 921b245273 Added support for ExtraUtilities drums 2013-12-20 22:31:09 +01:00
Thomas Guimbretiere 2cbaeca169 Fixed Thermal Expansion conduits. 2013-12-20 21:52:53 +01:00
Thomas Guimbretiere bc344cab41 Added tag 1.4.3 for changeset 1c391d52f3d9 2013-12-17 18:59:24 +01:00
Thomas Guimbretiere 005cc66115 Merge with dev 2013-06-29 15:22:48 +02:00
162 changed files with 6412 additions and 1831 deletions

No files matched your search

+3
View File
@@ -132,3 +132,6 @@ option.bcapi.consump=Zeige maximale Energie
option.bcapi.trigger=Zeige Startenergie
option.pr.showio=Zeige Gatter IO
option.pr.showdata=Zeige Gatterdaten
option.extrautilities.fluidamount=Zeige Flüssigk.-Menge
option.openblocks.fluidamount=Zeige Flüssigk.-Menge
option.railcraft.fluidamount=Zeige Flüssigk.-Menge
+14
View File
@@ -18,6 +18,8 @@ choice.showhidewaila=Show/Hide Waila
choice.showhideidmeta=Show ID:Metadata
choice.toggledmaintained=Toggled/Maintained
choice.showliquids=Liquids
choice.shifttoggledblock=Sneak toggle blocks
choice.shifttoggledents=Sneak toggle entities
screen.button.configureaspect=Configure aspect...
enchant.title.name=Name
@@ -122,6 +124,7 @@ option.vanilla.repeater=Repeater delay
option.vanilla.comparator=Comparator mode
option.vanilla.redstone=Redstone power
option.vanilla.jukebox=Jukebox disk
option.vanilla.silverfish=Hide silverfish
option.etb.displaydata=Show socket data
option.enderio.inout=Show input/output
option.enderio.storage=Show stored MJ
@@ -132,3 +135,14 @@ option.bcapi.consump=Show maximum power
option.bcapi.trigger=Show triggering energy
option.pr.showio=Show gates IO
option.pr.showdata=Show gates data
option.extrautilities.fluidamount=Show fluid amount
option.openblocks.fluidamount=Show fluid amount
option.railcraft.fluidamount=Show fluid amount
option.secretrooms.hide=Hide camo blocks
option.carpenters.hide=Hide camo blocks
option.stevescarts.showall=Show data
option.stevescarts.colorblind=Colorblind mode
option.stevescarts.shifttoggle=Shift toggle
option.general.showhp=Show entities health
option.general.showcrop=Show crop growth
option.thaumcraft.aspects=Show aspects
+4 -1
View File
@@ -130,4 +130,7 @@ option.bcapi.storage=Afficher MJ stocké
option.bcapi.consump=Afficher puissance maximale
option.bcapi.trigger=Energie déclanchement
option.pr.showio=Afficher plaques IO
option.pr.showdata=Afficher plaques data
option.pr.showdata=Afficher plaques data
option.extrautilities.fluidamount=Afficher niveau fluides
option.openblocks.fluidamount=Afficher niveau fluides
option.railcraft.fluidamount=Afficher niveau fluides
+4 -1
View File
@@ -111,4 +111,7 @@ option.vanilla.leverstate=Hendel status
option.vanilla.repeater=Herhaler vertraging
option.vanilla.comparator=Vergelijker modus
option.vanilla.redstone=Redstone vermogen
option.vanilla.jukebox=Jukebox schijf
option.vanilla.jukebox=Jukebox schijf
option.extrautilities.fluidamount=Toon vloeistofhoeveelheid
option.openblocks.fluidamount=Toon vloeistofhoeveelheid
option.railcraft.fluidamount=Toon vloeistofhoeveelheid
+3
View File
@@ -126,3 +126,6 @@ option.bcapi.consump=Показывать макс. энергию
option.bcapi.trigger=Показывать энергию активации
option.pr.showio=Показывать ввод/вывод схем
option.pr.showdata=Показывать инф. о схемах
option.extrautilities.fluidamount=Показывать кол-во жидкости
option.openblocks.fluidamount=Показывать кол-во жидкости
option.railcraft.fluidamount=Показывать кол-во жидкости
+323
View File
@@ -0,0 +1,323 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
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
http://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.
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A very simple CSV parser released under a commercial-friendly license.
* This just implements splitting a single line into fields.
*
* @author Glen Smith
* @author Rainer Pruy
*/
public class CSVParser {
private final char separator;
private final char quotechar;
private final char escape;
private final boolean strictQuotes;
private String pending;
private boolean inField = false;
private final boolean ignoreLeadingWhiteSpace;
/**
* The default separator to use if none is supplied to the constructor.
*/
public static final char DEFAULT_SEPARATOR = ',';
public static final int INITIAL_READ_SIZE = 128;
/**
* The default quote character to use if none is supplied to the
* constructor.
*/
public static final char DEFAULT_QUOTE_CHARACTER = '"';
/**
* The default escape character to use if none is supplied to the
* constructor.
*/
public static final char DEFAULT_ESCAPE_CHARACTER = '\\';
/**
* The default strict quote behavior to use if none is supplied to the
* constructor
*/
public static final boolean DEFAULT_STRICT_QUOTES = false;
/**
* The default leading whitespace behavior to use if none is supplied to the
* constructor
*/
public static final boolean DEFAULT_IGNORE_LEADING_WHITESPACE = true;
/**
* This is the "null" character - if a value is set to this then it is ignored.
* I.E. if the quote character is set to null then there is no quote character.
*/
public static final char NULL_CHARACTER = '\0';
/**
* Constructs CSVParser using a comma for the separator.
*/
public CSVParser() {
this(DEFAULT_SEPARATOR, DEFAULT_QUOTE_CHARACTER, DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVParser with supplied separator.
*
* @param separator the delimiter to use for separating entries.
*/
public CSVParser(char separator) {
this(separator, DEFAULT_QUOTE_CHARACTER, DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVParser with supplied separator and quote char.
*
* @param separator the delimiter to use for separating entries
* @param quotechar the character to use for quoted elements
*/
public CSVParser(char separator, char quotechar) {
this(separator, quotechar, DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param separator the delimiter to use for separating entries
* @param quotechar the character to use for quoted elements
* @param escape the character to use for escaping a separator or quote
*/
public CSVParser(char separator, char quotechar, char escape) {
this(separator, quotechar, escape, DEFAULT_STRICT_QUOTES);
}
/**
* Constructs CSVReader with supplied separator and quote char.
* Allows setting the "strict quotes" flag
*
* @param separator the delimiter to use for separating entries
* @param quotechar the character to use for quoted elements
* @param escape the character to use for escaping a separator or quote
* @param strictQuotes if true, characters outside the quotes are ignored
*/
public CSVParser(char separator, char quotechar, char escape, boolean strictQuotes) {
this(separator, quotechar, escape, strictQuotes, DEFAULT_IGNORE_LEADING_WHITESPACE);
}
/**
* Constructs CSVReader with supplied separator and quote char.
* Allows setting the "strict quotes" and "ignore leading whitespace" flags
*
* @param separator the delimiter to use for separating entries
* @param quotechar the character to use for quoted elements
* @param escape the character to use for escaping a separator or quote
* @param strictQuotes if true, characters outside the quotes are ignored
* @param ignoreLeadingWhiteSpace if true, white space in front of a quote in a field is ignored
*/
public CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace) {
if (anyCharactersAreTheSame(separator, quotechar, escape)) {
throw new UnsupportedOperationException("The separator, quote, and escape characters must be different!");
}
if (separator == NULL_CHARACTER) {
throw new UnsupportedOperationException("The separator character must be defined!");
}
this.separator = separator;
this.quotechar = quotechar;
this.escape = escape;
this.strictQuotes = strictQuotes;
this.ignoreLeadingWhiteSpace = ignoreLeadingWhiteSpace;
}
private boolean anyCharactersAreTheSame(char separator, char quotechar, char escape) {
return isSameCharacter(separator, quotechar) || isSameCharacter(separator, escape) || isSameCharacter(quotechar, escape);
}
private boolean isSameCharacter(char c1, char c2) {
return c1 != NULL_CHARACTER && c1 == c2;
}
/**
* @return true if something was left over from last call(s)
*/
public boolean isPending() {
return pending != null;
}
public String[] parseLineMulti(String nextLine) throws IOException {
return parseLine(nextLine, true);
}
public String[] parseLine(String nextLine) throws IOException {
return parseLine(nextLine, false);
}
/**
* Parses an incoming String and returns an array of elements.
*
* @param nextLine the string to parse
* @param multi
* @return the comma-tokenized list of elements, or null if nextLine is null
* @throws IOException if bad things happen during the read
*/
private String[] parseLine(String nextLine, boolean multi) throws IOException {
if (!multi && pending != null) {
pending = null;
}
if (nextLine == null) {
if (pending != null) {
String s = pending;
pending = null;
return new String[]{s};
} else {
return null;
}
}
List<String> tokensOnThisLine = new ArrayList<String>();
StringBuilder sb = new StringBuilder(INITIAL_READ_SIZE);
boolean inQuotes = false;
if (pending != null) {
sb.append(pending);
pending = null;
inQuotes = true;
}
for (int i = 0; i < nextLine.length(); i++) {
char c = nextLine.charAt(i);
if (c == this.escape) {
if (isNextCharacterEscapable(nextLine, inQuotes || inField, i)) {
sb.append(nextLine.charAt(i + 1));
i++;
}
} else if (c == quotechar) {
if (isNextCharacterEscapedQuote(nextLine, inQuotes || inField, i)) {
sb.append(nextLine.charAt(i + 1));
i++;
} else {
//inQuotes = !inQuotes;
// the tricky case of an embedded quote in the middle: a,bc"d"ef,g
if (!strictQuotes) {
if (i > 2 //not on the beginning of the line
&& nextLine.charAt(i - 1) != this.separator //not at the beginning of an escape sequence
&& nextLine.length() > (i + 1) &&
nextLine.charAt(i + 1) != this.separator //not at the end of an escape sequence
) {
if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) {
sb.setLength(0); //discard white space leading up to quote
} else {
sb.append(c);
//continue;
}
}
}
inQuotes = !inQuotes;
}
inField = !inField;
} else if (c == separator && !inQuotes) {
tokensOnThisLine.add(sb.toString());
sb.setLength(0); // start work on next token
inField = false;
} else {
if (!strictQuotes || inQuotes) {
sb.append(c);
inField = true;
}
}
}
// line is done - check status
if (inQuotes) {
if (multi) {
// continuing a quoted section, re-append newline
sb.append("\n");
pending = sb.toString();
sb = null; // this partial content is not to be added to field list yet
} else {
throw new IOException("Un-terminated quoted field at end of CSV line");
}
}
if (sb != null) {
tokensOnThisLine.add(sb.toString());
}
return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]);
}
/**
* precondition: the current character is a quote or an escape
*
* @param nextLine the current line
* @param inQuotes true if the current context is quoted
* @param i current index in line
* @return true if the following character is a quote
*/
private boolean isNextCharacterEscapedQuote(String nextLine, boolean inQuotes, int i) {
return inQuotes // we are in quotes, therefore there can be escaped quotes in here.
&& nextLine.length() > (i + 1) // there is indeed another character to check.
&& nextLine.charAt(i + 1) == quotechar;
}
/**
* precondition: the current character is an escape
*
* @param nextLine the current line
* @param inQuotes true if the current context is quoted
* @param i current index in line
* @return true if the following character is a quote
*/
protected boolean isNextCharacterEscapable(String nextLine, boolean inQuotes, int i) {
return inQuotes // we are in quotes, therefore there can be escaped quotes in here.
&& nextLine.length() > (i + 1) // there is indeed another character to check.
&& (nextLine.charAt(i + 1) == quotechar || nextLine.charAt(i + 1) == this.escape);
}
/**
* precondition: sb.length() > 0
*
* @param sb A sequence of characters to examine
* @return true if every character in the sequence is whitespace
*/
protected boolean isAllWhiteSpace(CharSequence sb) {
boolean result = true;
for (int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
if (!Character.isWhitespace(c)) {
return false;
}
}
return result;
}
}
+282
View File
@@ -0,0 +1,282 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
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
http://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.
*/
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
/**
* A very simple CSV reader released under a commercial-friendly license.
*
* @author Glen Smith
*
*/
public class CSVReader implements Closeable {
private BufferedReader br;
private boolean hasNext = true;
private CSVParser parser;
private int skipLines;
private boolean linesSkiped;
/**
* The default line to start reading.
*/
public static final int DEFAULT_SKIP_LINES = 0;
/**
* Constructs CSVReader using a comma for the separator.
*
* @param reader
* the reader to an underlying CSV source.
*/
public CSVReader(Reader reader) {
this(reader, CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVReader with supplied separator.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries.
*/
public CSVReader(Reader reader, char separator) {
this(reader, separator, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
*/
public CSVReader(Reader reader, char separator, char quotechar) {
this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, DEFAULT_SKIP_LINES, CSVParser.DEFAULT_STRICT_QUOTES);
}
/**
* Constructs CSVReader with supplied separator, quote char and quote handling
* behavior.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param strictQuotes
* sets if characters outside the quotes are ignored
*/
public CSVReader(Reader reader, char separator, char quotechar, boolean strictQuotes) {
this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, DEFAULT_SKIP_LINES, strictQuotes);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escape
* the character to use for escaping a separator or quote
*/
public CSVReader(Reader reader, char separator,
char quotechar, char escape) {
this(reader, separator, quotechar, escape, DEFAULT_SKIP_LINES, CSVParser.DEFAULT_STRICT_QUOTES);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param line
* the line number to skip for start reading
*/
public CSVReader(Reader reader, char separator, char quotechar, int line) {
this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, line, CSVParser.DEFAULT_STRICT_QUOTES);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escape
* the character to use for escaping a separator or quote
* @param line
* the line number to skip for start reading
*/
public CSVReader(Reader reader, char separator, char quotechar, char escape, int line) {
this(reader, separator, quotechar, escape, line, CSVParser.DEFAULT_STRICT_QUOTES);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escape
* the character to use for escaping a separator or quote
* @param line
* the line number to skip for start reading
* @param strictQuotes
* sets if characters outside the quotes are ignored
*/
public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes) {
this(reader, separator, quotechar, escape, line, strictQuotes, CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE);
}
/**
* Constructs CSVReader with supplied separator and quote char.
*
* @param reader
* the reader to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escape
* the character to use for escaping a separator or quote
* @param line
* the line number to skip for start reading
* @param strictQuotes
* sets if characters outside the quotes are ignored
* @param ignoreLeadingWhiteSpace
* it true, parser should ignore white space before a quote in a field
*/
public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace) {
this.br = new BufferedReader(reader);
this.parser = new CSVParser(separator, quotechar, escape, strictQuotes, ignoreLeadingWhiteSpace);
this.skipLines = line;
}
/**
* Reads the entire file into a List with each element being a String[] of
* tokens.
*
* @return a List of String[], with each String[] representing a line of the
* file.
*
* @throws IOException
* if bad things happen during the read
*/
public List<String[]> readAll() throws IOException {
List<String[]> allElements = new ArrayList<String[]>();
while (hasNext) {
String[] nextLineAsTokens = readNext();
if (nextLineAsTokens != null)
allElements.add(nextLineAsTokens);
}
return allElements;
}
/**
* Reads the next line from the buffer and converts to a string array.
*
* @return a string array with each comma-separated element as a separate
* entry.
*
* @throws IOException
* if bad things happen during the read
*/
public String[] readNext() throws IOException {
String[] result = null;
do {
String nextLine = getNextLine();
if (!hasNext) {
return result; // should throw if still pending?
}
String[] r = parser.parseLineMulti(nextLine);
if (r.length > 0) {
if (result == null) {
result = r;
} else {
String[] t = new String[result.length+r.length];
System.arraycopy(result, 0, t, 0, result.length);
System.arraycopy(r, 0, t, result.length, r.length);
result = t;
}
}
} while (parser.isPending());
return result;
}
/**
* Reads the next line from the file.
*
* @return the next line from the file without trailing newline
* @throws IOException
* if bad things happen during the read
*/
private String getNextLine() throws IOException {
if (!this.linesSkiped) {
for (int i = 0; i < skipLines; i++) {
br.readLine();
}
this.linesSkiped = true;
}
String nextLine = br.readLine();
if (nextLine == null) {
hasNext = false;
}
return hasNext ? nextLine : null;
}
/**
* Closes the underlying reader.
*
* @throws IOException if the close fails
*/
public void close() throws IOException{
br.close();
}
}
+302
View File
@@ -0,0 +1,302 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
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
http://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.
*/
import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
/**
* A very simple CSV writer released under a commercial-friendly license.
*
* @author Glen Smith
*
*/
public class CSVWriter implements Closeable {
public static final int INITIAL_STRING_SIZE = 128;
private Writer rawWriter;
private PrintWriter pw;
private char separator;
private char quotechar;
private char escapechar;
private String lineEnd;
/** The character used for escaping quotes. */
public static final char DEFAULT_ESCAPE_CHARACTER = '"';
/** The default separator to use if none is supplied to the constructor. */
public static final char DEFAULT_SEPARATOR = ',';
/**
* The default quote character to use if none is supplied to the
* constructor.
*/
public static final char DEFAULT_QUOTE_CHARACTER = '"';
/** The quote constant to use when you wish to suppress all quoting. */
public static final char NO_QUOTE_CHARACTER = '\u0000';
/** The escape constant to use when you wish to suppress all escaping. */
public static final char NO_ESCAPE_CHARACTER = '\u0000';
/** Default line terminator uses platform encoding. */
public static final String DEFAULT_LINE_END = "\n";
private ResultSetHelper resultService = new ResultSetHelperService();
/**
* Constructs CSVWriter using a comma for the separator.
*
* @param writer
* the writer to an underlying CSV source.
*/
public CSVWriter(Writer writer) {
this(writer, DEFAULT_SEPARATOR);
}
/**
* Constructs CSVWriter with supplied separator.
*
* @param writer
* the writer to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries.
*/
public CSVWriter(Writer writer, char separator) {
this(writer, separator, DEFAULT_QUOTE_CHARACTER);
}
/**
* Constructs CSVWriter with supplied separator and quote char.
*
* @param writer
* the writer to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
*/
public CSVWriter(Writer writer, char separator, char quotechar) {
this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER);
}
/**
* Constructs CSVWriter with supplied separator and quote char.
*
* @param writer
* the writer to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escapechar
* the character to use for escaping quotechars or escapechars
*/
public CSVWriter(Writer writer, char separator, char quotechar, char escapechar) {
this(writer, separator, quotechar, escapechar, DEFAULT_LINE_END);
}
/**
* Constructs CSVWriter with supplied separator and quote char.
*
* @param writer
* the writer to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param lineEnd
* the line feed terminator to use
*/
public CSVWriter(Writer writer, char separator, char quotechar, String lineEnd) {
this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER, lineEnd);
}
/**
* Constructs CSVWriter with supplied separator, quote char, escape char and line ending.
*
* @param writer
* the writer to an underlying CSV source.
* @param separator
* the delimiter to use for separating entries
* @param quotechar
* the character to use for quoted elements
* @param escapechar
* the character to use for escaping quotechars or escapechars
* @param lineEnd
* the line feed terminator to use
*/
public CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd) {
this.rawWriter = writer;
this.pw = new PrintWriter(writer);
this.separator = separator;
this.quotechar = quotechar;
this.escapechar = escapechar;
this.lineEnd = lineEnd;
}
/**
* Writes the entire list to a CSV file. The list is assumed to be a
* String[]
*
* @param allLines
* a List of String[], with each String[] representing a line of
* the file.
*/
public void writeAll(List<String[]> allLines) {
for (String[] line : allLines) {
writeNext(line);
}
}
protected void writeColumnNames(ResultSet rs)
throws SQLException {
writeNext(resultService.getColumnNames(rs));
}
/**
* Writes the entire ResultSet to a CSV file.
*
* The caller is responsible for closing the ResultSet.
*
* @param rs the recordset to write
* @param includeColumnNames true if you want column names in the output, false otherwise
*
* @throws java.io.IOException thrown by getColumnValue
* @throws java.sql.SQLException thrown by getColumnValue
*/
public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames) throws SQLException, IOException {
if (includeColumnNames) {
writeColumnNames(rs);
}
while (rs.next())
{
writeNext(resultService.getColumnValues(rs));
}
}
/**
* Writes the next line to the file.
*
* @param nextLine
* a string array with each comma-separated element as a separate
* entry.
*/
public void writeNext(String[] nextLine) {
if (nextLine == null)
return;
StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE);
for (int i = 0; i < nextLine.length; i++) {
if (i != 0) {
sb.append(separator);
}
String nextElement = nextLine[i];
if (nextElement == null)
continue;
if (quotechar != NO_QUOTE_CHARACTER)
sb.append(quotechar);
sb.append(stringContainsSpecialCharacters(nextElement) ? processLine(nextElement) : nextElement);
if (quotechar != NO_QUOTE_CHARACTER)
sb.append(quotechar);
}
sb.append(lineEnd);
pw.write(sb.toString());
}
private boolean stringContainsSpecialCharacters(String line) {
return line.indexOf(quotechar) != -1 || line.indexOf(escapechar) != -1;
}
protected StringBuilder processLine(String nextElement)
{
StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE);
for (int j = 0; j < nextElement.length(); j++) {
char nextChar = nextElement.charAt(j);
if (escapechar != NO_ESCAPE_CHARACTER && nextChar == quotechar) {
sb.append(escapechar).append(nextChar);
} else if (escapechar != NO_ESCAPE_CHARACTER && nextChar == escapechar) {
sb.append(escapechar).append(nextChar);
} else {
sb.append(nextChar);
}
}
return sb;
}
/**
* Flush underlying stream to writer.
*
* @throws IOException if bad things happen
*/
public void flush() throws IOException {
pw.flush();
}
/**
* Close the underlying stream writer flushing any buffered content.
*
* @throws IOException if bad things happen
*
*/
public void close() throws IOException {
flush();
pw.close();
rawWriter.close();
}
/**
* Checks to see if the there has been an error in the printstream.
*/
public boolean checkError() {
return pw.checkError();
}
public void setResultService(ResultSetHelper resultService) {
this.resultService = resultService;
}
}
@@ -0,0 +1,33 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
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
http://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.
*/
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
*
*
*
*
*/
public interface ResultSetHelper {
public String[] getColumnNames(ResultSet rs) throws SQLException;
public String[] getColumnValues(ResultSet rs) throws SQLException, IOException;
}
@@ -0,0 +1,183 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
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
http://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.
*/
import java.io.IOException;
import java.io.Reader;
import java.math.BigDecimal;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* helper class for processing JDBC ResultSet objects
*
*
*/
public class ResultSetHelperService implements ResultSetHelper {
public static final int CLOBBUFFERSIZE = 2048;
// note: we want to maintain compatibility with Java 5 VM's
// These types don't exist in Java 5
private static final int NVARCHAR = -9;
private static final int NCHAR = -15;
private static final int LONGNVARCHAR = -16;
private static final int NCLOB = 2011;
public String[] getColumnNames(ResultSet rs) throws SQLException {
List<String> names = new ArrayList<String>();
ResultSetMetaData metadata = rs.getMetaData();
for (int i = 0; i < metadata.getColumnCount(); i++) {
names.add(metadata.getColumnName(i+1));
}
String[] nameArray = new String[names.size()];
return names.toArray(nameArray);
}
public String[] getColumnValues(ResultSet rs) throws SQLException, IOException {
List<String> values = new ArrayList<String>();
ResultSetMetaData metadata = rs.getMetaData();
for (int i = 0; i < metadata.getColumnCount(); i++) {
values.add(getColumnValue(rs, metadata.getColumnType(i + 1), i + 1));
}
String[] valueArray = new String[values.size()];
return values.toArray(valueArray);
}
private String handleObject(Object obj){
return obj == null ? "" : String.valueOf(obj);
}
private String handleBigDecimal(BigDecimal decimal) {
return decimal == null ? "" : decimal.toString();
}
private String handleLong(ResultSet rs, int columnIndex) throws SQLException {
long lv = rs.getLong(columnIndex);
return rs.wasNull() ? "" : Long.toString(lv);
}
private String handleInteger(ResultSet rs, int columnIndex) throws SQLException {
int i = rs.getInt(columnIndex);
return rs.wasNull() ? "" : Integer.toString(i);
}
private String handleDate(ResultSet rs, int columnIndex) throws SQLException {
java.sql.Date date = rs.getDate(columnIndex);
String value = null;
if (date != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
value = dateFormat.format(date);
}
return value;
}
private String handleTime(Time time) {
return time == null ? null : time.toString();
}
private String handleTimestamp(Timestamp timestamp) {
SimpleDateFormat timeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
return timestamp == null ? null : timeFormat.format(timestamp);
}
private String getColumnValue(ResultSet rs, int colType, int colIndex)
throws SQLException, IOException {
String value = "";
switch (colType)
{
case Types.BIT:
case Types.JAVA_OBJECT:
value = handleObject(rs.getObject(colIndex));
break;
case Types.BOOLEAN:
boolean b = rs.getBoolean(colIndex);
value = Boolean.valueOf(b).toString();
break;
case NCLOB: // todo : use rs.getNClob
case Types.CLOB:
Clob c = rs.getClob(colIndex);
if (c != null) {
value = read(c);
}
break;
case Types.BIGINT:
value = handleLong(rs, colIndex);
break;
case Types.DECIMAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.REAL:
case Types.NUMERIC:
value = handleBigDecimal(rs.getBigDecimal(colIndex));
break;
case Types.INTEGER:
case Types.TINYINT:
case Types.SMALLINT:
value = handleInteger(rs, colIndex);
break;
case Types.DATE:
value = handleDate(rs, colIndex);
break;
case Types.TIME:
value = handleTime(rs.getTime(colIndex));
break;
case Types.TIMESTAMP:
value = handleTimestamp(rs.getTimestamp(colIndex));
break;
case NVARCHAR: // todo : use rs.getNString
case NCHAR: // todo : use rs.getNString
case LONGNVARCHAR: // todo : use rs.getNString
case Types.LONGVARCHAR:
case Types.VARCHAR:
case Types.CHAR:
value = rs.getString(colIndex);
break;
default:
value = "";
}
if (value == null)
{
value = "";
}
return value;
}
private static String read(Clob c) throws SQLException, IOException
{
StringBuilder sb = new StringBuilder( (int) c.length());
Reader r = c.getCharacterStream();
char[] cbuf = new char[CLOBBUFFERSIZE];
int n;
while ((n = r.read(cbuf, 0, cbuf.length)) != -1) {
sb.append(cbuf, 0, n);
}
return sb.toString();
}
}
@@ -0,0 +1,37 @@
package au.com.bytecode.opencsv.bean;
import au.com.bytecode.opencsv.CSVReader;
import java.io.IOException;
/**
Copyright 2007 Kyle Miller.
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
http://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.
*/
public class ColumnPositionMappingStrategy<T> extends HeaderColumnNameMappingStrategy<T> {
private String[] columnMapping = new String[] {};
public void captureHeader(CSVReader reader) throws IOException {
//do nothing, first line is not header
}
protected String getColumnName(int col) {
return (null != columnMapping && col < columnMapping.length) ? columnMapping[col] : null ;
}
public String[] getColumnMapping() {
return columnMapping != null ? columnMapping.clone() : null;
}
public void setColumnMapping(String[] columnMapping) {
this.columnMapping = columnMapping != null ? columnMapping.clone() : null;
}
}
+119
View File
@@ -0,0 +1,119 @@
package au.com.bytecode.opencsv.bean;
/**
Copyright 2007 Kyle Miller.
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
http://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.
*/
import au.com.bytecode.opencsv.CSVReader;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CsvToBean<T> {
private Map<Class<?>, PropertyEditor> editorMap = null;
public CsvToBean() {
}
public List<T> parse(MappingStrategy<T> mapper, Reader reader) {
return parse(mapper, new CSVReader(reader));
}
public List<T> parse(MappingStrategy<T> mapper, CSVReader csv) {
try {
mapper.captureHeader(csv);
String[] line;
List<T> list = new ArrayList<T>();
while (null != (line = csv.readNext())) {
T obj = processLine(mapper, line);
list.add(obj); // TODO: (Kyle) null check object
}
return list;
} catch (Exception e) {
throw new RuntimeException("Error parsing CSV!", e);
}
}
protected T processLine(MappingStrategy<T> mapper, String[] line) throws IllegalAccessException, InvocationTargetException, InstantiationException, IntrospectionException {
T bean = mapper.createBean();
for (int col = 0; col < line.length; col++) {
PropertyDescriptor prop = mapper.findDescriptor(col);
if (null != prop) {
String value = checkForTrim(line[col], prop);
Object obj = convertValue(value, prop);
prop.getWriteMethod().invoke(bean, obj);
}
}
return bean;
}
private String checkForTrim(String s, PropertyDescriptor prop) {
return trimmableProperty(prop) ? s.trim() : s;
}
private boolean trimmableProperty(PropertyDescriptor prop) {
return !prop.getPropertyType().getName().contains("String");
}
protected Object convertValue(String value, PropertyDescriptor prop) throws InstantiationException, IllegalAccessException {
PropertyEditor editor = getPropertyEditor(prop);
Object obj = value;
if (null != editor) {
editor.setAsText(value);
obj = editor.getValue();
}
return obj;
}
private PropertyEditor getPropertyEditorValue(Class<?> cls) {
if (editorMap == null) {
editorMap = new HashMap<Class<?>, PropertyEditor>();
}
PropertyEditor editor = editorMap.get(cls);
if (editor == null) {
editor = PropertyEditorManager.findEditor(cls);
addEditorToMap(cls, editor);
}
return editor;
}
private void addEditorToMap(Class<?> cls, PropertyEditor editor) {
if (editor != null) {
editorMap.put(cls, editor);
}
}
/*
* Attempt to find custom property editor on descriptor first, else try the propery editor manager.
*/
protected PropertyEditor getPropertyEditor(PropertyDescriptor desc) throws InstantiationException, IllegalAccessException {
Class<?> cls = desc.getPropertyEditorClass();
if (null != cls) return (PropertyEditor) cls.newInstance();
return getPropertyEditorValue(desc.getPropertyType());
}
}
@@ -0,0 +1,84 @@
package au.com.bytecode.opencsv.bean;
import au.com.bytecode.opencsv.CSVReader;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright 2007 Kyle Miller.
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
*/
public class HeaderColumnNameMappingStrategy<T> implements MappingStrategy<T> {
protected String[] header;
protected Map<String, PropertyDescriptor> descriptorMap = null;
protected Class<T> type;
public void captureHeader(CSVReader reader) throws IOException {
header = reader.readNext();
}
public PropertyDescriptor findDescriptor(int col) throws IntrospectionException {
String columnName = getColumnName(col);
return (null != columnName && columnName.trim().length() > 0) ? findDescriptor(columnName) : null;
}
protected String getColumnName(int col) {
return (null != header && col < header.length) ? header[col] : null;
}
protected PropertyDescriptor findDescriptor(String name) throws IntrospectionException {
if (null == descriptorMap) descriptorMap = loadDescriptorMap(getType()); //lazy load descriptors
return descriptorMap.get(name.toUpperCase().trim());
}
protected boolean matches(String name, PropertyDescriptor desc) {
return desc.getName().equals(name.trim());
}
protected Map<String, PropertyDescriptor> loadDescriptorMap(Class<T> cls) throws IntrospectionException {
Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>();
PropertyDescriptor[] descriptors;
descriptors = loadDescriptors(getType());
for (PropertyDescriptor descriptor : descriptors) {
map.put(descriptor.getName().toUpperCase().trim(), descriptor);
}
return map;
}
private PropertyDescriptor[] loadDescriptors(Class<T> cls) throws IntrospectionException {
BeanInfo beanInfo = Introspector.getBeanInfo(cls);
return beanInfo.getPropertyDescriptors();
}
public T createBean() throws InstantiationException, IllegalAccessException {
return type.newInstance();
}
public Class<T> getType() {
return type;
}
public void setType(Class<T> type) {
this.type = type;
}
}
@@ -0,0 +1,34 @@
package au.com.bytecode.opencsv.bean;
import java.util.HashMap;
import java.util.Map;
/**
Copyright 2007,2010 Kyle Miller.
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
http://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.
*/
public class HeaderColumnNameTranslateMappingStrategy<T> extends HeaderColumnNameMappingStrategy<T> {
private Map<String, String> columnMapping = new HashMap<String, String>();
protected String getColumnName(int col) {
return col < header.length ? columnMapping.get(header[col].toUpperCase()) : null;
}
public Map<String, String> getColumnMapping() {
return columnMapping;
}
public void setColumnMapping(Map<String, String> columnMapping) {
for (String key : columnMapping.keySet()) {
this.columnMapping.put(key.toUpperCase(), columnMapping.get(key));
}
}
}
@@ -0,0 +1,46 @@
package au.com.bytecode.opencsv.bean;
/**
Copyright 2007 Kyle Miller.
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
http://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.
*/
import au.com.bytecode.opencsv.CSVReader;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.io.IOException;
public interface MappingStrategy<T> {
/**
* Implementation will have to return a property descriptor from a bean based on the current column.
* @param col the column to find the description for
* @throws java.beans.IntrospectionException
* @return the related PropertyDescriptor
*/
public abstract PropertyDescriptor findDescriptor(int col) throws IntrospectionException;
public abstract T createBean() throws InstantiationException, IllegalAccessException;
/**
* Implementation of this method can grab the header line before parsing begins to use to map columns
* to bean properties.
* @param reader the CSVReader to use for header parsing
* @throws java.io.IOException if parsing fails
*/
public void captureHeader(CSVReader reader) throws IOException;
}
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
</head>
<body bgcolor="white">
<p>
A simple bean binding interface for use with opencsv.
</p>
<br>
<a href="http://opencsv.sourceforge.net/">opencsv.sourceforge.net</a>
</body>
</html>
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
</head>
<body bgcolor="white">
<p>
A very simple CSV parser for Java released under a commercial-friendly license.
</p>
<br>
<a href="http://opencsv.sourceforge.net/">opencsv.sourceforge.net</a>
</body>
</html>
@@ -2,45 +2,33 @@ package mcp.mobius.waila;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.client.WailaClientEventHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.network.WailaConnectionHandler;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.overlay.OverlayConfig;
import mcp.mobius.waila.overlay.DecoratorRenderer;
import mcp.mobius.waila.server.ProxyServer;
import mcp.mobius.waila.tools.ModIdentification;
import mcp.mobius.waila.tools.Reflect;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraft.client.resources.I18n;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import codechicken.core.CommonUtils;
import net.minecraftforge.oredict.OreDictionary;
import codechicken.lib.lang.LangUtil;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLModContainer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.IMCCallback;
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.ModContainer;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
@@ -49,63 +37,29 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.ItemData;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid="Waila", name="Waila", version="1.4.3", dependencies="required-after:NotEnoughItems")
@Mod(modid="Waila", name="Waila", version="1.5.2", dependencies="required-after:NotEnoughItems")
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)")
//packetHandler = WailaPacketHandler.class)
public class mod_Waila {
public class Waila {
// The instance of your mod that Forge uses.
@Instance("Waila")
public static mod_Waila instance;
public static Waila instance;
@SidedProxy(clientSide="mcp.mobius.waila.client.ProxyClient", serverSide="mcp.mobius.waila.server.ProxyServer")
public static ProxyServer proxy;
public static Logger log = Logger.getLogger("Waila");
public Configuration config = null;
public boolean serverPresent = false;
public static int posX;
public static int posY;
public static int alpha;
public static int bgcolor;
public static int gradient1;
public static int gradient2;
public static int fontcolor;
public static float scale;
/* INIT SEQUENCE */
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
config = new Configuration(event.getSuggestedConfigurationFile());
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010).getInt();
gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff).getInt();
gradient2 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2, 0x28007f).getInt();
fontcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR, 0xA0A0A0).getInt();
scale = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, 100).getInt() / 100.0f;
config.save();
updateColors();
MinecraftForge.EVENT_BUS.register(new WailaClientEventHandler());
ConfigHandler.instance().loadDefaultConfig(event);
OverlayConfig.updateColors();
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
}
@EventHandler
@@ -123,10 +77,10 @@ public class mod_Waila {
proxy.registerHandlers();
ModIdentification.init();
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_KEYBIND)){
if (!ModLoader.isModLoaded("nek") && ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true)){
for (String key: ModIdentification.keyhandlerStrings.keySet()){
String orig = I18n.func_135053_a(key);
String orig = I18n.getString(key);
if (orig.equals(key))
orig = LanguageRegistry.instance().getStringLocalization(key);
if (orig.equals(key))
@@ -161,9 +115,15 @@ public class mod_Waila {
@Subscribe
public void loadComplete(FMLLoadCompleteEvent event) {
proxy.registerMods();
String[] ores = OreDictionary.getOreNames();
for (String s : ores)
for (ItemStack stack : OreDictionary.getOres(s))
System.out.printf("%s : %s\n", s, stack);
}
@IMCCallback
@EventHandler
public void processIMC(FMLInterModComms.IMCEvent event)
{
for (IMCMessage imcMessage : event.getMessages()){
@@ -172,15 +132,15 @@ public class mod_Waila {
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()));
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()));
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()));
Waila.log.info(String.format("Receiving registration request from [ %s ] for method %s", imcMessage.getSender(), imcMessage.getStringValue()));
this.callbackRegistration(imcMessage.getStringValue(), imcMessage.getSender());
}
}
@@ -191,31 +151,22 @@ public class mod_Waila {
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));
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());
reflectMethod.invoke(null, (IWailaRegistrar)ModuleRegistrar.instance());
mod_Waila.log.info(String.format("Success in registering %s", modname));
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));
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));
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()));
Waila.log.warning(String.format("Exception while trying to access the method : %s", e.toString()));
}
}
public static void updateColors(){
alpha = (int)(ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f * 256) << 24;
bgcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_BGCOLOR);
gradient1 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT1);
gradient2 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT2);
fontcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_FONTCOLOR);
}
}
-103
View File
@@ -1,103 +0,0 @@
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);
}
public int getConfigInt(String key){
mod_Waila.instance.config.load();
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0);
return prop.getInt();
}
@Override
public void setConfig(String key, boolean value){
mod_Waila.instance.config.load();
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, true).set(value);;
mod_Waila.instance.config.save();
}
public void setConfigInt(String key, int value){
mod_Waila.instance.config.load();
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0).set(value);;
mod_Waila.instance.config.save();
}
}
@@ -1,397 +0,0 @@
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.lib.lang.LangUtil;
import codechicken.nei.api.API;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.handlers.hud.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<Integer, ArrayList<IWailaBlockDecorator>> blockIdDecorators = new LinkedHashMap<Integer, ArrayList<IWailaBlockDecorator>>();
public LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>> blockClassDecorators = new LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>>();
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, LangUtil.translateG(configname));
}
@Override
public void addConfigRemote(String modname, String key, String configname) {
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG(configname));
}
@Override
public void addConfig(String modname, String key) {
ConfigHandler.instance().addConfig(modname, key, LangUtil.translateG("option." + key));
}
@Override
public void addConfigRemote(String modname, String key) {
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG("option." + key));
}
@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);
}
@Override
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);
}
@Override
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);
}
@Override
public void registerBlockDecorator(IWailaBlockDecorator decorator, int blockID) {
if (!this.blockIdDecorators.containsKey(blockID))
this.blockIdDecorators.put(blockID, new ArrayList<IWailaBlockDecorator>());
this.blockIdDecorators.get(blockID).add(decorator);
}
@Override
public void registerBlockDecorator(IWailaBlockDecorator decorator, Class block) {
if (!this.blockClassDecorators.containsKey(block))
this.blockClassDecorators.put(block, new ArrayList<IWailaBlockDecorator>());
this.blockClassDecorators.get(block).add(decorator);
}
/* 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;
}
public ArrayList<IWailaBlockDecorator> getBlockDecorators(int blockID){
return this.blockIdDecorators.get(blockID);
}
public ArrayList<IWailaBlockDecorator> getBlockDecorators(Object block){
ArrayList<IWailaBlockDecorator> returnList = new ArrayList<IWailaBlockDecorator>();
for (Class clazz : this.blockClassDecorators.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.blockClassDecorators.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);
}
public boolean hasBlockDecorator(int blockID){
return this.blockIdDecorators.containsKey(blockID);
}
public boolean hasBlockDecorator(Object block){
for (Class clazz : this.blockClassDecorators.keySet())
if (clazz.isInstance(block))
return true;
return false;
}
/* ----------------- */
@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,30 @@
package mcp.mobius.waila.addons.agriculture;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class AgricultureModule {
public static Class BlockCrop = null;
public static void register(){
try{
Class Agriculture = Class.forName("com.teammetallurgy.agriculture.Agriculture");
Waila.log.log(Level.INFO, "Agriculture mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[Agriculture] Agriculture mod not found.");
return;
}
try{
BlockCrop = Class.forName("com.teammetallurgy.agriculture.crops.BlockCrop");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[Agriculture] Class not found. " + e);
return;
}
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCrop(), BlockCrop);
}
}
@@ -1,30 +1,42 @@
package mcp.mobius.waila.addons.thaumcraft;
package mcp.mobius.waila.addons.agriculture;
import java.util.List;
import codechicken.lib.lang.LangUtil;
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 {
public class HUDHandlerCrop implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showcrop")) return currenttip;
int growthStage = accessor.getMetadata();
float growthValue = (growthStage / 6.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
}
@@ -6,8 +6,8 @@ import java.util.logging.Level;
import codechicken.lib.lang.LangUtil;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class AppEngModule {
@@ -26,18 +26,19 @@ public class AppEngModule {
IAEItemStack_getItemStack = IAEItemStack.getMethod("getItemStack");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[AppEng] Class not found. " + e);
Waila.log.log(Level.WARNING, "[AppEng] Class not found. " + e);
return;
} catch (SecurityException e) {
mod_Waila.log.log(Level.WARNING, "[AppEng] Security Exception. " + e);
Waila.log.log(Level.WARNING, "[AppEng] Security Exception. " + e);
return;
} catch (NoSuchMethodException e) {
mod_Waila.log.log(Level.WARNING, "[AppEng] Method not found. " + e);
Waila.log.log(Level.WARNING, "[AppEng] Method not found. " + e);
return;
}
mod_Waila.log.log(Level.INFO, "AppEng mod found.");
ExternalModulesHandler.instance().addConfig("Applied Energetic", "appeng.monitorcontent");
ExternalModulesHandler.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
Waila.log.log(Level.INFO, "AppEng mod found.");
ModuleRegistrar.instance().addConfig("Applied Energetic", "appeng.monitorcontent");
ModuleRegistrar.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileStorageMonitor);
}
}
@@ -4,8 +4,8 @@ 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.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import codechicken.lib.lang.LangUtil;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
@@ -24,17 +24,17 @@ public class BetterBarrelsModule {
IBarrelStorage_getItem = IBarrelStorage.getMethod("getItem");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[BB] BetterBarrel classes not found.");
Waila.log.log(Level.WARNING, "[BB] BetterBarrel classes not found.");
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[BB] Storage field not found.");
Waila.log.log(Level.WARNING, "[BB] Storage field not found.");
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[BB] getItem() not found.");
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");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBBContent(), TileEntityBarrel);
Waila.log.log(Level.INFO, "Waila module BetterBarrel succefully hooked.");
ModuleRegistrar.instance().addConfig("BetterBarrels", "bb.content");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBBContent(), TileEntityBarrel);
}
}
@@ -5,7 +5,7 @@ import java.lang.reflect.Method;
import java.util.List;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -43,7 +43,7 @@ public class HUDHandlerBBContent implements IWailaDataProvider {
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));
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;
}
@@ -3,8 +3,8 @@ 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 mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import net.minecraftforge.common.ForgeDirection;
public class BCModule {
@@ -20,9 +20,9 @@ public class BCModule {
public static void register(){
try {
Class ModBuildcraftFactory = Class.forName("buildcraft.BuildCraftFactory");
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
Waila.log.log(Level.INFO, "Buildcraft|Factory mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
Waila.log.log(Level.INFO, "Buildcraft|Factory mod not found. Skipping.");
return;
}
@@ -31,17 +31,18 @@ public class BCModule {
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[BC] Class not found. " + e);
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);
Waila.log.log(Level.WARNING, "[BC] Method not found." + e);
return;
}
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tankamount");
ExternalModulesHandler.instance().addConfig("Buildcraft", "bc.tanktype");
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTank);
}
}
@@ -5,8 +5,8 @@ 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;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class BCPowerAPIModule {
@@ -30,9 +30,9 @@ public class BCPowerAPIModule {
public static void register(){
try{
Class ModClass = Class.forName("buildcraft.api.power.IPowerReceptor");
mod_Waila.log.log(Level.INFO, "Buildcraft Power API found.");
Waila.log.log(Level.INFO, "Buildcraft Power API found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[Buildcraft Power API] Buildcraft Power API mod not found.");
Waila.log.log(Level.INFO, "[Buildcraft Power API] Buildcraft Power API mod not found.");
return;
}
@@ -56,23 +56,24 @@ public class BCPowerAPIModule {
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
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);
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);
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfigRemote("BuildcraftAPI", "bcapi.storage");
ExternalModulesHandler.instance().addConfig("BuildcraftAPI", "bcapi.consump");
ExternalModulesHandler.instance().addConfig("BuildcraftAPI", "bcapi.trigger");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIPowerReceptor(), IPowerReceptor);
ModuleRegistrar.instance().addConfigRemote("BuildcraftAPI", "bcapi.storage");
ModuleRegistrar.instance().addConfig("BuildcraftAPI", "bcapi.consump");
ModuleRegistrar.instance().addConfig("BuildcraftAPI", "bcapi.trigger");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIPowerReceptor(), IPowerReceptor);
ModuleRegistrar.instance().registerSyncedNBTKey("*", IPowerReceptor);
}
@@ -10,12 +10,13 @@ import java.util.logging.Level;
import codechicken.lib.lang.LangUtil;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.impl.ConfigHandler;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
@@ -69,7 +70,7 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
try{
tank = ((FluidTankInfo[])BCModule.TileTank_getTankInfo.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));
Waila.log.log(Level.SEVERE, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
return null;
}
return tank;
@@ -5,10 +5,10 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerIPowerReceptor implements IWailaDataProvider {
@@ -52,12 +52,14 @@ public class HUDHandlerIPowerReceptor implements IWailaDataProvider {
currenttip.add(String.format("%.1f / %.1f MJ", energyStored, maxEnergyStor));
}
/*
if (maxEnergyRecv != 0.0f && config.getConfig("bcapi.consump"))
//currenttip.add(String.format("Min/Max Input : %.1f / %.1f MJ/t", minEnergyRecv, maxEnergyRecv));
currenttip.add(String.format("%s : %.1f MJ/t", maxPowerStr, maxEnergyRecv));
if (activation != 0.0f && config.getConfig("bcapi.trigger"))
currenttip.add(String.format("%s : %.1f MJ", triggerStr, activation));
currenttip.add(String.format("%s : %.1f MJ", triggerStr, activation));
*/
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.addons.carpenters;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class CarpentersModule {
public static Class TEBase = null;
public static Class BlockCarpentersDoor = null;
public static Class BlockCarpentersHatch = null;
public static void register(){
try{
Class CarpentersBlocks = Class.forName("carpentersblocks.CarpentersBlocks");
Waila.log.log(Level.INFO, "CarpentersBlocks mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[CarpentersBlocks] CarpentersBlocks mod not found.");
return;
}
try{
TEBase = Class.forName("carpentersblocks.tileentity.TEBase");
BlockCarpentersDoor = Class.forName("carpentersblocks.block.BlockCarpentersDoor");
BlockCarpentersHatch = Class.forName("carpentersblocks.block.BlockCarpentersHatch");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[CarpentersBlocks] Class not found. " + e);
return;
} catch (Exception e) {
Waila.log.log(Level.WARNING, "[CarpentersBlocks] Error while loading module. " + e);
return;
}
ModuleRegistrar.instance().addConfig("Carpenter's Blocks", "carpenters.hide");
ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersDoor);
ModuleRegistrar.instance().registerStackProvider(new HUDCarpentersBlocksTE(), BlockCarpentersHatch);
ModuleRegistrar.instance().registerSyncedNBTKey("data", TEBase);
ModuleRegistrar.instance().registerSyncedNBTKey("cover_6", TEBase);
}
}
@@ -0,0 +1,56 @@
package mcp.mobius.waila.addons.carpenters;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDCarpentersBlocksTE implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("carpenters.hide")) return null;
NBTTagCompound tag = accessor.getNBTData();
short data = tag.getShort("data");
short cover = tag.getShort("cover_6");
if(CarpentersModule.BlockCarpentersDoor.isInstance(accessor.getBlock())){
int type = data & 0x7;
if (type != 5) return null;
if (cover == 0) return null;
return new ItemStack(cover & 0xfff, 0, (cover & 0xf000) >>> 12);
}
else if (CarpentersModule.BlockCarpentersHatch.isInstance(accessor.getBlock())){
int type = data & 0x7;
if (type != 0) return null;
if (cover == 0) return null;
return new ItemStack(cover & 0xfff, 0, (cover & 0xf000) >>> 12);
}
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) {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -5,8 +5,8 @@ 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;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class EnderIOModule {
@@ -22,9 +22,9 @@ public class EnderIOModule {
public static void register(){
try{
Class ModClass = Class.forName("crazypants.enderio.EnderIO");
mod_Waila.log.log(Level.INFO, "EnderIO mod found.");
Waila.log.log(Level.INFO, "EnderIO mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
Waila.log.log(Level.INFO, "[EnderIO] EnderIO mod not found.");
return;
}
@@ -40,25 +40,27 @@ public class EnderIOModule {
TileTesseract = Class.forName("crazypants.enderio.machine.hypercube.TileHyperCube");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
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);
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);
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfig("EnderIO", "enderio.inout");
ExternalModulesHandler.instance().addConfig("EnderIO", "enderio.storage");
ExternalModulesHandler.instance().addConfig("EnderIO", "enderio.owner");
ExternalModulesHandler.instance().addConfig("EnderIO", "enderio.channel");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCapacitorBank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.inout");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.storage");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.owner");
ModuleRegistrar.instance().addConfig("EnderIO", "enderio.channel");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCapacitorBank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileCapacitorBank);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTesseract);
}
}
@@ -4,10 +4,10 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
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;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerCapacitor implements IWailaDataProvider{
@@ -4,8 +4,8 @@ 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.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class EnderStorageModule {
@@ -20,9 +20,9 @@ public class EnderStorageModule {
public static void register(){
try{
Class EnderStorage = Class.forName("codechicken.enderstorage.EnderStorage");
mod_Waila.log.log(Level.INFO, "EnderStorage mod found.");
Waila.log.log(Level.INFO, "EnderStorage mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
Waila.log.log(Level.INFO, "[EnderStorage] EnderStorage mod not found.");
return;
}
@@ -37,20 +37,21 @@ public class EnderStorageModule {
TileEnderTank = Class.forName("codechicken.enderstorage.storage.liquid.TileEnderTank");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
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);
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);
Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
return;
} catch (Exception e){
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfig("EnderStorage", "enderstorage.colors");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerStorage(), TileFrequencyOwner);
ModuleRegistrar.instance().addConfig("EnderStorage", "enderstorage.colors");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerStorage(), TileFrequencyOwner);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileFrequencyOwner);
}
}
@@ -4,10 +4,10 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
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;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerStorage implements IWailaDataProvider {
+10 -10
View File
@@ -4,8 +4,8 @@ import java.lang.reflect.Field;
import java.util.logging.Level;
import net.minecraft.item.Item;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ETBModule {
@@ -29,9 +29,9 @@ public class ETBModule {
public static void register(){
try{
Class ModClass = Class.forName("emasher.sockets.TileSocket");
mod_Waila.log.log(Level.INFO, "Engineer Toolbox mod found.");
Waila.log.log(Level.INFO, "Engineer Toolbox mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[Engineer Toolbox] Engineer Toolbox mod not found.");
Waila.log.log(Level.INFO, "[Engineer Toolbox] Engineer Toolbox mod not found.");
return;
}
@@ -63,21 +63,21 @@ public class ETBModule {
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Class not found. " + e);
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Class not found. " + e);
return;
// } catch (NoSuchMethodException e){
// mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Method not found." + e);
// return;
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Field not found." + e);
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Field not found." + e);
return;
} catch (Exception e){
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Unhandled exception." + e);
Waila.log.log(Level.WARNING, "[Engineer Toolbox] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfig("Engineer Toolbox", "etb.displaydata");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerSocket(), TileSocket);
ModuleRegistrar.instance().addConfig("Engineer Toolbox", "etb.displaydata");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerSocket(), TileSocket);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileSocket);
}
}
@@ -6,10 +6,10 @@ import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerSocket implements IWailaDataProvider {
@@ -0,0 +1,35 @@
package mcp.mobius.waila.addons.exu;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ExtraUtilitiesModule {
public static Class ModExtraUtilities = null;
public static Class TileEntityDrum = null;
public static void register(){
try{
Class ModExtraUtilities = Class.forName("extrautils.ExtraUtils");
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
return;
}
try{
TileEntityDrum = Class.forName("extrautils.tileentity.TileEntityDrum");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[ExtraUtilities] Class not found. " + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityDrum);
}
}
@@ -0,0 +1,53 @@
package mcp.mobius.waila.addons.exu;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerDrum 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("extrautilities.fluidamount")) return currenttip;
int amount = 0;
NBTTagCompound subtag = accessor.getNBTData().getCompoundTag("tank");
if (subtag.hasKey("Amount"))
amount = accessor.getNBTInteger(subtag, "Amount");
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks.length != 1) return currenttip;
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -2,8 +2,8 @@ package mcp.mobius.waila.addons.gravestone;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class GravestoneModule {
@@ -13,20 +13,21 @@ public class GravestoneModule {
try{
Class ModGravestone = Class.forName("GraveStone.ModGraveStone");
mod_Waila.log.log(Level.INFO, "GraveStone mod found.");
Waila.log.log(Level.INFO, "GraveStone mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[GraveStone] GraveStone mod not found.");
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);
Waila.log.log(Level.WARNING, "[GraveStone] Class not found. " + e);
}
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockGraveStone);
}
}
@@ -1,14 +1,15 @@
package mcp.mobius.waila.addons.thaumcraft;
package mcp.mobius.waila.addons.harvestcraft;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.utils.NBTUtil;
public class HUDHandlerCapacitor implements IWailaDataProvider {
public class HUDHandlerPamCrop implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -22,22 +23,22 @@ public class HUDHandlerCapacitor implements IWailaDataProvider {
@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());
if (!config.getConfig("general.showcrop")) return currenttip;
currenttip.add(String.format("%s/%s vis", storedVis, maxVis));
}catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getClass().getName(), currenttip);
}
}
int growthStage = NBTUtil.getNBTInteger(accessor.getNBTData(), "growthStage");
float growthValue = (growthStage / 2.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
}
@@ -0,0 +1,30 @@
package mcp.mobius.waila.addons.harvestcraft;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class HarvestcraftModule {
public static Class TileEntityPamCrop = null;
public static void register(){
try{
Class PamHarvestCraft = Class.forName("assets.pamharvestcraft.PamHarvestCraft");
Waila.log.log(Level.INFO, "PamHarvestCraft mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[PamHarvestCraft] PamHarvestCraft mod not found.");
return;
}
try{
TileEntityPamCrop = Class.forName("assets.pamharvestcraft.TileEntityPamCrop");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[PamHarvestCraft] Class not found. " + e);
return;
}
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerPamCrop(), TileEntityPamCrop);
}
}
@@ -4,11 +4,12 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.WailaExceptionHandler;
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 mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
@@ -50,7 +51,7 @@ public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
double stored = IC2Module.getStoredEnergy(accessor);
if ( stored >= 0.0 && storage > 0)
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
//else if (stored >= 0.0)
// currenttip.add(String.format("Stored : %d EU", stored));
@@ -58,7 +59,7 @@ public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
if ( production > 0)
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
}
} catch (Exception e){
@@ -4,11 +4,12 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.WailaExceptionHandler;
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 mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
@@ -37,13 +38,13 @@ public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
if ( stored >= 0.0 )
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
}
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
if ( production > 0)
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
}
} catch (Exception e){
@@ -4,11 +4,12 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.WailaExceptionHandler;
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 mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
@@ -53,17 +54,17 @@ public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
/* EU Storage */
if (ConfigHandler.instance().getConfig("ic2.storage")){
if ( stored >= 0.0 )
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
}
if (ConfigHandler.instance().getConfig("ic2.consump")){
if ( consumption > 0)
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", powerStr, consumption ));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", powerStr, TAB + ALIGNRIGHT, consumption ));
}
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
if ( maxinput > 0)
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", maxPowerStr, maxinput ));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", maxPowerStr, TAB + ALIGNRIGHT, maxinput ));
}
} catch (Exception e){
@@ -6,10 +6,11 @@ import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
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 mcp.mobius.waila.api.impl.ConfigHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerTETradeOMat implements IWailaDataProvider {
@@ -38,13 +39,13 @@ public class HUDHandlerTETradeOMat implements IWailaDataProvider {
if (offer.tagCount() == 1){
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, is.stackSize, is.getDisplayName()));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
}
if (demand.tagCount() == 1){
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, is.stackSize, is.getDisplayName()));
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
}
return currenttip;
+33 -19
View File
@@ -2,15 +2,18 @@ package mcp.mobius.waila.addons.ic2;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.logging.Level;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.AccessHelper;
public class IC2Module {
@@ -94,35 +97,42 @@ public class IC2Module {
} catch (ClassNotFoundException e){
//e.printStackTrace();
mod_Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
//e.printStackTrace();
mod_Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
return;
} catch (NoSuchFieldException e){
//e.printStackTrace();
mod_Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
return;
} catch (Exception e){
//e.printStackTrace();
mod_Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
return;
}
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
ModuleRegistrar.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStandardMachine);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityBaseGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntitySemifluidGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityGeoGenerator);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityElectricBlock);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTradeOMat);
}
/* Retuns the current stored energy if available in the nbt and config is true */
@@ -147,7 +157,11 @@ public class IC2Module {
if (!inventory.hasKey("upgrade")) return null;
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
for (Object subobj : nbtupgrades.tagList){
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
for (Object subobj : tagList){
NBTTagCompound subtag = (NBTTagCompound)subobj;
int id = subtag.getShort("id");
int meta = subtag.getShort("Damage");
@@ -1,17 +1,18 @@
package mcp.mobius.waila.addons.thaumcraft;
package mcp.mobius.waila.addons.magicalcrops;
import java.util.List;
import codechicken.lib.lang.LangUtil;
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 {
public class HUDHandlerMagicalCrops implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return new ItemStack(accessor.getBlock(), 0, accessor.getMetadata());
return null;
}
@Override
@@ -21,11 +22,21 @@ public class HUDHandlerLeaves implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showcrop")) return currenttip;
int growthStage = accessor.getMetadata();
float growthValue = (growthStage / 7.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
}
@@ -0,0 +1,30 @@
package mcp.mobius.waila.addons.magicalcrops;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class MagicalCropsModule {
public static Class BlockMagicalCrops = null;
public static void register(){
try{
Class MagicalCrops = Class.forName("magicalcrops.mod_sCrops");
Waila.log.log(Level.INFO, "MagicalCrops mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[MagicalCrops] MagicalCrops mod not found.");
return;
}
try{
BlockMagicalCrops = Class.forName("magicalcrops.BlockMagicalCrops");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[MagicalCrops] Class not found. " + e);
return;
}
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerMagicalCrops(), BlockMagicalCrops);
}
}
@@ -0,0 +1,69 @@
package mcp.mobius.waila.addons.openblocks;
import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerTank implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("openblocks.fluidamount")) return currenttip;
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks.length != 1) return currenttip;
FluidStack fluid = tanks[0].fluid;
String name = currenttip.get(0);
try{
name += String.format(" < %s >", fluid.getFluid().getLocalizedName());
} catch (NullPointerException f){
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.set(0, name);
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("openblocks.fluidamount")) return currenttip;
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks.length != 1) return currenttip;
if(tanks[0].fluid != null)
currenttip.add(String.format("%d / %d mB", tanks[0].fluid.amount, tanks[0].capacity));
else
currenttip.add(String.format("0 / %d mB", tanks[0].capacity));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -0,0 +1,34 @@
package mcp.mobius.waila.addons.openblocks;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class OpenBlocksModule {
public static Class ModOpenBlocks = null;
public static Class TileEntityTank = null;
public static void register(){
try{
Class ModOpenBlocks = Class.forName("openblocks.OpenBlocks");
Waila.log.log(Level.INFO, "OpenBlocks mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
return;
}
try{
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[OpenBlocks] Class not found. " + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTank);
}
}
@@ -8,9 +8,12 @@ import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.api.IWailaFMPDecorator;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.utils.NBTUtil;
public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
public class HUDDecoratorRsGateLogic implements IWailaFMPDecorator {
static byte[][] IOARRAY={
{1,1,2,1} /* OR */, {1,1,2,1} /* NOR */, {1,2,2,2} /* NOT */, {1,1,2,1} /* AND */,
@@ -22,36 +25,28 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
{11,12,11,12} /* Inver */, {11,12,11,12} /* Buff */, {1,9,2,8} /* Cmp */, {1,12,2,12} /* And */,
};
static byte[][] IOARRAYALTER={
{1,8,2,9} /* Cmp 1*/, {1,6,2,2} /* State 1*/, {2,8,2,9} /* Count 1*/, {6,2,2,1} /* Transp 1*/,
{2,1,2,1} /* Latch 1*/, {2,1,2,1} /* Latch 2*/, {2,1,2,1} /* Latch 3*/
};
static String[] IONAMES={ "", "IN", "OUT", "SWAP", "IN_A", "IN_B", "LOCK", "IO", "POS", "NEG", "BUS", "A", "B"};
@Override
public void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
public void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("pr.showio")) return;
int orient = 0;
int subID = 0;
int shape = 0;
boolean found = false;
if (!accessor.getNBTData().hasKey("parts")) return;
NBTTagList parts = accessor.getNBTData().getTagList("parts");
for (int i = 0; i < parts.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
String id = subtag.getString("id");
if (id.equals("pr_sgate") || id.equals("pr_igate") ||
id.equals("pr_tgate") || id.equals("pr_bgate") ||
id.equals("pr_agate") || id.equals("pr_rgate")){
orient = accessor.getNBTInteger(subtag, "orient");
subID = accessor.getNBTInteger(subtag, "subID");
shape = accessor.getNBTInteger(subtag, "shape");
found = true;
}
}
orient = NBTUtil.getNBTInteger(accessor.getNBTData(), "orient");
subID = NBTUtil.getNBTInteger(accessor.getNBTData(), "subID");
shape = NBTUtil.getNBTInteger(accessor.getNBTData(), "shape");
if (!found) return;
//orient = orient - ((orient & 0x10) + (orient & 0x8) + (orient & 0x4));
int hOrient = orient & 0x3;
ForgeDirection vOrient = ForgeDirection.getOrientation((orient - (orient & 0x3)) >> 2);
@@ -68,8 +63,27 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
hOrient = 3;
String[] IOStr = new String[4];
for (int i = 0; i < 4; i++)
IOStr[i] = IONAMES[IOARRAY[subID][i]];
if (shape != 0){
int altIndex = -1;
if (subID == 26 && shape == 1) altIndex = 0;
if (subID == 20 && shape == 1) altIndex = 1;
if (subID == 19 && shape == 1) altIndex = 2;
if (subID == 14 && shape == 1) altIndex = 3;
if (subID == 12 && shape == 1) altIndex = 4;
if (subID == 12 && shape == 2) altIndex = 5;
if (subID == 12 && shape == 3) altIndex = 6;
if (altIndex == -1)
for (int i = 0; i < 4; i++)
IOStr[i] = IONAMES[IOARRAY[subID][i]];
else
for (int i = 0; i < 4; i++)
IOStr[i] = IONAMES[IOARRAYALTER[altIndex][i]];
} else {
for (int i = 0; i < 4; i++)
IOStr[i] = IONAMES[IOARRAY[subID][i]];
}
String[] IOStrRot = new String[4];
@@ -118,7 +132,6 @@ public class HUDDecoratorRsGateLogic implements IWailaBlockDecorator {
break;
default:
break;
}
double x = accessor.getRenderingPosition().xCoord;
@@ -0,0 +1,82 @@
package mcp.mobius.waila.addons.projectred;
import java.util.List;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.api.IWailaFMPProvider;
import mcp.mobius.waila.utils.NBTUtil;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDFMPGateLogic implements IWailaFMPProvider {
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("pr.showdata")) return currenttip;
int orient = 0;
int subID = 0;
int shape = 0;
int pmax = 0;
int val = 0;
int max = 0;
int dec = 0;
int inc = 0;
orient = NBTUtil.getNBTInteger(accessor.getNBTData(), "orient");
subID = NBTUtil.getNBTInteger(accessor.getNBTData(), "subID");
shape = NBTUtil.getNBTInteger(accessor.getNBTData(), "shape");
if (subID == 17)
pmax = NBTUtil.getNBTInteger(accessor.getNBTData(), "pmax");
if (subID == 19){
val = NBTUtil.getNBTInteger(accessor.getNBTData(), "val");
max = NBTUtil.getNBTInteger(accessor.getNBTData(), "max");
dec = NBTUtil.getNBTInteger(accessor.getNBTData(), "dec");
inc = NBTUtil.getNBTInteger(accessor.getNBTData(), "inc");
}
switch(subID){
case 10:
currenttip.add(String.format("[Repeater]" + TAB + ALIGNRIGHT + WHITE + "%d" + GRAY + " ticks", (int)Math.pow(2, shape)));
break;
case 15:
if (shape == 0)
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Open");
if (shape == 1)
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Half closed");
if (shape == 2)
currenttip.add("[Sensor]" + TAB + ALIGNRIGHT + WHITE + "Closed");
break;
case 17:
currenttip.add(String.format("[Timer delay]" + TAB + ALIGNRIGHT + WHITE + "%d " + GRAY + "ms", (pmax + 2) * 50));
break;
case 19:
currenttip.add(String.format("[Counter value]"+ TAB + ALIGNRIGHT + WHITE + "%d " + GRAY + "/ " + WHITE + "%d", val, max));
currenttip.add(String.format("[Counter step]" + TAB + ALIGNRIGHT + WHITE + "-%d " + GRAY + "/ " + WHITE + "+%d", dec, inc));
default:
break;
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -1,105 +0,0 @@
package mcp.mobius.waila.addons.projectred;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class HUDHandlerRsGateLogic 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("pr.showdata")) return currenttip;
int orient = 0;
int subID = 0;
int shape = 0;
int pmax = 0;
int val = 0;
int max = 0;
int dec = 0;
int inc = 0;
boolean found = false;
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
NBTTagList parts = accessor.getNBTData().getTagList("parts");
for (int i = 0; i < parts.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
String id = subtag.getString("id");
if (id.equals("pr_sgate") || id.equals("pr_igate") ||
id.equals("pr_tgate") || id.equals("pr_bgate") ||
id.equals("pr_agate") || id.equals("pr_rgate")){
orient = accessor.getNBTInteger(subtag, "orient");
subID = accessor.getNBTInteger(subtag, "subID");
shape = accessor.getNBTInteger(subtag, "shape");
if (subID == 17)
pmax = accessor.getNBTInteger(subtag, "pmax");
if (subID == 19){
val = accessor.getNBTInteger(subtag, "val");
max = accessor.getNBTInteger(subtag, "max");
dec = accessor.getNBTInteger(subtag, "dec");
inc = accessor.getNBTInteger(subtag, "inc");
}
found = true;
}
}
if (!found) return currenttip;
switch(subID){
case 10:
currenttip.add(String.format("Delay : \u00a7f%d ticks", (int)Math.pow(2, shape)));
break;
case 15:
if (shape == 0)
currenttip.add("Shape : \u00a7fOpen");
if (shape == 1)
currenttip.add("Shape : \u00a7fHalf closed");
if (shape == 2)
currenttip.add("Shape : \u00a7fclosed");
break;
case 17:
currenttip.add(String.format("Timer : \u00a7f%d \u00a7rms", (pmax + 2) * 50));
break;
case 19:
currenttip.add(String.format("Value : \u00a7f%d \u00a7r/ \u00a7f%d", val, max));
currenttip.add(String.format("Step : \u00a7f-%d \u00a7r/ \u00a7f+%d", dec, inc));
default:
break;
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -5,47 +5,40 @@ import java.util.logging.Level;
import net.minecraft.block.Block;
import net.minecraftforge.common.Configuration;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ProjectRedModule {
public static Class BlockMultipart = null;
public static void register(){
try{
Class ModClass = Class.forName("mrtjp.projectred.ProjectRedIntegration");
mod_Waila.log.log(Level.INFO, "ProjectRed|Integration mod found.");
Waila.log.log(Level.INFO, "ProjectRed|Integration mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[ProjectRed] ProjectRed|Integration mod not found.");
Waila.log.log(Level.INFO, "[ProjectRed] ProjectRed|Integration mod not found.");
return;
}
try{
//InstancedRsGateLogic = Class.forName("mrtjp.projectred.integration.InstancedRsGateLogic");
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
} 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;
}
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showio");
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showdata");
ExternalModulesHandler.instance().addConfigRemote("Project:Red", "pr.showio");
ExternalModulesHandler.instance().addConfigRemote("Project:Red", "pr.showdata");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_sgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_igate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_tgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_bgate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_agate");
ModuleRegistrar.instance().registerBodyProvider(new HUDFMPGateLogic(), "pr_rgate");
ExternalModulesHandler.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_sgate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_igate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_tgate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_bgate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_agate");
ModuleRegistrar.instance().registerDecorator(new HUDDecoratorRsGateLogic(), "pr_rgate");
//ModuleRegistrar.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
//ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMultipart);
}
}
@@ -0,0 +1,74 @@
package mcp.mobius.waila.addons.railcraft;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerTank implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
try {
IFluidTank tank = (IFluidTank)RailcraftModule.ITankTile_getTank.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
if (tank == null) return currenttip;
FluidStack fluid = tank.getFluid();
String name = currenttip.get(0);
try{
name += String.format(" < %s >", fluid.getFluid().getLocalizedName());
} catch (NullPointerException f){
name += " " + LangUtil.translateG("hud.msg.empty");
}
currenttip.set(0, name);
} catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
try {
IFluidTank tank = (IFluidTank)RailcraftModule.ITankTile_getTank.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
if (tank == null) return currenttip;
FluidStack fluid = tank.getFluid();
if (fluid != null)
currenttip.add(String.format("%d / %d mB", fluid.amount, tank.getInfo().capacity));
else
currenttip.add(String.format("0 / %d mB", tank.getInfo().capacity));
} catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.addons.railcraft;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class RailcraftModule {
public static Class TileTankBase = null;
public static Class ITankTile = null;
public static Method ITankTile_getTank = null;
//public static Class StandardTank = null;
public static void register(){
try{
Class ModRailcraft = Class.forName("mods.railcraft.common.core.Railcraft");
Waila.log.log(Level.INFO, "Railcraft mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
return;
}
try{
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
ITankTile_getTank = ITankTile.getMethod("getTank");
//StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[Railcraft] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
Waila.log.log(Level.WARNING, "[Railcraft] Method not found." + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTankBase);
}
}
@@ -0,0 +1,88 @@
package mcp.mobius.waila.addons.secretrooms;
import java.util.List;
import net.minecraft.block.Block;
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 HUDTileEntityCamo implements IWailaDataProvider {
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("secretrooms.hide")) return null;
if ( SecretRoomsModule.BlockCamoTrapDoor.isInstance(accessor.getBlock()) ){
return this.getTrapDoorBlock(accessor);
}
else if ( SecretRoomsModule.BlockTorchLever.isInstance(accessor.getBlock()) ){
return new ItemStack(Block.torchWood);
}
else if (accessor.getNBTData() != null){
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("copyID") && tag.hasKey("copyMeta")){
int copyID = accessor.getNBTInteger(tag, "copyID");
int copyMeta = accessor.getNBTInteger(tag, "copyMeta");
return new ItemStack(copyID, 1, copyMeta);
}
}
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) {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
private ItemStack getTrapDoorBlock(IWailaDataAccessor accessor){
// modify coordinates to get hinge Block.
int i = accessor.getMetadata();
int j = accessor.getPosition().blockX;
int k = accessor.getPosition().blockZ;
if ((i & 3) == 0)
{
k++;
}
if ((i & 3) == 1)
{
k--;
}
if ((i & 3) == 2)
{
j++;
}
if ((i & 3) == 3)
{
j--;
}
int blockID = accessor.getWorld().getBlockId(j, accessor.getPosition().blockY, k);
int blockMeta = accessor.getWorld().getBlockMetadata(j, accessor.getPosition().blockY, k);
return new ItemStack(blockID, 1, blockMeta);
}
}
@@ -0,0 +1,44 @@
package mcp.mobius.waila.addons.secretrooms;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class SecretRoomsModule {
public static Class TileEntityCamo = null;
public static Class BlockTorchLever = null;
public static Class BlockCamoTrapDoor = null;
public static void register(){
try{
Class SecretRooms = Class.forName("com.github.AbrarSyed.secretroomsmod.common.SecretRooms");
Waila.log.log(Level.INFO, "SecretRooms mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[SecretRooms] SecretRooms mod not found.");
return;
}
try{
TileEntityCamo = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.TileEntityCamo");
BlockTorchLever = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.BlockTorchLever");
BlockCamoTrapDoor = Class.forName("com.github.AbrarSyed.secretroomsmod.blocks.BlockCamoTrapDoor");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[SecretRooms] Class not found. " + e);
return;
} catch (Exception e) {
Waila.log.log(Level.WARNING, "[SecretRooms] Error while loading module. " + e);
return;
}
ModuleRegistrar.instance().addConfig("SecretRooms", "secretrooms.hide");
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), TileEntityCamo);
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), BlockTorchLever);
ModuleRegistrar.instance().registerStackProvider(new HUDTileEntityCamo(), BlockCamoTrapDoor);
ModuleRegistrar.instance().registerSyncedNBTKey("copyID", TileEntityCamo);
ModuleRegistrar.instance().registerSyncedNBTKey("copyMeta", TileEntityCamo);
}
}
@@ -0,0 +1,69 @@
package mcp.mobius.waila.addons.statues;
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;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerStatues 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) {
try {
String skinName = (String)StatuesModule.skinName.get(accessor.getTileEntity());
if (skinName.equals("")){
TileEntity belowEnt = accessor.getWorld().getBlockTileEntity(accessor.getPosition().blockX, accessor.getPosition().blockY - 1, accessor.getPosition().blockZ);
if (StatuesModule.TileEntityStatue.isInstance(belowEnt))
skinName = (String)StatuesModule.skinName.get(belowEnt);
}
if (skinName.equals("")){
currenttip.clear();
currenttip.add(WHITE + "Statue : Unknown");
} else {
currenttip.clear();
currenttip.add(WHITE + "Statue : " + skinName);
}
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
/*
String skinName = accessor.getNBTData().getString("skin");
if (skinName.equals("")){
if (accessor.getWorld().getBlockTileEntity(accessor.getPosition().blockX, accessor.getPosition().blockY - 1, accessor.getPosition().blockZ) != null){
}
}
*/
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
currenttip.add(BLUE + ITALIC + "Statues" );
return currenttip;
}
}
@@ -0,0 +1,39 @@
package mcp.mobius.waila.addons.statues;
import java.lang.reflect.Field;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class StatuesModule {
public static Class TileEntityStatue = null;
public static Field skinName = null;
public static void register(){
try{
Class Statues = Class.forName("info.jbcs.minecraft.statues.Statues");
Waila.log.log(Level.INFO, "Statues mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[Statues] Statues mod not found.");
return;
}
try{
TileEntityStatue = Class.forName("info.jbcs.minecraft.statues.TileEntityStatue");
skinName = TileEntityStatue.getDeclaredField("skinName");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[Statues] Class not found. " + e);
return;
} catch (NoSuchFieldException e){
Waila.log.log(Level.WARNING, "[Statues] Class not found. " + e);
return;
}
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerStatues(), TileEntityStatue);
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerStatues(), TileEntityStatue);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStatue);
}
}
@@ -0,0 +1,150 @@
package mcp.mobius.waila.addons.stevescarts;
import java.util.ArrayList;
import java.util.List;
import codechicken.lib.math.MathHelper;
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;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDCargoManager implements IWailaDataProvider {
private static String colors[] = {"NA", "Red", "Blue", "Yellow", "Green", "Dis."};
private static String sides[] = {"Yellow", "Blue", "Green", "Red"};
@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("stevescarts.showall")) return currenttip;
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
currenttip.add(ITALIC + "Press shift for more data");
return currenttip;
}
NBTTagCompound tag = accessor.getNBTData();
if (config.getConfig("stevescarts.colorblind")){
int side = accessor.getSide().ordinal() - 2;
if (side >= 0)
currenttip.add("Looking at side " + WHITE + sides[side]);
}
int layout = accessor.getNBTInteger(tag, "layout");
switch(layout){
case 0:
currenttip.add("Slots : "+ WHITE + "Shared");
break;
case 1:
currenttip.add("Slots : "+ WHITE + "By side");
break;
case 2:
currenttip.add("Slots : "+ WHITE + "By color");
break;
}
try{
ArrayList<Object> itemSelection = (ArrayList<Object>) StevesCartsModule.ItemSelections.get(accessor.getTileEntity());
int toCart = accessor.getNBTInteger(tag, "tocart");
int doReturn = accessor.getNBTInteger(tag, "doReturn");
for (int i = 0; i < 4; i++){
int target = accessor.getNBTInteger(tag, "target" + String.valueOf(i));
int color = accessor.getNBTInteger(tag, "color" + String.valueOf(i));
int amount = accessor.getNBTInteger(tag, "amount" + String.valueOf(i));
if (color == 5) continue;
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
String sAmount = amount == 0 ? "All" : String.valueOf(this.getAmount(amount) + " " + this.getAmountType(amount));
String selection = (String) StevesCartsModule.GetSelectionName.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
currenttip.add(String.format("Side %s %s[ %s ]%s[ %s , %s]%s[ %s ]", WHITE + colors[color] + GRAY,
TAB + ALIGNRIGHT, WHITE + selection + GRAY,
TAB + ALIGNRIGHT, WHITE + direction + GRAY,
TAB + ALIGNRIGHT + WHITE + shouldReturn + GRAY,
TAB + ALIGNRIGHT, WHITE + sAmount + GRAY));
}
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public int getAmount(int id)
{
switch (id)
{
case 1:
return 1;
case 2:
return 3;
case 3:
return 8;
case 4:
return 16;
case 5:
return 32;
case 6:
return 64;
case 7:
return 1;
case 8:
return 2;
case 9:
return 3;
case 10:
return 5;
default:
return 0;
}
}
//0 - MAX
//1 - Items
//2 - Stacks
public String getAmountType(int id)
{
if (id <= 6)
{
return "I";
}
else
{
return "S";
}
}
}
@@ -0,0 +1,88 @@
package mcp.mobius.waila.addons.stevescarts;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDCartAssembler 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("stevescarts.showall")) return currenttip;
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
currenttip.add(ITALIC + "Press shift for more data");
return currenttip;
}
int currTime = accessor.getNBTInteger(accessor.getNBTData(), "currentTime");
int maxTime = accessor.getNBTInteger(accessor.getNBTData(), "maxTime");
int isAssembling = accessor.getNBTInteger(accessor.getNBTData(), "isAssembling");
NBTTagList slots = accessor.getNBTData().getTagList("Items");
boolean hasOutput = false;
Item ItemCartModule = null;
try {
ItemCartModule = (Item)StevesCartsModule.ItemCartModule.get(null);
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
return currenttip;
}
for (int i = 0; i < slots.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)(slots.tagAt(i));
byte slot = subtag.getByte("Slot");
if (slot == 30)
hasOutput = true;
}
if (isAssembling == 1){
currenttip.add(String.format("Time remaining : %.1f sec", (maxTime - currTime) / 20.0f));
NBTTagCompound output = accessor.getNBTData().getCompoundTag("Output");
short outID = output.getShort("id");
byte[] metas = output.getCompoundTag("tag").getByteArray("Modules");
for (byte b : metas){
currenttip.add(new ItemStack(ItemCartModule, 1, b).getDisplayName());
}
}
else
if (hasOutput)
currenttip.add(String.format("Time remaining : <Done>"));
else
currenttip.add(String.format("Time remaining : <Idle>"));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -0,0 +1,126 @@
package mcp.mobius.waila.addons.stevescarts;
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;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDLiquidManager implements IWailaDataProvider {
private static String colors[] = {"NA", "Red", "Blue", "Yellow", "Green", "Dis."};
private static String sides[] = {"Yellow", "Blue", "Green", "Red"};
@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("stevescarts.showall")) return currenttip;
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
currenttip.add(ITALIC + "Press shift for more data");
return currenttip;
}
NBTTagCompound tag = accessor.getNBTData();
if (config.getConfig("stevescarts.colorblind")){
int side = accessor.getSide().ordinal() - 2;
if (side >= 0)
currenttip.add("Looking at side " + WHITE + sides[side]);
}
int layout = accessor.getNBTInteger(tag, "layout");
switch(layout){
case 0:
currenttip.add("Tanks : "+ WHITE + "Shared");
break;
case 1:
currenttip.add("Tanks : "+ WHITE + "By side");
break;
case 2:
currenttip.add("Tanks : "+ WHITE + "By color");
break;
}
int toCart = accessor.getNBTInteger(tag, "tocart");
int doReturn = accessor.getNBTInteger(tag, "doReturn");
for (int i = 0; i < 4; i++){
int target = accessor.getNBTInteger(tag, "target" + String.valueOf(i));
int color = accessor.getNBTInteger(tag, "color" + String.valueOf(i));
int amount = accessor.getNBTInteger(tag, "amount" + String.valueOf(i));
String fluidName = "<Empty>";
int fluidAmount = 0;
if (tag.hasKey("Fluid" + i)){
fluidName = tag.getCompoundTag("Fluid" + i).getString("FluidName");
fluidAmount = tag.getCompoundTag("Fluid" + i).getInteger("Amount");
}
String fluidString = fluidAmount == 0 ? "<Empty>" : String.format("%s mB of %s", fluidAmount, fluidName);
if (color == 5) continue;
String direction = (toCart & (1 << i)) != 0 ? "Load" : "Unload";
String shouldReturn = (doReturn & (1 << i)) != 0 ? "Ret." : "Cont.";
String sAmount = amount == 0 ? "All" : String.valueOf(this.getMaxAmountBuckets(amount)) + " mB";
//String selection = (String) StevesCartsModule.GetSelectionName.invoke(StevesCartsModule.CargoItemSelection.cast(itemSelection.get(target)));
currenttip.add(String.format("Side %s %s[ %s ]%s[ %s , %s]%s[ %s ]", WHITE + colors[color] + GRAY,
TAB + ALIGNRIGHT, WHITE + fluidString + GRAY,
TAB + ALIGNRIGHT, WHITE + direction + GRAY,
TAB + ALIGNRIGHT + WHITE + shouldReturn + GRAY,
TAB + ALIGNRIGHT, WHITE + sAmount + GRAY));
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public int getMaxAmountBuckets(int id) {
switch(id) {
case 1:
return 250;
case 2:
return 500;
case 3:
return 750;
case 4:
return 1000;
case 5:
return 2000;
case 6:
return 3000;
case 7:
return 5000;
case 8:
return 7500;
case 9:
return 10000;
case 10:
return 15000;
default:
return 0;
}
}
}
@@ -0,0 +1,85 @@
package mcp.mobius.waila.addons.stevescarts;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaEntityAccessor;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDMinecartModular implements IWailaEntityProvider {
@Override
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
if (currenttip.get(0).contains("entity.StevesCarts.Minecart")){
currenttip.remove(0);
currenttip.add(WHITE + "Modular Minecart");
}
return currenttip;
}
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("stevescarts.showall")) return currenttip;
if (config.getConfig("stevescarts.shifttoggle") && !accessor.getPlayer().isSneaking()){
currenttip.add(ITALIC + "Press shift for more data");
return currenttip;
}
Item ItemCartModule = null;
try {
ItemCartModule = (Item)StevesCartsModule.ItemCartModule.get(null);
} catch (Exception e) {
currenttip = WailaExceptionHandler.handleErr(e, accessor.getEntity().getClass().getName(), currenttip);
return currenttip;
}
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("Modules")){
byte[] metas = tag.getByteArray("Modules");
for (int i = 0; i < metas.length; i++){
if (tag.hasKey("module" + String.valueOf(i) + "Fuel")){
int fuel = accessor.getNBTInteger(tag, "module" + String.valueOf(i) + "Fuel");
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " [ " + WHITE + fuel + GRAY + " POW ]");
} else if (tag.hasKey("module" + String.valueOf(i) + "Fluid")){
NBTTagCompound subtag = tag.getCompoundTag("module" + String.valueOf(i) + "Fluid");
if (subtag.hasKey("Amount")){
int amount = accessor.getNBTInteger(subtag, "Amount");
String fluid = subtag.getString("FluidName");
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " [ " + WHITE + String.valueOf(amount) + GRAY + " mB of " + WHITE + fluid + GRAY + " ]");
} else {
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName() + TAB + ALIGNRIGHT + " < " + WHITE + "Empty" + GRAY + " > ");
}
}else{
currenttip.add(new ItemStack(ItemCartModule, 1, metas[i]).getDisplayName());
}
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -0,0 +1,78 @@
package mcp.mobius.waila.addons.stevescarts;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class StevesCartsModule {
public static Class TileEntityCartAssembler = null;
public static Class TileEntityCargo = null;
public static Class TileEntityLiquid = null;
public static Class MinecartModular = null;
public static Class StevesItems = null;
public static Class CargoItemSelection = null;
public static Field ItemCartComponent = null; //Items.component
public static Field ItemCartModule = null; //Items.modules
public static Field ItemSelections = null; //TileEntityCargo.itemSelections
public static Method GetSelectionName = null; // CargoItemSelection.getName
public static void register(){
try{
Class ModStevesCarts = Class.forName("vswe.stevescarts.StevesCarts");
Waila.log.log(Level.INFO, "StevesCarts mod found.");
} catch (ClassNotFoundException e){
Waila.log.log(Level.INFO, "[StevesCarts] StevesCarts mod not found.");
return;
}
try{
TileEntityCartAssembler = Class.forName("vswe.stevescarts.TileEntities.TileEntityCartAssembler");
TileEntityCargo = Class.forName("vswe.stevescarts.TileEntities.TileEntityCargo");
TileEntityLiquid = Class.forName("vswe.stevescarts.TileEntities.TileEntityLiquid");
MinecartModular = Class.forName("vswe.stevescarts.Carts.MinecartModular");
StevesItems = Class.forName("vswe.stevescarts.Items.Items");
CargoItemSelection = Class.forName("vswe.stevescarts.Helpers.CargoItemSelection");
ItemCartComponent = StevesItems.getDeclaredField("component");
ItemCartModule = StevesItems.getDeclaredField("modules");
ItemSelections = TileEntityCargo.getDeclaredField("itemSelections");
GetSelectionName = CargoItemSelection.getDeclaredMethod("getName");
} catch (ClassNotFoundException e){
Waila.log.log(Level.WARNING, "[StevesCarts] Class not found. " + e);
return;
} catch (NoSuchFieldException e) {
Waila.log.log(Level.WARNING, "[StevesCarts] Field not found. " + e);
return;
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARNING, "[StevesCarts] Method not found. " + e);
return;
} catch (Exception e) {
Waila.log.log(Level.WARNING, "[StevesCarts] Error while loading module. " + e);
return;
}
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.showall");
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.colorblind");
ModuleRegistrar.instance().addConfigRemote("Steve's carts", "stevescarts.shifttoggle");
ModuleRegistrar.instance().registerBodyProvider(new HUDCartAssembler(), TileEntityCartAssembler);
ModuleRegistrar.instance().registerBodyProvider(new HUDCargoManager(), TileEntityCargo);
ModuleRegistrar.instance().registerBodyProvider(new HUDLiquidManager(), TileEntityLiquid);
ModuleRegistrar.instance().registerHeadProvider(new HUDMinecartModular(), MinecartModular);
ModuleRegistrar.instance().registerBodyProvider(new HUDMinecartModular(), MinecartModular);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityCartAssembler);
ModuleRegistrar.instance().registerSyncedNBTKey("*", MinecartModular);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityCargo);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityLiquid);
}
}
@@ -0,0 +1,108 @@
package mcp.mobius.waila.addons.thaumcraft;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StringUtils;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.NBTUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerIAspectContainer 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.aspects")) return currenttip;
ItemStack headSlot = accessor.getPlayer().inventory.armorInventory[3];
if (headSlot == null) return currenttip;
boolean hasReveal = ThaumcraftModule.ItemGoggles.isInstance(headSlot.getItem()) ||
(ThaumcraftModule.ItemRevealingHelm != null && ThaumcraftModule.ItemRevealingHelm.isInstance(headSlot.getItem())) ||
(ThaumcraftModule.ItemGemHelm != null && ThaumcraftModule.ItemGemHelm.isInstance(headSlot.getItem()));
if (!hasReveal) return currenttip;
NBTTagCompound tag = accessor.getNBTData();
if (tag.hasKey("Aspect") && tag.hasKey("Amount") && !tag.getString("Aspect").equals("")){
String aspect = Character.toUpperCase(tag.getString("Aspect").charAt(0)) + tag.getString("Aspect").substring(1);
currenttip.add(this.getAspectString(tag, "Aspect", "Amount", accessor));
}
if (tag.hasKey("aspect") && tag.hasKey("amount") && !tag.getString("aspect").equals("")){
String aspect = Character.toUpperCase(tag.getString("aspect").charAt(0)) + tag.getString("aspect").substring(1);
currenttip.add(this.getAspectString(tag, "aspect", "amount", accessor));
}
if (tag.hasKey("Aspects")){
NBTTagList taglist = tag.getTagList("Aspects");
for (int i = 0; i < taglist.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)taglist.tagAt(i);
if (subtag.hasKey("amount") && subtag.hasKey("key") && !subtag.getString("key").equals("")){
currenttip.add(this.getAspectString(subtag, "key", "amount", accessor));
}
}
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
private String getAspectString(NBTTagCompound tag, String keyAspect, String keyAmount, IWailaDataAccessor accessor){
String aspect = tag.getString(keyAspect);
aspect = knowAspect(aspect, accessor) ? aspect : "????";
aspect = Character.toUpperCase(aspect.charAt(0)) + aspect.substring(1);
String amount = String.valueOf(NBTUtil.getNBTInteger(tag, keyAmount));
return String.format("%s" + TAB + ALIGNRIGHT + WHITE + "%s", aspect, amount);
}
private boolean knowAspect(String name, IWailaDataAccessor accessor){
try{
Object proxy = ThaumcraftModule.TC_proxy.get(null);
Object known = ThaumcraftModule.getKnownAspects.invoke(proxy, (Object[])null);
Object listAspc = ((Map<String, Object>)known).get(accessor.getPlayer().username);
//Object research = ThaumcraftModule.playerResearch.get(proxy);
//Object aspect = ThaumcraftModule.getAspect.invoke(null, name);
//Object knownaspects = ThaumcraftModule.aspectsDiscovered.get(research);
//Boolean known = (Boolean)ThaumcraftModule.hasDiscoveredAspect.invoke(research, accessor.getPlayer().username, aspect);
Object[] aspects = (Object[])ThaumcraftModule.list_getAspects.invoke(listAspc);
for (Object o : aspects){
if (ThaumcraftModule.aspect_tag.get(o).equals(name)){
return true;
}
}
return false;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
return false;
}
}
}
@@ -1,57 +1,92 @@
package mcp.mobius.waila.addons.thaumcraft;
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.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class ThaumcraftModule {
public static Class BlockMagicalLeaves = null;
public static Class BlockCustomPlant = null;
public static Class IAspectContainer = null;
public static Class TileAlchemyFurnace = null;
public static Class ItemGoggles = null;
public static Class ItemRevealingHelm = null;
public static Class ItemGemHelm = null;
public static Class TileCrystalCapacitor = null;
public static Field TileCrystalCapacitor_StoredVis = null;
public static Field TileCrystalCapacitor_MaxVis = null;
public static Class Thaumcraft = null;
public static Class TCClientProxy = null;
public static Class TCCommonProxy = null;
//public static Class PlayerKnowledge = null;
public static Class Aspect = null;
public static Class AspectList = null;
public static Field TC_proxy = null; //Thaumcraft.proxy
//public static Field playerResearch = null; //ClientProxy.playerResearch
//public static Field aspectsDiscovered = null; //PlayerKnowledge.aspectsDiscovered
public static Field aspect_tag = null; //Aspect.tag
//public static Method hasDiscoveredAspect = null; //PlayerKnowledge.hasDiscoveredAspect
//public static Method getAspect = null; //Aspect.getAspect
public static Method getKnownAspects = null; //CommonProxy.getKnownAspects
public static Method list_getAspects = null; //AspectList.getAspects
public static void register(){
try{
Class ModThaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
mod_Waila.log.log(Level.INFO, "Thaumcraft mod found.");
Thaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
Waila.log.log(Level.INFO, "Thaumcraft mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
return;
}
try{
ItemRevealingHelm = Class.forName("vazkii.tinkerer.common.item.ItemRevealingHelm");
} catch (ClassNotFoundException e){ }
try{
BlockMagicalLeaves = Class.forName("thaumcraft.common.world.BlockMagicalLeaves");
BlockCustomPlant = Class.forName("thaumcraft.common.world.BlockCustomPlant");
ItemGemHelm = Class.forName("vazkii.tinkerer.common.item.kami.armor.ItemGemHelm");
} catch (ClassNotFoundException e){ }
try{
IAspectContainer = Class.forName("thaumcraft.api.aspects.IAspectContainer");
TileAlchemyFurnace = Class.forName("thaumcraft.common.tiles.TileAlchemyFurnace");
ItemGoggles = Class.forName("thaumcraft.common.items.armor.ItemGoggles");
TCClientProxy = Class.forName("thaumcraft.client.ClientProxy");
TCCommonProxy = Class.forName("thaumcraft.common.CommonProxy");
//PlayerKnowledge = Class.forName("thaumcraft.common.lib.research.PlayerKnowledge");
Aspect = Class.forName("thaumcraft.api.aspects.Aspect");
AspectList = Class.forName("thaumcraft.api.aspects.AspectList");
TileCrystalCapacitor = Class.forName("thaumcraft.common.tiles.TileCrystalCapacitor");
TileCrystalCapacitor_StoredVis = TileCrystalCapacitor.getField("storedVis");
TileCrystalCapacitor_MaxVis = TileCrystalCapacitor.getField("maxVis");
TC_proxy = Thaumcraft.getDeclaredField("proxy");
//playerResearch = TCClientProxy.getDeclaredField("playerResearch");
//aspectsDiscovered = PlayerKnowledge.getDeclaredField("aspectsDiscovered");
//playerResearch.setAccessible(true);
aspect_tag = Aspect.getDeclaredField("tag");
aspect_tag.setAccessible(true);
//hasDiscoveredAspect = PlayerKnowledge.getDeclaredMethod("hasDiscoveredAspect", String.class, Aspect);
//getAspect = Aspect.getDeclaredMethod("getAspect", String.class);
getKnownAspects = TCCommonProxy.getDeclaredMethod("getKnownAspects");
list_getAspects = AspectList.getDeclaredMethod("getAspects");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Class not found. " + e);
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);
} catch (Exception e){
Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
//WailaExceptionHandler.handleErr(e, null, null);
return;
// } catch (Exception e){
// mod_Waila.log.log(Level.WARNING, "[Thaumcraft] Unhandled exception." + e);
// return;
}
ExternalModulesHandler.instance().addConfig("Thaumcraft", "thaumcraft.storedvis");
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerLeaves(), BlockMagicalLeaves);
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
}
ModuleRegistrar.instance().addConfigRemote("Thaumcraft", "thaumcraft.aspects");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), IAspectContainer);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIAspectContainer(), TileAlchemyFurnace);
ModuleRegistrar.instance().registerSyncedNBTKey("*", IAspectContainer);
}
}
@@ -4,11 +4,13 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerConduitFluid implements IWailaDataProvider {
@@ -25,22 +27,31 @@ public class HUDHandlerConduitFluid implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (config.getConfig("thermalexpansion.fluidtype")){
if (!config.getConfig("thermalexpansion.fluidtype")) return currenttip;
try {
FluidStack fluid = (FluidStack)ThermalExpansionModule.TileConduitFluid_getRenderFluid.invoke(accessor.getTileEntity());
try{
currenttip.add(fluid.getFluid().getLocalizedName());
} catch (NullPointerException f){
currenttip.add(LangUtil.translateG("hud.msg.empty"));
}
} catch (Exception e){
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
}
boolean found = false;
FluidStack fluid = null;
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
NBTTagList parts = accessor.getNBTData().getTagList("parts");
for (int i = 0; i < parts.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
String id = subtag.getString("id");
}
if (id.contains("ConduitFluid")){
found = true;
NBTTagCompound fluidTag = subtag.getCompoundTag("ConnFluid");
fluid = FluidStack.loadFluidStackFromNBT(fluidTag);
}
}
if (!found) return currenttip;
if (fluid != null)
currenttip.add(fluid.getFluid().getLocalizedName());
else
currenttip.add(LangUtil.translateG("hud.msg.empty"));
return currenttip;
}
@@ -3,6 +3,8 @@ package mcp.mobius.waila.addons.thermalexpansion;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -22,18 +24,35 @@ public class HUDHandlerConduitItem implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (accessor.getNBTData().hasKey("Mode") && accessor.getNBTInteger(accessor.getNBTData(), "Mode") != 0){
int mode = accessor.getNBTInteger(accessor.getNBTData(), "Mode");
if (!config.getConfig("thermalexpansion.conditemmode")) return currenttip;
boolean found = false;
int mode = -1;
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
NBTTagList parts = accessor.getNBTData().getTagList("parts");
for (int i = 0; i < parts.tagCount(); i++){
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
String id = subtag.getString("id");
if (mode == 1)
currenttip.add("Mode : \u00a7fDense");
else if (mode == 2)
currenttip.add("Mode : \u00a7fVacuum");
else if (mode == 3)
currenttip.add("Mode : \u00a7fRound-Robin");
else
currenttip.add("Mode : <UNKNOWN>");
}
if (id.contains("ConduitItem")){
mode = accessor.getNBTInteger(subtag, "Mode");
found = true;
}
}
if (!found) return currenttip;
if (mode == 0){}
else if (mode == 1)
currenttip.add("Mode : \u00a7fDense");
else if (mode == 2)
currenttip.add("Mode : \u00a7fVacuum");
else if (mode == 3)
currenttip.add("Mode : \u00a7fRound-Robin");
else
currenttip.add("Mode : <UNKNOWN>");
return currenttip;
}
@@ -4,10 +4,10 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
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;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerEnergyCell implements IWailaDataProvider {
@@ -5,10 +5,10 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
@@ -6,10 +6,10 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
public class HUDHandlerTank implements IWailaDataProvider {
@@ -5,8 +5,8 @@ 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;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ThermalExpansionModule {
@@ -20,16 +20,18 @@ public class ThermalExpansionModule {
public static Method TileTank_getTankCapacity = null;
public static Field TileTank_mode = null;
public static Class TileConduitFluid = null;
public static Method TileConduitFluid_getRenderFluid = null;
public static Method TileConduitFluid_getRenderFluidLevel = null;
//public static Class TileConduitFluid = null;
//public static Method TileConduitFluid_getRenderFluid = null;
//public static Method TileConduitFluid_getRenderFluidLevel = null;
public static Class TileConduitItems = null;
//public static Class TileConduitItems = null;
public static Class TileTesseract = null;
public static Class ISecureTile = null;
public static Class BlockMultipart = null;
//public static Field TileTesseract_modItem = null;
//public static Field TileTesseract_modFluid = null;
//public static Field TileTesseract_modEnergy = null;
@@ -43,9 +45,9 @@ public class ThermalExpansionModule {
try{
Class ModThermalExpansion = Class.forName("thermalexpansion.ThermalExpansion");
mod_Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[Thermal Expansion] ThermalExpansion mod not found.");
Waila.log.log(Level.INFO, "[Thermal Expansion] ThermalExpansion mod not found.");
return;
}
@@ -59,16 +61,17 @@ public class ThermalExpansionModule {
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
TileTank_mode = TileTank.getField("mode");
TileConduitFluid = Class.forName("thermalexpansion.block.conduit.fluid.TileConduitFluid");
TileConduitFluid_getRenderFluid = TileConduitFluid.getMethod("getRenderFluid");
TileConduitFluid_getRenderFluidLevel = TileConduitFluid.getMethod("getRenderFluidLevel");
TileConduitItems = Class.forName("thermalexpansion.block.conduit.item.TileConduitItem");
//TileConduitFluid = Class.forName("thermalexpansion.block.conduit.fluid.TileConduitFluid");
//TileConduitFluid_getRenderFluid = TileConduitFluid.getMethod("getRenderFluid");
//TileConduitFluid_getRenderFluidLevel = TileConduitFluid.getMethod("getRenderFluidLevel");
//TileConduitItems = Class.forName("thermalexpansion.block.conduit.item.TileConduitItem");
TileTesseract = Class.forName("thermalexpansion.block.tesseract.TileTesseract");
ISecureTile = Class.forName("cofh.api.tileentity.ISecureTile");
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
//TileTesseract_modItem = TileTesseract.getField("modItem");
//TileTesseract_modFluid = TileTesseract.getField("modFluid");
//TileTesseract_modEnergy = TileTesseract.getField("modEnergy");
@@ -81,43 +84,47 @@ public class ThermalExpansionModule {
//TileEnergyCell_energySend = TileEnergyCell.getField("energySend");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Class not found. " + e);
Waila.log.log(Level.WARNING, "[Thermal Expansion] Class not found. " + e);
return;
} catch (NoSuchMethodException e){
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Method not found." + e);
Waila.log.log(Level.WARNING, "[Thermal Expansion] Method not found." + e);
return;
} catch (NoSuchFieldException e){
mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Field not found." + e);
Waila.log.log(Level.WARNING, "[Thermal Expansion] Field not found." + e);
return;
// } catch (Exception e){
// mod_Waila.log.log(Level.WARNING, "[Thermal Expansion] Unhandled exception." + e);
// return;
}
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
ExternalModulesHandler.instance().addConfig("Thermal Expansion", "thermalexpansion.fluidtype");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.conditemmode");
ExternalModulesHandler.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tesssendrecv");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tessfreq");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.owner");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.conditemmode");
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tesssendrecv");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tessfreq");
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.owner");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyHandler);
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), TileEnergyCell);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyHandler);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitFluid(), TileConduitFluid);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitItem(), TileConduitItems);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitBase(), TileConduitBase);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitFluid(), BlockMultipart);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitItem(), BlockMultipart);
ModuleRegistrar.instance().registerSyncedNBTKey("*", IEnergyHandler);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEnergyCell);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTank);
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileTesseract);
ModuleRegistrar.instance().registerSyncedNBTKey("*", ISecureTile);
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockMultipart);
}
@@ -2,8 +2,8 @@ package mcp.mobius.waila.addons.twilightforest;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class TwilightForestModule {
@@ -15,9 +15,9 @@ public class TwilightForestModule {
try{
Class TwilightForestMod = Class.forName("twilightforest.TwilightForestMod");
mod_Waila.log.log(Level.INFO, "TwilightForestMod mod found.");
Waila.log.log(Level.INFO, "TwilightForestMod mod found.");
} catch (ClassNotFoundException e){
mod_Waila.log.log(Level.INFO, "[TwilightForestMod] TwilightForestMod mod not found.");
Waila.log.log(Level.INFO, "[TwilightForestMod] TwilightForestMod mod not found.");
return;
}
@@ -26,13 +26,16 @@ public class TwilightForestModule {
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);
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);
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFRoots);
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFPlant);
//ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFSapling);
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockTFRoots);
ModuleRegistrar.instance().registerSyncedNBTKey("*", BlockTFPlant);
}
}
@@ -4,52 +4,74 @@ import java.util.List;
import codechicken.lib.lang.LangUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSilverfish;
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;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
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;
static int cocoa = Block.cocoaPlant.blockID;
static int netherwart = Block.netherStalk.blockID;
static Block mobSpawner = Block.mobSpawner;
static Block crops = Block.crops;
static Block melonStem = Block.melonStem;
static Block pumpkinStem = Block.pumpkinStem;
static Block carrot = Block.carrot;
static Block potato = Block.potato;
static Block lever = Block.lever;
static Block repeaterIdle = Block.redstoneRepeaterIdle;
static Block repeaterActv = Block.redstoneRepeaterActive;
static Block comparatorIdl = Block.redstoneComparatorIdle;
static Block comparatorAct = Block.redstoneComparatorActive;
static Block redstone = Block.redstoneWire;
static Block jukebox = Block.jukebox;
static Block cocoa = Block.cocoaPlant;
static Block netherwart = Block.netherStalk;
static Block silverfish = Block.silverfish;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
Block block = accessor.getBlock();
if (block == silverfish && config.getConfig("vanilla.silverfish")){
int metadata = accessor.getMetadata();
switch(metadata){
case 0:
return new ItemStack(Block.stone);
case 1:
return new ItemStack(Block.cobblestone);
case 2:
return new ItemStack(Block.stoneBrick);
default:
return null;
}
}
if (block == redstone){
return new ItemStack(Item.redstone);
}
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
int blockID = accessor.getBlockID();
Block block = accessor.getBlock();
/* Mob spawner handler */
if (blockID == mobSpawnerID && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
if (block == mobSpawner && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
String name = currenttip.get(0);
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).getSpawnerLogic().getEntityNameToSpawn();
currenttip.set(0, String.format("%s (%s)", name, mobname));
}
if (blockID == redstone){
if (block == redstone){
String name = currenttip.get(0).replaceFirst(String.format(" %s", accessor.getMetadata()), "");
currenttip.set(0, name);
}
@@ -59,10 +81,11 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
int blockID = accessor.getBlockID();
Block block = accessor.getBlock();
/* Crops */
if (config.getConfig("vanilla.growthvalue"))
if (blockID == cropsID || blockID == melonStemID || blockID == pumpkinStemID || blockID == carrotID || blockID == potatoID){
boolean iscrop = crops.getClass().isInstance(block); //Done to cover all inheriting mods
if (config.getConfig("general.showcrop"))
if (iscrop || block == melonStem || block == pumpkinStem || block == carrot || block == potato){
float growthValue = (accessor.getMetadata() / 7.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
@@ -71,7 +94,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return currenttip;
}
if (blockID == cocoa){
if (block == cocoa && config.getConfig("general.showcrop")){
float growthValue = ((accessor.getMetadata() >> 2) / 2.0F) * 100.0F;
if (growthValue < 100.0)
@@ -81,7 +104,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return currenttip;
}
if (blockID == netherwart){
if (block == netherwart && config.getConfig("general.showcrop")){
float growthValue = (accessor.getMetadata() / 3.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
@@ -91,14 +114,14 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
}
if (config.getConfig("vanilla.leverstate"))
if (blockID == leverID){
if (block == lever){
String redstoneOn = (accessor.getMetadata() & 8) == 0 ? LangUtil.translateG("hud.msg.off") : LangUtil.translateG("hud.msg.on");
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.state"), redstoneOn));
return currenttip;
}
if (config.getConfig("vanilla.repeater"))
if ((blockID == repeaterIdle) ||(blockID == repeaterActv)){
if ((block == repeaterIdle) ||(block == repeaterActv)){
int tick = (accessor.getMetadata() >> 2) + 1 ;
if (tick == 1)
currenttip.add(String.format("%s : %s tick", LangUtil.translateG("hud.msg.delay"), tick));
@@ -108,7 +131,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
}
if (config.getConfig("vanilla.comparator"))
if ((blockID == comparatorIdl) ||(blockID == comparatorAct)){
if ((block == comparatorIdl) ||(block == comparatorAct)){
String mode = ((accessor.getMetadata() >> 2) & 1) == 0 ? LangUtil.translateG("hud.msg.comparator") : LangUtil.translateG("hud.msg.substractor");
//int outputSignal = ((TileEntityComparator)entity).func_96100_a();
currenttip.add("Mode : " + mode);
@@ -117,13 +140,13 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
}
if (config.getConfig("vanilla.redstone"))
if (blockID == redstone){
if (block == redstone){
currenttip.add(String.format("%s : %s" , LangUtil.translateG("hud.msg.power"), accessor.getMetadata()));
return currenttip;
}
if (config.getConfig("vanilla.jukebox"))
if (blockID == jukebox){
if (block == jukebox){
NBTTagCompound tag = accessor.getNBTData();
Item record = null;
if (tag.hasKey("Record")){
@@ -143,31 +166,53 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
}
public static void register(){
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.spawntype");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.growthvalue");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.leverstate");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.repeater");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.comparator");
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.redstone");
ExternalModulesHandler.instance().addConfigRemote("VanillaMC", "vanilla.jukebox");
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().registerBodyProvider(new HUDHandlerVanilla(), cocoa);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), netherwart);
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.spawntype");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.leverstate");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.repeater");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.comparator");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.redstone");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.silverfish");
ModuleRegistrar.instance().addConfigRemote("VanillaMC", "vanilla.jukebox");
ExternalModulesHandler.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
IWailaDataProvider provider = new HUDHandlerVanilla();
ModuleRegistrar.instance().registerStackProvider(provider, silverfish.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, redstone.getClass());
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawner.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, crops.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, melonStem.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, pumpkinStem.getClass());
//ModuleRegistrar.instance().registerBodyProvider(provider, carrot.getClass());
//ModuleRegistrar.instance().registerBodyProvider(provider, potato.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, lever.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterIdle.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterActv.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorIdl.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorAct.getClass());
ModuleRegistrar.instance().registerHeadProvider(provider, redstone.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, redstone.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, jukebox.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, cocoa.getClass());
ModuleRegistrar.instance().registerBodyProvider(provider, netherwart.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.mobSpawner.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.crops.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.melonStem.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.pumpkinStem.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.carrot.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.potato.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.lever.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneRepeaterIdle.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneRepeaterActive.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneComparatorIdle.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneComparatorActive.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.redstoneWire.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.jukebox.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.cocoaPlant.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.netherStalk.getClass());
ModuleRegistrar.instance().registerSyncedNBTKey("*", Block.silverfish.getClass());
ModuleRegistrar.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
//ExternalModulesHandler.instance().registerBlockDecorator(new HUDDecoratorVanilla(), repeaterIdle);
}
+1
View File
@@ -4,6 +4,7 @@ import java.util.List;
import net.minecraft.item.ItemStack;
@Deprecated
public interface IWailaBlock {
/*
* Use this method to return an item stack in case the default lookup system fails.
@@ -1,7 +1,5 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaBlockDecorator {
@@ -24,5 +24,5 @@ public interface IWailaConfigHandler {
/* Returns the current value of an option (true/false) with a default value true if not set*/
public boolean getConfig(String key);
public void setConfig(String key, boolean value);
//public void setConfig(String key, boolean value);
}
@@ -2,6 +2,7 @@ package mcp.mobius.waila.api;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
@@ -9,7 +10,13 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaDataAccessor {
World getWorld();
EntityPlayer getPlayer();
Block getBlock();
@@ -22,4 +29,5 @@ public interface IWailaDataAccessor {
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
ForgeDirection getSide();
ItemStack getStack();
}
+30 -1
View File
@@ -1,4 +1,33 @@
package mcp.mobius.waila.api;
public interface IWailaDataProvider extends IWailaBlock{
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaDataProvider{
/*
* 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);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}
@@ -0,0 +1,24 @@
package mcp.mobius.waila.api;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaEntityAccessor {
World getWorld();
EntityPlayer getPlayer();
Entity getEntity();
MovingObjectPosition getPosition();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
}
@@ -0,0 +1,16 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.entity.Entity;
public interface IWailaEntityProvider {
/* A way to get an override on the entity returned by the raytracing */
Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config);
/* The classical HEAD/BODY/TAIL text getters */
List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config);
}
@@ -0,0 +1,28 @@
package mcp.mobius.waila.api;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/* The Accessor is used to get some basic data out of the game without having to request
* direct access to the game engine.
* It will also return things that are unmodified by the overriding systems (like getWailaStack).
*/
public interface IWailaFMPAccessor {
World getWorld();
EntityPlayer getPlayer();
TileEntity getTileEntity();
MovingObjectPosition getPosition();
NBTTagCompound getNBTData();
NBTTagCompound getFullNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
Vec3 getRenderingPosition();
String getID();
}
@@ -0,0 +1,7 @@
package mcp.mobius.waila.api;
import net.minecraft.item.ItemStack;
public interface IWailaFMPDecorator {
void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config);
}
@@ -0,0 +1,12 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IWailaFMPProvider {
/* The classical HEAD/BODY/TAIL text getters */
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config);
}
+28 -3
View File
@@ -8,11 +8,15 @@ public interface IWailaRegistrar {
public void addConfigRemote(String modname, String keyname);
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
@Deprecated
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
@Deprecated
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
@Deprecated
public void registerTailProvider (IWailaDataProvider dataProvider, int blockID);
/* Register a stack overrider for the given blockID */
@Deprecated
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
public void registerStackProvider(IWailaDataProvider dataProvider, Class block);
@@ -20,12 +24,33 @@ public interface IWailaRegistrar {
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
public void registerTailProvider (IWailaDataProvider dataProvider, Class block);
/* Entity text registration methods */
public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity);
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity);
/* FMP Providers */
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name);
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name);
public void registerTailProvider(IWailaFMPProvider dataProvider, String name);
/* The block decorators */
public void registerBlockDecorator (IWailaBlockDecorator decorator, int blockID);
public void registerBlockDecorator (IWailaBlockDecorator decorator, Class block);
@Deprecated
public void registerDecorator (IWailaBlockDecorator decorator, int blockID);
public void registerDecorator (IWailaBlockDecorator decorator, Class block);
public void registerDecorator (IWailaFMPDecorator decorator, String name);
/* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent).
* Accept * as a ending wildcard
* registerNBTKey("bob.*", MyBlock.class)
* registerNBTKey("data.life", MyEntity.class)
* registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5
* */
public void registerSyncedNBTKey(String key, Class target);
/* UNUSED FOR NOW (Will be used for the ingame wiki */
public void registerDocTextFile (String filename);
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
}
+40
View File
@@ -0,0 +1,40 @@
package mcp.mobius.waila.api;
public class SpecialChars {
public static String MCStyle = "\u00A7";
public static String BLACK = MCStyle + "0";
public static String DBLUE = MCStyle + "1";
public static String DGREEN = MCStyle + "2";
public static String DAQUA = MCStyle + "3";
public static String DRED = MCStyle + "4";
public static String DPURPLE = MCStyle + "5";
public static String GOLD = MCStyle + "6";
public static String GRAY = MCStyle + "7";
public static String DGRAY = MCStyle + "8";
public static String BLUE = MCStyle + "9";
public static String GREEN = MCStyle + "a";
public static String AQUA = MCStyle + "b";
public static String RED = MCStyle + "c";
public static String LPURPLE = MCStyle + "d";
public static String YELLOW = MCStyle + "e";
public static String WHITE = MCStyle + "f";
public static String OBF = MCStyle + "k";
public static String BOLD = MCStyle + "l";
public static String STRIKE = MCStyle + "m";
public static String UNDER = MCStyle + "n";
public static String ITALIC = MCStyle + "o";
public static String RESET = MCStyle + "r";
public static String WailaStyle = "\u00A4";
public static String WailaIcon = "\u00A5";
public static String TAB = WailaStyle + WailaStyle +"a";
public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b";
public static String ALIGNCENTER = WailaStyle + WailaStyle +"c";
public static String HEART = WailaStyle + WailaIcon +"a";
public static String HHEART = WailaStyle + WailaIcon +"b";
public static String EHEART = WailaStyle + WailaIcon +"c";
}
@@ -0,0 +1,159 @@
package mcp.mobius.waila.api.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.overlay.OverlayConfig;
import mcp.mobius.waila.utils.Constants;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
public class ConfigHandler implements IWailaConfigHandler {
/* SINGLETON */
private static ConfigHandler _instance = null;
private ConfigHandler() { _instance = this; }
public static ConfigHandler instance(){ return _instance == null ? new ConfigHandler() : _instance; }
/* === */
private LinkedHashMap<String, ConfigModule> modules = new LinkedHashMap<String, ConfigModule>();
private ArrayList<String> serverconfigs = new ArrayList<String>();
public HashMap<String, Boolean> forcedConfigs = new HashMap<String, Boolean>();
public Configuration config = null;
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;
}
private void saveModuleKey(String modName, String key){
config.get(Constants.CATEGORY_MODULES, key, true);
config.get(Constants.CATEGORY_SERVER , key, Constants.SERVER_FREE);
config.save();
}
public void addConfig(String modName, String key, String name){
this.saveModuleKey(modName, key);
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){
this.saveModuleKey(modName, key);
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){
return this.getConfig(key, true);
}
@Override
public boolean getConfig(String key, boolean defvalue){
if (this.serverconfigs.contains(key) && !Waila.instance.serverPresent)
return false;
if (this.forcedConfigs.containsKey(key))
return this.forcedConfigs.get(key);
Property prop = config.get(Constants.CATEGORY_MODULES, key, defvalue);
return prop.getBoolean(defvalue);
}
public boolean isServerRequired(String key){
return this.serverconfigs.contains(key);
}
/* GENERAL ACCESS METHODS TO GET/SET VALUES IN THE CONFIG FILE */
public boolean getConfig(String category, String key, boolean default_){
Property prop = config.get(category, key, default_);
return prop.getBoolean(default_);
}
public void setConfig(String category, String key, boolean state){
config.getCategory(category).put(key, new Property(key,String.valueOf(state),Property.Type.BOOLEAN));
config.save();
}
public int getConfig(String category, String key, int default_){
Property prop = config.get(category, key, default_);
return prop.getInt();
}
public void setConfig(String category, String key, int state){
config.getCategory(category).put(key, new Property(key,String.valueOf(state),Property.Type.INTEGER));
config.save();
}
/* Default config loading */
public void loadDefaultConfig(FMLPreInitializationEvent event){
config = new Configuration(event.getSuggestedConfigurationFile());
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_KEYBIND, true);
OverlayConfig.posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
OverlayConfig.alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
OverlayConfig.bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010).getInt();
OverlayConfig.gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff).getInt();
OverlayConfig.gradient2 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2, 0x28007f).getInt();
OverlayConfig.fontcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR, 0xA0A0A0).getInt();
OverlayConfig.scale = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, 100).getInt() / 100.0f;
HUDHandlerEntities.nhearts = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NHEARTS, 20).getInt();
HUDHandlerEntities.maxhpfortext = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MAXHP, 40).getInt();
config.getCategory(Constants.CATEGORY_MODULES).setComment("Those are the config keys defined in modules.\nServer side, it is used to enforce keys client side using the next section.");
config.getCategory(Constants.CATEGORY_SERVER).setComment("Any key set to true here will ensure that the client is using the configuration set in the 'module' section above.\nThis is useful for enforcing false to 'cheating' keys like silverfish.");
config.save();
}
}
@@ -1,4 +1,4 @@
package mcp.mobius.waila.addons;
package mcp.mobius.waila.api.impl;
import java.util.HashMap;
@@ -1,9 +1,9 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.api.impl;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
@@ -15,8 +15,9 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessor implements IWailaDataAccessor {
public class DataAccessorBlock implements IWailaDataAccessor {
public World world;
public EntityPlayer player;
@@ -29,8 +30,9 @@ public class DataAccessor implements IWailaDataAccessor {
public NBTTagCompound remoteNbt = null;
public long timeLastUpdate = System.currentTimeMillis();
public double partialFrame;
public ItemStack stack;
public static DataAccessor instance = new DataAccessor();
public static DataAccessorBlock instance = new DataAccessorBlock();
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
this.set(_world, _player, _mop, null, 0.0);
@@ -44,6 +46,8 @@ public class DataAccessor implements IWailaDataAccessor {
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);
try{ this.stack = new ItemStack(this.blockID, 1, this.metadata); } catch (Exception e) {}
if (viewEntity != null){
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
@@ -69,11 +73,28 @@ public class DataAccessor implements IWailaDataAccessor {
return this.block;
}
@Override
public int getBlockID() {
return this.blockID;
}
@Override
public int getMetadata() {
return this.metadata;
}
public void setBlock(Block block) {
this.block = block;
}
public void setBlockID(int val) {
this.blockID = val;
}
public void setMetadata(int val) {
this.metadata = val;
}
@Override
public TileEntity getTileEntity() {
return this.entity;
@@ -98,22 +119,9 @@ public class DataAccessor implements IWailaDataAccessor {
@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;
return NBTUtil.getNBTInteger(tag, keyname);
}
@Override
public int getBlockID() {
return this.blockID;
}
private boolean isTagCorrect(NBTTagCompound tag){
if (tag == null){
this.timeLastUpdate = System.currentTimeMillis() - 250;
@@ -144,22 +152,20 @@ public class DataAccessor implements IWailaDataAccessor {
@Override
public ForgeDirection getSide(){
int side = this.getPosition().sideHit;
switch (side){
case 0:
return ForgeDirection.DOWN;
case 1:
return ForgeDirection.UP;
case 2:
return ForgeDirection.EAST;
case 3:
return ForgeDirection.WEST;
case 4:
return ForgeDirection.NORTH;
case 5:
return ForgeDirection.SOUTH;
}
return ForgeDirection.UNKNOWN;
return ForgeDirection.getOrientation(this.getPosition().sideHit);
}
public boolean isTimeElapsed(long time){
return System.currentTimeMillis() - this.timeLastUpdate >= time;
}
public void resetTimer(){
this.timeLastUpdate = System.currentTimeMillis();
}
@Override
public ItemStack getStack() {
return this.stack;
}
}
@@ -0,0 +1,122 @@
package mcp.mobius.waila.api.impl;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaEntityAccessor;
import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorEntity implements IWailaEntityAccessor {
public World world;
public EntityPlayer player;
public MovingObjectPosition mop;
public Vec3 renderingvec = null;
public Entity entity;
public NBTTagCompound remoteNbt = null;
public long timeLastUpdate = System.currentTimeMillis();
public double partialFrame;
public static DataAccessorEntity instance = new DataAccessorEntity();
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
this.set(_world, _player, _mop, null, 0.0);
}
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.entity = _mop.entityHit;
if (viewEntity != null){
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
this.partialFrame = partialTicks;
}
}
@Override
public World getWorld() {
return this.world;
}
@Override
public EntityPlayer getPlayer() {
return this.player;
}
@Override
public Entity getEntity() {
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;
}
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;
}
}
@Override
public int getNBTInteger(NBTTagCompound tag, String keyname){
return NBTUtil.getNBTInteger(tag, keyname);
}
@Override
public Vec3 getRenderingPosition() {
return this.renderingvec;
}
@Override
public double getPartialFrame() {
return this.partialFrame;
}
public boolean isTimeElapsed(long time){
return System.currentTimeMillis() - this.timeLastUpdate >= time;
}
public void resetTimer(){
this.timeLastUpdate = System.currentTimeMillis();
}
}
@@ -0,0 +1,118 @@
package mcp.mobius.waila.api.impl;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorFMP implements IWailaFMPAccessor {
public String id;
public World world;
public EntityPlayer player;
public MovingObjectPosition mop;
public Vec3 renderingvec = null;
public TileEntity entity;
public NBTTagCompound partialNBT = null;
public NBTTagCompound remoteNBT = null;
public long timeLastUpdate = System.currentTimeMillis();
public double partialFrame;
public static DataAccessorFMP instance = new DataAccessorFMP();
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT, String id) {
this.set(_world, _player, _mop, _partialNBT, id, null, 0.0);
}
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT, String id, Vec3 renderVec, double partialTicks) {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.entity = world.getBlockTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
this.partialNBT = _partialNBT;
this.id = id;
this.renderingvec = renderVec;
this.partialFrame = partialTicks;
}
@Override
public World getWorld() {
return this.world;
}
@Override
public EntityPlayer getPlayer() {
return this.player;
}
@Override
public TileEntity getTileEntity() {
return this.entity;
}
@Override
public MovingObjectPosition getPosition() {
return this.mop;
}
@Override
public NBTTagCompound getNBTData() {
return this.partialNBT;
}
@Override
public NBTTagCompound getFullNBTData() {
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) {
return NBTUtil.getNBTInteger(tag, keyname);
}
@Override
public double getPartialFrame() {
return this.partialFrame;
}
@Override
public Vec3 getRenderingPosition() {
return this.renderingvec;
}
@Override
public String getID() {
return this.id;
}
private boolean isTagCorrect(NBTTagCompound tag){
if (tag == null){
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
int x = tag.getInteger("x");
int y = tag.getInteger("y");
int z = tag.getInteger("z");
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
return true;
else {
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
}
}
@@ -0,0 +1,230 @@
package mcp.mobius.waila.api.impl;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.network.Packet0x01TERequest;
import mcp.mobius.waila.network.Packet0x03EntRequest;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.ItemInfo.Layout;
import cpw.mods.fml.common.network.PacketDispatcher;
public class MetaDataProvider{
private ArrayList<IWailaDataProvider> headBlockProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> bodyBlockProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> tailBlockProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaEntityProvider> headEntityProviders = new ArrayList<IWailaEntityProvider>();
private ArrayList<IWailaEntityProvider> bodyEntityProviders = new ArrayList<IWailaEntityProvider>();
private ArrayList<IWailaEntityProvider> tailEntityProviders = new ArrayList<IWailaEntityProvider>();
private Class prevBlock = null;
private Class prevTile = null;
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor) {
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(ModuleRegistrar.instance().hasStackProviders(block)){
for (IWailaDataProvider dataProvider : ModuleRegistrar.instance().getStackProviders(block)){
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;
}
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor, List<String> currenttip, Layout layout) {
Block block = accessor.getBlock();
if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
accessor.resetTimer();
HashSet<String> keys = new HashSet<String>();
if (ModuleRegistrar.instance().hasSyncedNBTKeys(block))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(block));
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getTileEntity()))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getTileEntity()));
if (keys.size() != 0)
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop, keys));
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
try{
NBTTagCompound tag = new NBTTagCompound();
accessor.getTileEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
}
}
/* Interface IWailaBlock */
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);
}
else if (layout == Layout.FOOTER)
try{
return ((IWailaBlock)block).getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
}
headBlockProviders.clear();
bodyBlockProviders.clear();
tailBlockProviders.clear();
/* Lookup by class (for blocks)*/
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(block))
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(block));
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(block))
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(block));
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(block))
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(block));
/* Lookup by class (for tileentities)*/
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(accessor.getTileEntity()))
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(accessor.getTileEntity()))
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(accessor.getTileEntity()))
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
/* Apply all collected providers */
if (layout == Layout.HEADER)
for (IWailaDataProvider dataProvider : headBlockProviders)
try{
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (layout == Layout.BODY)
for (IWailaDataProvider dataProvider : bodyBlockProviders)
try{
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (layout == Layout.FOOTER)
for (IWailaDataProvider dataProvider : tailBlockProviders)
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
return currenttip;
}
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorEntity accessor, List<String> currenttip, Layout layout) {
if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
accessor.resetTimer();
HashSet<String> keys = new HashSet<String>();
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getEntity()))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getEntity()));
if (keys.size() != 0)
PacketDispatcher.sendPacketToServer(Packet0x03EntRequest.create(world, accessor.getEntity(), keys));
} else if (accessor.getEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
try{
NBTTagCompound tag = new NBTTagCompound();
accessor.getEntity().writeToNBT(tag);
accessor.remoteNbt = tag;
} catch (Exception e){
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
}
}
headEntityProviders.clear();
bodyEntityProviders.clear();
tailEntityProviders.clear();
/* Lookup by class (for entities)*/
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadEntityProviders(entity))
headEntityProviders.addAll(ModuleRegistrar.instance().getHeadEntityProviders(entity));
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyEntityProviders(entity))
bodyEntityProviders.addAll(ModuleRegistrar.instance().getBodyEntityProviders(entity));
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailEntityProviders(entity))
tailEntityProviders.addAll(ModuleRegistrar.instance().getTailEntityProviders(entity));
/* Apply all collected providers */
if (layout == Layout.HEADER)
for (IWailaEntityProvider dataProvider : headEntityProviders)
try{
currenttip = dataProvider.getWailaHead(entity, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (layout == Layout.BODY)
for (IWailaEntityProvider dataProvider : bodyEntityProviders)
try{
currenttip = dataProvider.getWailaBody(entity, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (layout == Layout.FOOTER)
for (IWailaEntityProvider dataProvider : tailEntityProviders)
try{
currenttip = dataProvider.getWailaTail(entity, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
return currenttip;
}
}
@@ -0,0 +1,485 @@
package mcp.mobius.waila.api.impl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import au.com.bytecode.opencsv.CSVReader;
import net.minecraft.block.Block;
import codechicken.lib.lang.LangUtil;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.api.IWailaFMPDecorator;
import mcp.mobius.waila.api.IWailaFMPProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
public class ModuleRegistrar implements IWailaRegistrar {
private static ModuleRegistrar instance = null;
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<Class, ArrayList<IWailaBlockDecorator>> blockClassDecorators = new LinkedHashMap<Class, ArrayList<IWailaBlockDecorator>>();
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> headEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> bodyEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> tailEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
public LinkedHashMap<Class, ArrayList<IWailaEntityProvider>> overrideEntityProviders = new LinkedHashMap<Class, ArrayList<IWailaEntityProvider>>();
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> headFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> bodyFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> tailFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
public LinkedHashMap<String, ArrayList<IWailaFMPDecorator>> FMPClassDecorators = new LinkedHashMap<String, ArrayList<IWailaFMPDecorator>>();
public LinkedHashMap<Class, HashSet<String>> syncedNBTKeys = new LinkedHashMap<Class, HashSet<String>>();
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 ModuleRegistrar() {
instance = this;
}
public static ModuleRegistrar instance(){
if (ModuleRegistrar.instance == null)
ModuleRegistrar.instance = new ModuleRegistrar();
return ModuleRegistrar.instance;
}
/* CONFIG HANDLING */
@Override
public void addConfig(String modname, String key, String configname) {
ConfigHandler.instance().addConfig(modname, key, LangUtil.translateG(configname));
}
@Override
public void addConfigRemote(String modname, String key, String configname) {
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG(configname));
}
@Override
public void addConfig(String modname, String key) {
ConfigHandler.instance().addConfig(modname, key, LangUtil.translateG("option." + key));
}
@Override
public void addConfigRemote(String modname, String key) {
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG("option." + key));
}
/* REGISTRATION METHODS */
@Override
@Deprecated
public void registerHeadProvider(IWailaDataProvider dataProvider, int blockID) {
this.registerHeadProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerHeadProvider(IWailaDataProvider dataProvider, Class block) {
this.registerProvider(dataProvider, block, this.headBlockProviders);
}
@Override
@Deprecated
public void registerBodyProvider(IWailaDataProvider dataProvider, int blockID) {
this.registerBodyProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerBodyProvider(IWailaDataProvider dataProvider, Class block) {
this.registerProvider(dataProvider, block, this.bodyBlockProviders);
}
@Override
@Deprecated
public void registerTailProvider(IWailaDataProvider dataProvider, int blockID) {
this.registerTailProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
this.registerProvider(dataProvider, block, this.tailBlockProviders);
}
@Override
@Deprecated
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID) {
this.registerStackProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerStackProvider(IWailaDataProvider dataProvider, Class block) {
this.registerProvider(dataProvider, block, this.stackBlockProviders);
}
@Override
public void registerHeadProvider(IWailaEntityProvider dataProvider, Class entity) {
this.registerProvider(dataProvider, entity, this.headEntityProviders);
}
@Override
public void registerBodyProvider(IWailaEntityProvider dataProvider, Class entity) {
this.registerProvider(dataProvider, entity, this.bodyEntityProviders);
}
@Override
public void registerTailProvider(IWailaEntityProvider dataProvider, Class entity) {
this.registerProvider(dataProvider, entity, this.tailEntityProviders);
}
@Override
public void registerHeadProvider(IWailaFMPProvider dataProvider, String name) {
this.registerProvider(dataProvider, name, this.headFMPProviders);
}
@Override
public void registerBodyProvider(IWailaFMPProvider dataProvider, String name) {
this.registerProvider(dataProvider, name, this.bodyFMPProviders);
}
@Override
public void registerTailProvider(IWailaFMPProvider dataProvider, String name) {
this.registerProvider(dataProvider, name, this.tailFMPProviders);
}
@Override
public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity){
this.registerProvider(dataProvider, entity, this.overrideEntityProviders);
}
@Override
public void registerShortDataProvider(IWailaSummaryProvider dataProvider, Class item) {
this.registerProvider(dataProvider, item, this.summaryProviders);
}
@Override
@Deprecated
public void registerDecorator(IWailaBlockDecorator decorator, int blockID) {
this.registerDecorator(decorator, Block.blocksList[blockID].getClass());
}
@Override
public void registerDecorator(IWailaBlockDecorator decorator, Class block) {
this.registerProvider(decorator, block, this.blockClassDecorators);
}
@Override
public void registerDecorator(IWailaFMPDecorator decorator, String name) {
this.registerProvider(decorator, name, this.FMPClassDecorators);
}
private <T, V> void registerProvider(T dataProvider, V clazz, LinkedHashMap<V, ArrayList<T>> target) {
if (!target.containsKey(clazz))
target.put(clazz, new ArrayList<T>());
ArrayList<T> providers =target.get(clazz);
if (providers.contains(dataProvider)) return;
target.get(clazz).add(dataProvider);
}
@Override
public void registerSyncedNBTKey(String key, Class target){
if (!this.syncedNBTKeys.containsKey(target))
this.syncedNBTKeys.put(target, new HashSet<String>());
this.syncedNBTKeys.get(target).add(key);
}
/* PROVIDER GETTERS */
public ArrayList<IWailaDataProvider> getHeadProviders(Object block) {
return getProviders(block, this.headBlockProviders);
}
public ArrayList<IWailaDataProvider> getBodyProviders(Object block) {
return getProviders(block, this.bodyBlockProviders);
}
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
return getProviders(block, this.tailBlockProviders);
}
public ArrayList<IWailaDataProvider> getStackProviders(Object block) {
return getProviders(block, this.stackBlockProviders);
}
public ArrayList<IWailaEntityProvider> getHeadEntityProviders(Object entity) {
return getProviders(entity, this.headEntityProviders);
}
public ArrayList<IWailaEntityProvider> getBodyEntityProviders(Object entity) {
return getProviders(entity, this.bodyEntityProviders);
}
public ArrayList<IWailaEntityProvider> getTailEntityProviders(Object entity) {
return getProviders(entity, this.tailEntityProviders);
}
public ArrayList<IWailaEntityProvider> getOverrideEntityProviders(Object entity) {
return getProviders(entity, this.overrideEntityProviders);
}
public ArrayList<IWailaFMPProvider> getHeadFMPProviders(String name) {
return getProviders(name, this.headFMPProviders);
}
public ArrayList<IWailaFMPProvider> getBodyFMPProviders(String name) {
return getProviders(name, this.bodyFMPProviders);
}
public ArrayList<IWailaFMPProvider> getTailFMPProviders(String name) {
return getProviders(name, this.tailFMPProviders);
}
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
return getProviders(item, this.summaryProviders);
}
public ArrayList<IWailaBlockDecorator> getBlockDecorators(Object block){
return getProviders(block, this.blockClassDecorators);
}
public ArrayList<IWailaFMPDecorator> getFMPDecorators(String name){
return getProviders(name, this.FMPClassDecorators);
}
private <T> ArrayList<T> getProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
ArrayList<T> returnList = new ArrayList<T>();
for (Class clazz : target.keySet())
if (clazz.isInstance(obj))
returnList.addAll(target.get(clazz));
return returnList;
}
private <T> ArrayList<T> getProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
return target.get(name);
}
public HashSet<String> getSyncedNBTKeys(Object target){
HashSet<String> returnList = new HashSet<String>();
for (Class clazz : this.syncedNBTKeys.keySet())
if (clazz.isInstance(target))
returnList.addAll(this.syncedNBTKeys.get(clazz));
return returnList;
}
/* HAS METHODS */
public boolean hasStackProviders(Object block){
return hasProviders(block, this.stackBlockProviders);
}
public boolean hasHeadProviders(Object block){
return hasProviders(block, this.headBlockProviders);
}
public boolean hasBodyProviders(Object block){
return hasProviders(block, this.bodyBlockProviders);
}
public boolean hasTailProviders(Object block){
return hasProviders(block, this.tailBlockProviders);
}
public boolean hasHeadEntityProviders(Object entity){
return hasProviders(entity, this.headEntityProviders);
}
public boolean hasBodyEntityProviders(Object entity){
return hasProviders(entity, this.bodyEntityProviders);
}
public boolean hasTailEntityProviders(Object entity){
return hasProviders(entity, this.tailEntityProviders);
}
public boolean hasOverrideEntityProviders(Object entity){
return hasProviders(entity, this.overrideEntityProviders);
}
public boolean hasHeadFMPProviders(String name){
return hasProviders(name, this.headFMPProviders);
}
public boolean hasBodyFMPProviders(String name){
return hasProviders(name, this.bodyFMPProviders);
}
public boolean hasTailFMPProviders(String name){
return hasProviders(name, this.tailFMPProviders);
}
public boolean hasBlockDecorator(Object block){
return hasProviders(block, this.blockClassDecorators);
}
public boolean hasFMPDecorator(String name){
return hasProviders(name, this.FMPClassDecorators);
}
private <T> boolean hasProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
for (Class clazz : target.keySet())
if (clazz.isInstance(obj))
return true;
return false;
}
private <T> boolean hasProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
return target.containsKey(name);
}
public boolean hasSummaryProvider(Class item){
return this.summaryProviders.containsKey(item);
}
public boolean hasSyncedNBTKeys(Object target){
for (Class clazz : this.syncedNBTKeys.keySet())
if (clazz.isInstance(target))
return true;
return false;
}
/* ----------------- */
@Override
public void registerDocTextFile(String filename) {
List<String[]> docData = null;
int nentries = 0;
try{
docData = this.readFileAsString(filename);
} catch (IOException e){
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);
}
}
}
*/
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();
*/
}
}
+3
View File
@@ -0,0 +1,3 @@
@API(apiVersion="1.0",owner="Waila",provides="WailaAPI")
package mcp.mobius.waila.api;
import cpw.mods.fml.common.API;
+14 -14
View File
@@ -3,18 +3,19 @@ package mcp.mobius.waila.client;
import java.util.EnumSet;
import java.util.List;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
import mcp.mobius.waila.handlers.nei.HandlerEnchants;
import mcp.mobius.waila.overlay.RayTracing;
import mcp.mobius.waila.utils.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraftforge.common.Configuration;
import org.lwjgl.input.Keyboard;
@@ -25,7 +26,6 @@ import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
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 {
@@ -81,18 +81,18 @@ public class ConfigKeyHandler extends KeyHandler {
if (mc.currentScreen != null)
return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_SHOW);
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, !status);
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
boolean status = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, !status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, true);
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
}
else if (kb.keyDescription == Constants.BIND_WAILA_LIQUID){
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID);
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_LIQUID, !status);
boolean status = ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true);
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, !status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_RECIPE){
@@ -111,8 +111,8 @@ public class ConfigKeyHandler extends KeyHandler {
boolean uiResult;
String msg;
if ((RayTracing.raytracedTarget != null) && (RayTracing.raytracedTarget.typeOfHit == EnumMovingObjectType.TILE)){
List<ItemStack> stacks = RayTracing.getIdentifierItems();
if ((RayTracing.instance().getTarget() != null) && (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.TILE)){
List<ItemStack> stacks = RayTracing.instance().getIdentifierItems();
if (stacks.size() > 0){
mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
if (firstInventory){
@@ -148,8 +148,8 @@ public class ConfigKeyHandler extends KeyHandler {
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
if (!tickEnd) return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, false);
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true)){
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
}
}
+74 -15
View File
@@ -1,39 +1,54 @@
package mcp.mobius.waila.client;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.addons.agriculture.AgricultureModule;
import mcp.mobius.waila.addons.appeng.AppEngModule;
import mcp.mobius.waila.addons.buildcraft.BCModule;
import mcp.mobius.waila.addons.buildcraft.BCPowerAPIModule;
import mcp.mobius.waila.addons.carpenters.CarpentersModule;
import mcp.mobius.waila.addons.enderio.EnderIOModule;
import mcp.mobius.waila.addons.enderstorage.EnderStorageModule;
import mcp.mobius.waila.addons.etb.ETBModule;
import mcp.mobius.waila.addons.exu.ExtraUtilitiesModule;
import mcp.mobius.waila.addons.gravestone.GravestoneModule;
import mcp.mobius.waila.addons.harvestcraft.HarvestcraftModule;
import mcp.mobius.waila.addons.ic2.IC2Module;
import mcp.mobius.waila.addons.magicalcrops.MagicalCropsModule;
import mcp.mobius.waila.addons.openblocks.OpenBlocksModule;
import mcp.mobius.waila.addons.projectred.ProjectRedModule;
import mcp.mobius.waila.addons.railcraft.RailcraftModule;
import mcp.mobius.waila.addons.secretrooms.SecretRoomsModule;
import mcp.mobius.waila.addons.statues.StatuesModule;
import mcp.mobius.waila.addons.stevescarts.StevesCartsModule;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
import mcp.mobius.waila.addons.thermalexpansion.ThermalExpansionModule;
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.gui.truetyper.FontLoader;
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
import mcp.mobius.waila.handlers.DecoratorFMP;
import mcp.mobius.waila.handlers.HUDHandlerBlocks;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.handlers.HUDHandlerFMP;
import mcp.mobius.waila.handlers.SummaryProviderDefault;
import mcp.mobius.waila.handlers.hud.HUDHandlerExternal;
import mcp.mobius.waila.handlers.hud.HUDHandlerWaila;
import mcp.mobius.waila.handlers.tooltip.TooltipHandlerWaila;
import mcp.mobius.waila.handlers.nei.TooltipHandlerWaila;
import mcp.mobius.waila.overlay.WailaTickHandler;
import mcp.mobius.waila.server.ProxyServer;
import mcp.mobius.waila.utils.Constants;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import codechicken.lib.lang.LangUtil;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.forge.GuiContainerManager;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -49,17 +64,13 @@ public class ProxyClient extends ProxyServer {
@Override
public void registerHandlers(){
LangUtil.instance.loadLangDir("waila");
LangUtil.loadLangDir("waila");
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
TickRegistry.registerTickHandler(new WailaTickHandler(), Side.CLIENT);
TickRegistry.registerTickHandler(WailaTickHandler.instance(), Side.CLIENT);
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());
@@ -69,8 +80,18 @@ public class ProxyClient extends ProxyServer {
//API.addKeyBind(Constants.BIND_WIKI, "Display wiki", Keyboard.KEY_RSHIFT);
//API.addKeyBind(Constants.BIND_TECH, "Display techtree", Keyboard.KEY_RSHIFT);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBlocks(), Block.class);
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerBlocks(), Block.class);
ExternalModulesHandler.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerEntities(), Entity.class);
ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
ModuleRegistrar.instance().addConfig("General", "general.showhp");
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
}
@Override
@@ -115,7 +136,45 @@ public class ProxyClient extends ProxyServer {
BCPowerAPIModule.register();
/* ProjectRed API */
ProjectRedModule.register();
ProjectRedModule.register();
/* ExtraUtilities */
ExtraUtilitiesModule.register();
/* OpenBlocks */
OpenBlocksModule.register();
/* Railcraft */
RailcraftModule.register();
/* Steve's Carts */
StevesCartsModule.register();
/* Secret Rooms */
SecretRoomsModule.register();
/* Carpenter's Blocks */
CarpentersModule.register();
/* Pam's HarvestCraft */
HarvestcraftModule.register();
/* Magical crops */
MagicalCropsModule.register();
/* Statues */
StatuesModule.register();
/* Agriculture */
AgricultureModule.register();
if(Loader.isModLoaded("ForgeMultipart")){
HUDHandlerFMP.register();
DecoratorFMP.register();
}
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), Block.class);
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBlocks(), TileEntity.class);
}
@Override
@@ -1,81 +0,0 @@
package mcp.mobius.waila.client;
import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.handlers.DataAccessor;
import mcp.mobius.waila.overlay.RayTracing;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.ForgeSubscribe;
public class WailaClientEventHandler {
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void onRenderWorldLast(RenderWorldLastEvent event) {
if (RayTracing.raytracedTarget == null || RayTracing.raytracedStack == null) return;
double partialTicks = event.partialTicks;
DataAccessor accessor = DataAccessor.instance;
World world = Minecraft.getMinecraft().theWorld;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
EntityLivingBase viewEntity = Minecraft.getMinecraft().renderViewEntity;
if (world == null || player == null || viewEntity == null) return;
accessor.set(world, player, RayTracing.raytracedTarget, viewEntity, partialTicks);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (!ExternalModulesHandler.instance().hasBlockDecorator(blockID) && !ExternalModulesHandler.instance().hasBlockDecorator(block)) return;
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
if (ExternalModulesHandler.instance().hasBlockDecorator(blockID)){
for (IWailaBlockDecorator decorator : ExternalModulesHandler.instance().getBlockDecorators(blockID))
try{
GL11.glPushMatrix();
decorator.decorateBlock(RayTracing.raytracedStack, accessor, ConfigHandler.instance());
GL11.glPopMatrix();
} catch (Throwable e){
GL11.glPopMatrix();
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
}
}
if (ExternalModulesHandler.instance().hasBlockDecorator(block)){
for (IWailaBlockDecorator decorator : ExternalModulesHandler.instance().getBlockDecorators(block))
try{
GL11.glPushMatrix();
decorator.decorateBlock(RayTracing.raytracedStack, accessor, ConfigHandler.instance());
GL11.glPopMatrix();
} catch (Throwable e){
GL11.glPopMatrix();
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
}
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glPopAttrib();
}
}
+44 -13
View File
@@ -59,6 +59,45 @@ public class UIHelper {
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawBillboard(Vec3 pos, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame){
UIHelper.drawBillboard((float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, x1, y1, x2, y2, r, g, b, a, partialFrame);
}
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame){
EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float)partialFrame;
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float)partialFrame;
UIHelper.drawBillboard(posX, posY, posZ, offX, offY, offZ, playerViewX, playerViewY * -1.0F, 0.0F, x1, y1, x2, y2, r, g, b, a);
}
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, float rotX, float rotY, float rotZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a){
float f = 1.6F;
float f1 = 0.016666668F * f;
GL11.glPushMatrix();
GL11.glTranslatef(posX + offX, posY + offY, posZ + offZ);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(rotY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(rotX, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(rotZ, 0.0F, 0.0F, 1.0F);
//GL11.glScalef(-f1, -f1, f1);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glDisable(GL11.GL_TEXTURE_2D);
drawRectangle(x1, y1, 0, x2, y2, 0, r, g, b, a);
GL11.glPopMatrix();
}
public static void drawBillboardText(String text, Vec3 pos, float offX, float offY, float offZ, double partialFrame){
UIHelper.drawBillboardText(text, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, partialFrame);
}
@@ -104,17 +143,9 @@ public class UIHelper {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
byte b0 = 0;
Tessellator tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int j = fontrenderer.getStringWidth(text) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex((double)(-j - 1), (double)(-1 + b0), 0.0D);
tessellator.addVertex((double)(-j - 1), (double)(8 + b0), 0.0D);
tessellator.addVertex((double)(j + 1), (double)(8 + b0), 0.0D);
tessellator.addVertex((double)(j + 1), (double)(-1 + b0), 0.0D);
tessellator.draw();
drawRectangle((double)(-j - 1), (double)(8 + b0), 0.0, (double)(j + 1), (double)(-1 + b0), 0.0, 0, 0, 0, 64);
GL11.glEnable(GL11.GL_TEXTURE_2D);
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, b0, 553648127);
@@ -132,9 +163,9 @@ public class UIHelper {
public static void drawRectangle(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
Tessellator tessellator = Tessellator.instance;
tessellator.setColorRGBA(r, g, b, a);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(r, g, b, a);
tessellator.addVertex(x1, y2, z1);
tessellator.addVertex(x1, y1, z2);
tessellator.addVertex(x2, y1, z2);
@@ -147,9 +178,9 @@ public class UIHelper {
public static void drawRectangleEW(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
Tessellator tessellator = Tessellator.instance;
tessellator.setColorRGBA(r, g, b, a);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(r, g, b, a);
tessellator.addVertex(x1, y1, z1);
tessellator.addVertex(x1, y1, z2);
tessellator.addVertex(x2, y2, z2);
Loaded 100 of 162 files, more files were not shown because too many files have changed in this diff. Show more