mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 17:44:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
198d0c7079 | ||
|
|
03f4bed4fe | ||
|
|
1bfcc07e1f | ||
|
|
ef9a1bedfc | ||
|
|
4121e689fd | ||
|
|
0b1911b711 | ||
|
|
ac73b6b537 | ||
|
|
4188ec37b2 | ||
|
|
6cefb32520 | ||
|
|
7ba3a2b7e8 | ||
|
|
3d7c3f0726 | ||
|
|
74cdb0fa1e | ||
|
|
dc07947ccf | ||
|
|
3b1f35e7a8 | ||
|
|
dbd06b2552 | ||
|
|
9c121fb5c8 | ||
|
|
28d19ef015 | ||
|
|
3843fd9815 | ||
|
|
2777e0ea80 | ||
|
|
e62f26a0ee | ||
|
|
403e2aad57 | ||
|
|
c171d33e8c | ||
|
|
b1f7f2f2df | ||
|
|
a49d359656 | ||
|
|
03ec8ac17b | ||
|
|
75f3618424 | ||
|
|
e400edb92f | ||
|
|
42170ca050 | ||
|
|
f9868afde1 | ||
|
|
4e79797cd1 | ||
|
|
921b245273 | ||
|
|
2cbaeca169 | ||
|
|
bc344cab41 | ||
|
|
7a2fd4363c | ||
|
|
11d0f86320 | ||
|
|
d83fb8fe76 | ||
|
|
a36013c28c | ||
|
|
1934171e5a | ||
|
|
4b2e873261 | ||
|
|
6319cbd425 | ||
|
|
72ae5eccb3 | ||
|
|
5d1c7d532f | ||
|
|
afb9549da9 | ||
|
|
0d749d80ae | ||
|
|
050fd992c6 | ||
|
|
3694992eb5 | ||
|
|
6f0301667d | ||
|
|
d2606bfc25 | ||
|
|
299ef5307e | ||
|
|
005cc66115 |
No files matched your search
@@ -43,7 +43,8 @@ hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
hud.msg.in=In
|
||||
hud.msg.power=Energie
|
||||
hud.msg.storage=Gespeichert
|
||||
hud.msg.storage=Speicher
|
||||
hud.msg.stored=Gespeichert
|
||||
hud.msg.any=Jegliches
|
||||
hud.msg.mode=Modus
|
||||
hud.msg.maxpower=Max Energie
|
||||
@@ -89,6 +90,9 @@ hud.msg.comparator=Komparator
|
||||
hud.msg.substractor=Substraktor
|
||||
hud.msg.record=Platte
|
||||
|
||||
hud.msg.offers=Angebote
|
||||
hud.msg.demands=Bedarf
|
||||
|
||||
option.appeng.monitorcontent=Monitorinhalt
|
||||
option.bb.content=Fassinhalt
|
||||
option.bc.tankamount=Flüssigk.-Menge
|
||||
@@ -96,8 +100,11 @@ option.bc.tanktype=Flüssigk.-Typ
|
||||
option.enderstorage.colors=Farben
|
||||
option.ic2.inputeumach=Max EU-Input [Maschinen]
|
||||
option.ic2.inputeuother=Max EU-Input [Anderes]
|
||||
option.ic2.inputeu=Max EU-Input
|
||||
option.ic2.outputeu=Max EU-Output
|
||||
option.ic2.storage=Energie gespeichert
|
||||
option.ic2.consump=Zeige Verbrauch
|
||||
option.ic2.tradeomat=Zeige Tauschautomaten-Forderung
|
||||
option.thaumcraft.storedvis=Kondensatorspeicher
|
||||
option.thermalexpansion.energyhandler=Zeige RO-Speicher
|
||||
option.thermalexpansion.energycell=Zeige EZellen IN/OUT
|
||||
@@ -115,7 +122,7 @@ option.vanilla.repeater=Repeater-Verzögerung
|
||||
option.vanilla.comparator=Komparatormodus
|
||||
option.vanilla.redstone=Redstone-Stärke
|
||||
option.vanilla.jukebox=Musikbox-Platte
|
||||
option.etb.displaydata=Zeigel Sockeldaten
|
||||
option.etb.displaydata=Zeige Sockeldaten
|
||||
option.enderio.inout=Zeige Input/Output
|
||||
option.enderio.storage=Zeige gespeicherte MJ
|
||||
option.enderio.owner=Zeige Block-Besitzer
|
||||
@@ -125,3 +132,6 @@ option.bcapi.consump=Zeige maximale Energie
|
||||
option.bcapi.trigger=Zeige Startenergie
|
||||
option.pr.showio=Zeige Gatter IO
|
||||
option.pr.showdata=Zeige Gatterdaten
|
||||
option.extrautilities.fluidamount=Zeige Flüssigk.-Menge
|
||||
option.openblocks.fluidamount=Zeige Flüssigk.-Menge
|
||||
option.railcraft.fluidamount=Zeige Flüssigk.-Menge
|
||||
@@ -44,6 +44,7 @@ hud.msg.out=Out
|
||||
hud.msg.in=In
|
||||
hud.msg.power=Power
|
||||
hud.msg.storage=Storage
|
||||
hud.msg.stored=Stored
|
||||
hud.msg.any=Any
|
||||
hud.msg.mode=Mode
|
||||
hud.msg.maxpower=Max Power
|
||||
@@ -89,6 +90,9 @@ hud.msg.comparator=Comparator
|
||||
hud.msg.substractor=Substractor
|
||||
hud.msg.record=Record
|
||||
|
||||
hud.msg.offers=Offers
|
||||
hud.msg.demands=Demands
|
||||
|
||||
option.appeng.monitorcontent=Monitor's content
|
||||
option.bb.content=Barrel's content
|
||||
option.bc.tankamount=Liquid amount
|
||||
@@ -96,8 +100,11 @@ option.bc.tanktype=Liquid type
|
||||
option.enderstorage.colors=Colors
|
||||
option.ic2.inputeumach=Max EU input [Machines]
|
||||
option.ic2.inputeuother=Max EU input [Other]
|
||||
option.ic2.inputeu=Max EU input
|
||||
option.ic2.outputeu=Max EU output
|
||||
option.ic2.storage=Energy stored
|
||||
option.ic2.consump=Show consumption
|
||||
option.ic2.tradeomat=Show Trade-O-Mat request
|
||||
option.thaumcraft.storedvis=Capacitor storage
|
||||
option.thermalexpansion.energyhandler=Show RF storage
|
||||
option.thermalexpansion.energycell=Show ECell IN/OUT
|
||||
@@ -125,3 +132,6 @@ option.bcapi.consump=Show maximum power
|
||||
option.bcapi.trigger=Show triggering energy
|
||||
option.pr.showio=Show gates IO
|
||||
option.pr.showdata=Show gates data
|
||||
option.extrautilities.fluidamount=Show fluid amount
|
||||
option.openblocks.fluidamount=Show fluid amount
|
||||
option.railcraft.fluidamount=Show fluid amount
|
||||
@@ -44,6 +44,7 @@ hud.msg.out=Sortie
|
||||
hud.msg.in=Entrée
|
||||
hud.msg.power=Energie
|
||||
hud.msg.storage=Stockage
|
||||
hud.msg.stored=Stocké
|
||||
hud.msg.any=Tout
|
||||
hud.msg.mode=Mode
|
||||
hud.msg.maxpower=Max Puissance
|
||||
@@ -89,6 +90,9 @@ hud.msg.comparator=Comparateur
|
||||
hud.msg.substractor=Soustracteur
|
||||
hud.msg.record=Disque
|
||||
|
||||
hud.msg.offers=Offre
|
||||
hud.msg.demands=Demande
|
||||
|
||||
option.appeng.monitorcontent=Contenu des écrans
|
||||
option.bb.content=Contenu des barils
|
||||
option.bc.tankamount=Niveau de liquide
|
||||
@@ -96,8 +100,10 @@ option.bc.tanktype=Sorte de liquide
|
||||
option.enderstorage.colors=Couleurs
|
||||
option.ic2.inputeumach=Max EU en entrée [Machines]
|
||||
option.ic2.inputeuother=Max EU en entrée [Autres]
|
||||
option.ic2.inputeu=Max EU en entrée
|
||||
option.ic2.outputeu=Max EU en sortie
|
||||
option.ic2.storage=Energie stockée
|
||||
option.ic2.consump=Afficher consommation
|
||||
option.thaumcraft.storedvis=Condensateur de stockage
|
||||
option.thermalexpansion.energyhandler=Afficher stockage RF
|
||||
option.thermalexpansion.energycell=Afficher ECell Entrée/Sortie
|
||||
@@ -124,4 +130,7 @@ option.bcapi.storage=Afficher MJ stocké
|
||||
option.bcapi.consump=Afficher puissance maximale
|
||||
option.bcapi.trigger=Energie déclanchement
|
||||
option.pr.showio=Afficher plaques IO
|
||||
option.pr.showdata=Afficher plaques data
|
||||
option.pr.showdata=Afficher plaques data
|
||||
option.extrautilities.fluidamount=Afficher niveau fluides
|
||||
option.openblocks.fluidamount=Afficher niveau fluides
|
||||
option.railcraft.fluidamount=Afficher niveau fluides
|
||||
@@ -0,0 +1,117 @@
|
||||
screen.button.waila=Waila
|
||||
screen.button.modules=Modules
|
||||
screen.label.scale=Schaal
|
||||
screen.label.dragtuto=Sleep de HUD om zijn positie in te stellen.
|
||||
|
||||
screen.button.default=Standaard
|
||||
screen.button.cancel=Annuleren
|
||||
screen.button.ok=Ok
|
||||
screen.button.yes=Ja
|
||||
screen.button.no=Nee
|
||||
screen.button.back=Terug
|
||||
screen.button.hidden=Verborgen
|
||||
screen.button.visible=Zichtbaar
|
||||
screen.button.maintained=Gehandhaafd
|
||||
screen.button.toggled=Omgeschakeld
|
||||
|
||||
choice.showhidewaila=Toon/Verberg Waila
|
||||
choice.showhideidmeta=Toon ID:Metadata
|
||||
choice.toggledmaintained=Omgeschakeld/Gehandhaafd
|
||||
choice.showliquids=Vloeistoffen
|
||||
screen.button.configureaspect=Configureer aspect...
|
||||
|
||||
enchant.title.name=Naam
|
||||
enchant.title.minlvl=Min lvl
|
||||
enchant.title.maxlvl=Max lvl
|
||||
enchant.title.weight=Gewicht
|
||||
enchant.label.enchantability=Enchantbaarheid
|
||||
|
||||
keybind.configscreen=[Waila] Configuratiescherm
|
||||
keybind.showhide=[Waila] Toon/Verberg
|
||||
keybind.showliquid=[Waila] Toon vloeistoffen
|
||||
keybind.showrecipe=[Waila] Toon recepten
|
||||
keybind.showusage=[Waila] Toon gebruik
|
||||
keybind.testing=[Waila] Testen
|
||||
|
||||
client.msg.norecipe=Geen recept gevonden.
|
||||
client.msg.nousage=Geen gebruik gevonden.
|
||||
|
||||
hud.msg.none=<Geen>
|
||||
hud.msg.empty=<Leeg>
|
||||
hud.msg.output=Uitvoer
|
||||
hud.msg.input=Invoer
|
||||
hud.msg.out=Uit
|
||||
hud.msg.in=In
|
||||
hud.msg.power=Vermogen
|
||||
hud.msg.storage=Opslag
|
||||
hud.msg.any=Om het even welke
|
||||
hud.msg.mode=Modus
|
||||
|
||||
hud.msg.send=Zend
|
||||
hud.msg.recv=Ontv
|
||||
hud.msg.item=Item
|
||||
hud.msg.fluid=Vloeistof
|
||||
hud.msg.energ=Energie
|
||||
hud.msg.frequency=Frequentie
|
||||
|
||||
hud.msg.owner=Eigenaar
|
||||
hud.msg.public=Publiek
|
||||
hud.msg.restricted=Begrensd
|
||||
hud.msg.private=Privé
|
||||
|
||||
hud.msg.white=Wit
|
||||
hud.msg.orange=Oranje
|
||||
hud.msg.magenta=Magenta
|
||||
hud.msg.lblue=LBlauw
|
||||
hud.msg.yellow=Geel
|
||||
hud.msg.lime=Limoen
|
||||
hud.msg.pink=Roze
|
||||
hud.msg.gray=Grijs
|
||||
hud.msg.lgray=LGrijs
|
||||
hud.msg.cyan=Cyaan
|
||||
hud.msg.purple=Paars
|
||||
hud.msg.blue=Blauw
|
||||
hud.msg.brown=Bruin
|
||||
hud.msg.green=Groen
|
||||
hud.msg.red=Rood
|
||||
hud.msg.black=Zwart
|
||||
|
||||
hud.msg.growth=Groei
|
||||
hud.msg.mature=Volwassen
|
||||
hud.msg.off=Af
|
||||
hud.msg.on=Aan
|
||||
hud.msg.state=Status
|
||||
hud.msg.delay=Vertraging
|
||||
hud.msg.comparator=Vergelijker
|
||||
hud.msg.substractor=Aftrekker
|
||||
hud.msg.record=Neem op
|
||||
|
||||
option.appeng.monitorcontent=Scherm inhoud
|
||||
option.bb.content=Ton inhoud
|
||||
option.bc.tankamount=Vloeistofhoeveelheid
|
||||
option.bc.tanktype=Vloeistoftype
|
||||
option.enderstorage.colors=Kleuren
|
||||
option.ic2.inputeumach=Max EU invoer [Machines]
|
||||
option.ic2.inputeuother=Max EU invoer [Andere]
|
||||
option.ic2.inputeu=Max EU invoer
|
||||
option.ic2.outputeu=Max EU uitvoer
|
||||
option.ic2.storage=Opgeslagen energie
|
||||
option.thaumcraft.storedvis=Condensator opslag
|
||||
option.thermalexpansion.energyhandler=Toon RF opslag
|
||||
option.thermalexpansion.energycell=Toon ECell IN/UIT
|
||||
option.thermalexpansion.fluidtype=Toon vloeistoftype
|
||||
option.thermalexpansion.fluidamount=Toon vloeistofhoeveelheid
|
||||
option.thermalexpansion.tankmode=Toon tank modus
|
||||
option.thermalexpansion.tesssendrecv=Tesseract modus
|
||||
option.thermalexpansion.tessfreq=Tesseract frequentie
|
||||
option.thermalexpansion.owner=Toon eigenaar
|
||||
option.vanilla.spawntype=Spawner type
|
||||
option.vanilla.growthvalue=Groei hoeveelheid
|
||||
option.vanilla.leverstate=Hendel status
|
||||
option.vanilla.repeater=Herhaler vertraging
|
||||
option.vanilla.comparator=Vergelijker modus
|
||||
option.vanilla.redstone=Redstone vermogen
|
||||
option.vanilla.jukebox=Jukebox schijf
|
||||
option.extrautilities.fluidamount=Toon vloeistofhoeveelheid
|
||||
option.openblocks.fluidamount=Toon vloeistofhoeveelheid
|
||||
option.railcraft.fluidamount=Toon vloeistofhoeveelheid
|
||||
@@ -0,0 +1,131 @@
|
||||
screen.button.waila=Waila
|
||||
screen.button.modules=Модули
|
||||
screen.label.scale=Размер
|
||||
screen.label.dragtuto=Перетащите интерфейс, чтобы изменить позицию.
|
||||
|
||||
screen.button.default=По умолчанию
|
||||
screen.button.cancel=Отмена
|
||||
screen.button.ok=Ок
|
||||
screen.button.yes=Да
|
||||
screen.button.no=Нет
|
||||
screen.button.back=Назад
|
||||
screen.button.hidden=Скрывать
|
||||
screen.button.visible=Показывать
|
||||
screen.button.maintained=При нажатой клавише
|
||||
screen.button.toggled=Вкл./Выкл. гор. клавишей
|
||||
|
||||
choice.showhidewaila=Показать/Скрыть Waila
|
||||
choice.showhideidmeta=Показать ID:Метаданные
|
||||
choice.toggledmaintained=Переключ./Нажатая клав.
|
||||
choice.showliquids=Жидкости
|
||||
screen.button.configureaspect=Настроить индикатор...
|
||||
|
||||
enchant.title.name=Название
|
||||
enchant.title.minlvl=Мин. уровень
|
||||
enchant.title.maxlvl=Макс. уровень
|
||||
enchant.title.weight=Вес
|
||||
enchant.label.enchantability=Зачарование
|
||||
|
||||
waila.keybind.wailaconfig=[Waila] Меню настроек
|
||||
waila.keybind.wailadisplay=[Waila] Показать/Скрыть
|
||||
waila.keybind.liquid=[Waila] Показать жидкости
|
||||
waila.keybind.recipe=[Waila] Показать рецепт
|
||||
waila.keybind.usage=[Waila] Показать применение
|
||||
waila.keybind.testing=[Waila] Тестировать
|
||||
|
||||
client.msg.norecipe=Рецептов не найдено.
|
||||
client.msg.nousage=Применений не найдено.
|
||||
|
||||
hud.msg.none=<Ничего>
|
||||
hud.msg.empty=<Пусто>
|
||||
hud.msg.output=Вывод
|
||||
hud.msg.input=Ввод
|
||||
hud.msg.out=Из
|
||||
hud.msg.in=В
|
||||
hud.msg.power=Энергия
|
||||
hud.msg.storage=Хранилище
|
||||
hud.msg.any=Всё
|
||||
hud.msg.mode=Режим
|
||||
hud.msg.maxpower=Макс. энергия
|
||||
hud.msg.trigger=Триггер
|
||||
hud.msg.maxio=Макс. ввод/вывод
|
||||
|
||||
hud.msg.send=Передача
|
||||
hud.msg.recv=Приём
|
||||
hud.msg.item=Предмет
|
||||
hud.msg.fluid=Жидкость
|
||||
hud.msg.energ=Энергия
|
||||
hud.msg.frequency=Частота
|
||||
|
||||
hud.msg.owner=Владелец
|
||||
hud.msg.public=Публичный
|
||||
hud.msg.restricted=Ограниченный
|
||||
hud.msg.private=Приватный
|
||||
|
||||
hud.msg.white=Белый
|
||||
hud.msg.orange=Оранжевый
|
||||
hud.msg.magenta=Сиреневый
|
||||
hud.msg.lblue=Светло-синий
|
||||
hud.msg.yellow=Жёлтый
|
||||
hud.msg.lime=Светло-зелёный
|
||||
hud.msg.pink=Розовый
|
||||
hud.msg.gray=Серый
|
||||
hud.msg.lgray=Светло-серый
|
||||
hud.msg.cyan=Бирюзовый
|
||||
hud.msg.purple=Фиолетовый
|
||||
hud.msg.blue=Синий
|
||||
hud.msg.brown=Коричневый
|
||||
hud.msg.green=Зелёный
|
||||
hud.msg.red=Красный
|
||||
hud.msg.black=Чёрный
|
||||
|
||||
hud.msg.growth=Рост
|
||||
hud.msg.mature=Вырос
|
||||
hud.msg.off=Выкл.
|
||||
hud.msg.on=Вкл.
|
||||
hud.msg.state=Статус
|
||||
hud.msg.delay=Задержка
|
||||
hud.msg.comparator=Компаратор
|
||||
hud.msg.substractor=Вычитатель
|
||||
hud.msg.record=Пластинка
|
||||
|
||||
option.appeng.monitorcontent=Содержимое монитора
|
||||
option.bb.content=Содержимое бочки
|
||||
option.bc.tankamount=Кол-во жидкости
|
||||
option.bc.tanktype=Тип жидкости
|
||||
option.enderstorage.colors=Цвета
|
||||
option.ic2.inputeumach=Макс. ввод еЭ [Машины]
|
||||
option.ic2.inputeuother=Макс. ввод еЭ [Другое]
|
||||
option.ic2.inputeu=Макс. ввод еЭ
|
||||
option.ic2.outputeu=Макс. вывод еЭ
|
||||
option.ic2.storage=Заряд энергии
|
||||
option.thaumcraft.storedvis=Заряд конденсатора
|
||||
option.thermalexpansion.energyhandler=Показывать заряд заряжателя
|
||||
option.thermalexpansion.energycell=Показывать Ввод/Вывод Р.батареи
|
||||
option.thermalexpansion.fluidtype=Показывать тип жидкости
|
||||
option.thermalexpansion.fluidamount=Показывать кол-во жидкости
|
||||
option.thermalexpansion.tankmode=Режим цистерны
|
||||
option.thermalexpansion.tesssendrecv=Режим тессеракта
|
||||
option.thermalexpansion.tessfreq=Частота тессеракта
|
||||
option.thermalexpansion.owner=Показывать владельца
|
||||
option.thermalexpansion.conditemmode=Показывать режим труб
|
||||
option.vanilla.spawntype=Тип спаунера
|
||||
option.vanilla.growthvalue=Стадия роста
|
||||
option.vanilla.leverstate=Положение рычага
|
||||
option.vanilla.repeater=Задержка повторителя
|
||||
option.vanilla.comparator=Режим компаратора
|
||||
option.vanilla.redstone=Сила красного камня
|
||||
option.vanilla.jukebox=Пластинка в проигрывателе
|
||||
option.etb.displaydata=Показывать инф. о сокетах
|
||||
option.enderio.inout=Показывать ввод/вывод
|
||||
option.enderio.storage=Показывать заряд MJ
|
||||
option.enderio.owner=Показывать владельца блока
|
||||
option.enderio.channel=Показывать канал гиперкуба
|
||||
option.bcapi.storage=Показывать заряд MJ
|
||||
option.bcapi.consump=Показывать макс. энергию
|
||||
option.bcapi.trigger=Показывать энергию активации
|
||||
option.pr.showio=Показывать ввод/вывод схем
|
||||
option.pr.showdata=Показывать инф. о схемах
|
||||
option.extrautilities.fluidamount=Показывать кол-во жидкости
|
||||
option.openblocks.fluidamount=Показывать кол-во жидкости
|
||||
option.railcraft.fluidamount=Показывать кол-во жидкости
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ETBModule {
|
||||
//public static Field Socket_facMeta = null;
|
||||
|
||||
public static Class SocketsMod = null;
|
||||
public static Item module = null;
|
||||
public static Field module = null;
|
||||
|
||||
public static Class SideConfig = null;
|
||||
public static Field SC_tank = null;
|
||||
@@ -46,7 +46,14 @@ public class ETBModule {
|
||||
//Socket_facMeta = TileSocket.getField("facMeta");
|
||||
|
||||
SocketsMod = Class.forName("emasher.sockets.SocketsMod");
|
||||
module = (Item)SocketsMod.getField("module").get(null);
|
||||
module = SocketsMod.getField("module");
|
||||
//module = (Item)SocketsMod.getField("module").get(null);
|
||||
/*
|
||||
if (module == null){
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] module field is null !");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
SideConfig = Class.forName("emasher.api.SideConfig");
|
||||
SC_tank = SideConfig.getField("tank");
|
||||
@@ -56,21 +63,21 @@ public class ETBModule {
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Class not found. " + e);
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Class not found. " + e);
|
||||
return;
|
||||
// } catch (NoSuchMethodException e){
|
||||
// mod_Waila.log.log(Level.WARNING, "[EnderStorage] Method not found." + e);
|
||||
// mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Method not found." + e);
|
||||
// return;
|
||||
} catch (NoSuchFieldException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Field not found." + e);
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.WARNING, "[EnderStorage] Unhandled exception." + e);
|
||||
mod_Waila.log.log(Level.WARNING, "[Engineer Toolbox] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfig("Engineer Toolbox", "etb.displaydata");
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerSocket(), TileSocket);
|
||||
ModuleRegistrar.instance().addConfig("Engineer Toolbox", "etb.displaydata");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerSocket(), TileSocket);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package mcp.mobius.waila.addons.etb;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
@@ -29,9 +30,11 @@ public class HUDHandlerSocket implements IWailaDataProvider {
|
||||
try {
|
||||
int[] sides = (int[])ETBModule.Socket_sides.get(accessor.getTileEntity());
|
||||
Object[] configs = (Object[])ETBModule.Socket_configs.get(accessor.getTileEntity());
|
||||
Item module = (Item)ETBModule.module.get(null);
|
||||
|
||||
|
||||
for( int s = 0; s < 6; s++){
|
||||
if (sides[s]!=0){
|
||||
if (sides[s] != 0){
|
||||
|
||||
int tank = (Integer)ETBModule.SC_tank.get(configs[s]);
|
||||
int inventory = (Integer)ETBModule.SC_inventory.get(configs[s]);
|
||||
@@ -39,7 +42,7 @@ public class HUDHandlerSocket implements IWailaDataProvider {
|
||||
boolean[] rsLatch = (boolean[])ETBModule.SC_rsLatch.get(configs[s]);
|
||||
|
||||
|
||||
ItemStack stack = new ItemStack(ETBModule.module, 1, sides[s]);
|
||||
ItemStack stack = new ItemStack(module, 1, sides[s]);
|
||||
String tipstr = String.format("%-5s : %s ", ForgeDirection.getOrientation(s), stack.getDisplayName());
|
||||
|
||||
String configstr = "[ ";
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package mcp.mobius.waila.addons.exu;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ExtraUtilitiesModule {
|
||||
|
||||
public static Class ModExtraUtilities = null;
|
||||
public static Class TileEntityDrum = null;
|
||||
|
||||
public static void register(){
|
||||
|
||||
|
||||
try{
|
||||
Class ModExtraUtilities = Class.forName("extrautils.ExtraUtils");
|
||||
mod_Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityDrum = Class.forName("extrautils.tileentity.TileEntityDrum");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[ExtraUtilities] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("ExtraUtilities", "extrautilities.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDrum(), TileEntityDrum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package mcp.mobius.waila.addons.exu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerDrum implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("extrautilities.fluidamount")) return currenttip;
|
||||
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound subtag = accessor.getNBTData().getCompoundTag("tank");
|
||||
if (subtag.hasKey("Amount"))
|
||||
amount = accessor.getNBTInteger(subtag, "Amount");
|
||||
|
||||
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
|
||||
if (handler == null) return currenttip;
|
||||
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerDoor implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return IC2Module.ReinforcedDoorStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class HUDHandlerIC2IEnergySink implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
|
||||
int maxinput = -1;
|
||||
try{
|
||||
if (IC2Module.IEnergySink.isInstance(accessor.getTileEntity()))
|
||||
maxinput = (Integer)(IC2Module.IEnergySink_GetInput.invoke(IC2Module.IEnergySink.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySink for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
int ntransformers = this.getTransformerUpgrades(accessor);
|
||||
if (ntransformers > 0){
|
||||
maxinput = maxinput * (int)Math.pow(4.0D, Math.min(3, ntransformers));
|
||||
}
|
||||
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput > 4096))
|
||||
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.input"), LangUtil.translateG("hud.msg.any")));
|
||||
|
||||
else if (ConfigHandler.instance().getConfig("ic2.inputeuother") && (maxinput != -1) && !this.canUpgrade(accessor.getNBTData()))
|
||||
currenttip.add(String.format("%s : %s EU/t", LangUtil.translateG("hud.msg.input"), maxinput));
|
||||
|
||||
else if (ConfigHandler.instance().getConfig("ic2.inputeumach") && (maxinput != -1) && this.canUpgrade(accessor.getNBTData()))
|
||||
currenttip.add(String.format("%s : %s EU/t", LangUtil.translateG("hud.msg.input"), maxinput));
|
||||
|
||||
if (config.getConfig("ic2.storage"))
|
||||
if (accessor.getNBTData().hasKey("energy") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
currenttip.add(String.format("%s : %s EU", LangUtil.translateG("hud.msg.storage"), accessor.getNBTInteger(accessor.getNBTData(), "energy")));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public boolean canUpgrade(NBTTagCompound tag){
|
||||
if (tag.hasKey("InvSlots"))
|
||||
if (tag.getCompoundTag("InvSlots").hasKey("upgrade"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTransformerUpgrades(IWailaDataAccessor accessor){
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (!canUpgrade(tag)) return -1;
|
||||
|
||||
int ntransformers = 0;
|
||||
NBTTagList contents = tag.getCompoundTag("InvSlots").getCompoundTag("upgrade").getTagList("Contents");
|
||||
for (NBTTagCompound subtag : (List<NBTTagCompound>)contents.tagList){
|
||||
ItemStack currentSlot = new ItemStack(accessor.getNBTInteger(subtag, "id"),accessor.getNBTInteger(subtag, "Count"),accessor.getNBTInteger(subtag, "Damage"));
|
||||
if (IC2Module.TransformerUpgradeStack.isItemEqual(currentSlot)){
|
||||
ntransformers += currentSlot.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return ntransformers;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDHandlerIC2IEnergySource implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
//if (accessor.getTileEntity() != null && TEElectricBlock.isInstance(accessor.getTileEntity())){
|
||||
int output = -1;
|
||||
|
||||
/*
|
||||
try{
|
||||
if (IC2Module.IEnergySource.isInstance(accessor.getTileEntity()))
|
||||
output = (Integer)(IC2Module.IEnergySource_GetOutput.invoke(IC2Module.IEnergySource.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergySource for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
*/
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu") && (output != -1))
|
||||
currenttip.add(String.format("%s : %s EU/t", LangUtil.translateG("hud.msg.output"), output));
|
||||
|
||||
if (config.getConfig("ic2.storage"))
|
||||
if (accessor.getNBTData().hasKey("storage") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
currenttip.add(String.format("%s : %s EU", LangUtil.translateG("hud.msg.storage"), accessor.getNBTInteger(accessor.getNBTData(), "storage")));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HUDHandlerIC2IEnergyStorage implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("ic2.storage"))
|
||||
return currenttip;
|
||||
|
||||
int stored = -1;
|
||||
int capacity = -1;
|
||||
try{
|
||||
if (IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
|
||||
capacity = (Integer)(IC2Module.IEnergyStorage_GetCapacity.invoke(IC2Module.IEnergyStorage.cast(accessor.getTileEntity())));
|
||||
} catch (Exception e){
|
||||
mod_Waila.log.log(Level.SEVERE, "[IC2] Unhandled exception trying to access an IEnergyStorage for display !.\n" + String.valueOf(e));
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
if (accessor.getNBTData().hasKey("energy"))
|
||||
stored = accessor.getNBTInteger(accessor.getNBTData(), "energy");
|
||||
|
||||
if ((capacity != -1) && (stored != -1))
|
||||
currenttip.add(String.format("%s/%s EU", stored, capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
int storage = -1;
|
||||
int production = -1;
|
||||
|
||||
if (IC2Module.TileEntityBaseGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEBG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEBG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntityGeoGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEGG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEGG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntitySemifluidGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TESG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = (int)IC2Module.TESG_Production.getDouble(accessor.getTileEntity());
|
||||
}
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
if ( stored >= 0.0 && storage > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
|
||||
//else if (stored >= 0.0)
|
||||
// currenttip.add(String.format("Stored : %d EU", stored));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", outputStr, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
|
||||
IC2Upgrades upgrades = IC2Module.getUpgrades(accessor);
|
||||
int baseConsumption = IC2Module.TESM_DefaultEnergyConsume.getInt(accessor.getTileEntity());
|
||||
int baseOpTime = IC2Module.TESM_DefaultOperationLength.getInt(accessor.getTileEntity());
|
||||
int baseStorage = IC2Module.TESM_DefaultEnergyStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
long consumption = Math.round(Math.min(baseConsumption * Math.pow(1.6D, upgrades.overclocker), 2147483647));
|
||||
|
||||
double stackOpLen = baseOpTime * 64.0D * Math.pow(0.7D, upgrades.overclocker);
|
||||
int opPerTick = ((int)Math.min(Math.ceil(64.0D / stackOpLen), 2147483647.0D));
|
||||
int opTime = ((int)Math.round(stackOpLen * opPerTick / 64.0D));
|
||||
|
||||
int storage = Math.round(Math.min(baseStorage + 10000 * upgrades.storage + opTime * consumption, 2147483647));;
|
||||
|
||||
|
||||
int maxinput = (Integer)IC2Module.IES_GetMaxSafeInput.invoke(accessor.getTileEntity()) * (int)Math.pow(4.0D, Math.min(4, upgrades.transform));
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String powerStr = LangUtil.translateG("hud.msg.power");
|
||||
String maxPowerStr = LangUtil.translateG("hud.msg.maxpower");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.consump")){
|
||||
if ( consumption > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", powerStr, consumption ));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
|
||||
if ( maxinput > 0)
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r EU/t", maxPowerStr, maxinput ));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import 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 {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack,List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (!ConfigHandler.instance().getConfig("ic2.tradeomat")) return currenttip;
|
||||
|
||||
NBTTagCompound slots = accessor.getNBTData().getCompoundTag("InvSlots");
|
||||
NBTTagList offer = slots.getCompoundTag("offer").getTagList("Contents");
|
||||
NBTTagList demand = slots.getCompoundTag("demand").getTagList("Contents");
|
||||
String offersStr = LangUtil.translateG("hud.msg.offers");
|
||||
String demandsStr = LangUtil.translateG("hud.msg.demands");
|
||||
|
||||
|
||||
if (offer.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
if (demand.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s : \u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,90 +2,174 @@ 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 mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
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.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 {
|
||||
|
||||
/* Our interfaces */
|
||||
public static Class IEnergyStorage = null;
|
||||
public static Class IEnergySink = null;
|
||||
public static Class IEnergySource = null;
|
||||
public static Class TileEntityStandardMachine = null;
|
||||
public static Field TESM_DefaultEnergyStorage = null;
|
||||
public static Field TESM_DefaultEnergyConsume = null;
|
||||
public static Field TESM_DefaultOperationLength = null;
|
||||
public static Field TESM_MaxEnergy = null;
|
||||
|
||||
/* Methods interfaces */
|
||||
public static Method IEnergyStorage_GetCapacity = null;
|
||||
public static Method IEnergySink_GetInput = null;
|
||||
//public static Method IEnergySource_GetOutput = null;
|
||||
public static Class TileEntityBaseGenerator = null;
|
||||
public static Field TEBG_MaxStorage = null;
|
||||
public static Field TEBG_Production = null;
|
||||
|
||||
public static Class TileEntitySemifluidGenerator = null;
|
||||
public static Field TESG_MaxStorage = null;
|
||||
public static Field TESG_Production = null;
|
||||
|
||||
public static Class TileEntityGeoGenerator = null;
|
||||
public static Field TEGG_MaxStorage = null;
|
||||
public static Field TEGG_Production = null;
|
||||
|
||||
public static Class TileEntityElectricBlock = null;
|
||||
public static Field TEEB_MaxStorage = null;
|
||||
public static Field TEEB_Output = null;
|
||||
|
||||
public static Class IEnergySink = null;
|
||||
public static Method IES_GetMaxSafeInput = null;
|
||||
|
||||
public static Class TileEntityTradeOMat = null;
|
||||
|
||||
/* Some required items */
|
||||
public static Class IC2Items = null;
|
||||
public static Field TransformerUpgrade = null;
|
||||
public static ItemStack TransformerUpgradeStack = null;
|
||||
public static Field EnergyStorageUpgrade = null;
|
||||
public static ItemStack EnergyStorageUpgradeStack = null;
|
||||
|
||||
/* Fix for doors */
|
||||
public static Class BlockIC2Door = null;
|
||||
public static Field ReinforcedDoor = null;
|
||||
public static ItemStack ReinforcedDoorStack = null;
|
||||
public static ItemStack TransformerUpgradeStack = null;
|
||||
public static Field EnergyStorageUpgrade = null;
|
||||
public static ItemStack EnergyStorageUpgradeStack = null;
|
||||
public static Field OverclockerUpgrade = null;
|
||||
public static ItemStack OverclockerUpgradeStack = null;
|
||||
|
||||
|
||||
public static void register(){
|
||||
|
||||
try{
|
||||
Class ModIndustrialCraft = Class.forName("ic2.core.IC2");
|
||||
mod_Waila.log.log(Level.INFO, "Industrialcraft2 mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[IC2] Industrialcraft2 mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityStandardMachine = Class.forName("ic2.core.block.machine.tileentity.TileEntityStandardMachine");
|
||||
TESM_DefaultEnergyStorage = TileEntityStandardMachine.getField("defaultEnergyStorage");
|
||||
TESM_DefaultEnergyConsume = TileEntityStandardMachine.getField("defaultEnergyConsume");
|
||||
TESM_DefaultOperationLength = TileEntityStandardMachine.getField("defaultOperationLength");
|
||||
TESM_MaxEnergy = TileEntityStandardMachine.getField("maxEnergy");
|
||||
|
||||
IEnergyStorage = Class.forName("ic2.api.tile.IEnergyStorage");
|
||||
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
|
||||
IEnergySource = Class.forName("ic2.api.energy.tile.IEnergySource");
|
||||
|
||||
IEnergySink_GetInput = IEnergySink.getMethod("getMaxSafeInput");
|
||||
//IEnergySource_GetOutput = IEnergySource.getMethod("getMaxEnergyOutput");
|
||||
IEnergyStorage_GetCapacity = IEnergyStorage.getMethod("getCapacity");
|
||||
TileEntityBaseGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityBaseGenerator");
|
||||
TEBG_MaxStorage = TileEntityBaseGenerator.getField("maxStorage");
|
||||
TEBG_Production = TileEntityBaseGenerator.getField("production");
|
||||
|
||||
TileEntitySemifluidGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator");
|
||||
TESG_MaxStorage = TileEntitySemifluidGenerator.getDeclaredField("maxStorage");
|
||||
TESG_Production = TileEntitySemifluidGenerator.getDeclaredField("production");
|
||||
TESG_MaxStorage.setAccessible(true);
|
||||
TESG_Production.setAccessible(true);
|
||||
|
||||
IC2Items = Class.forName("ic2.core.Ic2Items");
|
||||
TransformerUpgrade = IC2Items.getDeclaredField("transformerUpgrade");
|
||||
EnergyStorageUpgrade = IC2Items.getDeclaredField("energyStorageUpgrade");
|
||||
TileEntityGeoGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityGeoGenerator");
|
||||
TEGG_MaxStorage = TileEntityGeoGenerator.getField("maxStorage");
|
||||
TEGG_Production = TileEntityGeoGenerator.getField("production");
|
||||
|
||||
TileEntityElectricBlock = Class.forName("ic2.core.block.wiring.TileEntityElectricBlock");
|
||||
TEEB_MaxStorage = TileEntityElectricBlock.getField("maxStorage");
|
||||
TEEB_Output = TileEntityElectricBlock.getField("output");
|
||||
|
||||
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
|
||||
IES_GetMaxSafeInput = IEnergySink.getMethod("getMaxSafeInput");
|
||||
|
||||
IC2Items = Class.forName("ic2.core.Ic2Items");
|
||||
TransformerUpgrade = IC2Items.getField("transformerUpgrade");
|
||||
EnergyStorageUpgrade = IC2Items.getField("energyStorageUpgrade");
|
||||
OverclockerUpgrade = IC2Items.getField("overclockerUpgrade");
|
||||
|
||||
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
|
||||
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
|
||||
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
|
||||
OverclockerUpgradeStack = (ItemStack)OverclockerUpgrade.get(null);
|
||||
|
||||
BlockIC2Door = Class.forName("ic2.core.block.BlockIC2Door");
|
||||
ReinforcedDoor = IC2Items.getDeclaredField("reinforcedDoor");
|
||||
ReinforcedDoorStack = (ItemStack)ReinforcedDoor.get(null);
|
||||
TileEntityTradeOMat = Class.forName("ic2.core.block.personal.TileEntityTradeOMat");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
//e.printStackTrace();
|
||||
mod_Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeumach");
|
||||
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.inputeuother");
|
||||
ExternalModulesHandler.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
|
||||
ExternalModulesHandler.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySink(), IEnergySink);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergySource(), IEnergySource);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIC2IEnergyStorage(), IEnergyStorage);
|
||||
ExternalModulesHandler.instance().registerStackProvider(new HUDHandlerDoor(), BlockIC2Door);
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
|
||||
ModuleRegistrar.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
|
||||
}
|
||||
|
||||
/* Retuns the current stored energy if available in the nbt and config is true */
|
||||
public static double getStoredEnergy(IWailaDataAccessor accessor){
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if (accessor.getNBTData().hasKey("energy"))
|
||||
return accessor.getNBTData().getDouble("energy");
|
||||
else if (accessor.getNBTData().hasKey("storage"))
|
||||
return accessor.getNBTData().getDouble("storage");
|
||||
}
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
public static IC2Upgrades getUpgrades(IWailaDataAccessor accessor){
|
||||
|
||||
NBTTagCompound nbt = accessor.getNBTData();
|
||||
IC2Upgrades upgrades = new IC2Upgrades();
|
||||
|
||||
if (!nbt.hasKey("InvSlots")) return null;
|
||||
|
||||
NBTTagCompound inventory = nbt.getCompoundTag("InvSlots");
|
||||
if (!inventory.hasKey("upgrade")) return null;
|
||||
|
||||
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
|
||||
|
||||
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
|
||||
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
|
||||
|
||||
for (Object subobj : tagList){
|
||||
NBTTagCompound subtag = (NBTTagCompound)subobj;
|
||||
int id = subtag.getShort("id");
|
||||
int meta = subtag.getShort("Damage");
|
||||
int count = subtag.getByte("Count");
|
||||
|
||||
//ItemStack is = new ItemStack(id, 1, count);
|
||||
if (TransformerUpgradeStack.getItemDamage() == meta && TransformerUpgradeStack.itemID == id)
|
||||
upgrades.transform += count;
|
||||
if (EnergyStorageUpgradeStack.getItemDamage() == meta && EnergyStorageUpgradeStack.itemID == id)
|
||||
upgrades.storage += count;
|
||||
if (OverclockerUpgradeStack.getItemDamage() == meta && OverclockerUpgradeStack.itemID == id)
|
||||
upgrades.overclocker += count;
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
public class IC2Upgrades {
|
||||
public int transform = 0;
|
||||
public int storage = 0;
|
||||
public int overclocker = 0;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package mcp.mobius.waila.addons.openblocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("openblocks.fluidamount")) return currenttip;
|
||||
|
||||
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
|
||||
if (handler == null) return currenttip;
|
||||
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
FluidStack fluid = tanks[0].fluid;
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try{
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName());
|
||||
} catch (NullPointerException f){
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("openblocks.fluidamount")) return currenttip;
|
||||
|
||||
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
|
||||
if (handler == null) return currenttip;
|
||||
|
||||
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
if (tanks.length != 1) return currenttip;
|
||||
|
||||
if(tanks[0].fluid != null)
|
||||
currenttip.add(String.format("%d / %d mB", tanks[0].fluid.amount, tanks[0].capacity));
|
||||
else
|
||||
currenttip.add(String.format("0 / %d mB", tanks[0].capacity));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package mcp.mobius.waila.addons.openblocks;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class OpenBlocksModule {
|
||||
|
||||
public static Class ModOpenBlocks = null;
|
||||
public static Class TileEntityTank = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModOpenBlocks = Class.forName("openblocks.OpenBlocks");
|
||||
mod_Waila.log.log(Level.INFO, "OpenBlocks mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[OpenBlocks] OpenBlocks mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityTank = Class.forName("openblocks.common.tileentity.TileEntityTank");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[OpenBlocks] Class not found. " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("OpenBlocks", "openblocks.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileEntityTank);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerTank implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
try {
|
||||
IFluidTank tank = (IFluidTank)RailcraftModule.ITankTile_getTank.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
|
||||
String name = currenttip.get(0);
|
||||
|
||||
try{
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName());
|
||||
} catch (NullPointerException f){
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.set(0, name);
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("railcraft.fluidamount")) return currenttip;
|
||||
|
||||
try {
|
||||
IFluidTank tank = (IFluidTank)RailcraftModule.ITankTile_getTank.invoke(RailcraftModule.ITankTile.cast(accessor.getTileEntity()));
|
||||
if (tank == null) return currenttip;
|
||||
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid != null)
|
||||
currenttip.add(String.format("%d / %d mB", fluid.amount, tank.getInfo().capacity));
|
||||
else
|
||||
currenttip.add(String.format("0 / %d mB", tank.getInfo().capacity));
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package mcp.mobius.waila.addons.railcraft;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class RailcraftModule {
|
||||
public static Class TileTankBase = null;
|
||||
public static Class ITankTile = null;
|
||||
public static Method ITankTile_getTank = null;
|
||||
//public static Class StandardTank = null;
|
||||
|
||||
public static void register(){
|
||||
try{
|
||||
Class ModRailcraft = Class.forName("mods.railcraft.common.core.Railcraft");
|
||||
mod_Waila.log.log(Level.INFO, "Railcraft mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.INFO, "[Railcraft] Railcraft mod not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
TileTankBase = Class.forName("mods.railcraft.common.blocks.machine.beta.TileTankBase");
|
||||
ITankTile = Class.forName("mods.railcraft.common.blocks.machine.ITankTile");
|
||||
ITankTile_getTank = ITankTile.getMethod("getTank");
|
||||
//StandardTank = Class.forName("mods.railcraft.common.fluids.tanks.StandardTank");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Railcraft] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
mod_Waila.log.log(Level.WARNING, "[Railcraft] Method not found." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Railcraft", "railcraft.fluidamount");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTankBase);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTankBase);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
@@ -25,22 +27,31 @@ public class HUDHandlerConduitFluid implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (config.getConfig("thermalexpansion.fluidtype")){
|
||||
if (!config.getConfig("thermalexpansion.fluidtype")) return currenttip;
|
||||
|
||||
try {
|
||||
FluidStack fluid = (FluidStack)ThermalExpansionModule.TileConduitFluid_getRenderFluid.invoke(accessor.getTileEntity());
|
||||
|
||||
try{
|
||||
currenttip.add(fluid.getFluid().getLocalizedName());
|
||||
} catch (NullPointerException f){
|
||||
currenttip.add(LangUtil.translateG("hud.msg.empty"));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
boolean found = false;
|
||||
FluidStack fluid = null;
|
||||
|
||||
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
|
||||
NBTTagList parts = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < parts.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
}
|
||||
if (id.contains("ConduitFluid")){
|
||||
found = true;
|
||||
NBTTagCompound fluidTag = subtag.getCompoundTag("ConnFluid");
|
||||
fluid = FluidStack.loadFluidStackFromNBT(fluidTag);
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return currenttip;
|
||||
|
||||
if (fluid != null)
|
||||
currenttip.add(fluid.getFluid().getLocalizedName());
|
||||
else
|
||||
currenttip.add(LangUtil.translateG("hud.msg.empty"));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package mcp.mobius.waila.addons.thermalexpansion;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
@@ -22,18 +24,35 @@ public class HUDHandlerConduitItem implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (accessor.getNBTData().hasKey("Mode") && accessor.getNBTInteger(accessor.getNBTData(), "Mode") != 0){
|
||||
int mode = accessor.getNBTInteger(accessor.getNBTData(), "Mode");
|
||||
if (!config.getConfig("thermalexpansion.conditemmode")) return currenttip;
|
||||
|
||||
boolean found = false;
|
||||
int mode = -1;
|
||||
|
||||
if (!accessor.getNBTData().hasKey("parts")) return currenttip;
|
||||
NBTTagList parts = accessor.getNBTData().getTagList("parts");
|
||||
for (int i = 0; i < parts.tagCount(); i++){
|
||||
NBTTagCompound subtag = (NBTTagCompound)parts.tagAt(i);
|
||||
String id = subtag.getString("id");
|
||||
|
||||
if (mode == 1)
|
||||
currenttip.add("Mode : \u00a7fDense");
|
||||
else if (mode == 2)
|
||||
currenttip.add("Mode : \u00a7fVacuum");
|
||||
else if (mode == 3)
|
||||
currenttip.add("Mode : \u00a7fRound-Robin");
|
||||
else
|
||||
currenttip.add("Mode : <UNKNOWN>");
|
||||
}
|
||||
if (id.contains("ConduitItem")){
|
||||
mode = accessor.getNBTInteger(subtag, "Mode");
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return currenttip;
|
||||
|
||||
if (mode == 0){}
|
||||
else if (mode == 1)
|
||||
currenttip.add("Mode : \u00a7fDense");
|
||||
else if (mode == 2)
|
||||
currenttip.add("Mode : \u00a7fVacuum");
|
||||
else if (mode == 3)
|
||||
currenttip.add("Mode : \u00a7fRound-Robin");
|
||||
else
|
||||
currenttip.add("Mode : <UNKNOWN>");
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -20,16 +20,18 @@ public class ThermalExpansionModule {
|
||||
public static Method TileTank_getTankCapacity = null;
|
||||
public static Field TileTank_mode = null;
|
||||
|
||||
public static Class TileConduitFluid = null;
|
||||
public static Method TileConduitFluid_getRenderFluid = null;
|
||||
public static Method TileConduitFluid_getRenderFluidLevel = null;
|
||||
//public static Class TileConduitFluid = null;
|
||||
//public static Method TileConduitFluid_getRenderFluid = null;
|
||||
//public static Method TileConduitFluid_getRenderFluidLevel = null;
|
||||
|
||||
public static Class TileConduitItems = null;
|
||||
//public static Class TileConduitItems = null;
|
||||
|
||||
public static Class TileTesseract = null;
|
||||
|
||||
public static Class ISecureTile = null;
|
||||
|
||||
public static Class BlockMultipart = null;
|
||||
|
||||
//public static Field TileTesseract_modItem = null;
|
||||
//public static Field TileTesseract_modFluid = null;
|
||||
//public static Field TileTesseract_modEnergy = null;
|
||||
@@ -59,16 +61,17 @@ public class ThermalExpansionModule {
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_mode = TileTank.getField("mode");
|
||||
|
||||
TileConduitFluid = Class.forName("thermalexpansion.block.conduit.fluid.TileConduitFluid");
|
||||
TileConduitFluid_getRenderFluid = TileConduitFluid.getMethod("getRenderFluid");
|
||||
TileConduitFluid_getRenderFluidLevel = TileConduitFluid.getMethod("getRenderFluidLevel");
|
||||
|
||||
TileConduitItems = Class.forName("thermalexpansion.block.conduit.item.TileConduitItem");
|
||||
//TileConduitFluid = Class.forName("thermalexpansion.block.conduit.fluid.TileConduitFluid");
|
||||
//TileConduitFluid_getRenderFluid = TileConduitFluid.getMethod("getRenderFluid");
|
||||
//TileConduitFluid_getRenderFluidLevel = TileConduitFluid.getMethod("getRenderFluidLevel");
|
||||
//TileConduitItems = Class.forName("thermalexpansion.block.conduit.item.TileConduitItem");
|
||||
|
||||
TileTesseract = Class.forName("thermalexpansion.block.tesseract.TileTesseract");
|
||||
|
||||
ISecureTile = Class.forName("cofh.api.tileentity.ISecureTile");
|
||||
|
||||
BlockMultipart = Class.forName("codechicken.multipart.BlockMultipart");
|
||||
|
||||
//TileTesseract_modItem = TileTesseract.getField("modItem");
|
||||
//TileTesseract_modFluid = TileTesseract.getField("modFluid");
|
||||
//TileTesseract_modEnergy = TileTesseract.getField("modEnergy");
|
||||
@@ -94,30 +97,28 @@ public class ThermalExpansionModule {
|
||||
// return;
|
||||
}
|
||||
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
|
||||
ExternalModulesHandler.instance().addConfig("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.conditemmode");
|
||||
ExternalModulesHandler.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tesssendrecv");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tessfreq");
|
||||
ExternalModulesHandler.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.owner");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidtype");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.fluidamount");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.conditemmode");
|
||||
ModuleRegistrar.instance().addConfig("Thermal Expansion", "thermalexpansion.tankmode");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tesssendrecv");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.tessfreq");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.owner");
|
||||
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyHandler);
|
||||
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), TileEnergyCell);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyHandler);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerTank(), TileTank);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTank(), TileTank);
|
||||
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitFluid(), TileConduitFluid);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTesseract(), TileTesseract);
|
||||
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitItem(), TileConduitItems);
|
||||
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
|
||||
//ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerConduitBase(), TileConduitBase);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerISecureTile(), ISecureTile);
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitFluid(), BlockMultipart);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerConduitItem(), BlockMultipart);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,16 @@ import java.util.List;
|
||||
|
||||
import codechicken.lib.lang.LangUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSilverfish;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
|
||||
@@ -31,11 +32,32 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
static int jukebox = Block.jukebox.blockID;
|
||||
static int cocoa = Block.cocoaPlant.blockID;
|
||||
static int netherwart = Block.netherStalk.blockID;
|
||||
|
||||
static int silverfish = Block.silverfish.blockID;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (blockID == silverfish){
|
||||
int metadata = accessor.getMetadata();
|
||||
switch(metadata){
|
||||
case 0:
|
||||
return new ItemStack(Block.stone);
|
||||
case 1:
|
||||
return new ItemStack(Block.cobblestone);
|
||||
case 2:
|
||||
return new ItemStack(Block.stoneBrick);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (blockID == redstone){
|
||||
return new ItemStack(Item.redstone);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,31 +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");
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), mobSpawnerID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), cropsID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), melonStemID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), pumpkinStemID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), carrotID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), potatoID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), leverID);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterIdle);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), repeaterActv);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorIdl);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), comparatorAct);
|
||||
ExternalModulesHandler.instance().registerHeadProvider(new HUDHandlerVanilla(), redstone);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), redstone);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), jukebox);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), cocoa);
|
||||
ExternalModulesHandler.instance().registerBodyProvider(new HUDHandlerVanilla(), netherwart);
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.spawntype");
|
||||
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.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");
|
||||
|
||||
ExternalModulesHandler.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
|
||||
IWailaDataProvider provider = new HUDHandlerVanilla();
|
||||
|
||||
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);
|
||||
|
||||
ModuleRegistrar.instance().registerDocTextFile("/mcp/mobius/waila/addons/vanillamc/WikiData.csv");
|
||||
|
||||
//ExternalModulesHandler.instance().registerBlockDecorator(new HUDDecoratorVanilla(), repeaterIdle);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
World getWorld();
|
||||
@@ -20,4 +21,5 @@ public interface IWailaDataAccessor {
|
||||
NBTTagCompound getNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
ForgeDirection getSide();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.addons;
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mcp.mobius.waila.addons;
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
+24
-7
@@ -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;
|
||||
@@ -13,6 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
public class DataAccessor implements IWailaDataAccessor {
|
||||
@@ -68,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;
|
||||
@@ -108,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;
|
||||
@@ -141,4 +153,9 @@ public class DataAccessor implements IWailaDataAccessor {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
+142
-73
@@ -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){
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
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;
|
||||
import mcp.mobius.waila.addons.enderio.EnderIOModule;
|
||||
import mcp.mobius.waila.addons.enderstorage.EnderStorageModule;
|
||||
import mcp.mobius.waila.addons.etb.ETBModule;
|
||||
import mcp.mobius.waila.addons.exu.ExtraUtilitiesModule;
|
||||
import mcp.mobius.waila.addons.gravestone.GravestoneModule;
|
||||
import mcp.mobius.waila.addons.ic2.IC2Module;
|
||||
import mcp.mobius.waila.addons.openblocks.OpenBlocksModule;
|
||||
import mcp.mobius.waila.addons.projectred.ProjectRedModule;
|
||||
import mcp.mobius.waila.addons.railcraft.RailcraftModule;
|
||||
import mcp.mobius.waila.addons.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;
|
||||
|
||||
@@ -53,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());
|
||||
|
||||
@@ -69,12 +76,13 @@ 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);
|
||||
|
||||
this.registerMods();
|
||||
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerWaila(), Block.class);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerWaila(), Block.class);
|
||||
ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMods(){
|
||||
|
||||
HUDHandlerVanilla.register();
|
||||
@@ -116,7 +124,16 @@ public class ProxyClient extends ProxyServer {
|
||||
BCPowerAPIModule.register();
|
||||
|
||||
/* ProjectRed API */
|
||||
ProjectRedModule.register();
|
||||
ProjectRedModule.register();
|
||||
|
||||
/* ExtraUtilities */
|
||||
ExtraUtilitiesModule.register();
|
||||
|
||||
/* OpenBlocks */
|
||||
OpenBlocksModule.register();
|
||||
|
||||
/* Railcraft */
|
||||
RailcraftModule.register();
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+18
-18
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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,179 +0,0 @@
|
||||
package mcp.mobius.waila.handlers.hud;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.WailaExceptionHandler;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.api.IWailaBlock;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.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 {
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (IWailaBlock.class.isInstance(block)){
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaStack(accessor, ConfigHandler.instance());
|
||||
}catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, block.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
|
||||
if(ExternalModulesHandler.instance().hasStackProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
|
||||
try{
|
||||
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
return retval;
|
||||
}catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
if (accessor.getTileEntity() != null && mod_Waila.instance.serverPresent && (System.currentTimeMillis() - accessor.timeLastUpdate >= 250) ){
|
||||
accessor.timeLastUpdate = System.currentTimeMillis();
|
||||
PacketDispatcher.sendPacketToServer(Packet0x01TERequest.create(world, mop));
|
||||
}
|
||||
|
||||
if (IWailaBlock.class.isInstance(block)){
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
if (layout == Layout.HEADER)
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
|
||||
}
|
||||
else if (layout == Layout.BODY)
|
||||
try{
|
||||
return ((IWailaBlock)block).getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
|
||||
}
|
||||
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 (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(blockID))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(blockID))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(blockID)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(blockID))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(block))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(block))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(block)){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(block))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(accessor.getTileEntity())){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(accessor.getTileEntity()))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(accessor.getTileEntity())){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(accessor.getTileEntity()))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(accessor.getTileEntity())){
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(accessor.getTileEntity()))
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user