Compare commits

..
28 Commits
Author SHA1 Message Date
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 005cc66115 Merge with dev 2013-06-29 15:22:48 +02:00
91 changed files with 2297 additions and 608 deletions

No files matched your search

+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>
Executable
+3
View File
@@ -0,0 +1,3 @@
#gource --file-idle-time 0 --camera-mode overview --title "Minecraft Coder Pack" -s 2 --hide-filenames --stop-at-end --disable-progress --output-ppm-stream - | ffmpeg -y -r 60 -b 6000K -f image2pipe -vcodec ppm -i - -vcodec libtheora out.ogg
gource --file-idle-time 0 --camera-mode overview --title "Waila" -s 2 --hide-filenames --stop-at-end --disable-progress --output-ppm-stream - | ffmpeg -y -f image2pipe -vcodec ppm -i - -vpre libx264-medium -vcodec libx264 out_small.mkv
+33
View File
@@ -0,0 +1,33 @@
package mcp.mobius.waila;
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";
}
@@ -7,7 +7,7 @@ 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.api.impl.ModuleRegistrar;
public class AppEngModule {
@@ -37,7 +37,7 @@ public class AppEngModule {
}
mod_Waila.log.log(Level.INFO, "AppEng mod found.");
ExternalModulesHandler.instance().addConfig("Applied Energetic", "appeng.monitorcontent");
ExternalModulesHandler.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
ModuleRegistrar.instance().addConfig("Applied Energetic", "appeng.monitorcontent");
ModuleRegistrar.instance().registerBodyProvider(new HUDAppEngMonitor(), TileStorageMonitor);
}
}
@@ -5,7 +5,7 @@ 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.api.impl.ModuleRegistrar;
import codechicken.lib.lang.LangUtil;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
@@ -33,8 +33,8 @@ public class BetterBarrelsModule {
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);
ModuleRegistrar.instance().addConfig("BetterBarrels", "bb.content");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBBContent(), TileEntityBarrel);
}
}
@@ -4,7 +4,7 @@ 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.api.impl.ModuleRegistrar;
import net.minecraftforge.common.ForgeDirection;
public class BCModule {
@@ -38,10 +38,10 @@ public class BCModule {
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);
}
}
@@ -6,7 +6,7 @@ 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.api.impl.ModuleRegistrar;
public class BCPowerAPIModule {
@@ -69,10 +69,10 @@ public class BCPowerAPIModule {
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);
}
@@ -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.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;
@@ -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));
*/
}
@@ -6,7 +6,7 @@ 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.api.impl.ModuleRegistrar;
public class EnderIOModule {
@@ -53,12 +53,12 @@ public class EnderIOModule {
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);
}
}
@@ -5,7 +5,7 @@ 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.api.impl.ModuleRegistrar;
public class EnderStorageModule {
@@ -50,7 +50,7 @@ public class EnderStorageModule {
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);
}
}
+3 -3
View File
@@ -5,7 +5,7 @@ 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.api.impl.ModuleRegistrar;
public class ETBModule {
@@ -76,8 +76,8 @@ public class ETBModule {
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);
}
}
@@ -3,7 +3,7 @@ package mcp.mobius.waila.addons.exu;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ExtraUtilitiesModule {
@@ -28,7 +28,7 @@ public class ExtraUtilitiesModule {
return;
}
ExternalModulesHandler.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
}
}
@@ -3,7 +3,7 @@ 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.api.impl.ModuleRegistrar;
public class GravestoneModule {
@@ -26,7 +26,7 @@ public class GravestoneModule {
}
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerGravestone(), BlockGraveStone);
}
}
@@ -5,10 +5,10 @@ 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;
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
@@ -5,10 +5,10 @@ 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;
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
@@ -5,10 +5,10 @@ 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;
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
@@ -6,10 +6,10 @@ 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;
public class HUDHandlerTETradeOMat implements IWailaDataProvider {
+21 -14
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.api.IWailaDataAccessor;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.tools.AccessHelper;
public class IC2Module {
@@ -111,18 +114,18 @@ public class IC2Module {
}
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);
}
/* Retuns the current stored energy if available in the nbt and config is true */
@@ -147,7 +150,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");
@@ -3,7 +3,7 @@ package mcp.mobius.waila.addons.openblocks;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class OpenBlocksModule {
@@ -26,8 +26,8 @@ public class OpenBlocksModule {
return;
}
ExternalModulesHandler.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
}
}
@@ -6,7 +6,7 @@ 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.api.impl.ModuleRegistrar;
public class ProjectRedModule {
@@ -41,11 +41,11 @@ public class ProjectRedModule {
return;
}
ExternalModulesHandler.instance().addConfigRemote("Project:Red", "pr.showio");
ExternalModulesHandler.instance().addConfigRemote("Project:Red", "pr.showdata");
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showio");
ModuleRegistrar.instance().addConfigRemote("Project:Red", "pr.showdata");
ExternalModulesHandler.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
ModuleRegistrar.instance().registerBlockDecorator(new HUDDecoratorRsGateLogic(), BlockMultipart);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerRsGateLogic(), BlockMultipart);
}
}
@@ -4,7 +4,7 @@ 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.api.impl.ModuleRegistrar;
public class RailcraftModule {
public static Class TileTankBase = null;
@@ -35,8 +35,8 @@ public class RailcraftModule {
return;
}
ExternalModulesHandler.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
}
}
@@ -4,7 +4,7 @@ import java.lang.reflect.Field;
import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class ThaumcraftModule {
@@ -47,10 +47,10 @@ public class ThaumcraftModule {
// 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().addConfig("Thaumcraft", "thaumcraft.storedvis");
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerLeaves(), BlockMagicalLeaves);
ModuleRegistrar.instance().registerStackProvider(new HUDHandlerPlants(), BlockCustomPlant);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCapacitor(), TileCrystalCapacitor);
}
@@ -6,7 +6,7 @@ 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.api.impl.ModuleRegistrar;
public class ThermalExpansionModule {
@@ -97,27 +97,27 @@ public class ThermalExpansionModule {
// return;
}
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
ExternalModulesHandler.instance().addConfigRemote("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 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 HUDHandlerTesseract(), TileTesseract);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitFluid(), BlockMultipart);
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitItem(), BlockMultipart);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitFluid(), BlockMultipart);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitItem(), BlockMultipart);
}
@@ -3,7 +3,7 @@ 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.api.impl.ModuleRegistrar;
public class TwilightForestModule {
@@ -30,8 +30,8 @@ public class TwilightForestModule {
}
ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFRoots);
ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFPlant);
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFRoots);
ModuleRegistrar.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFPlant);
//ExternalModulesHandler.instance().registerStackProvider(new TwilightForestGenericOverride(), BlockTFSapling);
}
@@ -10,10 +10,10 @@ 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 {
@@ -34,7 +34,6 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
static int netherwart = Block.netherStalk.blockID;
static int silverfish = Block.silverfish.blockID;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
int blockID = accessor.getBlockID();
@@ -52,6 +51,10 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return null;
}
}
if (blockID == redstone){
return new ItemStack(Item.redstone);
}
return null;
@@ -162,35 +165,36 @@ 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");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.spawntype");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.growthvalue");
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().addConfigRemote("VanillaMC", "vanilla.jukebox");
IWailaDataProvider provider = new HUDHandlerVanilla();
ExternalModulesHandler.instance().registerStackProvider(provider, silverfish);
ExternalModulesHandler.instance().registerHeadProvider(provider, mobSpawnerID);
ExternalModulesHandler.instance().registerBodyProvider(provider, cropsID);
ExternalModulesHandler.instance().registerBodyProvider(provider, melonStemID);
ExternalModulesHandler.instance().registerBodyProvider(provider, pumpkinStemID);
ExternalModulesHandler.instance().registerBodyProvider(provider, carrotID);
ExternalModulesHandler.instance().registerBodyProvider(provider, potatoID);
ExternalModulesHandler.instance().registerBodyProvider(provider, leverID);
ExternalModulesHandler.instance().registerBodyProvider(provider, repeaterIdle);
ExternalModulesHandler.instance().registerBodyProvider(provider, repeaterActv);
ExternalModulesHandler.instance().registerBodyProvider(provider, comparatorIdl);
ExternalModulesHandler.instance().registerBodyProvider(provider, comparatorAct);
ExternalModulesHandler.instance().registerHeadProvider(provider, redstone);
ExternalModulesHandler.instance().registerBodyProvider(provider, redstone);
ExternalModulesHandler.instance().registerBodyProvider(provider, jukebox);
ExternalModulesHandler.instance().registerBodyProvider(provider, cocoa);
ExternalModulesHandler.instance().registerBodyProvider(provider, netherwart);
ModuleRegistrar.instance().registerStackProvider(provider, silverfish);
ModuleRegistrar.instance().registerStackProvider(provider, redstone);
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawnerID);
ModuleRegistrar.instance().registerBodyProvider(provider, cropsID);
ModuleRegistrar.instance().registerBodyProvider(provider, melonStemID);
ModuleRegistrar.instance().registerBodyProvider(provider, pumpkinStemID);
ModuleRegistrar.instance().registerBodyProvider(provider, carrotID);
ModuleRegistrar.instance().registerBodyProvider(provider, potatoID);
ModuleRegistrar.instance().registerBodyProvider(provider, leverID);
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterIdle);
ModuleRegistrar.instance().registerBodyProvider(provider, repeaterActv);
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorIdl);
ModuleRegistrar.instance().registerBodyProvider(provider, comparatorAct);
ModuleRegistrar.instance().registerHeadProvider(provider, redstone);
ModuleRegistrar.instance().registerBodyProvider(provider, redstone);
ModuleRegistrar.instance().registerBodyProvider(provider, jukebox);
ModuleRegistrar.instance().registerBodyProvider(provider, cocoa);
ModuleRegistrar.instance().registerBodyProvider(provider, netherwart);
ExternalModulesHandler.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
ModuleRegistrar.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
//ExternalModulesHandler.instance().registerBlockDecorator(new HUDDecoratorVanilla(), repeaterIdle);
}
@@ -0,0 +1,19 @@
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;
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,19 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.util.Icon;
public interface IWailaEntityProvider {
/* This is the icon that will be added on the side of the tooltip. Returning null means no icon at all */
Icon getWailaIcon(IWailaEntityAccessor accessor, IWailaConfigHandler config);
/* 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);
}
+13
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,21 @@ 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 block);
public void registerBodyProvider (IWailaEntityProvider dataProvider, Class block);
public void registerTailProvider (IWailaEntityProvider dataProvider, Class block);
/* The block decorators */
@Deprecated
public void registerBlockDecorator (IWailaBlockDecorator decorator, int blockID);
public void registerBlockDecorator (IWailaBlockDecorator decorator, Class block);
public void registerDocTextFile (String filename);
public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
/* Entity registration methods */
}
@@ -1,4 +1,4 @@
package mcp.mobius.waila.addons;
package mcp.mobius.waila.api.impl;
import java.util.ArrayList;
import java.util.HashMap;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.addons;
package mcp.mobius.waila.api.impl;
import java.util.HashMap;
@@ -1,7 +1,6 @@
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.nbt.NBTBase;
@@ -69,11 +68,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;
@@ -109,11 +125,6 @@ public class DataAccessor implements IWailaDataAccessor {
return 0;
}
@Override
public int getBlockID() {
return this.blockID;
}
private boolean isTagCorrect(NBTTagCompound tag){
if (tag == null){
this.timeLastUpdate = System.currentTimeMillis() - 250;
@@ -144,22 +155,7 @@ 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);
}
}
@@ -0,0 +1,139 @@
package mcp.mobius.waila.api.impl;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.network.Packet0x01TERequest;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.ItemInfo.Layout;
import cpw.mods.fml.common.network.PacketDispatcher;
public class MetaDataProvider{
private ArrayList<IWailaDataProvider> headProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> bodyProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> tailProviders = new ArrayList<IWailaDataProvider>();
private Class prevBlock = null;
private Class prevTile = null;
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor 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> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor accessor, List<String> currenttip, Layout layout) {
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent &&
((System.currentTimeMillis() - accessor.timeLastUpdate >= 250))){
accessor.timeLastUpdate = System.currentTimeMillis();
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
}
/* 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);
}
}
headProviders.clear();
bodyProviders.clear();
tailProviders.clear();
/* Lookup by class (for blocks)*/
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(block))
headProviders.addAll(ModuleRegistrar.instance().getHeadProviders(block));
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(block))
bodyProviders.addAll(ModuleRegistrar.instance().getBodyProviders(block));
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(block))
tailProviders.addAll(ModuleRegistrar.instance().getTailProviders(block));
/* Lookup by class (for tileentities)*/
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(accessor.getTileEntity()))
headProviders.addAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(accessor.getTileEntity()))
bodyProviders.addAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(accessor.getTileEntity()))
tailProviders.addAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
/* Apply all collected providers */
if (layout == Layout.HEADER)
for (IWailaDataProvider dataProvider : headProviders)
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 : bodyProviders)
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 : tailProviders)
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
return currenttip;
}
}
@@ -1,4 +1,4 @@
package mcp.mobius.waila.addons;
package mcp.mobius.waila.api.impl;
import java.io.BufferedReader;
import java.io.IOException;
@@ -13,44 +13,43 @@ 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.IWailaEntityProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.handlers.hud.HUDHandlerExternal;
public class ExternalModulesHandler implements IWailaRegistrar {
public class ModuleRegistrar 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>>();
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<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<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() {
private ModuleRegistrar() {
instance = this;
}
public static ExternalModulesHandler instance(){
if (ExternalModulesHandler.instance == null)
ExternalModulesHandler.instance = new ExternalModulesHandler();
return ExternalModulesHandler.instance;
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));
@@ -71,62 +70,74 @@ public class ExternalModulesHandler implements IWailaRegistrar {
ConfigHandler.instance().addConfigServer(modname, key, LangUtil.translateG("option." + key));
}
/* REGISTRATION METHODS */
@Override
@Deprecated
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);
this.registerHeadProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerHeadProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.headBlockProviders.containsKey(block))
this.headBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
ArrayList<IWailaDataProvider> providers = this.headBlockProviders.get(block);
if (providers.contains(dataProvider)) return;
this.headBlockProviders.get(block).add(dataProvider);
}
@Override
@Deprecated
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);
this.registerBodyProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerBodyProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.bodyBlockProviders.containsKey(block))
this.bodyBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
ArrayList<IWailaDataProvider> providers = this.bodyBlockProviders.get(block);
if (providers.contains(dataProvider)) return;
this.bodyBlockProviders.get(block).add(dataProvider);
}
@Override
@Deprecated
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);
this.registerTailProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@Override
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.tailBlockProviders.containsKey(block))
this.tailBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
ArrayList<IWailaDataProvider> providers = this.tailBlockProviders.get(block);
if (providers.contains(dataProvider)) return;
this.tailBlockProviders.get(block).add(dataProvider);
}
@Override
@Deprecated
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());
this.registerStackProvider(dataProvider, Block.blocksList[blockID].getClass());
}
@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);
}
if (!this.stackBlockProviders.containsKey(block))
this.stackBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
ArrayList<IWailaDataProvider> providers = this.stackBlockProviders.get(block);
if (providers.contains(dataProvider)) return;
this.stackBlockProviders.get(block).add(dataProvider);
}
@Override
@@ -137,10 +148,9 @@ public class ExternalModulesHandler implements IWailaRegistrar {
}
@Override
@Deprecated
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);
this.registerBlockDecorator(decorator, Block.blocksList[blockID].getClass());
}
@Override
@@ -149,21 +159,44 @@ public class ExternalModulesHandler implements IWailaRegistrar {
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);
@Override
public void registerHeadProvider(IWailaEntityProvider dataProvider, Class entity) {
if (!this.headEntityProviders.containsKey(entity))
this.headEntityProviders.put(entity, new ArrayList<IWailaEntityProvider>());
ArrayList<IWailaEntityProvider> providers = this.headEntityProviders.get(entity);
if (providers.contains(dataProvider)) return;
this.headEntityProviders.get(entity).add(dataProvider);
}
public ArrayList<IWailaDataProvider> getTailProviders(int blockID) {
return this.tailProviders.get(blockID);
}
@Override
public void registerBodyProvider(IWailaEntityProvider dataProvider, Class entity) {
if (!this.bodyEntityProviders.containsKey(entity))
this.bodyEntityProviders.put(entity, new ArrayList<IWailaEntityProvider>());
ArrayList<IWailaEntityProvider> providers = this.bodyEntityProviders.get(entity);
if (providers.contains(dataProvider)) return;
this.bodyEntityProviders.get(entity).add(dataProvider);
}
@Override
public void registerTailProvider(IWailaEntityProvider dataProvider, Class entity) {
if (!this.tailEntityProviders.containsKey(entity))
this.tailEntityProviders.put(entity, new ArrayList<IWailaEntityProvider>());
ArrayList<IWailaEntityProvider> providers = this.tailEntityProviders.get(entity);
if (providers.contains(dataProvider)) return;
this.tailEntityProviders.get(entity).add(dataProvider);
}
/* PROVIDER GETTERS */
public ArrayList<IWailaDataProvider> getHeadProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.headBlockProviders.keySet())
@@ -184,17 +217,22 @@ public class ExternalModulesHandler implements IWailaRegistrar {
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.bodyBlockProviders.keySet())
for (Class clazz : this.tailBlockProviders.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.bodyBlockProviders.get(clazz));
returnList.addAll(this.tailBlockProviders.get(clazz));
return returnList;
}
public ArrayList<IWailaDataProvider> getStackProviders(int blockID) {
return this.stackProviders.get(blockID);
}
public ArrayList<IWailaDataProvider> getStackProviders(Object block) {
ArrayList<IWailaDataProvider> returnList = new ArrayList<IWailaDataProvider>();
for (Class clazz : this.stackBlockProviders.keySet())
if (clazz.isInstance(block))
returnList.addAll(this.stackBlockProviders.get(clazz));
return returnList;
}
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
ArrayList<IWailaSummaryProvider> returnList = new ArrayList<IWailaSummaryProvider>();
for (Class clazz : this.summaryProviders.keySet())
@@ -204,10 +242,6 @@ public class ExternalModulesHandler implements IWailaRegistrar {
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())
@@ -217,22 +251,40 @@ public class ExternalModulesHandler implements IWailaRegistrar {
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 ArrayList<IWailaEntityProvider> getHeadEntityProviders(Object entity) {
ArrayList<IWailaEntityProvider> returnList = new ArrayList<IWailaEntityProvider>();
for (Class clazz : this.headEntityProviders.keySet())
if (clazz.isInstance(entity))
returnList.addAll(this.headEntityProviders.get(clazz));
return returnList;
}
public boolean hasTailProviders(int blockID){
return this.tailProviders.containsKey(blockID);
public ArrayList<IWailaEntityProvider> getBodyEntityProviders(Object entity) {
ArrayList<IWailaEntityProvider> returnList = new ArrayList<IWailaEntityProvider>();
for (Class clazz : this.bodyEntityProviders.keySet())
if (clazz.isInstance(entity))
returnList.addAll(this.bodyEntityProviders.get(clazz));
return returnList;
}
public boolean hasStackProviders(int blockID){
return this.stackProviders.containsKey(blockID);
public ArrayList<IWailaEntityProvider> getTailEntityProviders(Object entity) {
ArrayList<IWailaEntityProvider> returnList = new ArrayList<IWailaEntityProvider>();
for (Class clazz : this.tailEntityProviders.keySet())
if (clazz.isInstance(entity))
returnList.addAll(this.tailEntityProviders.get(clazz));
return returnList;
}
/* HAS METHODS */
public boolean hasStackProviders(Object block){
for (Class clazz : this.stackBlockProviders.keySet())
if (clazz.isInstance(block))
return true;
return false;
}
public boolean hasHeadProviders(Object block){
@@ -260,10 +312,6 @@ public class ExternalModulesHandler implements IWailaRegistrar {
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))
@@ -271,6 +319,27 @@ public class ExternalModulesHandler implements IWailaRegistrar {
return false;
}
public boolean hasHeadEntityProviders(Object entity){
for (Class clazz : this.headEntityProviders.keySet())
if (clazz.isInstance(entity))
return true;
return false;
}
public boolean hasBodyEntityProviders(Object entity){
for (Class clazz : this.bodyEntityProviders.keySet())
if (clazz.isInstance(entity))
return true;
return false;
}
public boolean hasTailEntityProviders(Object entity){
for (Class clazz : this.tailEntityProviders.keySet())
if (clazz.isInstance(entity))
return true;
return false;
}
/* ----------------- */
@Override
public void registerDocTextFile(String filename) {
@@ -4,7 +4,7 @@ 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;
@@ -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){
+17 -11
View File
@@ -1,7 +1,7 @@
package mcp.mobius.waila.client;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.appeng.AppEngModule;
import mcp.mobius.waila.addons.buildcraft.BCModule;
import mcp.mobius.waila.addons.buildcraft.BCPowerAPIModule;
@@ -18,14 +18,16 @@ 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.impl.MetaDataProvider;
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.HUDHandlerWaila;
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 net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
@@ -56,13 +58,15 @@ public class ProxyClient extends ProxyServer {
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);
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.HEADER);
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.BODY);
//API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.FOOTER);
//API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.FOOTER);
//API.registerHighlightHandler(new HUDHandlerWaila(), ItemInfo.Layout.HEADER);
KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
@@ -72,8 +76,10 @@ 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);
ExternalModulesHandler.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerWaila(), Block.class);
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerWaila(), Block.class);
ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
}
@Override
@@ -7,10 +7,10 @@ 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.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.DataAccessor;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.overlay.RayTracing;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -26,7 +26,7 @@ public class WailaClientEventHandler {
@ForgeSubscribe
@SideOnly(Side.CLIENT)
public void onRenderWorldLast(RenderWorldLastEvent event) {
if (RayTracing.raytracedTarget == null || RayTracing.raytracedStack == null) return;
if (RayTracing.instance().getTarget() == null || RayTracing.instance().getTargetStack() == null) return;
double partialTicks = event.partialTicks;
@@ -37,36 +37,24 @@ public class WailaClientEventHandler {
if (world == null || player == null || viewEntity == null) return;
accessor.set(world, player, RayTracing.raytracedTarget, viewEntity, partialTicks);
accessor.set(world, player, RayTracing.instance().getTarget(), viewEntity, partialTicks);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (!ExternalModulesHandler.instance().hasBlockDecorator(blockID) && !ExternalModulesHandler.instance().hasBlockDecorator(block)) return;
if (!ModuleRegistrar.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))
if (ModuleRegistrar.instance().hasBlockDecorator(block)){
for (IWailaBlockDecorator decorator : ModuleRegistrar.instance().getBlockDecorators(block))
try{
GL11.glPushMatrix();
decorator.decorateBlock(RayTracing.raytracedStack, accessor, ConfigHandler.instance());
decorator.decorateBlock(RayTracing.instance().getTargetStack(), accessor, ConfigHandler.instance());
GL11.glPopMatrix();
} catch (Throwable e){
GL11.glPopMatrix();
@@ -4,7 +4,7 @@ import org.lwjgl.util.Point;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
@@ -1,6 +1,6 @@
package mcp.mobius.waila.gui.screens.config;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
@@ -8,7 +8,6 @@ import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
import net.minecraft.client.gui.GuiScreen;
public class ScreenModuleChoice extends ScreenBase {
@@ -1,6 +1,6 @@
package mcp.mobius.waila.gui.screens.config;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
@@ -11,8 +11,6 @@ import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfigRemote;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui_old.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui_old.widget_old.ButtonConfigRemote;
import net.minecraft.client.gui.GuiScreen;
public class ScreenModuleConfig extends ScreenBase {
@@ -57,7 +57,7 @@ public class FontLoader{
Font font;
TrueTypeFont out = null;
try {
font = Font.createFont(type, Minecraft.getMinecraft().func_110442_L().func_110536_a(res).func_110527_b());
font = Font.createFont(type, Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream());
font = font.deriveFont(defSize);
out = new TrueTypeFont(font, antialias);
} catch (Exception e) {
@@ -22,7 +22,7 @@ public class PictureDisplay extends WidgetBase {
this.saveGLState();
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
this.texManager.bindTexture(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
@@ -27,7 +27,7 @@ public class PictureSwitch extends WidgetBase {
ResourceLocation texture = mouseOver ? this.texture2 : this.texture1;
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
this.texManager.bindTexture(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
@@ -42,7 +42,7 @@ public abstract class ButtonBase extends WidgetBase {
if (this.mouseOver)
texOffset = 1;
this.mc.func_110434_K().func_110577_a(widgetsTexture);
this.mc.getTextureManager().bindTexture(widgetsTexture);
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
this.loadGLState();
@@ -44,7 +44,7 @@ public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
else{
this.saveGLState();
int texOffset = -1;
this.mc.func_110434_K().func_110577_a(widgetsTexture);
this.mc.getTextureManager().bindTexture(widgetsTexture);
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
this.loadGLState();
}
@@ -58,7 +58,7 @@ public class PictureMovableRC extends WidgetBase {
this.saveGLState();
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
this.texManager.bindTexture(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
@@ -4,8 +4,8 @@ import java.util.LinkedHashMap;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.gui_old.GuiIngameWiki;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.handlers.SummaryProvider;
@@ -19,26 +19,26 @@ import codechicken.nei.forge.IContainerInputHandler;
public class HandlerWiki implements IContainerInputHandler {
public String getDescriptionString(String modid, String name, String meta){
if (ExternalModulesHandler.instance().hasDocTextModID(modid)){
if (ModuleRegistrar.instance().hasDocTextModID(modid)){
//Do we have an direct entry for this item ?
if (ExternalModulesHandler.instance().hasDocTextItem(modid, name)){
if (ModuleRegistrar.instance().hasDocTextItem(modid, name)){
//We check if we have an exact match, a wildcard match and finally, an meta 0 match
if (ExternalModulesHandler.instance().hasDocTextMeta(modid, name, meta)){
return ExternalModulesHandler.instance().getDocText(modid, name, meta);
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, name, "*")){
return ExternalModulesHandler.instance().getDocText(modid, name, "*");
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, name, "0")){
return ExternalModulesHandler.instance().getDocText(modid, name, "0");
if (ModuleRegistrar.instance().hasDocTextMeta(modid, name, meta)){
return ModuleRegistrar.instance().getDocText(modid, name, meta);
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "*")){
return ModuleRegistrar.instance().getDocText(modid, name, "*");
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "0")){
return ModuleRegistrar.instance().getDocText(modid, name, "0");
}
} else if (ExternalModulesHandler.instance().getDoxTextWildcardMatch(modid, name) != null) {
String key = ExternalModulesHandler.instance().getDoxTextWildcardMatch(modid, name);
if (ExternalModulesHandler.instance().hasDocTextMeta(modid, key, meta)){
return ExternalModulesHandler.instance().getDocText(modid, key, meta);
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, key, "*")){
return ExternalModulesHandler.instance().getDocText(modid, key, "*");
} else if (ExternalModulesHandler.instance().hasDocTextSpecificMeta(modid, key, "0")){
return ExternalModulesHandler.instance().getDocText(modid, key, "0");
} else if (ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name) != null) {
String key = ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name);
if (ModuleRegistrar.instance().hasDocTextMeta(modid, key, meta)){
return ModuleRegistrar.instance().getDocText(modid, key, meta);
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "*")){
return ModuleRegistrar.instance().getDocText(modid, key, "*");
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "0")){
return ModuleRegistrar.instance().getDocText(modid, key, "0");
}
}
@@ -0,0 +1,72 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import static mcp.mobius.waila.SpecialChars.*;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.tools.ModIdentification;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import codechicken.nei.forge.GuiContainerManager;
public class HUDHandlerWaila 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) {
String name = null;
try
{
String s = GuiContainerManager.itemDisplayNameShort(itemStack);
if(s != null && !s.endsWith("Unnamed"))
name = s;
if(name != null)
currenttip.add(name);
}
catch(Exception e)
{
}
if(itemStack.getItem() == Item.redstone)
{
int md = accessor.getMetadata();
String s = ""+md;
if(s.length() < 2)
s=" "+s;
currenttip.set(currenttip.size()-1, name+" "+s);
}
if (currenttip.size() == 0)
currenttip.add("< Unnamed >");
else{
if (config.getConfig(Constants.CFG_WAILA_METADATA)){
name = currenttip.get(0);
currenttip.set(0, name + String.format(" %s:%s", accessor.getBlockID(), accessor.getMetadata()));
}
}
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) {
String modName = ModIdentification.nameFromStack(itemStack);
if (modName != null && !modName.equals(""))
currenttip.add(BLUE + ITALIC + modName);
return currenttip;
}
}
@@ -3,9 +3,9 @@ package mcp.mobius.waila.handlers;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
public class SummaryProvider {
@@ -24,7 +24,7 @@ public class SummaryProvider {
public LinkedHashMap<String, String> getSummary(ItemStack stack, IWailaConfigHandler config) {
LinkedHashMap<String, String> currentSummary = new LinkedHashMap<String, String>();
for (IWailaSummaryProvider provider : ExternalModulesHandler.instance().getSummaryProvider(stack.getItem())){
for (IWailaSummaryProvider provider : ModuleRegistrar.instance().getSummaryProvider(stack.getItem())){
currentSummary = provider.getSummary(stack, currentSummary, config);
}
return currentSummary;
@@ -1,172 +0,0 @@
package mcp.mobius.waila.handlers.hud;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.handlers.DataAccessor;
import mcp.mobius.waila.network.Packet0x01TERequest;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.IHighlightHandler;
import codechicken.nei.api.ItemInfo.Layout;
import cpw.mods.fml.common.network.PacketDispatcher;
public class HUDHandlerExternal implements IHighlightHandler {
private ArrayList<IWailaDataProvider> headProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> bodyProviders = new ArrayList<IWailaDataProvider>();
private ArrayList<IWailaDataProvider> tailProviders = new ArrayList<IWailaDataProvider>();
private MovingObjectPosition prevMOP = null;
private int prevWorldID = -999;
@Override
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
DataAccessor accessor = DataAccessor.instance;
accessor.set(world, player, mop);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (IWailaBlock.class.isInstance(block)){
try{
return ((IWailaBlock)block).getWailaStack(accessor, ConfigHandler.instance());
}catch (Throwable e){
WailaExceptionHandler.handleErr(e, block.getClass().toString(), null);
}
}
if(ExternalModulesHandler.instance().hasStackProviders(blockID)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
try{
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
if (retval != null)
return retval;
}catch (Throwable e){
WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), null);
}
}
}
return null;
}
@Override
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
if (this.prevMOP == null)
this.prevMOP = mop;
DataAccessor accessor = DataAccessor.instance;
accessor.set(world, player, mop);
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent &&
((System.currentTimeMillis() - accessor.timeLastUpdate >= 250) || this.areMopDifferent(player, mop))){
accessor.timeLastUpdate = System.currentTimeMillis();
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
}
/* 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);
}
}
if (this.areMopDifferent(player, mop)){
headProviders.clear();
bodyProviders.clear();
tailProviders.clear();
this.prevMOP = mop;
this.prevWorldID = player.dimension;
/* Lookup by block ID */
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID))
headProviders.addAll(ExternalModulesHandler.instance().getHeadProviders(blockID));
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID))
bodyProviders.addAll(ExternalModulesHandler.instance().getBodyProviders(blockID));
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(blockID))
tailProviders.addAll(ExternalModulesHandler.instance().getTailProviders(blockID));
/* Lookup by class (for blocks)*/
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(block))
headProviders.addAll(ExternalModulesHandler.instance().getHeadProviders(block));
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(block))
bodyProviders.addAll(ExternalModulesHandler.instance().getBodyProviders(block));
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(block))
tailProviders.addAll(ExternalModulesHandler.instance().getTailProviders(block));
/* Lookup by class (for tileentities)*/
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(accessor.getTileEntity()))
headProviders.addAll(ExternalModulesHandler.instance().getHeadProviders(accessor.getTileEntity()));
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(accessor.getTileEntity()))
bodyProviders.addAll(ExternalModulesHandler.instance().getBodyProviders(accessor.getTileEntity()));
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(accessor.getTileEntity()))
tailProviders.addAll(ExternalModulesHandler.instance().getTailProviders(accessor.getTileEntity()));
}
/* Apply all collected providers */
for (IWailaDataProvider dataProvider : headProviders)
try{
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
for (IWailaDataProvider dataProvider : bodyProviders)
try{
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
for (IWailaDataProvider dataProvider : tailProviders)
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
return currenttip;
}
public boolean areMopDifferent(EntityPlayer player, MovingObjectPosition mop){
return this.prevMOP.blockX != mop.blockX || this.prevMOP.blockY != mop.blockY || this.prevMOP.blockZ != mop.blockZ || prevWorldID != player.dimension;
}
}
@@ -1,41 +0,0 @@
package mcp.mobius.waila.handlers.hud;
import java.util.List;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.tools.ModIdentification;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.ItemInfo.Layout;
import codechicken.nei.api.IHighlightHandler;
public class HUDHandlerWaila implements IHighlightHandler {
@Override
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
return null;
}
@Override
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
if (layout == Layout.FOOTER){
String modName = ModIdentification.nameFromStack(itemStack);
if (modName != null && !modName.equals(""))
currenttip.add("\u00A79\u00A7o" + modName);
} else if (layout == Layout.HEADER && ConfigHandler.instance().getConfig(Constants.CFG_WAILA_METADATA, false)){
if (currenttip.size() == 0)
currenttip.add("< Unnamed >");
else{
String name = currenttip.get(0);
currenttip.set(0, name + String.format(" %s:%s", world.getBlockId(mop.blockX, mop.blockY, mop.blockZ), world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ)));
}
}
return currenttip;
}
}
@@ -1,10 +1,7 @@
package mcp.mobius.waila.handlers.nei;
import java.util.Map;
import java.util.logging.Level;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
import mcp.mobius.waila.tools.ModIdentification;
import net.minecraft.client.Minecraft;
@@ -1,8 +1,7 @@
package mcp.mobius.waila.handlers.tooltip;
package mcp.mobius.waila.handlers.nei;
import java.util.List;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.tools.ModIdentification;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
+14 -6
View File
@@ -10,9 +10,10 @@ 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.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.MetaDataProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.client.WailaClientEventHandler;
import mcp.mobius.waila.network.WailaConnectionHandler;
import mcp.mobius.waila.network.WailaPacketHandler;
@@ -26,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import codechicken.core.CommonUtils;
import codechicken.lib.lang.LangUtil;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
@@ -53,7 +55,7 @@ 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.4", dependencies="required-after:NotEnoughItems")
@Mod(modid="Waila", name="Waila", version="1.4.5a", dependencies="required-after:NotEnoughItems")
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
@@ -126,7 +128,7 @@ public class mod_Waila {
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_KEYBIND)){
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 +163,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()){
@@ -196,7 +204,7 @@ public class mod_Waila {
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));
@@ -48,8 +48,13 @@ public class Packet0x02TENBTData {
else
{
byte[] abyte = CompressedStreamTools.compress(par0NBTTagCompound);
par1DataOutputStream.writeShort((short)abyte.length);
par1DataOutputStream.write(abyte);
if (abyte.length > 32000)
par1DataOutputStream.writeShort(-1);
else{
par1DataOutputStream.writeShort((short)abyte.length);
par1DataOutputStream.write(abyte);
}
}
}
@@ -6,7 +6,7 @@ import java.io.IOException;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.handlers.DataAccessor;
import mcp.mobius.waila.api.impl.DataAccessor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
+8 -27
View File
@@ -1,14 +1,11 @@
package mcp.mobius.waila.overlay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.forge.GuiContainerManager;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.EntityRegistry;
@@ -19,14 +16,13 @@ import java.awt.Point;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.world.World;
import static codechicken.core.gui.GuiDraw.*;
public class OverlayRenderer {
@@ -40,35 +36,20 @@ public class OverlayRenderer {
Minecraft mc = Minecraft.getMinecraft();
if(!(mc.currentScreen == null &&
mc.theWorld != null &&
mc.isGuiEnabled() &&
!mc.gameSettings.keyBindPlayerList.pressed &&
ConfigHandler.instance().getConfig(Constants.CFG_WAILA_SHOW, true) &&
mc.objectMouseOver != null &&
RayTracing.raytracedTarget != null))
RayTracing.instance().getTarget() != null))
return;
if (RayTracing.raytracedTarget.typeOfHit == EnumMovingObjectType.TILE)
if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.TILE && RayTracing.instance().getTargetStack() != null)
{
World world = mc.theWorld;
ArrayList<ItemStack> items = RayTracing.getIdentifierItems();
if (items.isEmpty())
return;
Collections.sort(items, new Comparator<ItemStack>()
{
@Override
public int compare(ItemStack stack0, ItemStack stack1)
{
return stack1.getItemDamage() - stack0.getItemDamage();
}
});
RayTracing.raytracedStack = items.get(0);
renderOverlay(RayTracing.raytracedStack, ItemInfo.getText(RayTracing.raytracedStack, world, mc.thePlayer, RayTracing.raytracedTarget), getPositioning());
renderOverlay(RayTracing.instance().getTargetStack(), WailaTickHandler.instance().currenttip, getPositioning());
}
if (RayTracing.raytracedTarget.typeOfHit == EnumMovingObjectType.ENTITY)
if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.ENTITY)
{
Entity ent = mc.objectMouseOver.entityHit;
Entity ent = RayTracing.instance().getTarget().entityHit;
String modName = getEntityMod(ent);
List<String> textData = new ArrayList<String>();
@@ -109,7 +90,7 @@ public class OverlayRenderer {
public static void renderOverlay(ItemStack stack, List<String> textData, Point pos)
{
TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
//TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
GL11.glPushMatrix();
+91 -56
View File
@@ -1,18 +1,20 @@
package mcp.mobius.waila.overlay;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import codechicken.nei.api.IHighlightHandler;
import codechicken.nei.api.ItemInfo;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.DataAccessor;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@@ -20,67 +22,95 @@ import net.minecraftforge.common.IShearable;
public class RayTracing {
public static MovingObjectPosition raytracedTarget = null;
public static ItemStack raytracedStack = null;
public static void raytrace(){
if (Minecraft.getMinecraft().objectMouseOver == null){
raytracedTarget = null;
return;
}
if(Minecraft.getMinecraft().objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY)
raytracedTarget = Minecraft.getMinecraft().objectMouseOver;
else
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID))
raytracedTarget = getLiquidRaytrace();
else
raytracedTarget = Minecraft.getMinecraft().objectMouseOver;
private static RayTracing _instance;
private RayTracing(){}
public static RayTracing instance(){
if(_instance == null)
_instance = new RayTracing();
return _instance;
}
public static MovingObjectPosition getLiquidRaytrace()
private MovingObjectPosition target = null;
private ItemStack targetStack = null;
private Minecraft mc = Minecraft.getMinecraft();
public void fire(){
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == EnumMovingObjectType.ENTITY){
this.target = mc.objectMouseOver;
this.targetStack = null;
return;
}
EntityLivingBase viewpoint = mc.renderViewEntity;
if (viewpoint == null) return;
this.target = this.rayTrace(viewpoint, 4.0, 0);
if (this.target == null) return;
}
public MovingObjectPosition getTarget(){
return this.target;
}
public ItemStack getTargetStack(){
if (this.target.typeOfHit == EnumMovingObjectType.TILE)
this.targetStack = this.getIdentifierStack();
else
this.targetStack = null;
return this.targetStack;
}
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
World world = Minecraft.getMinecraft().theWorld;
if ((player == null) || (world == null)) return null;
float f = 1.0F;
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
double d1 = player.prevPosY + (player.posY - player.prevPosY) * f + 1.62D - player.yOffset;
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = 5.0D;
Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
return world.clip(vec3, vec31, true);
Vec3 vec3 = entity.getPosition(par3);
Vec3 vec31 = entity.getLook(par3);
Vec3 vec32 = vec3.addVector(vec31.xCoord * par1, vec31.yCoord * par1, vec31.zCoord * par1);
}
public static ArrayList<ItemStack> getIdentifierItems()
if (ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID))
return entity.worldObj.clip(vec3, vec32, true);
else
return entity.worldObj.clip(vec3, vec32, false);
}
public ItemStack getIdentifierStack(){
World world = mc.theWorld;
ArrayList<ItemStack> items = this.getIdentifierItems();
if (items.isEmpty())
return null;
Collections.sort(items, new Comparator<ItemStack>()
{
@Override
public int compare(ItemStack stack0, ItemStack stack1)
{
return stack1.getItemDamage() - stack0.getItemDamage();
}
});
return items.get(0);
}
public ArrayList<ItemStack> getIdentifierItems()
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
if (raytracedTarget == null)
if (this.target == null)
return items;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
World world = Minecraft.getMinecraft().theWorld;
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
int x = raytracedTarget.blockX;
int y = raytracedTarget.blockY;
int z = raytracedTarget.blockZ;
Block mouseoverBlock = Block.blocksList[world.getBlockId(x, y, z)];
int x = this.target.blockX;
int y = this.target.blockY;
int z = this.target.blockZ;
int blockID = world.getBlockId(x, y, z);
Block mouseoverBlock = Block.blocksList[blockID];
if (mouseoverBlock == null) return items;
// TODO This block need to be redone to handle Waila API
/*
ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
if(ItemInfo.highlightIdentifiers.get(0) != null)
handlers.addAll(ItemInfo.highlightIdentifiers.get(0));
@@ -89,10 +119,14 @@ public class RayTracing {
for(IHighlightHandler ident : handlers)
{
ItemStack item = ident.identifyHighlight(world, player, raytracedTarget);
ItemStack item = ident.identifyHighlight(world, player, this.target);
if(item != null)
items.add(item);
}
*/
if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock))
items.add(ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessor.instance, ConfigHandler.instance()));
if(items.size() > 0)
return items;
@@ -109,7 +143,7 @@ public class RayTracing {
return items;
try{
ItemStack pick = mouseoverBlock.getPickBlock(raytracedTarget, world, x, y, z);
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, x, y, z);
if(pick != null)
items.add(pick);
}catch(Exception e){}
@@ -139,5 +173,6 @@ public class RayTracing {
items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
return items;
}
}
}
+52 -10
View File
@@ -1,8 +1,21 @@
package mcp.mobius.waila.overlay;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import codechicken.lib.lang.LangUtil;
import mcp.mobius.waila.api.impl.DataAccessor;
import mcp.mobius.waila.api.impl.MetaDataProvider;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.ItemInfo.Layout;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
@@ -11,6 +24,19 @@ public class WailaTickHandler implements ITickHandler {
//public static LangUtil lang = LangUtil.loadLangDir("waila");
private int ticks = 0;
public ItemStack identifiedHighlight = new ItemStack(Block.dirt);
public List<String> currenttip = new ArrayList<String>();
public MetaDataProvider handler = new MetaDataProvider();
private Minecraft mc = Minecraft.getMinecraft();
private static WailaTickHandler _instance;
private WailaTickHandler(){}
public static WailaTickHandler instance(){
if(_instance == null)
_instance = new WailaTickHandler();
return _instance;
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
@@ -19,22 +45,38 @@ public class WailaTickHandler implements ITickHandler {
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
if(type.contains(TickType.RENDER)){
RayTracing.raytrace();
OverlayRenderer.renderOverlay();
OverlayRenderer.renderOverlay();
}
//if (ticks == 100){
// ticks = 0;
// mod_Waila.updateColors();
//}
//ticks++;
if(type.contains(TickType.CLIENT)){
World world = mc.theWorld;
EntityPlayer player = mc.thePlayer;
if (world != null && player != null){
RayTracing.instance().fire();
MovingObjectPosition target = RayTracing.instance().getTarget();
if (target != null && target.typeOfHit == EnumMovingObjectType.TILE){
DataAccessor accessor = DataAccessor.instance;
accessor.set(world, player, target);
ItemStack targetStack = RayTracing.instance().getTargetStack();
if (targetStack != null){
this.currenttip.clear();
//this.identifiedHighlight = handler.identifyHighlight(world, player, target);
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.HEADER);
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.BODY);
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.FOOTER);
}
}
}
}
}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.RENDER);
return EnumSet.of(TickType.RENDER, TickType.CLIENT);
}
@Override
+3 -3
View File
@@ -21,7 +21,7 @@ public class AccessHelper {
Class class_ = Class.forName(classname);
Field field_ = class_.getDeclaredField(fieldname);
field_.setAccessible(true);
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
return field_;
}
catch (NoSuchFieldException e) {
@@ -45,7 +45,7 @@ public class AccessHelper {
Field field_ = class_.getDeclaredField(fieldname);
field_.setAccessible(true);
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
return field_.get(instance);
}
catch (NoSuchFieldException e) {
@@ -74,7 +74,7 @@ public class AccessHelper {
Field field_ = class_.getDeclaredField(fieldname);
field_.setAccessible(true);
mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
//mod_Waila.log.fine(String.format("++ Found field %s %s\n", classname, fieldname));
return field_.get(instance);
}