mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-17 19:15:19 +00:00
Compare commits
63
Commits
v1.5.7_1.7.10
...
latest
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66759201a1 | ||
|
|
aa093a4174 | ||
|
|
2431509d41 | ||
|
|
156c9f3905 | ||
|
|
a1f4378fe7 | ||
|
|
af42a25d2e | ||
|
|
07b0b83f4a | ||
|
|
d932d91a77 | ||
|
|
87261267e1 | ||
|
|
7af9692632 | ||
|
|
1eb78112eb | ||
|
|
4ed103dd25 | ||
|
|
118bab5a2b | ||
|
|
ce6474fc29 | ||
|
|
cbeb3b3628 | ||
|
|
d27d6db57c | ||
|
|
e60974ab20 | ||
|
|
f481e46fb2 | ||
|
|
7638322f7f | ||
|
|
0afbc6efb4 | ||
|
|
6d97a3a595 | ||
|
|
737c4e2cbf | ||
|
|
f4f5920d88 | ||
|
|
ea95fadb78 | ||
|
|
77277c6024 | ||
|
|
0b85d18865 | ||
|
|
9d0b942667 | ||
|
|
caf8cf7e7b | ||
|
|
01546d40e9 | ||
|
|
6d6e7616e4 | ||
|
|
1c2af8da33 | ||
|
|
197305bf78 | ||
|
|
8483573146 | ||
|
|
a05c6aa6d7 | ||
|
|
28196d451e | ||
|
|
e83009414e | ||
|
|
46b0f19572 | ||
|
|
730f57be90 | ||
|
|
6f30e64849 | ||
|
|
156e672dbc | ||
|
|
fdd401469e | ||
|
|
2b5eb13f83 | ||
|
|
0476bca1bf | ||
|
|
f46ac15842 | ||
|
|
616e02e047 | ||
|
|
e74174aff7 | ||
|
|
38fa57823e | ||
|
|
7d1c25872c | ||
|
|
f9f2c4041e | ||
|
|
9050654e42 | ||
|
|
14bee7ab58 | ||
|
|
a63dc221ba | ||
|
|
6bba5f1e7e | ||
|
|
eae1de6698 | ||
|
|
ef7812c64d | ||
|
|
8924997fa0 | ||
|
|
9f6e79c467 | ||
|
|
08db0ed7fd | ||
|
|
adcc7783a8 | ||
|
|
b686bb431c | ||
|
|
7251015c3a | ||
|
|
ff8980089a | ||
|
|
4132d2941b |
No files matched your search
@@ -0,0 +1,9 @@
|
||||
directory="run/crash-reports"
|
||||
if [ -d $directory ]; then
|
||||
echo "Crash reports detected:"
|
||||
cat $directory/*
|
||||
exit 1
|
||||
else
|
||||
echo "No crash reports detected"
|
||||
exit 0
|
||||
fi
|
||||
@@ -0,0 +1,45 @@
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main ]
|
||||
push:
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Setup the workspace
|
||||
run: ./gradlew setupCIWorkspace
|
||||
|
||||
- name: Build the mod
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Run server for 1 minute
|
||||
run: |
|
||||
mkdir run
|
||||
echo "eula=true" > run/eula.txt
|
||||
timeout 10 ./gradlew runServer || true
|
||||
|
||||
- name: Test no crashes happend
|
||||
run: |
|
||||
chmod +x .github/scripts/test-no-crash-reports.sh
|
||||
.github/scripts/test-no-crash-reports.sh
|
||||
@@ -0,0 +1,44 @@
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Release latest build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set release version
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Setup the workspace
|
||||
run: ./gradlew setupCIWorkspace
|
||||
|
||||
- name: Build the mod
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Update latest tag
|
||||
uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
automatic_release_tag: "latest"
|
||||
prerelease: false
|
||||
title: "Latest build"
|
||||
files: build/libs/*.jar
|
||||
@@ -0,0 +1,45 @@
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Release tagged build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set release version
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Setup the workspace
|
||||
run: ./gradlew setupCIWorkspace
|
||||
|
||||
- name: Build the mod
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Release under current tag
|
||||
uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
|
||||
prerelease: false
|
||||
title: "${{ env.RELEASE_VERSION }}"
|
||||
files: build/libs/*.jar
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
.gradle
|
||||
.settings
|
||||
/.idea/
|
||||
/run/
|
||||
/build/
|
||||
/eclipse/
|
||||
.classpath
|
||||
.project
|
||||
/bin/
|
||||
/config/
|
||||
/crash-reports/
|
||||
/logs/
|
||||
options.txt
|
||||
/saves/
|
||||
usernamecache.json
|
||||
banned-ips.json
|
||||
banned-players.json
|
||||
eula.txt
|
||||
ops.json
|
||||
server.properties
|
||||
servers.dat
|
||||
usercache.json
|
||||
whitelist.json
|
||||
/out/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
src/main/resources/mixins.*.json
|
||||
@@ -1,25 +0,0 @@
|
||||
28ccc9a07b5421f7e529c417b9baf0cf0a384d9f v1.2.0
|
||||
38f148ebeb8f6cfbdbaff0afc93612eb297188cd v1.3.1
|
||||
4a92f4e3296c1b64557ecf30023c61badf598a3e 1.3.2
|
||||
8ee781ebab6c82631601fee3dc1fb4d3a03f9351 1.3.3
|
||||
2f6144f8e55ca2f0fa6ccbbee707ca58f5e75c80 1.3.4
|
||||
45e01e7ee1a8e1587832e388584fd102672066ae 1.3.8_1.6.2
|
||||
1e7cde94ccceb8c1425a03c90fe2523afbe20d53 1.3.9_1.6.2
|
||||
02ebbb4aeebe23b3eaaded32bda20dad2fe14381 Nightly_131024
|
||||
bc4937f3a7d4c8eef31b8273cab6e043a8b354ef Nightly_131025
|
||||
246642120b36fb05ed2682ef79e7b48020edf21d Nightly_131116
|
||||
9280666656c77770a35c2797129f9fb806ed6367 Nightly_13111
|
||||
d2ec5e84d19f679d5b482112ed1fab4cb4d0b427 Nightly_131118
|
||||
c7e3d16cb236195aaa6d978fe15706d63831a4e2 Nightly_131121a
|
||||
e8b1906c3f51a14a12539850404b4622311b936b v1.4.0
|
||||
f9daea609042db35e35989da99a1c4c8696eb8ab 1.4.1
|
||||
1c391d52f3d955eebe3437d81dd8eca8ca142a8c 1.4.3
|
||||
7ff010d0fad85eb59eca7f1bc6583a6dada6ef8d 1.4.5
|
||||
5dd753fa7c80d22c3526714d48cf9c3a01918dec 1.4.5a
|
||||
1066f782daede2a968ec282d4e3eba5a6ec74a53 Waila_1.5.0_dev2
|
||||
ad46f8b41bbe08c95a6ae4a6c609be96196148ca Waila_1.5.0
|
||||
<<<<<<< local
|
||||
be89d97648acdc95afe1f7fea6a190641ae629d5 v1.5.2
|
||||
=======
|
||||
bb4fc720238a6545946c35de78e417141625a69c v1.4.5_1.7.2
|
||||
>>>>>>> other
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 77 KiB |
+460
-108
@@ -1,153 +1,505 @@
|
||||
//version: eb0b030ab9cb1d0f9a31f11e69e1ceed1dab2c89
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||
*/
|
||||
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
url = "https://maven.minecraftforge.net"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
maven {
|
||||
name = "Scala CI dependencies"
|
||||
url = "https://repo1.maven.org/maven2/"
|
||||
}
|
||||
maven {
|
||||
name = "jitpack"
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'idea'
|
||||
id 'scala'
|
||||
id("org.ajoberstar.grgit") version("3.1.1")
|
||||
id("com.github.johnrengelman.shadow") version("4.0.4")
|
||||
id("com.palantir.git-version") version("0.12.3")
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(projectJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
inheritOutputDirs = true
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
}
|
||||
}
|
||||
|
||||
checkPropertyExists("modName")
|
||||
checkPropertyExists("modId")
|
||||
checkPropertyExists("modGroup")
|
||||
checkPropertyExists("autoUpdateBuildScript")
|
||||
checkPropertyExists("minecraftVersion")
|
||||
checkPropertyExists("forgeVersion")
|
||||
checkPropertyExists("replaceGradleTokenInFile")
|
||||
checkPropertyExists("gradleTokenModId")
|
||||
checkPropertyExists("gradleTokenModName")
|
||||
checkPropertyExists("gradleTokenVersion")
|
||||
checkPropertyExists("gradleTokenGroupName")
|
||||
checkPropertyExists("apiPackage")
|
||||
checkPropertyExists("accessTransformersFile")
|
||||
checkPropertyExists("usesMixins")
|
||||
checkPropertyExists("mixinPlugin")
|
||||
checkPropertyExists("mixinsPackage")
|
||||
checkPropertyExists("coreModClass")
|
||||
checkPropertyExists("containsMixinsAndOrCoreModOnly")
|
||||
checkPropertyExists("usesShadowedDependencies")
|
||||
checkPropertyExists("developmentEnvironmentUserName")
|
||||
|
||||
def checkPropertyExists(String propertyName) {
|
||||
if (project.hasProperty(propertyName) == false) {
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
|
||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
}
|
||||
|
||||
if(apiPackage) {
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
}
|
||||
}
|
||||
|
||||
if(accessTransformersFile) {
|
||||
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
|
||||
if(new File(targetFile).exists() == false) {
|
||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||
}
|
||||
}
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
|
||||
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
|
||||
}
|
||||
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||
}
|
||||
|
||||
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
|
||||
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||
if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||
}
|
||||
}
|
||||
|
||||
if(coreModClass) {
|
||||
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
|
||||
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||
if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) {
|
||||
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
|
||||
|
||||
// Make sure GregTech build won't time out
|
||||
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
|
||||
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
|
||||
}
|
||||
|
||||
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
|
||||
'git config core.fileMode false'.execute()
|
||||
// Pulls version from git tag
|
||||
version = minecraftVersion + "-" + gitVersion()
|
||||
group = modGroup
|
||||
archivesBaseName = modId
|
||||
|
||||
minecraft {
|
||||
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
|
||||
runDir = "run"
|
||||
|
||||
if (replaceGradleTokenInFile) {
|
||||
replaceIn replaceGradleTokenInFile
|
||||
if(gradleTokenModId) {
|
||||
replace gradleTokenModId, modId
|
||||
}
|
||||
if(gradleTokenModName) {
|
||||
replace gradleTokenModName, modName
|
||||
}
|
||||
if(gradleTokenVersion) {
|
||||
replace gradleTokenVersion, versionDetails().lastTag
|
||||
}
|
||||
if(gradleTokenGroupName) {
|
||||
replace gradleTokenGroupName, modGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(file("addon.gradle").exists()) {
|
||||
apply from: "addon.gradle"
|
||||
}
|
||||
|
||||
apply from: 'repositories.gradle'
|
||||
|
||||
configurations {
|
||||
deployerJars
|
||||
//packed
|
||||
//compile.extendsFrom packed
|
||||
implementation.extendsFrom(shadowImplementation)
|
||||
}
|
||||
|
||||
//add dependency repositories
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "chickenbones"
|
||||
url = "http://chickenbones.net/maven/"
|
||||
name = "Overmind forge repo mirror"
|
||||
url = "https://gregtech.overminddl1.com/"
|
||||
}
|
||||
if(usesMixins.toBoolean()) {
|
||||
maven {
|
||||
name = "sponge"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'forge'
|
||||
apply plugin: 'maven'
|
||||
|
||||
version = "1.5.7_1.7.10"
|
||||
group= "mcp.mobius.waila" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "Waila"
|
||||
|
||||
// Define properties file
|
||||
ext.configFile = file "build.properties"
|
||||
|
||||
configFile.withReader {
|
||||
// Load config. It shall from now be referenced as simply config or project.config
|
||||
def prop = new Properties()
|
||||
prop.load(it)
|
||||
project.ext.config = new ConfigSlurper().parse prop
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:dev"
|
||||
compile "codechicken:CodeChickenCore:${config.mc_version}-${config.ccc_version}:dev"
|
||||
compile "codechicken:NotEnoughItems:${config.mc_version}-${config.nei_version}:dev"
|
||||
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.2.1264"
|
||||
runDir = "eclipse"
|
||||
}
|
||||
|
||||
def root = project.projectDir.parentFile
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir new File(root, "src")
|
||||
if(usesMixins.toBoolean()) {
|
||||
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||
// using 0.8 to workaround a issue in 0.7 which fails mixin application
|
||||
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: "launchwrapper"
|
||||
exclude module: "guava"
|
||||
exclude module: "gson"
|
||||
exclude module: "commons-io"
|
||||
exclude module: "log4j-core"
|
||||
}
|
||||
resources {
|
||||
srcDir new File(root, "resources")
|
||||
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'dependencies.gradle'
|
||||
|
||||
def mixinConfigJson = "mixins." + modId + ".json"
|
||||
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
|
||||
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
|
||||
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
|
||||
|
||||
task generateAssets {
|
||||
if(usesMixins.toBoolean()) {
|
||||
new File(projectDir.toString() + "/src/main/resources/", mixinConfigJson).text = """{
|
||||
"required": true,
|
||||
"minVersion": "0.7.11",
|
||||
"package": "${modGroup}.${mixinsPackage}",
|
||||
"plugin": "${modGroup}.${mixinPlugin}",
|
||||
"refmap": "${mixingConfigRefMap}",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
task relocateShadowJar(type: ConfigureShadowRelocation) {
|
||||
target = tasks.shadowJar
|
||||
prefix = modGroup + ".shadow"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
|
||||
minimize() // This will only allow shading for actually used classes
|
||||
configurations = [project.configurations.shadowImplementation]
|
||||
dependsOn(relocateShadowJar)
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
|
||||
if(usesShadowedDependencies.toBoolean()) {
|
||||
dependsOn(shadowJar)
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
reobf {
|
||||
if(usesMixins.toBoolean()) {
|
||||
addExtraSrgFile mixinSrg
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if(usesMixins.toBoolean()) {
|
||||
tasks.compileJava {
|
||||
options.compilerArgs += [
|
||||
"-AreobfSrgFile=${tasks.reobf.srg}",
|
||||
"-AoutSrgFile=${mixinSrg}",
|
||||
"-AoutRefMapFile=${refMap}",
|
||||
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
|
||||
"-XDenableSunApiLintControl",
|
||||
"-XDignore.symbol.file"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runClient {
|
||||
def arguments = []
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=../build/libs/$modId-${version}.jar",
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
}
|
||||
|
||||
if(developmentEnvironmentUserName) {
|
||||
arguments += [
|
||||
"--username",
|
||||
developmentEnvironmentUserName
|
||||
]
|
||||
}
|
||||
|
||||
args(arguments)
|
||||
}
|
||||
|
||||
runServer {
|
||||
def arguments = []
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=../build/libs/$modId-${version}.jar",
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
}
|
||||
|
||||
args(arguments)
|
||||
}
|
||||
|
||||
tasks.withType(JavaExec).configureEach {
|
||||
javaLauncher.set(
|
||||
javaToolchains.launcherFor {
|
||||
languageVersion = projectJavaVersion
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand "minecraftVersion": project.minecraft.version,
|
||||
"modVersion": versionDetails().lastTag,
|
||||
"modId": modId,
|
||||
"modName": modName
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
||||
|
||||
def getManifestAttributes() {
|
||||
def manifestAttributes = [:]
|
||||
if(containsMixinsAndOrCoreModOnly.toBoolean() == false) {
|
||||
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
|
||||
if(accessTransformersFile) {
|
||||
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
|
||||
}
|
||||
|
||||
if(coreModClass) {
|
||||
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
|
||||
}
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
manifestAttributes += [
|
||||
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"MixinConfigs" : mixinConfigJson,
|
||||
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
|
||||
]
|
||||
}
|
||||
return manifestAttributes
|
||||
}
|
||||
|
||||
//def commonManifest = {
|
||||
// attributes 'FMLCorePlugin': 'mcp.mobius.wailacore.asm.CoreDescription'
|
||||
// attributes 'FMLCorePluginContainsFMLMod': 'mcp.mobius.waila.Waila'
|
||||
//}
|
||||
|
||||
jar {
|
||||
exclude "**/client/gui/inventory/GuiContainer.class"
|
||||
exclude "**/client/gui/inventory/GuiContainer.java"
|
||||
|
||||
// manifest commonManifest
|
||||
|
||||
// from {
|
||||
// configurations.packed.collect {
|
||||
// it.isDirectory() ? it : zipTree(it).matching {
|
||||
// exclude "META-INF", "META-INF/**", "*META-INF*", "meta-inf"
|
||||
// exclude "**.jar", "**/*.jar", "*.jar"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
task sourcesJar(type: Jar) {
|
||||
from (sourceSets.main.allJava)
|
||||
from (file("$projectDir/LICENSE"))
|
||||
getArchiveClassifier().set('sources')
|
||||
}
|
||||
|
||||
task sourceJar(type: Jar) {
|
||||
from sourceSets.main.java
|
||||
from new File(root, "dev")
|
||||
classifier = 'sources'
|
||||
task shadowDevJar(type: ShadowJar) {
|
||||
from sourceSets.main.output
|
||||
getArchiveClassifier().set("dev")
|
||||
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
|
||||
minimize() // This will only allow shading for actually used classes
|
||||
configurations = [project.configurations.shadowImplementation]
|
||||
}
|
||||
|
||||
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
|
||||
target = tasks.shadowDevJar
|
||||
prefix = modGroup + ".shadow"
|
||||
}
|
||||
|
||||
task circularResolverJar(type: Jar) {
|
||||
dependsOn(relocateShadowDevJar)
|
||||
dependsOn(shadowDevJar)
|
||||
enabled = false
|
||||
}
|
||||
|
||||
task devJar(type: Jar) {
|
||||
from sourceSets.main.output
|
||||
classifier = 'dev'
|
||||
getArchiveClassifier().set("dev")
|
||||
|
||||
manifest {
|
||||
attributes(getManifestAttributes())
|
||||
}
|
||||
|
||||
if(usesShadowedDependencies.toBoolean()) {
|
||||
dependsOn(circularResolverJar)
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
task apiJar(type: Jar) {
|
||||
from (sourceSets.main.allJava) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**'
|
||||
}
|
||||
|
||||
from (sourceSets.main.output) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**'
|
||||
}
|
||||
|
||||
from (sourceSets.main.resources.srcDirs) {
|
||||
include("LICENSE")
|
||||
}
|
||||
|
||||
getArchiveClassifier().set('api')
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourceJar, devJar
|
||||
}
|
||||
|
||||
uploadArchives {
|
||||
dependsOn 'reobf'
|
||||
repositories.mavenDeployer {
|
||||
configuration = configurations.deployerJars
|
||||
repository(url: "scp://mobiusstrip.eu/home/mobius/web/maven"){
|
||||
authentication(userName: "mobius")
|
||||
}
|
||||
|
||||
pom {
|
||||
groupId = project.group
|
||||
version = project.version
|
||||
artifactId = project.archivesBaseName
|
||||
project {
|
||||
name project.archivesBaseName
|
||||
packaging 'jar'
|
||||
description 'Waila '
|
||||
url 'http://mobiusstrip.eu'
|
||||
}
|
||||
}
|
||||
archives sourcesJar
|
||||
archives devJar
|
||||
if(apiPackage) {
|
||||
archives apiJar
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Updating
|
||||
task updateBuildScript {
|
||||
doLast {
|
||||
if (updateBuildScript()) return
|
||||
|
||||
print("Build script already up-to-date!")
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewBuildScriptVersionAvailable()) {
|
||||
if (autoUpdateBuildScript.toBoolean()) {
|
||||
updateBuildScript()
|
||||
} else {
|
||||
println("Build script update available! Run 'gradle updateBuildScript'")
|
||||
}
|
||||
}
|
||||
|
||||
static URL availableBuildScriptUrl() {
|
||||
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
|
||||
}
|
||||
|
||||
static boolean updateBuildScript() {
|
||||
if (isNewBuildScriptVersionAvailable()) {
|
||||
def buildscriptFile = new File("build.gradle")
|
||||
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
|
||||
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
static boolean isNewBuildScriptVersionAvailable() {
|
||||
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
|
||||
|
||||
String currentBuildScript = new File("build.gradle").getText()
|
||||
String currentBuildScriptHash = getVersionHash(currentBuildScript)
|
||||
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
|
||||
String availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||
|
||||
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
|
||||
return !isUpToDate
|
||||
}
|
||||
|
||||
static String getVersionHash(String buildScriptContent) {
|
||||
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
|
||||
if(versionLine != null) {
|
||||
return versionLine.split(": ").last()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
configure(updateBuildScript) {
|
||||
group = 'forgegradle'
|
||||
description = 'Updates the build script to the latest version'
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
mc_version=1.7.10
|
||||
forge_version=10.13.0.1187
|
||||
ccl_version=1.1.1.106
|
||||
ccc_version=1.0.+
|
||||
nei_version=1.0.+
|
||||
mod_version=1.0
|
||||
waila_version=1.5.2a
|
||||
@@ -0,0 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev")
|
||||
|
||||
shadowImplementation("au.com.bytecode:opencsv:2.4")
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
modName = Waila
|
||||
|
||||
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
||||
modId = Waila
|
||||
|
||||
modGroup = mcp.mobius.waila
|
||||
|
||||
# WHY is there no version field?
|
||||
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
||||
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
||||
|
||||
# Will update your build.gradle automatically whenever an update is available
|
||||
autoUpdateBuildScript = false
|
||||
|
||||
minecraftVersion = 1.7.10
|
||||
forgeVersion = 10.13.4.1614
|
||||
|
||||
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
|
||||
# restart Minecraft in development. Choose this dependent on your mod:
|
||||
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
||||
developmentEnvironmentUserName = "Developer"
|
||||
|
||||
# Define a source file of your project with:
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...])
|
||||
# Leave these properties empty to skip individual token replacements
|
||||
replaceGradleTokenInFile = Waila.java
|
||||
gradleTokenModId =
|
||||
gradleTokenModName =
|
||||
gradleTokenVersion = GRADLETOKEN_VERSION
|
||||
gradleTokenGroupName =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
|
||||
# leave this property empty.
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
apiPackage = api
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
|
||||
# Example value: mymodid_at.cfg
|
||||
accessTransformersFile =
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage =
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatability only
|
||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass =
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
containsMixinsAndOrCoreModOnly = false
|
||||
|
||||
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
|
||||
# responsibility check the licence and request permission for distribution, if required.
|
||||
usesShadowedDependencies = true
|
||||
Vendored
BIN
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+100
@@ -0,0 +1,100 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,2 @@
|
||||
before_install:
|
||||
- ./gradlew setupCIWorkspace
|
||||
@@ -0,0 +1,7 @@
|
||||
// Add any additional repositiroes for your dependencies here
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<!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>
|
||||
@@ -1,12 +0,0 @@
|
||||
<!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>
|
||||
@@ -44,7 +44,7 @@ import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.client.KeyEvent;
|
||||
import mcp.mobius.waila.commands.CommandDumpHandlers;
|
||||
|
||||
@Mod(modid="Waila", name="Waila", version="1.5.7", dependencies="required-after:NotEnoughItems", acceptableRemoteVersions="*")
|
||||
@Mod(modid="Waila", name="Waila", version="GRADLETOKEN_VERSION", dependencies="after:NotEnoughItems@[1.0.4.0,)", acceptableRemoteVersions="*")
|
||||
/*
|
||||
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
|
||||
packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)")
|
||||
@@ -82,7 +82,8 @@ public class Waila {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
|
||||
MinecraftForge.EVENT_BUS.register(new DecoratorRenderer());
|
||||
FMLCommonHandler.instance().bus().register(new KeyEvent());
|
||||
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
|
||||
FMLCommonHandler.instance().bus().register(WailaTickHandler.instance());
|
||||
|
||||
}
|
||||
FMLCommonHandler.instance().bus().register(new NetworkHandler());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ExtraUtilitiesModule {
|
||||
|
||||
|
||||
try{
|
||||
Class ModExtraUtilities = Class.forName("extrautils.ExtraUtils");
|
||||
Class ModExtraUtilities = Class.forName("com.rwtema.extrautils.ExtraUtils");
|
||||
Waila.log.log(Level.INFO, "ExtraUtilities mod found.");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.INFO, "[ExtraUtilities] ExtraUtilities mod not found.");
|
||||
@@ -22,7 +22,7 @@ public class ExtraUtilitiesModule {
|
||||
}
|
||||
|
||||
try{
|
||||
TileEntityDrum = Class.forName("extrautils.tileentity.TileEntityDrum");
|
||||
TileEntityDrum = Class.forName("com.rwtema.extrautils.tileentity.TileEntityDrum");
|
||||
} catch (ClassNotFoundException e){
|
||||
Waila.log.log(Level.WARN, "[ExtraUtilities] Class not found. " + e);
|
||||
return;
|
||||
|
||||
@@ -31,6 +31,8 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider{
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
if (!config.getConfig("thaumcraft.aspects")) return currenttip;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Aspects")){
|
||||
NBTTagList taglist = tag.getTagList("Aspects", 10);
|
||||
@@ -83,16 +85,18 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider{
|
||||
}
|
||||
|
||||
for (Object o : tileAspects.keySet()){
|
||||
if (playerAspects.containsKey(o)){
|
||||
NBTTagCompound cmptag = new NBTTagCompound();
|
||||
cmptag.setString ("key", (String)ThaumcraftModule.Aspect_tag.get(o));
|
||||
cmptag.setInteger("value", (Integer) tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
} else {
|
||||
NBTTagCompound cmptag = new NBTTagCompound();
|
||||
cmptag.setString ("key", "???");
|
||||
cmptag.setInteger("value", (Integer) tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
if ((Integer) tileAspects.get(o) > 0){
|
||||
if (playerAspects.containsKey(o)){
|
||||
NBTTagCompound cmptag = new NBTTagCompound();
|
||||
cmptag.setString ("key", (String)ThaumcraftModule.Aspect_tag.get(o));
|
||||
cmptag.setInteger("value", (Integer) tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
} else {
|
||||
NBTTagCompound cmptag = new NBTTagCompound();
|
||||
cmptag.setString ("key", "???");
|
||||
cmptag.setInteger("value", (Integer) tileAspects.get(o));
|
||||
aspects.appendTag(cmptag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Lordmau5 on 28.02.2015.
|
||||
*/
|
||||
public class HUDHandlerDuct 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("thermaldynamics.fluiductsFluid")) return currenttip;
|
||||
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(accessor.getNBTData());
|
||||
|
||||
String name = "";
|
||||
|
||||
try{
|
||||
name += String.format(" < %s >", fluid.getFluid().getLocalizedName(fluid));
|
||||
} catch (NullPointerException f){
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
}
|
||||
|
||||
currenttip.add(name);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermaldynamics.fluiductsAmount")) return currenttip;
|
||||
|
||||
int amount = 0;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
if (tag.hasKey("Amount"))
|
||||
amount = accessor.getNBTInteger(tag, "Amount");
|
||||
|
||||
currenttip.add(String.format(" %d / 1000 mB", amount));
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package mcp.mobius.waila.addons.thermaldynamics;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public class ThermalDynamicsModule {
|
||||
|
||||
public static Class TileFluidDuct = null;
|
||||
|
||||
public static void register(){
|
||||
// XXX : We register the Fluiduct
|
||||
try{
|
||||
TileFluidDuct = Class.forName("cofh.thermaldynamics.ducts.fluid.TileFluidDuct");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsFluid");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Dynamics", "thermaldynamics.fluidDuctsAmount");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerDuct(), TileFluidDuct);
|
||||
ModuleRegistrar.instance().registerNBTProvider (new HUDHandlerDuct(), TileFluidDuct);
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks." + e);
|
||||
}
|
||||
|
||||
// XXX : We register the IBlockInfo interface
|
||||
/*
|
||||
try{
|
||||
IBlockInfo = Class.forName("cofh.api.block.IBlockInfo");
|
||||
IBlockInfo_getBlockInfo = IBlockInfo.getMethod("getBlockInfo", IBlockAccess.class, int.class, int.class, int.class, ForgeDirection.class, EntityPlayer.class, List.class, boolean.class);
|
||||
|
||||
|
||||
//ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIBlockInfo(), IBlockInfo);
|
||||
ModuleRegistrar.instance().registerNBTProvider (new HUDHandlerIBlockInfo(), IBlockInfo);
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading IBlockInfo hooks." + e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
public class HUDHandlerCache 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("thermalexpansion.cache"))
|
||||
return currenttip;
|
||||
try {
|
||||
ItemStack storedItem = null;
|
||||
if(accessor.getNBTData().hasKey("Item"))
|
||||
storedItem = readItemStack(accessor.getNBTData().getCompoundTag("Item"));
|
||||
|
||||
String name = currenttip.get(0);
|
||||
String color = "";
|
||||
if(name.startsWith("\u00a7"))
|
||||
color = name.substring(0, 2);
|
||||
|
||||
if(storedItem != null) {
|
||||
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
|
||||
name += String.format(" < " + SpecialChars.getRenderString("waila.stack", "1", namex, "0", String.valueOf(storedItem.getItemDamage())) + color + " %s >", storedItem.getDisplayName());
|
||||
}
|
||||
else
|
||||
name += " " + LangUtil.translateG("hud.msg.empty");
|
||||
|
||||
currenttip.set(0, name);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
if (!config.getConfig("thermalexpansion.cache"))
|
||||
return currenttip;
|
||||
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
ItemStack storedItem = null;
|
||||
if(tag.hasKey("Item"))
|
||||
storedItem = readItemStack(tag.getCompoundTag("Item"));
|
||||
|
||||
int stored = 0;
|
||||
int maxStored = 0;
|
||||
if(tag.hasKey("Stored"))
|
||||
stored = tag.getInteger("Stored");
|
||||
if(tag.hasKey("MaxStored"))
|
||||
maxStored = tag.getInteger("MaxStored");
|
||||
|
||||
if(storedItem != null) {
|
||||
currenttip.add("Stored: " + stored + "/" + maxStored);
|
||||
}
|
||||
else
|
||||
currenttip.add("Capacity: " + maxStored);
|
||||
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if(te != null)
|
||||
te.writeToNBT(tag);
|
||||
try {
|
||||
tag.setInteger("MaxStored", (Integer) ThermalExpansionModule.TileCache_getMaxStored.invoke(te));
|
||||
tag.setInteger("Stored", (Integer) ThermalExpansionModule.TileCache_getStored.invoke(te));
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ItemStack readItemStack(NBTTagCompound tag) {
|
||||
ItemStack is = new ItemStack(Item.getItemById(tag.getShort("id")));
|
||||
is.stackSize = tag.getInteger("Count");
|
||||
is.setItemDamage(Math.max(0, tag.getShort("Damage")));
|
||||
if (tag.hasKey("tag", 10)) {
|
||||
is.stackTagCompound = tag.getCompoundTag("tag");
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
public class HUDHandlerIBlockInfo 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) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
try{
|
||||
List info = new ArrayList();
|
||||
Block block = world.getBlock(x, y, z);
|
||||
ThermalExpansionModule.IBlockInfo_getBlockInfo.invoke(block, world, x, y, z, ForgeDirection.UNKNOWN, player, info, false);
|
||||
|
||||
for (Object i : info){
|
||||
System.out.printf("%s\n", i);
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,7 +70,6 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
tag.setInteger("MaxStorage", maxsto);
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
+50
-11
@@ -1,14 +1,13 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class ThermalExpansionModule {
|
||||
|
||||
public static Class IEnergyProvider = null;
|
||||
@@ -41,9 +40,17 @@ public class ThermalExpansionModule {
|
||||
public static Class ISecureTile = null;
|
||||
public static Method ISecureTile_getAccess = null;
|
||||
public static Method ISecureTile_getOwnerName = null;
|
||||
|
||||
public static Class TileCache = null;
|
||||
public static Method TileCache_getItemStack = null;
|
||||
public static Method TileCache_getMaxStored = null;
|
||||
public static Method TileCache_getStored = null;
|
||||
|
||||
public static Class BlockMultipart = null;
|
||||
|
||||
public static Class IBlockInfo = null;
|
||||
public static Method IBlockInfo_getBlockInfo = null;
|
||||
|
||||
public static void register(){
|
||||
// XXX : We register the Energy interface first
|
||||
try{
|
||||
@@ -70,15 +77,15 @@ public class ThermalExpansionModule {
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks." + e);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX : We register the energy cell
|
||||
try{
|
||||
TileEnergyCell = Class.forName("thermalexpansion.block.cell.TileCell");
|
||||
TileEnergyCell = Class.forName("cofh.thermalexpansion.block.cell.TileCell");
|
||||
TileEnergyCell_Recv = TileEnergyCell.getDeclaredField("energyReceive");
|
||||
TileEnergyCell_Send = TileEnergyCell.getDeclaredField("energySend");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energycell");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
ModuleRegistrar.instance().registerNBTProvider (new HUDHandlerEnergyCell(), TileEnergyCell);
|
||||
|
||||
@@ -88,7 +95,7 @@ public class ThermalExpansionModule {
|
||||
|
||||
// XXX : We register the Tank interface
|
||||
try{
|
||||
TileTank = Class.forName("thermalexpansion.block.tank.TileTank");
|
||||
TileTank = Class.forName("cofh.thermalexpansion.block.tank.TileTank");
|
||||
TileTank_getTankFluid = TileTank.getMethod("getTankFluid");
|
||||
TileTank_getTankCapacity = TileTank.getMethod("getTankCapacity");
|
||||
TileTank_getTankAmount = TileTank.getMethod("getTankFluidAmount");
|
||||
@@ -107,7 +114,7 @@ public class ThermalExpansionModule {
|
||||
|
||||
// XXX : We register the Tesseract interface
|
||||
try{
|
||||
TileTesseract = Class.forName("thermalexpansion.block.ender.TileTesseract");
|
||||
TileTesseract = Class.forName("cofh.thermalexpansion.block.ender.TileTesseract");
|
||||
TileTesseract_Item = TileTesseract.getDeclaredField("modeItem");
|
||||
TileTesseract_Fluid = TileTesseract.getDeclaredField("modeFluid");
|
||||
TileTesseract_Energy = TileTesseract.getDeclaredField("modeEnergy");
|
||||
@@ -135,7 +142,39 @@ public class ThermalExpansionModule {
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks." + e);
|
||||
}
|
||||
|
||||
// XXX : We register the Cache interface
|
||||
try{
|
||||
TileCache = Class.forName("cofh.thermalexpansion.block.cache.TileCache");
|
||||
TileCache_getItemStack = TileCache.getDeclaredMethod("getStoredItemType");
|
||||
TileCache_getMaxStored = TileCache.getDeclaredMethod("getMaxStoredCount");
|
||||
TileCache_getStored = TileCache.getDeclaredMethod("getStoredCount");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.cache");
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerCache(), TileCache);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerCache(), TileCache);
|
||||
ModuleRegistrar.instance().registerNBTProvider (new HUDHandlerCache(), TileCache);
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks." + e);
|
||||
}
|
||||
|
||||
// XXX : We register the IBlockInfo interface
|
||||
/*
|
||||
try{
|
||||
IBlockInfo = Class.forName("cofh.api.block.IBlockInfo");
|
||||
IBlockInfo_getBlockInfo = IBlockInfo.getMethod("getBlockInfo", IBlockAccess.class, int.class, int.class, int.class, ForgeDirection.class, EntityPlayer.class, List.class, boolean.class);
|
||||
|
||||
|
||||
//ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIBlockInfo(), IBlockInfo);
|
||||
ModuleRegistrar.instance().registerNBTProvider (new HUDHandlerIBlockInfo(), IBlockInfo);
|
||||
|
||||
} catch (Exception e){
|
||||
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading IBlockInfo hooks." + e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package mcp.mobius.waila.addons.vanillamc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
|
||||
public class HUDHandlerFurnace 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) {
|
||||
int cookTime = accessor.getNBTData().getShort("CookTime");
|
||||
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
|
||||
|
||||
String renderStr = "";
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString("waila.stack", "1", name, String.valueOf(stack.stackSize), String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(1));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString("waila.stack", "1", name, String.valueOf(stack.stackSize), String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
renderStr += SpecialChars.getRenderString("waila.progress", String.valueOf(cookTime), String.valueOf(200));
|
||||
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString("waila.stack", "1", name, String.valueOf(stack.stackSize), String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
currenttip.add(renderStr);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register(){
|
||||
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerFurnace(), TileEntityFurnace.class);
|
||||
//ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerFurnace(), TileEntityFurnace.class);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,9 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
static Block doubleplant = Blocks.double_plant;
|
||||
static Block leave = Blocks.leaves;
|
||||
static Block leave2 = Blocks.leaves2;
|
||||
static Block log = Blocks.log;
|
||||
static Block log2 = Blocks.log2;
|
||||
static Block quartz = Blocks.quartz_block;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
@@ -84,6 +87,14 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
return new ItemStack(block, 1, accessor.getMetadata() - 4);
|
||||
}
|
||||
|
||||
if (block == log || block == log2){
|
||||
return new ItemStack(block, 1, accessor.getMetadata()%4);
|
||||
}
|
||||
|
||||
if ((block == quartz) && (accessor.getMetadata() > 2)){
|
||||
return new ItemStack(block, 1, 2);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -228,6 +239,9 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, crops.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, leave.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, leave2.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, log.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, log2.getClass());
|
||||
ModuleRegistrar.instance().registerStackProvider(provider, quartz.getClass());
|
||||
|
||||
//ModuleRegistrar.instance().registerStackProvider(provider, Block.class);
|
||||
ModuleRegistrar.instance().registerHeadProvider(provider, mobSpawner.getClass());
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The Accessor is used to get some basic data out of the game without having to request direct access to the game engine.<br>
|
||||
* It will also return things that are unmodified by the overriding systems (like getWailaStack).<br>
|
||||
* Common accessor for both Entity and Block/TileEntity.<br>
|
||||
* Available data depends on what it is called upon (ie : getEntity() will return null if looking at a block, etc).<br>
|
||||
*
|
||||
*/
|
||||
public interface IWailaCommonAccessor {
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Block getBlock();
|
||||
int getBlockID();
|
||||
String getBlockQualifiedName();
|
||||
int getMetadata();
|
||||
TileEntity getTileEntity();
|
||||
Entity getEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
Vec3 getRenderingPosition();
|
||||
NBTTagCompound getNBTData();
|
||||
int getNBTInteger(NBTTagCompound tag, String keyname);
|
||||
double getPartialFrame();
|
||||
ForgeDirection getSide();
|
||||
ItemStack getStack();
|
||||
}
|
||||
@@ -18,12 +18,13 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
public interface IWailaDataAccessor{
|
||||
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
Block getBlock();
|
||||
int getBlockID();
|
||||
String getBlockQualifiedName();
|
||||
int getMetadata();
|
||||
TileEntity getTileEntity();
|
||||
MovingObjectPosition getPosition();
|
||||
|
||||
@@ -69,6 +69,8 @@ public interface IWailaRegistrar {
|
||||
@Deprecated
|
||||
public void registerSyncedNBTKey(String key, Class target);
|
||||
|
||||
public void registerTooltipRenderer(String name, IWailaTooltipRenderer renderer);
|
||||
|
||||
/* UNUSED FOR NOW (Will be used for the ingame wiki */
|
||||
//public void registerDocTextFile (String filename);
|
||||
//public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
|
||||
public interface IWailaTooltipRenderer {
|
||||
/**
|
||||
*
|
||||
* @param params Array of string parameters as passed to the RENDER arg in the tooltip ({rendername,param1,param2,...})
|
||||
* @param accessor A global accessor for TileEntities and Entities
|
||||
* @return Dimension of the reserved area
|
||||
*/
|
||||
Dimension getSize(String[] params, IWailaCommonAccessor accessor);
|
||||
|
||||
/**
|
||||
* Draw method for the renderer. The GL matrice is automatically moved to the top left of the reserved zone.<br>
|
||||
* All calls should be relative to (0,0)
|
||||
*
|
||||
* @param params Array of string parameters as passed to the RENDER arg in the tooltip ({rendername,param1,param2,...})
|
||||
* @param accessor A global accessor for TileEntities and Entities
|
||||
*/
|
||||
void draw (String[] params, IWailaCommonAccessor accessor);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package mcp.mobius.waila.api;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SpecialChars {
|
||||
|
||||
public static String MCStyle = "\u00A7";
|
||||
@@ -30,11 +35,36 @@ public class SpecialChars {
|
||||
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
public static String WailaRenderer = "\u00A6";
|
||||
public static String TAB = WailaStyle + WailaStyle +"a";
|
||||
public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b";
|
||||
public static String ALIGNCENTER = WailaStyle + WailaStyle +"c";
|
||||
public static String HEART = WailaStyle + WailaIcon +"a";
|
||||
public static String HHEART = WailaStyle + WailaIcon +"b";
|
||||
public static String EHEART = WailaStyle + WailaIcon +"c";
|
||||
public static String RENDER = WailaStyle + WailaRenderer +"a";
|
||||
|
||||
public static final Pattern patternMinecraft = Pattern.compile("(?i)" + MCStyle + "[0-9A-FK-OR]");
|
||||
public static final Pattern patternWaila = Pattern.compile("(?i)(" + WailaStyle + "(?<type>..))");
|
||||
public static final Pattern patternRender = Pattern.compile("(?i)(" + RENDER + "\\{(?<name>[^,}]*),?(?<args>[^}]*)\\})");
|
||||
public static final Pattern patternTab = Pattern.compile("(?i)" + TAB);
|
||||
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
|
||||
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
|
||||
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9a-z]))");
|
||||
public static final Pattern patternLineSplit = Pattern.compile("(?i)(" + WailaStyle + WailaStyle + "[^" + WailaStyle + "]+|" + WailaStyle + WailaIcon + "[0-9A-Z]|" + WailaStyle + WailaRenderer + "a\\{([^,}]*),?([^}]*)\\}|[^" + WailaStyle + "]+)");
|
||||
|
||||
/**
|
||||
* Helper method to get a proper RENDER string. Just put the name of the renderer and the params in, and it will give back a directly usable String for the tooltip.
|
||||
* @param name
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String getRenderString(String name, String... params){
|
||||
String result = RENDER + "{" + name;
|
||||
for (String s : params){
|
||||
result += "," + s;
|
||||
}
|
||||
result += "}";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,10 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Some accessor helpers */
|
||||
public boolean showTooltip(){
|
||||
return getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorBlock implements IWailaDataAccessor {
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public Block block;
|
||||
public int blockID;
|
||||
public int metadata;
|
||||
public TileEntity entity;
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
public ItemStack stack;
|
||||
|
||||
public static DataAccessorBlock instance = new DataAccessorBlock();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
//this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
//this.block = Block.blocksList[this.blockID];
|
||||
this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {}
|
||||
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNbt))
|
||||
return this.remoteNbt;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try{
|
||||
this.entity.writeToNBT(tag);
|
||||
} catch (Exception e){}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
if (tag == null){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("WailaX");
|
||||
int y = tag.getInteger("WailaY");
|
||||
int z = tag.getInteger("WailaZ");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide(){
|
||||
return ForgeDirection.getOrientation(this.getPosition().sideHit);
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor{
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public Block block;
|
||||
public int blockID;
|
||||
public String blockResource;
|
||||
public int metadata;
|
||||
public TileEntity tileEntity;
|
||||
public Entity entity;
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
public ItemStack stack;
|
||||
|
||||
public static DataAccessorCommon instance = new DataAccessorCommon();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
|
||||
if (this.mop.typeOfHit == MovingObjectType.BLOCK){
|
||||
this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = null;
|
||||
this.blockID = Block.getIdFromBlock(this.block);
|
||||
this.blockResource = GameData.getBlockRegistry().getNameForObject(this.block);
|
||||
try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {}
|
||||
|
||||
} else if (this.mop.typeOfHit == MovingObjectType.ENTITY){
|
||||
this.block = null;
|
||||
this.metadata = -1;
|
||||
this.tileEntity = null;
|
||||
this.stack = null;
|
||||
this.entity = _mop.entityHit;
|
||||
}
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {return this.world;}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {return this.player;}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {return this.block;}
|
||||
|
||||
@Override
|
||||
public int getBlockID() {return this.blockID;}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {return this.metadata;}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() { return this.tileEntity;}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {return this.entity;}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {return this.mop;}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {return this.renderingvec;}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt))
|
||||
return remoteNbt;
|
||||
|
||||
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt))
|
||||
return remoteNbt;
|
||||
|
||||
if (this.tileEntity != null){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try{
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
} catch (Exception e){}
|
||||
return tag;
|
||||
}
|
||||
|
||||
if (this.entity != null){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setNBTData(NBTTagCompound tag){
|
||||
this.remoteNbt = tag;
|
||||
}
|
||||
|
||||
private boolean isTagCorrectTileEntity(NBTTagCompound tag){
|
||||
if (tag == null || !tag.hasKey("WailaX")){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("WailaX");
|
||||
int y = tag.getInteger("WailaY");
|
||||
int z = tag.getInteger("WailaZ");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTagCorrectEntity(NBTTagCompound tag){
|
||||
if (tag == null || !tag.hasKey("WailaEntityID")){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int id = tag.getInteger("WailaEntityID");
|
||||
|
||||
if (id == this.entity.getEntityId())
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname) {
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide() {
|
||||
return ForgeDirection.getOrientation(this.getPosition().sideHit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockQualifiedName() {
|
||||
return this.blockResource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorEntity implements IWailaEntityAccessor {
|
||||
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public Entity entity;
|
||||
public NBTTagCompound remoteNbt = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
|
||||
public static DataAccessorEntity instance = new DataAccessorEntity();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.entity = _mop.entityHit;
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNbt))
|
||||
return this.remoteNbt;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
if (tag == null){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,16 +11,16 @@ import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorFMP implements IWailaFMPAccessor {
|
||||
|
||||
public String id;
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
public Vec3 renderingvec = null;
|
||||
public TileEntity entity;
|
||||
public NBTTagCompound partialNBT = null;
|
||||
public NBTTagCompound remoteNBT = null;
|
||||
public long timeLastUpdate = System.currentTimeMillis();
|
||||
public double partialFrame;
|
||||
String id;
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
TileEntity entity;
|
||||
NBTTagCompound partialNBT = null;
|
||||
NBTTagCompound remoteNBT = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
|
||||
public static DataAccessorFMP instance = new DataAccessorFMP();
|
||||
|
||||
|
||||
@@ -3,14 +3,18 @@ package mcp.mobius.waila.api.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaBlock;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.cbcore.Layout;
|
||||
import mcp.mobius.waila.network.Message0x01TERequest;
|
||||
import mcp.mobius.waila.network.Message0x03EntRequest;
|
||||
import mcp.mobius.waila.network.WailaPacketHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -20,22 +24,22 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public class MetaDataProvider{
|
||||
|
||||
private ArrayList<IWailaDataProvider> headBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> bodyBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
private ArrayList<IWailaDataProvider> tailBlockProviders = new ArrayList<IWailaDataProvider>();
|
||||
private Map<Integer, List<IWailaDataProvider>> headBlockProviders = new TreeMap<Integer, List<IWailaDataProvider>>();
|
||||
private Map<Integer, List<IWailaDataProvider>> bodyBlockProviders = new TreeMap<Integer, List<IWailaDataProvider>>();
|
||||
private Map<Integer, List<IWailaDataProvider>> tailBlockProviders = new TreeMap<Integer, List<IWailaDataProvider>>();
|
||||
|
||||
private ArrayList<IWailaEntityProvider> headEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
private ArrayList<IWailaEntityProvider> bodyEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
private ArrayList<IWailaEntityProvider> tailEntityProviders = new ArrayList<IWailaEntityProvider>();
|
||||
private Map<Integer, List<IWailaEntityProvider>> headEntityProviders = new TreeMap<Integer, List<IWailaEntityProvider>>();
|
||||
private Map<Integer, List<IWailaEntityProvider>> bodyEntityProviders = new TreeMap<Integer, List<IWailaEntityProvider>>();
|
||||
private Map<Integer, List<IWailaEntityProvider>> tailEntityProviders = new TreeMap<Integer, List<IWailaEntityProvider>>();
|
||||
|
||||
private Class prevBlock = null;
|
||||
private Class prevTile = null;
|
||||
|
||||
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor) {
|
||||
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
@@ -48,23 +52,25 @@ public class MetaDataProvider{
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
for (List<IWailaDataProvider> providerList : ModuleRegistrar.instance().getStackProviders(block).values()){
|
||||
for (IWailaDataProvider dataProvider : providerList){
|
||||
try{
|
||||
ItemStack retval = dataProvider.getWailaStack(accessor, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
return retval;
|
||||
}catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor, List<String> currenttip, Layout layout) {
|
||||
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List<String> currenttip, Layout layout) {
|
||||
Block block = accessor.getBlock();
|
||||
|
||||
if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250) && ConfigHandler.instance().showTooltip()){
|
||||
accessor.resetTimer();
|
||||
HashSet<String> keys = new HashSet<String>();
|
||||
|
||||
@@ -77,12 +83,12 @@ public class MetaDataProvider{
|
||||
if (keys.size() != 0 || ModuleRegistrar.instance().hasNBTProviders(block) || ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
|
||||
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
|
||||
|
||||
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
|
||||
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250) && ConfigHandler.instance().showTooltip()) {
|
||||
|
||||
try{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
accessor.getTileEntity().writeToNBT(tag);
|
||||
accessor.remoteNbt = tag;
|
||||
accessor.setNBTData(tag);
|
||||
} catch (Exception e){
|
||||
WailaExceptionHandler.handleErr(e, this.getClass().getName(), null);
|
||||
}
|
||||
@@ -117,54 +123,58 @@ public class MetaDataProvider{
|
||||
|
||||
/* Lookup by class (for blocks)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(block))
|
||||
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(block));
|
||||
headBlockProviders.putAll(ModuleRegistrar.instance().getHeadProviders(block));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(block))
|
||||
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(block));
|
||||
bodyBlockProviders.putAll(ModuleRegistrar.instance().getBodyProviders(block));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(block))
|
||||
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(block));
|
||||
tailBlockProviders.putAll(ModuleRegistrar.instance().getTailProviders(block));
|
||||
|
||||
|
||||
/* Lookup by class (for tileentities)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadProviders(accessor.getTileEntity()))
|
||||
headBlockProviders.addAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
|
||||
headBlockProviders.putAll(ModuleRegistrar.instance().getHeadProviders(accessor.getTileEntity()));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyProviders(accessor.getTileEntity()))
|
||||
bodyBlockProviders.addAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
|
||||
bodyBlockProviders.putAll(ModuleRegistrar.instance().getBodyProviders(accessor.getTileEntity()));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailProviders(accessor.getTileEntity()))
|
||||
tailBlockProviders.addAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
|
||||
tailBlockProviders.putAll(ModuleRegistrar.instance().getTailProviders(accessor.getTileEntity()));
|
||||
|
||||
/* Apply all collected providers */
|
||||
if (layout == Layout.HEADER)
|
||||
for (IWailaDataProvider dataProvider : headBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
for (List<IWailaDataProvider> providersList : headBlockProviders.values()){
|
||||
for (IWailaDataProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY)
|
||||
for (IWailaDataProvider dataProvider : bodyBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY)
|
||||
for (List<IWailaDataProvider> providersList : bodyBlockProviders.values()){
|
||||
for (IWailaDataProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
if (layout == Layout.FOOTER)
|
||||
for (IWailaDataProvider dataProvider : tailBlockProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
|
||||
for (List<IWailaDataProvider> providersList : tailBlockProviders.values()){
|
||||
for (IWailaDataProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorEntity accessor, List<String> currenttip, Layout layout) {
|
||||
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List<String> currenttip, Layout layout) {
|
||||
|
||||
if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
accessor.resetTimer();
|
||||
@@ -193,38 +203,44 @@ public class MetaDataProvider{
|
||||
|
||||
/* Lookup by class (for entities)*/
|
||||
if (layout == Layout.HEADER && ModuleRegistrar.instance().hasHeadEntityProviders(entity))
|
||||
headEntityProviders.addAll(ModuleRegistrar.instance().getHeadEntityProviders(entity));
|
||||
headEntityProviders.putAll(ModuleRegistrar.instance().getHeadEntityProviders(entity));
|
||||
|
||||
else if (layout == Layout.BODY && ModuleRegistrar.instance().hasBodyEntityProviders(entity))
|
||||
bodyEntityProviders.addAll(ModuleRegistrar.instance().getBodyEntityProviders(entity));
|
||||
bodyEntityProviders.putAll(ModuleRegistrar.instance().getBodyEntityProviders(entity));
|
||||
|
||||
else if (layout == Layout.FOOTER && ModuleRegistrar.instance().hasTailEntityProviders(entity))
|
||||
tailEntityProviders.addAll(ModuleRegistrar.instance().getTailEntityProviders(entity));
|
||||
tailEntityProviders.putAll(ModuleRegistrar.instance().getTailEntityProviders(entity));
|
||||
|
||||
/* Apply all collected providers */
|
||||
if (layout == Layout.HEADER)
|
||||
for (IWailaEntityProvider dataProvider : headEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
for (List<IWailaEntityProvider> providersList : headEntityProviders.values()){
|
||||
for (IWailaEntityProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaHead(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.BODY)
|
||||
for (IWailaEntityProvider dataProvider : bodyEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
for (List<IWailaEntityProvider> providersList : bodyEntityProviders.values()){
|
||||
for (IWailaEntityProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaBody(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
if (layout == Layout.FOOTER)
|
||||
for (IWailaEntityProvider dataProvider : tailEntityProviders)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
for (List<IWailaEntityProvider> providersList : tailEntityProviders.values()){
|
||||
for (IWailaEntityProvider dataProvider : providersList)
|
||||
try{
|
||||
currenttip = dataProvider.getWailaTail(entity, currenttip, accessor, ConfigHandler.instance());
|
||||
} catch (Throwable e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -21,6 +24,7 @@ import mcp.mobius.waila.api.IWailaFMPDecorator;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.IWailaSummaryProvider;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
|
||||
@@ -55,6 +59,8 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
|
||||
public LinkedHashMap<String, String> IMCRequests = new LinkedHashMap<String, String>();
|
||||
|
||||
public LinkedHashMap<String, IWailaTooltipRenderer> tooltipRenderers = new LinkedHashMap<String, IWailaTooltipRenderer>();
|
||||
|
||||
private ModuleRegistrar() {
|
||||
instance = this;
|
||||
}
|
||||
@@ -196,6 +202,9 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
}
|
||||
|
||||
private <T, V> void registerProvider(T dataProvider, V clazz, LinkedHashMap<V, ArrayList<T>> target) {
|
||||
if (clazz == null || dataProvider == null)
|
||||
throw new RuntimeException(String.format("Trying to register a null provider or null block ! Please check the stacktrace to know what was the original registration method. [Provider : %s, Target : %s]", dataProvider.getClass().getName(), clazz));
|
||||
|
||||
if (!target.containsKey(clazz))
|
||||
target.put(clazz, new ArrayList<T>());
|
||||
|
||||
@@ -214,83 +223,102 @@ public class ModuleRegistrar implements IWailaRegistrar {
|
||||
this.syncedNBTKeys.get(target).add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTooltipRenderer(String name, IWailaTooltipRenderer renderer){
|
||||
if (!this.tooltipRenderers.containsKey(name))
|
||||
this.tooltipRenderers.put(name, renderer);
|
||||
else
|
||||
Waila.log.warn(String.format("A renderer named %s already exists (Class : %s). Skipping new renderer.", name, renderer.getClass().getName()));
|
||||
}
|
||||
|
||||
/* PROVIDER GETTERS */
|
||||
|
||||
public ArrayList<IWailaDataProvider> getHeadProviders(Object block) {
|
||||
public Map<Integer, List<IWailaDataProvider>> getHeadProviders(Object block) {
|
||||
return getProviders(block, this.headBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getBodyProviders(Object block) {
|
||||
public Map<Integer, List<IWailaDataProvider>> getBodyProviders(Object block) {
|
||||
return getProviders(block, this.bodyBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getTailProviders(Object block) {
|
||||
public Map<Integer, List<IWailaDataProvider>> getTailProviders(Object block) {
|
||||
return getProviders(block, this.tailBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getStackProviders(Object block) {
|
||||
public Map<Integer, List<IWailaDataProvider>> getStackProviders(Object block) {
|
||||
return getProviders(block, this.stackBlockProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaDataProvider> getNBTProviders(Object block) {
|
||||
public Map<Integer, List<IWailaDataProvider>> getNBTProviders(Object block) {
|
||||
return getProviders(block, this.NBTDataProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getHeadEntityProviders(Object entity) {
|
||||
public Map<Integer, List<IWailaEntityProvider>> getHeadEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.headEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getBodyEntityProviders(Object entity) {
|
||||
public Map<Integer, List<IWailaEntityProvider>> getBodyEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.bodyEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getTailEntityProviders(Object entity) {
|
||||
public Map<Integer, List<IWailaEntityProvider>> getTailEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.tailEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getOverrideEntityProviders(Object entity) {
|
||||
public Map<Integer, List<IWailaEntityProvider>> getOverrideEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.overrideEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaEntityProvider> getNBTEntityProviders(Object entity) {
|
||||
public Map<Integer, List<IWailaEntityProvider>> getNBTEntityProviders(Object entity) {
|
||||
return getProviders(entity, this.NBTEntityProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getHeadFMPProviders(String name) {
|
||||
public Map<Integer, List<IWailaFMPProvider>> getHeadFMPProviders(String name) {
|
||||
return getProviders(name, this.headFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getBodyFMPProviders(String name) {
|
||||
public Map<Integer, List<IWailaFMPProvider>> getBodyFMPProviders(String name) {
|
||||
return getProviders(name, this.bodyFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPProvider> getTailFMPProviders(String name) {
|
||||
public Map<Integer, List<IWailaFMPProvider>> getTailFMPProviders(String name) {
|
||||
return getProviders(name, this.tailFMPProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaSummaryProvider> getSummaryProvider(Object item){
|
||||
public Map<Integer, List<IWailaSummaryProvider>> getSummaryProvider(Object item){
|
||||
return getProviders(item, this.summaryProviders);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaBlockDecorator> getBlockDecorators(Object block){
|
||||
public Map<Integer, List<IWailaBlockDecorator>> getBlockDecorators(Object block){
|
||||
return getProviders(block, this.blockClassDecorators);
|
||||
}
|
||||
|
||||
public ArrayList<IWailaFMPDecorator> getFMPDecorators(String name){
|
||||
public Map<Integer, List<IWailaFMPDecorator>> getFMPDecorators(String name){
|
||||
return getProviders(name, this.FMPClassDecorators);
|
||||
}
|
||||
|
||||
private <T> ArrayList<T> getProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
|
||||
ArrayList<T> returnList = new ArrayList<T>();
|
||||
for (Class clazz : target.keySet())
|
||||
public IWailaTooltipRenderer getTooltipRenderer(String name){
|
||||
return this.tooltipRenderers.get(name);
|
||||
}
|
||||
|
||||
private <T> Map<Integer, List<T>> getProviders(Object obj, LinkedHashMap<Class, ArrayList<T>> target){
|
||||
Map<Integer, List<T>> returnList = new TreeMap<Integer, List<T>>();
|
||||
Integer index = 0;
|
||||
|
||||
for (Class clazz : target.keySet()){
|
||||
if (clazz.isInstance(obj))
|
||||
returnList.addAll(target.get(clazz));
|
||||
|
||||
returnList.put(index, target.get(clazz));
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
private <T> ArrayList<T> getProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
|
||||
return target.get(name);
|
||||
private <T> Map<Integer, List<T>> getProviders(String name, LinkedHashMap<String, ArrayList<T>> target){
|
||||
Map<Integer, List<T>> returnList = new TreeMap<Integer, List<T>>();
|
||||
returnList.put(0, target.get(name));
|
||||
return returnList;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@API(apiVersion="1.1",owner="Waila",provides="WailaAPI")
|
||||
@API(apiVersion="1.2",owner="Waila",provides="WailaAPI")
|
||||
package mcp.mobius.waila.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -0,0 +1,6 @@
|
||||
package mcp.mobius.waila.cbcore;
|
||||
|
||||
public enum Layout
|
||||
{
|
||||
HEADER, BODY, FOOTER
|
||||
}
|
||||
@@ -4,17 +4,13 @@ import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
|
||||
import mcp.mobius.waila.handlers.nei.HandlerEnchants;
|
||||
import mcp.mobius.waila.overlay.RayTracing;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -32,7 +28,6 @@ public class KeyEvent {
|
||||
public static KeyBinding key_liquid;
|
||||
public static KeyBinding key_recipe;
|
||||
public static KeyBinding key_usage;
|
||||
static boolean firstInventory = true;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyEvent(KeyInputEvent event){
|
||||
@@ -60,11 +55,19 @@ public class KeyEvent {
|
||||
}
|
||||
|
||||
else if (key == key_recipe.getKeyCode()){
|
||||
this.openRecipeGUI(true);
|
||||
if (Loader.isModLoaded("NotEnoughItems")){
|
||||
try{
|
||||
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler").getDeclaredMethod("openRecipeGUI", boolean.class).invoke(null, true);
|
||||
} catch (Exception e){}
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == key_usage.getKeyCode()){
|
||||
this.openRecipeGUI(false);
|
||||
if (Loader.isModLoaded("NotEnoughItems")){
|
||||
try{
|
||||
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler").getDeclaredMethod("openRecipeGUI", boolean.class).invoke(null, false);
|
||||
} catch (Exception e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,8 +84,6 @@ public class KeyEvent {
|
||||
ClientRegistry.registerKeyBinding(KeyEvent.key_liquid);
|
||||
ClientRegistry.registerKeyBinding(KeyEvent.key_recipe);
|
||||
ClientRegistry.registerKeyBinding(KeyEvent.key_usage);
|
||||
GuiContainerManager.addInputHandler(new HandlerEnchants());
|
||||
API.addKeyBind(Constants.BIND_SCREEN_ENCH, Keyboard.KEY_I);
|
||||
|
||||
/*
|
||||
Minecraft.getMinecraft().gameSettings.keyBindings = (KeyBinding[])ArrayUtils.addAll(
|
||||
@@ -90,43 +91,4 @@ public class KeyEvent {
|
||||
Minecraft.getMinecraft().gameSettings.keyBindings);
|
||||
*/
|
||||
}
|
||||
|
||||
public void openRecipeGUI(boolean recipe){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
boolean uiResult;
|
||||
String msg;
|
||||
|
||||
if ((RayTracing.instance().getTarget() != null) && (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)){
|
||||
List<ItemStack> stacks = RayTracing.instance().getIdentifierItems();
|
||||
if (stacks.size() > 0){
|
||||
mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
|
||||
if (firstInventory){
|
||||
try {Thread.sleep(1000);} catch (Exception e){};
|
||||
firstInventory = false;
|
||||
}
|
||||
|
||||
if(recipe)
|
||||
if(!GuiCraftingRecipe.openRecipeGui("item", stacks.get(0).copy())){
|
||||
ItemStack target = stacks.get(0).copy();
|
||||
target.setItemDamage(0);
|
||||
if(!GuiCraftingRecipe.openRecipeGui("item", target)){
|
||||
mc.thePlayer.addChatMessage(new ChatComponentTranslation("\u00a7f\u00a7o" + LangUtil.translateG("client.msg.norecipe")));
|
||||
mc.displayGuiScreen((GuiScreen)null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipe)
|
||||
if(!GuiUsageRecipe.openRecipeGui("item", stacks.get(0).copy())){
|
||||
ItemStack target = stacks.get(0).copy();
|
||||
target.setItemDamage(0);
|
||||
if(!GuiUsageRecipe.openRecipeGui("item", target)){
|
||||
mc.thePlayer.addChatMessage(new ChatComponentTranslation("\u00a7f\u00a7o" + LangUtil.translateG("client.msg.nousage")));
|
||||
mc.displayGuiScreen((GuiScreen)null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,23 @@
|
||||
package mcp.mobius.waila.client;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.Waila;
|
||||
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.HUDHandlerBlocks;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerEntities;
|
||||
import mcp.mobius.waila.handlers.nei.ModNameFilter;
|
||||
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
//import mcp.mobius.waila.handlers.SummaryProviderDefault;
|
||||
import mcp.mobius.waila.handlers.nei.TooltipHandlerWaila;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
|
||||
public class ProxyClient extends ProxyServer {
|
||||
@@ -41,20 +38,16 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
//TickRegistry.registerTickHandler(WailaTickHandler.instance(), Side.CLIENT);
|
||||
|
||||
//GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NEWFILTERS, true))
|
||||
API.addSearchProvider(new ModNameFilter());
|
||||
|
||||
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
|
||||
//KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
|
||||
|
||||
// We mute the default keybind for displaying the tooltip
|
||||
NEIClientConfig.getSetting(Constants.BIND_NEI_SHOW).setIntValue(Keyboard.KEY_NONE);
|
||||
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(false);
|
||||
|
||||
//API.addKeyBind(Constants.BIND_WIKI, "Display wiki", Keyboard.KEY_RSHIFT);
|
||||
//API.addKeyBind(Constants.BIND_TECH, "Display techtree", Keyboard.KEY_RSHIFT);
|
||||
if (Loader.isModLoaded("NotEnoughItems")){
|
||||
try{
|
||||
Class.forName("mcp.mobius.waila.handlers.nei.NEIHandler").getDeclaredMethod("register").invoke(null);
|
||||
} catch (Exception e){
|
||||
Waila.log.error("Failed to hook into NEI properly. Reverting to Vanilla tooltip handler");
|
||||
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
|
||||
}
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.register(new VanillaTooltipHandler());
|
||||
}
|
||||
|
||||
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBlocks(), Block.class);
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerBlocks(), Block.class);
|
||||
@@ -64,9 +57,14 @@ public class ProxyClient extends ProxyServer {
|
||||
ModuleRegistrar.instance().registerTailProvider(new HUDHandlerEntities(), Entity.class);
|
||||
|
||||
//ModuleRegistrar.instance().registerShortDataProvider(new SummaryProviderDefault(), Item.class);
|
||||
|
||||
|
||||
ModuleRegistrar.instance().addConfig("General", "general.showents");
|
||||
ModuleRegistrar.instance().addConfig("General", "general.showhp");
|
||||
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
|
||||
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,10 +35,12 @@ public class FontHelper {
|
||||
private static String formatEscape = "\u00A7";
|
||||
|
||||
|
||||
/*
|
||||
public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY, float... rgba){
|
||||
drawString(s,x,y,font,scaleX,scaleY,0,rgba);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY, float rotationZ, float... rgba){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@@ -473,12 +473,11 @@ public class TrueTypeFont {
|
||||
return textureId.get(0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
throw new RuntimeException(e);
|
||||
//System.exit(-1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean isSupported(String fontname) {
|
||||
Font font[] = getFonts();
|
||||
for (int i = font.length-1; i >= 0; i--) {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package mcp.mobius.waila.gui.widgets;
|
||||
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class ItemStackDisplay extends WidgetBase {
|
||||
|
||||
ItemStack stack = null;
|
||||
@@ -42,7 +41,7 @@ public class ItemStackDisplay extends WidgetBase {
|
||||
GL11.glScalef(scaleX, scaleY, 1.0f);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GuiContainerManager.drawItem((int)(pos.getX()/scaleX), (int)(pos.getY()/scaleX), this.stack);
|
||||
DisplayUtil.renderStack((int)(pos.getX()/scaleX), (int)(pos.getY()/scaleX), this.stack);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -25,8 +27,9 @@ public class DecoratorFMP implements IWailaBlockDecorator {
|
||||
if (ModuleRegistrar.instance().hasFMPDecorator(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id, accessor.getRenderingPosition(), accessor.getPartialFrame());
|
||||
|
||||
for (IWailaFMPDecorator provider : ModuleRegistrar.instance().getFMPDecorators(id))
|
||||
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
|
||||
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id).values())
|
||||
for (IWailaFMPDecorator provider : providersList)
|
||||
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,23 @@ package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
@@ -31,7 +35,7 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
String name = null;
|
||||
try
|
||||
{
|
||||
String s = GuiContainerManager.itemDisplayNameShort(itemStack);
|
||||
String s = DisplayUtil.itemDisplayNameShort(itemStack);
|
||||
if(s != null && !s.endsWith("Unnamed"))
|
||||
name = s;
|
||||
|
||||
@@ -55,9 +59,7 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
currenttip.add("< Unnamed >");
|
||||
else{
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, true)){
|
||||
name = currenttip.get(0);
|
||||
//currenttip.set(0, name + String.format(" %s:%s", accessor.getBlockID(), accessor.getMetadata()));
|
||||
//currenttip.set(0, name + String.format(" %s:%s", itemStack.itemID, itemStack.getItemDamage()));
|
||||
currenttip.add(String.format(ITALIC + "[%d:%d] | %s", accessor.getBlockID(), accessor.getMetadata(), accessor.getBlockQualifiedName()));
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
@@ -77,6 +79,8 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
currenttip.add(RENDER + "{Plip}" + RENDER + "{Plop,thisisatest,222,333}");
|
||||
|
||||
String modName = ModIdentification.nameFromStack(itemStack);
|
||||
if (modName != null && !modName.equals("")){
|
||||
currenttip.add(BLUE + ITALIC + modName);
|
||||
|
||||
@@ -48,36 +48,11 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
|
||||
float health = ((EntityLivingBase)entity).getHealth() / 2.0f;
|
||||
float maxhp = ((EntityLivingBase)entity).getMaxHealth() / 2.0f;
|
||||
|
||||
if (((EntityLivingBase)entity).getHealth() > maxhpfortext)
|
||||
if (((EntityLivingBase)entity).getMaxHealth() > maxhpfortext)
|
||||
currenttip.add(String.format("HP : " + WHITE + "%.0f" + GRAY + " / " + WHITE + "%.0f", ((EntityLivingBase)entity).getHealth(), ((EntityLivingBase)entity).getMaxHealth()));
|
||||
|
||||
else{
|
||||
for (int i = 0; i < MathHelper.floor_float(health); i++){
|
||||
hptip += HEART;
|
||||
if(hptip.length() % (nhearts * HEART.length()) == 0){
|
||||
currenttip.add(hptip);
|
||||
hptip = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (((EntityLivingBase)entity).getHealth() > MathHelper.floor_float(health) * 2.0f){
|
||||
hptip += HHEART;
|
||||
if(hptip.length() % (nhearts * HEART.length()) == 0){
|
||||
currenttip.add(hptip);
|
||||
hptip = "";
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MathHelper.floor_float(maxhp - health); i++){
|
||||
hptip += EHEART;
|
||||
if(hptip.length() % (nhearts * HEART.length()) == 0){
|
||||
currenttip.add(hptip);
|
||||
hptip = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!hptip.equals(""))
|
||||
currenttip.add(hptip);
|
||||
currenttip.add(getRenderString("waila.health", String.valueOf(nhearts), String.valueOf(health), String.valueOf(maxhp)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
if (ModuleRegistrar.instance().hasHeadFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getHeadFMPProviders(id))
|
||||
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getHeadFMPProviders(id).values()){
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +56,10 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
if (ModuleRegistrar.instance().hasBodyFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getBodyFMPProviders(id))
|
||||
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getBodyFMPProviders(id).values()){
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +76,10 @@ public class HUDHandlerFMP implements IWailaDataProvider {
|
||||
if (ModuleRegistrar.instance().hasTailFMPProviders(id)){
|
||||
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
|
||||
|
||||
for (IWailaFMPProvider provider : ModuleRegistrar.instance().getTailFMPProviders(id))
|
||||
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getTailFMPProviders(id).values()){
|
||||
for (IWailaFMPProvider provider : providersList)
|
||||
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import mcp.mobius.waila.utils.ModIdentification;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class VanillaTooltipHandler {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void tooltipEvent(ItemTooltipEvent event) {
|
||||
String canonicalName = ModIdentification.nameFromStack(event.itemStack);
|
||||
if (canonicalName != null && !canonicalName.equals(""))
|
||||
event.toolTip.add("\u00a79\u00a7o" + canonicalName);
|
||||
}
|
||||
}
|
||||
@@ -18,82 +18,30 @@ import codechicken.nei.api.ItemInfo;
|
||||
|
||||
public class ModNameFilter implements ISearchProvider{
|
||||
|
||||
List<ISearchProvider> searchProviders = null;
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
if(searchProviders == null)
|
||||
{
|
||||
searchProviders = new LinkedList<ISearchProvider>(SearchField.searchProviders);
|
||||
searchProviders.remove(this);
|
||||
}
|
||||
return new Filter(searchText, this.searchProviders);
|
||||
Pattern pattern = SearchField.getPattern(searchText);
|
||||
return pattern == null ? null : new Filter(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Filter implements ItemFilter {
|
||||
|
||||
String searchText;
|
||||
|
||||
Pattern pattern;
|
||||
boolean oreDictSearch = false;
|
||||
List<ISearchProvider> searchProviders = new LinkedList<ISearchProvider>();
|
||||
|
||||
public Filter(String searchText, List<ISearchProvider> providers) {
|
||||
this.searchProviders = new ArrayList<ISearchProvider>(providers);
|
||||
this.searchText = searchText;
|
||||
|
||||
switch(NEIClientConfig.getIntSetting("inventory.searchmode")) {
|
||||
case 0://plain
|
||||
searchText = "\\Q"+searchText+"\\E";
|
||||
break;
|
||||
case 1:
|
||||
searchText = searchText
|
||||
.replace(".", "")
|
||||
.replace("?", ".")
|
||||
.replace("*", ".+?");
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
if (searchText.startsWith("#") && searchText.length() > 1){
|
||||
pattern = Pattern.compile(searchText.substring(1));
|
||||
oreDictSearch = true;
|
||||
} else {
|
||||
pattern = Pattern.compile(searchText);
|
||||
oreDictSearch = false;
|
||||
}
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
boolean result = true;
|
||||
|
||||
try{
|
||||
for (ISearchProvider provider : searchProviders){
|
||||
ItemFilter filter = provider.getFilter(searchText);
|
||||
if (filter != null)
|
||||
result &= provider.getFilter(searchText).matches(item);
|
||||
}
|
||||
|
||||
if (pattern == null || pattern.toString().equals("")){
|
||||
result &= true;
|
||||
} else if (pattern.toString().startsWith("@")){ // If it starts with @, we skip it
|
||||
} else if (oreDictSearch){
|
||||
int[] ids = OreDictionary.getOreIDs(item);
|
||||
boolean found = false;
|
||||
for (int id : ids){
|
||||
if (pattern.matcher(OreDictionary.getOreName(id).toLowerCase()).find()){
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
result &= found;
|
||||
} else {
|
||||
result &= pattern.matcher(ItemInfo.getSearchName(item)).find() || pattern.matcher(ModIdentification.nameFromStack(item).toLowerCase()).find();
|
||||
}
|
||||
} catch (Exception e){
|
||||
Waila.log.warn(String.format("Error while filtering items : %s : %s", e, e.getMessage()));
|
||||
}
|
||||
return result;
|
||||
public Filter(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack itemstack) {
|
||||
return this.pattern.matcher(ModIdentification.nameFromStack(itemstack).toLowerCase()).find();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.overlay.RayTracing;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
|
||||
public class NEIHandler {
|
||||
public static void register(){
|
||||
//GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_NEWFILTERS, true)){
|
||||
API.addSearchProvider(new ModNameFilter());
|
||||
API.addSearchProvider(new OreDictFilter());
|
||||
}
|
||||
|
||||
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
|
||||
|
||||
//KeyBindingRegistry.registerKeyBinding(new ConfigKeyHandler());
|
||||
|
||||
// We mute the default keybind for displaying the tooltip
|
||||
NEIClientConfig.getSetting(Constants.BIND_NEI_SHOW).setIntValue(Keyboard.KEY_NONE);
|
||||
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(false);
|
||||
|
||||
//API.addKeyBind(Constants.BIND_WIKI, "Display wiki", Keyboard.KEY_RSHIFT);
|
||||
//API.addKeyBind(Constants.BIND_TECH, "Display techtree", Keyboard.KEY_RSHIFT);
|
||||
|
||||
GuiContainerManager.addInputHandler(new HandlerEnchants());
|
||||
API.addKeyBind(Constants.BIND_SCREEN_ENCH, Keyboard.KEY_I);
|
||||
}
|
||||
|
||||
public static boolean firstInventory = true;
|
||||
public static void openRecipeGUI(boolean recipe){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
boolean uiResult;
|
||||
String msg;
|
||||
|
||||
if ((RayTracing.instance().getTarget() != null) && (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)){
|
||||
List<ItemStack> stacks = RayTracing.instance().getIdentifierItems();
|
||||
if (stacks.size() > 0){
|
||||
mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
|
||||
if (firstInventory){
|
||||
try {Thread.sleep(1000);} catch (Exception e){};
|
||||
firstInventory = false;
|
||||
}
|
||||
|
||||
if(recipe)
|
||||
if(!GuiCraftingRecipe.openRecipeGui("item", stacks.get(0).copy())){
|
||||
ItemStack target = stacks.get(0).copy();
|
||||
target.setItemDamage(0);
|
||||
if(!GuiCraftingRecipe.openRecipeGui("item", target)){
|
||||
mc.thePlayer.addChatMessage(new ChatComponentTranslation("\u00a7f\u00a7o" + LangUtil.translateG("client.msg.norecipe")));
|
||||
mc.displayGuiScreen((GuiScreen)null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipe)
|
||||
if(!GuiUsageRecipe.openRecipeGui("item", stacks.get(0).copy())){
|
||||
ItemStack target = stacks.get(0).copy();
|
||||
target.setItemDamage(0);
|
||||
if(!GuiUsageRecipe.openRecipeGui("item", target)){
|
||||
mc.thePlayer.addChatMessage(new ChatComponentTranslation("\u00a7f\u00a7o" + LangUtil.translateG("client.msg.nousage")));
|
||||
mc.displayGuiScreen((GuiScreen)null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mcp.mobius.waila.handlers.nei;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.SearchField.ISearchProvider;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
public class OreDictFilter implements ISearchProvider{
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
if (!searchText.startsWith("#") || searchText.length() < 2) return null;
|
||||
Pattern pattern = SearchField.getPattern(searchText.substring(1));
|
||||
return pattern == null ? null : new Filter(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Filter implements ItemFilter {
|
||||
|
||||
Pattern pattern;
|
||||
|
||||
public Filter(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack itemstack) {
|
||||
int[] ids = OreDictionary.getOreIDs(itemstack);
|
||||
boolean found = false;
|
||||
for (int id : ids){
|
||||
if (pattern.matcher(OreDictionary.getOreName(id).toLowerCase()).find()){
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
@@ -19,10 +18,11 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x01TERequest> implements IWailaMessage {
|
||||
|
||||
@@ -112,21 +112,30 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
|
||||
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer) ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).playerEntity;
|
||||
|
||||
for (IWailaDataProvider provider : ModuleRegistrar.instance().getNBTProviders(block)){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
}
|
||||
}
|
||||
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getNBTProviders(block).values()){
|
||||
for (IWailaDataProvider provider : providersList){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (NoSuchMethodError nsm){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IWailaDataProvider provider : ModuleRegistrar.instance().getNBTProviders(entity)){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getNBTProviders(entity).values()){
|
||||
for (IWailaDataProvider provider : providersList){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
} catch (NoSuchMethodError nsm){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
entity.writeToNBT(tag);
|
||||
@@ -136,13 +145,11 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
|
||||
tag.setInteger("WailaX", msg.posX);
|
||||
tag.setInteger("WailaY", msg.posY);
|
||||
tag.setInteger("WailaZ", msg.posZ);
|
||||
tag.setString ("WailaID", (String)((HashMap)classToNameMap.get(null)).get(entity.getClass()));
|
||||
|
||||
ctx.writeAndFlush(new Message0x02TENBTData(tag)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
|
||||
|
||||
tag.setString ("WailaID", (String)((HashMap)classToNameMap.get(null)).get(entity.getClass()));
|
||||
|
||||
WailaPacketHandler.INSTANCE.sendTo(new Message0x02TENBTData(tag), WailaPacketHandler.getPlayer(ctx));
|
||||
//ctx.writeAndFlush(new Message0x02TENBTData(tag)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -34,7 +34,7 @@ public class Message0x02TENBTData extends SimpleChannelInboundHandler<Message0x0
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Message0x02TENBTData msg) throws Exception {
|
||||
DataAccessorBlock.instance.remoteNbt = msg.tag;
|
||||
DataAccessorCommon.instance.setNBTData(msg.tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
@@ -16,10 +17,9 @@ import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x03EntRequest> implements IWailaMessage {
|
||||
|
||||
@@ -76,20 +76,25 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer) ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).playerEntity;
|
||||
|
||||
if (ModuleRegistrar.instance().hasNBTEntityProviders(entity)){
|
||||
for (IWailaEntityProvider provider : ModuleRegistrar.instance().getNBTEntityProviders(entity)){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag);
|
||||
}
|
||||
for (List<IWailaEntityProvider> providersList : ModuleRegistrar.instance().getNBTEntityProviders(entity).values()){
|
||||
for (IWailaEntityProvider provider : providersList){
|
||||
try{
|
||||
tag = provider.getNBTData(player, entity, tag, world);
|
||||
} catch (AbstractMethodError ame){
|
||||
tag = AccessHelper.getNBTData(provider, entity, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
entity.writeToNBT(tag);
|
||||
tag = NBTUtil.createTag(tag, msg.keys);
|
||||
}
|
||||
|
||||
tag.setInteger("WailaEntityID", entity.getEntityId());
|
||||
|
||||
ctx.writeAndFlush(new Message0x04EntNBTData(tag)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
WailaPacketHandler.INSTANCE.sendTo(new Message0x04EntNBTData(tag), WailaPacketHandler.getPlayer(ctx));
|
||||
//ctx.writeAndFlush(new Message0x04EntNBTData(tag)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}catch(Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -33,7 +33,7 @@ public class Message0x04EntNBTData extends SimpleChannelInboundHandler<Message0x
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Message0x04EntNBTData msg) throws Exception {
|
||||
DataAccessorEntity.instance.remoteNbt = msg.tag;
|
||||
DataAccessorCommon.instance.setNBTData(msg.tag);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumMap;
|
||||
|
||||
public enum WailaPacketHandler {
|
||||
INSTANCE;
|
||||
@@ -123,5 +122,9 @@ public enum WailaPacketHandler {
|
||||
int j = buffer.readShort();
|
||||
String s = new String(buffer.readBytes(j).array(), Charsets.UTF_8);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityPlayerMP getPlayer(ChannelHandlerContext ctx){
|
||||
return ((NetHandlerPlayServer) ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).playerEntity;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -7,7 +9,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -26,7 +28,7 @@ public class DecoratorRenderer {
|
||||
|
||||
double partialTicks = event.partialTicks;
|
||||
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
EntityLivingBase viewEntity = Minecraft.getMinecraft().renderViewEntity;
|
||||
@@ -46,15 +48,17 @@ public class DecoratorRenderer {
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
if (ModuleRegistrar.instance().hasBlockDecorator(block)){
|
||||
for (IWailaBlockDecorator decorator : ModuleRegistrar.instance().getBlockDecorators(block))
|
||||
try{
|
||||
GL11.glPushMatrix();
|
||||
decorator.decorateBlock(RayTracing.instance().getTargetStack(), accessor, ConfigHandler.instance());
|
||||
GL11.glPopMatrix();
|
||||
} catch (Throwable e){
|
||||
GL11.glPopMatrix();
|
||||
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
|
||||
}
|
||||
for (List<IWailaBlockDecorator> decoratorsList : ModuleRegistrar.instance().getBlockDecorators(block).values()){
|
||||
for (IWailaBlockDecorator decorator : decoratorsList)
|
||||
try{
|
||||
GL11.glPushMatrix();
|
||||
decorator.decorateBlock(RayTracing.instance().getTargetStack(), accessor, ConfigHandler.instance());
|
||||
GL11.glPopMatrix();
|
||||
} catch (Throwable e){
|
||||
GL11.glPopMatrix();
|
||||
WailaExceptionHandler.handleErr(e, decorator.getClass().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class DisplayUtil {
|
||||
private static FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
private static TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
private static RenderItem renderItem = new RenderItem();
|
||||
|
||||
public static int getDisplayWidth(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return 0;
|
||||
|
||||
int width = 0;
|
||||
|
||||
Matcher renderMatcher = patternRender.matcher(s);
|
||||
while (renderMatcher.find()){
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
|
||||
if (renderer != null)
|
||||
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
|
||||
}
|
||||
|
||||
Matcher iconMatcher = patternIcon.matcher(s);
|
||||
while (iconMatcher.find())
|
||||
width += 8;
|
||||
|
||||
width += fontRenderer.getStringWidth(stripSymbols(s));
|
||||
return width;
|
||||
}
|
||||
|
||||
public static Dimension displaySize() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
|
||||
}
|
||||
|
||||
public static String stripSymbols(String s){
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternMinecraft.matcher(result).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String stripWailaSymbols(String s){
|
||||
String result = patternRender.matcher(s).replaceAll("");
|
||||
result = patternWaila.matcher(result).replaceAll("");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void renderStack(int x, int y, ItemStack stack){
|
||||
enable3DRender();
|
||||
try{
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRenderer, textureManager, stack, x, y);
|
||||
renderItem.renderItemOverlayIntoGUI(fontRenderer, textureManager, stack, x, y);
|
||||
} catch (Exception e){
|
||||
String stackStr = stack != null ? stack.toString() : "NullStack";
|
||||
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
|
||||
}
|
||||
enable2DRender();
|
||||
}
|
||||
|
||||
public static void enable3DRender() {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public static void enable2DRender() {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int x, int y, int w, int h, int grad1, int grad2)
|
||||
{
|
||||
float zLevel = 0.0f;
|
||||
|
||||
float f = (float)(grad1 >> 24 & 255) / 255.0F;
|
||||
float f1 = (float)(grad1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (float)(grad1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float)(grad1 & 255) / 255.0F;
|
||||
float f4 = (float)(grad2 >> 24 & 255) / 255.0F;
|
||||
float f5 = (float)(grad2 >> 16 & 255) / 255.0F;
|
||||
float f6 = (float)(grad2 >> 8 & 255) / 255.0F;
|
||||
float f7 = (float)(grad2 & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex((double)(x+w), (double)y, (double)zLevel);
|
||||
tessellator.addVertex((double)x, (double)y, (double)zLevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex((double)x, (double)(y+h), (double)zLevel);
|
||||
tessellator.addVertex((double)(x+w), (double)(y+h), (double)zLevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
|
||||
tessellator.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void drawString(String text, int x, int y, int colour, boolean shadow) {
|
||||
if (shadow)
|
||||
fontRenderer.drawStringWithShadow(text, x, y, colour);
|
||||
else
|
||||
fontRenderer.drawString(text, x, y, colour);
|
||||
}
|
||||
|
||||
public static List<String> itemDisplayNameMultiline(ItemStack itemstack) {
|
||||
List<String> namelist = null;
|
||||
try {
|
||||
namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
if (namelist == null)
|
||||
namelist = new ArrayList<String>();
|
||||
|
||||
if (namelist.size() == 0)
|
||||
namelist.add("Unnamed");
|
||||
|
||||
if (namelist.get(0) == null || namelist.get(0).equals(""))
|
||||
namelist.set(0, "Unnamed");
|
||||
|
||||
namelist.set(0, itemstack.getRarity().rarityColor.toString() + namelist.get(0));
|
||||
for (int i = 1; i < namelist.size(); i++)
|
||||
namelist.set(i, "\u00a77" + namelist.get(i));
|
||||
|
||||
return namelist;
|
||||
}
|
||||
|
||||
public static String itemDisplayNameShort(ItemStack itemstack) {
|
||||
List<String> list = itemDisplayNameMultiline(itemstack);
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
|
||||
if (icon == null)
|
||||
return;
|
||||
|
||||
if (icon.bu != -1)
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
|
||||
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package mcp.mobius.waila.overlay;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -25,7 +23,6 @@ public class OverlayRenderer {
|
||||
protected static boolean hasRescaleNormal;
|
||||
protected static boolean hasColorMaterial;
|
||||
protected static int boundTexIndex;
|
||||
protected static RenderItem renderItem = new RenderItem();
|
||||
|
||||
public static void renderOverlay()
|
||||
{
|
||||
@@ -34,7 +31,7 @@ public class OverlayRenderer {
|
||||
mc.theWorld != null &&
|
||||
Minecraft.isGuiEnabled() &&
|
||||
!mc.gameSettings.keyBindPlayerList.getIsKeyPressed() &&
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true) &&
|
||||
ConfigHandler.instance().showTooltip() &&
|
||||
RayTracing.instance().getTarget() != null))
|
||||
return;
|
||||
|
||||
@@ -43,7 +40,7 @@ public class OverlayRenderer {
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
}
|
||||
|
||||
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY)
|
||||
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && ConfigHandler.instance().getConfig("general.showents"))
|
||||
{
|
||||
renderOverlay(WailaTickHandler.instance().tooltip);
|
||||
}
|
||||
@@ -67,18 +64,19 @@ public class OverlayRenderer {
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tooltip.drawStrings();
|
||||
tooltip.draw();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
tooltip.drawIcons();
|
||||
|
||||
tooltip.draw2nd();
|
||||
|
||||
if (tooltip.hasIcon)
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
if (tooltip.hasIcon && tooltip.stack != null && tooltip.stack.getItem() != null)
|
||||
GuiContainerManager.drawItem(tooltip.x+5, tooltip.y+tooltip.h/2-8, tooltip.stack);
|
||||
DisplayUtil.renderStack(tooltip.x+5, tooltip.y+tooltip.h/2-8, tooltip.stack);
|
||||
|
||||
|
||||
loadGLState();
|
||||
GL11.glPopMatrix();
|
||||
@@ -114,43 +112,17 @@ public class OverlayRenderer {
|
||||
public static void drawTooltipBox(int x, int y, int w, int h, int bg, int grad1, int grad2)
|
||||
{
|
||||
//int bg = 0xf0100010;
|
||||
GuiDraw.drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
|
||||
GuiDraw.drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
|
||||
GuiDraw.drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);//center
|
||||
GuiDraw.drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
|
||||
GuiDraw.drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);//center
|
||||
DisplayUtil.drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
|
||||
DisplayUtil.drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
|
||||
//int grad1 = 0x505000ff;
|
||||
//int grad2 = 0x5028007F;
|
||||
GuiDraw.drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
GuiDraw.drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
DisplayUtil.drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
|
||||
|
||||
GuiDraw.drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
|
||||
GuiDraw.drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
|
||||
DisplayUtil.drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
|
||||
tessellator.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
|
||||
tessellator.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
|
||||
if (icon == null)
|
||||
return;
|
||||
|
||||
if (icon.bu != -1)
|
||||
drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
|
||||
drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,12 @@ package mcp.mobius.waila.overlay;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -14,7 +16,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -113,8 +117,13 @@ public class RayTracing {
|
||||
if (this.target == null)
|
||||
return null;
|
||||
|
||||
if (ModuleRegistrar.instance().hasOverrideEntityProviders(this.target.entityHit))
|
||||
ents.add(ModuleRegistrar.instance().getOverrideEntityProviders(this.target.entityHit).get(0).getWailaOverride(DataAccessorEntity.instance, ConfigHandler.instance()));
|
||||
if (ModuleRegistrar.instance().hasOverrideEntityProviders(this.target.entityHit)){
|
||||
for (List<IWailaEntityProvider> listProviders : ModuleRegistrar.instance().getOverrideEntityProviders(this.target.entityHit).values()){
|
||||
for (IWailaEntityProvider provider : listProviders){
|
||||
ents.add(provider.getWailaOverride(DataAccessorCommon.instance, ConfigHandler.instance()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ents.size() > 0)
|
||||
return ents.get(0);
|
||||
@@ -142,15 +151,34 @@ public class RayTracing {
|
||||
if (mouseoverBlock == null) return items;
|
||||
|
||||
if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getStackProviders(mouseoverBlock).values()){
|
||||
for(IWailaDataProvider provider : providersList){
|
||||
ItemStack providerStack = provider.getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance());
|
||||
if (providerStack != null){
|
||||
|
||||
if (providerStack.getItem() == null)
|
||||
return new ArrayList<ItemStack>();
|
||||
|
||||
items.add(providerStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity != null && ModuleRegistrar.instance().hasStackProviders(tileEntity)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getStackProviders(tileEntity).values()){
|
||||
|
||||
for(IWailaDataProvider provider : providersList){
|
||||
ItemStack providerStack = provider.getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance());
|
||||
if (providerStack != null){
|
||||
|
||||
if (providerStack.getItem() == null)
|
||||
return new ArrayList<ItemStack>();
|
||||
|
||||
items.add(providerStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(items.size() > 0)
|
||||
|
||||
@@ -1,24 +1,42 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderIcon;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderTrueTyper;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class Tooltip {
|
||||
public static int TabSpacing = 8;
|
||||
public static int IconSize = 8;
|
||||
|
||||
ArrayList<Line> lines = new ArrayList<Line>();
|
||||
ArrayList<ArrayList<String>> lines = new ArrayList<ArrayList<String>>();
|
||||
ArrayList<ArrayList<Integer>> sizes = new ArrayList<ArrayList<Integer>>();
|
||||
ArrayList<Integer> columnsWidth = new ArrayList<Integer>();
|
||||
ArrayList<Integer> columnsPos = new ArrayList<Integer>();
|
||||
|
||||
ArrayList<Renderable> elements = new ArrayList<Renderable>();
|
||||
ArrayList<Renderable> elements2nd = new ArrayList<Renderable>();
|
||||
|
||||
int w,h,x,y,ty;
|
||||
int offsetX;
|
||||
int maxStringW;
|
||||
@@ -26,57 +44,56 @@ public class Tooltip {
|
||||
boolean hasIcon = false;
|
||||
ItemStack stack;
|
||||
|
||||
int[] columnsWidth;
|
||||
int columnsWidthMono;
|
||||
int[] columnsPos;
|
||||
int ncolumns = 0;
|
||||
IWailaCommonAccessor accessor = DataAccessorCommon.instance;
|
||||
|
||||
private class Line{
|
||||
String[] columnsRaw;
|
||||
ArrayList<ArrayList<String>> columns = new ArrayList<ArrayList<String>>();
|
||||
int ncolumns;
|
||||
int[] columnsWidth;
|
||||
int lineWidth;
|
||||
/////////////////////////////////////Renderable///////////////////////////////////////
|
||||
private class Renderable{
|
||||
final IWailaTooltipRenderer renderer;
|
||||
final Point pos;
|
||||
final String[] params;
|
||||
|
||||
public Line(String text){
|
||||
columnsRaw = text.split(TAB);
|
||||
ncolumns = columnsRaw.length;
|
||||
columnsWidth = new int[ncolumns];
|
||||
lineWidth = 0;
|
||||
|
||||
for (String s : columnsRaw)
|
||||
columns.add(parseString(s));
|
||||
public Renderable(IWailaTooltipRenderer renderer, Point pos, String[] params){
|
||||
this.renderer = renderer;
|
||||
this.pos = pos;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ncolumns; i++){
|
||||
for (String s : columns.get(i)){
|
||||
if (s.startsWith(WailaStyle + WailaIcon))
|
||||
columnsWidth[i] += IconSize;
|
||||
else if (s.startsWith(WailaStyle + WailaStyle))
|
||||
columnsWidth[i] += 0;
|
||||
else
|
||||
columnsWidth[i] += GuiDraw.getStringWidth(s);
|
||||
}
|
||||
lineWidth += columnsWidth[i];
|
||||
}
|
||||
public Renderable(IWailaTooltipRenderer renderer, Point pos){
|
||||
this(renderer, pos, new String[]{});
|
||||
}
|
||||
|
||||
public Point getPos(){
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
ArrayList<String> parseString(String s){
|
||||
ArrayList<String> retList = new ArrayList<String>();
|
||||
Pattern pattern = Pattern.compile(WailaStyle + "..");
|
||||
Matcher matcher = pattern.matcher(s);
|
||||
|
||||
int prevIndex = 0;
|
||||
while (matcher.find()){
|
||||
String substring = s.substring(prevIndex, matcher.start());
|
||||
if (!substring.equals(""))
|
||||
retList.add(substring);
|
||||
retList.add(s.substring(matcher.start(), matcher.end()));
|
||||
prevIndex = matcher.end();
|
||||
public Dimension getSize(IWailaCommonAccessor accessor) {
|
||||
Dimension dim = new Dimension(0,0);
|
||||
try {
|
||||
dim = this.renderer.getSize(this.params, accessor);
|
||||
} catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".getSize()", null);
|
||||
}
|
||||
retList.add(s.substring(prevIndex));
|
||||
return retList;
|
||||
return dim;
|
||||
}
|
||||
|
||||
public void draw(IWailaCommonAccessor accessor, int x, int y) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x + this.pos.x, y + this.pos.y, 0);
|
||||
try{
|
||||
this.renderer.draw(this.params, accessor);
|
||||
} catch (Throwable e){
|
||||
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".draw()", null);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("Renderable@[%d,%d] | %s", pos.x, pos.y, renderer);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Tooltip(List<String> textData, ItemStack stack){
|
||||
this(textData, true);
|
||||
@@ -84,90 +101,128 @@ public class Tooltip {
|
||||
}
|
||||
|
||||
public Tooltip(List<String> textData, boolean hasIcon){
|
||||
for (String s : textData)
|
||||
lines.add(new Line(s));
|
||||
|
||||
for (Line l : lines)
|
||||
ncolumns = Math.max(ncolumns, l.ncolumns);
|
||||
|
||||
columnsWidth = new int[ncolumns];
|
||||
columnsPos = new int[ncolumns];
|
||||
|
||||
for (Line l : lines){
|
||||
for (int i = 0; i < l.ncolumns; i++){
|
||||
if (l.ncolumns > 1 && ncolumns != 1)
|
||||
columnsWidth[i] = Math.max(columnsWidth[i], l.columnsWidth[i]);
|
||||
columnsWidth.add(0); // Small init of the arrays to have at least one element
|
||||
columnsPos.add(0);
|
||||
|
||||
for (String s : textData){
|
||||
|
||||
ArrayList<String> line = new ArrayList<String>(Arrays.asList(patternTab.split(s)));
|
||||
ArrayList<Integer> size = new ArrayList<Integer>();
|
||||
for (String ss : line)
|
||||
size.add(DisplayUtil.getDisplayWidth(ss));
|
||||
|
||||
// This line.size() > 1 is to prevent columns to align on lines without column (ie : the name & modid)
|
||||
if (line.size() > 1){
|
||||
while (columnsWidth.size() < line.size()){
|
||||
columnsWidth.add(0);
|
||||
columnsPos.add(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < line.size(); i++)
|
||||
columnsWidth.set(i, Math.max(columnsWidth.get(i), size.get(i)));
|
||||
}
|
||||
|
||||
columnsWidthMono = Math.max(columnsWidthMono, l.columnsWidth[0]);
|
||||
maxStringW = Math.max(maxStringW, DisplayUtil.getDisplayWidth(s) + TabSpacing * (line.size() - 1));
|
||||
|
||||
lines.add(line);
|
||||
sizes.add(size);
|
||||
}
|
||||
|
||||
maxStringW = 0;
|
||||
for (int i = 0; i < ncolumns; i++)
|
||||
maxStringW += columnsWidth[i];
|
||||
maxStringW += ncolumns * TabSpacing;
|
||||
|
||||
maxStringW = Math.max(maxStringW, columnsWidthMono);
|
||||
|
||||
for (int i = 0; i < ncolumns - 1; i++)
|
||||
columnsPos[i + 1] = columnsWidth[i] + columnsPos[i];
|
||||
// We correct if we only have one column
|
||||
if (columnsWidth.size() == 1)
|
||||
columnsWidth.set(0, maxStringW);
|
||||
|
||||
this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0),
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0));
|
||||
this.hasIcon = hasIcon;
|
||||
// We compute the position of the columns to be able to align the renderable later on
|
||||
for (int i = 1; i < columnsWidth.size(); i++)
|
||||
columnsPos.set(i, columnsWidth.get(i - 1) + columnsPos.get(i - 1) + TabSpacing);
|
||||
|
||||
int paddingW = hasIcon ? 29 : 13;
|
||||
int paddingH = hasIcon ? 24 : 0;
|
||||
offsetX = hasIcon ? 24 : 6;
|
||||
|
||||
w = maxStringW + paddingW;
|
||||
|
||||
h = Math.max(paddingH, 10 + 10*lines.size());
|
||||
|
||||
Dimension size = GuiDraw.displaySize();
|
||||
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
|
||||
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
|
||||
|
||||
ty = (h-10*lines.size())/2;
|
||||
this.computeRenderables();
|
||||
this.computePositionAndSize(hasIcon);
|
||||
}
|
||||
|
||||
public void drawStrings(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++){
|
||||
int offX = 0;
|
||||
|
||||
for (int is = 0; is < lines.get(i).columns.get(c).size(); is++){
|
||||
String s = lines.get(i).columns.get(c).get(is);
|
||||
if (s.startsWith(WailaStyle + WailaIcon))
|
||||
offX += IconSize;
|
||||
|
||||
else if (s.startsWith(ALIGNRIGHT))
|
||||
offX += columnsWidth[c] - GuiDraw.getStringWidth(lines.get(i).columns.get(c).get(is + 1));
|
||||
|
||||
else{
|
||||
GuiDraw.drawString(s, x + offsetX + columnsPos[c] + c*TabSpacing + offX, y + ty + 10*i, OverlayConfig.fontcolor, true);
|
||||
offX += GuiDraw.getStringWidth(s);
|
||||
}
|
||||
}
|
||||
private void computeRenderables(){
|
||||
int offsetY = 0;
|
||||
for (int i = 0; i < lines.size(); i++){ // We check all the lines, one by one
|
||||
int maxHeight = 0; // Maximum height of this line
|
||||
for (int c = 0; c < lines.get(i).size(); c++){ // We check all the columns for this line
|
||||
offsetX = columnsPos.get(c); // We move the "cursor" to the current column
|
||||
String currentLine = lines.get(i).get(c);
|
||||
Matcher lineMatcher = patternLineSplit.matcher(currentLine);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawIcons(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++){
|
||||
int offX = 0;
|
||||
for (String s : lines.get(i).columns.get(c)){
|
||||
if (s.startsWith(WailaStyle + WailaIcon)){
|
||||
OverlayRenderer.renderIcon(x + offsetX + columnsPos[c] + c*TabSpacing + offX, y + ty + 10*i, IconSize, IconSize, IconUI.bySymbol(s));
|
||||
offX += IconSize;
|
||||
}else{
|
||||
offX += GuiDraw.getStringWidth(s);
|
||||
while (lineMatcher.find()){
|
||||
String cs = lineMatcher.group();
|
||||
Renderable renderable = null;
|
||||
Matcher renderMatcher = patternRender.matcher(cs); //We keep a matcher here to be able to check if we have a Renderer. Might be better to do a startWith + full matcher init after the check
|
||||
Matcher iconMatcher = patternIcon.matcher(cs);
|
||||
|
||||
if (renderMatcher.find()){
|
||||
String renderName = renderMatcher.group("name");
|
||||
|
||||
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderName);
|
||||
if (renderer != null){
|
||||
renderable = new Renderable(renderer, new Point(offsetX, offsetY), renderMatcher.group("args").split(","));
|
||||
this.elements2nd.add(renderable);
|
||||
}
|
||||
} else if (iconMatcher.find()){
|
||||
renderable = new Renderable(new TTRenderIcon(iconMatcher.group("type")), new Point(offsetX, offsetY));
|
||||
this.elements2nd.add(renderable);
|
||||
} else {
|
||||
if (cs.startsWith(ALIGNRIGHT))
|
||||
offsetX += columnsWidth.get(c) - DisplayUtil.getDisplayWidth(currentLine.substring(lineMatcher.start()));
|
||||
|
||||
if (cs.startsWith(ALIGNCENTER))
|
||||
offsetX += (columnsWidth.get(c) - DisplayUtil.getDisplayWidth(currentLine.substring(lineMatcher.start()))) / 2;
|
||||
|
||||
renderable = new Renderable(new TTRenderString(DisplayUtil.stripWailaSymbols(cs)), new Point(offsetX, offsetY));
|
||||
//renderable = new Renderable(new TTRenderTrueTyper(DisplayUtil.stripWailaSymbols(cs)), new Point(offsetX, offsetY));
|
||||
this.elements.add(renderable);
|
||||
}
|
||||
|
||||
if (renderable != null){
|
||||
offsetX += renderable.getSize(accessor).width;
|
||||
maxHeight = Math.max(maxHeight, renderable.getSize(accessor).height + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
offsetY += maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
private int getRenderableTotalHeight(){
|
||||
int result = 0;
|
||||
for (Renderable r : this.elements)
|
||||
result = Math.max(r.getPos().y + r.getSize(accessor).height + 2, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void computePositionAndSize(boolean hasIcon){
|
||||
this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0),
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0));
|
||||
this.hasIcon = hasIcon;
|
||||
|
||||
int paddingW = hasIcon ? 29 : 13;
|
||||
int paddingH = hasIcon ? 24 : 0;
|
||||
offsetX = hasIcon ? 24 : 6;
|
||||
|
||||
w = maxStringW + paddingW;
|
||||
|
||||
h = Math.max(paddingH, this.getRenderableTotalHeight() + 8);
|
||||
|
||||
Dimension size = DisplayUtil.displaySize();
|
||||
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
|
||||
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
|
||||
|
||||
ty = (h - this.getRenderableTotalHeight())/2 + 1;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
for (Renderable r : this.elements)
|
||||
r.draw(accessor, x + offsetX, y + ty);
|
||||
}
|
||||
|
||||
public void draw2nd(){
|
||||
for (Renderable r : this.elements2nd)
|
||||
r.draw(accessor, x + offsetX, y + ty);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,12 @@ import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.TipList;
|
||||
import mcp.mobius.waila.cbcore.Layout;
|
||||
import mcp.mobius.waila.client.KeyEvent;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -19,7 +20,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -59,8 +59,10 @@ public class WailaTickHandler{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void tickClient(TickEvent.ClientTickEvent event) {
|
||||
|
||||
if (!Keyboard.isKeyDown(KeyEvent.key_show.getKeyCode()) && !ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false)){
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
|
||||
if (!Keyboard.isKeyDown(KeyEvent.key_show.getKeyCode()) &&
|
||||
!ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, false) &&
|
||||
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false)){
|
||||
ConfigHandler.instance().setConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,15 +73,15 @@ public class WailaTickHandler{
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack or the override
|
||||
|
||||
if (targetStack != null){
|
||||
this.currenttip.clear();
|
||||
this.currenttipHead.clear();
|
||||
this.currenttipBody.clear();
|
||||
this.currenttipTail.clear();
|
||||
this.currenttip = new TipList<String, String>();
|
||||
this.currenttipHead = new TipList<String, String>();
|
||||
this.currenttipBody = new TipList<String, String>();
|
||||
this.currenttipTail = new TipList<String, String>();
|
||||
|
||||
|
||||
//this.identifiedHighlight = handler.identifyHighlight(world, player, target);
|
||||
@@ -100,16 +102,16 @@ public class WailaTickHandler{
|
||||
}
|
||||
}
|
||||
else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY){
|
||||
DataAccessorEntity accessor = DataAccessorEntity.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
|
||||
Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override check.
|
||||
|
||||
if (targetEnt != null){
|
||||
this.currenttip.clear();
|
||||
this.currenttipHead.clear();
|
||||
this.currenttipBody.clear();
|
||||
this.currenttipTail.clear();
|
||||
this.currenttip = new TipList<String, String>();
|
||||
this.currenttipHead = new TipList<String, String>();
|
||||
this.currenttipBody = new TipList<String, String>();
|
||||
this.currenttipTail = new TipList<String, String>();
|
||||
|
||||
this.currenttipHead = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipHead, Layout.HEADER);
|
||||
this.currenttipBody = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttipBody, Layout.BODY);
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.overlay.IconUI;
|
||||
import mcp.mobius.waila.overlay.OverlayRenderer;
|
||||
|
||||
/**
|
||||
* Custom renderer for health bars.
|
||||
* Syntax : {waila.health, nheartperline, health, maxhealth}
|
||||
*
|
||||
*/
|
||||
public class TTRenderHealth implements IWailaTooltipRenderer {
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
float maxhearts = Float.valueOf(params[0]);
|
||||
float health = Float.valueOf(params[1]);
|
||||
float maxhealth = Float.valueOf(params[2]);
|
||||
|
||||
int heartsPerLine = (int)(Math.min(maxhearts, Math.ceil(maxhealth)));
|
||||
int nlines = (int)(Math.ceil(maxhealth/maxhearts));
|
||||
|
||||
return new Dimension(8 * heartsPerLine, 10 * nlines - 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
float maxhearts = Float.valueOf(params[0]);
|
||||
float health = Float.valueOf(params[1]);
|
||||
float maxhealth = Float.valueOf(params[2]);
|
||||
|
||||
int nhearts = MathHelper.ceiling_float_int(maxhealth);
|
||||
int heartsPerLine = (int)(Math.min(maxhearts, Math.ceil(maxhealth)));
|
||||
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
|
||||
for (int iheart = 1; iheart <= nhearts; iheart++){
|
||||
|
||||
|
||||
if (iheart <= MathHelper.floor_float(health)){
|
||||
DisplayUtil.renderIcon(offsetX, offsetY, 8, 8, IconUI.HEART);
|
||||
offsetX += 8;
|
||||
}
|
||||
|
||||
if ((iheart > health) && (iheart < health + 1)){
|
||||
DisplayUtil.renderIcon(offsetX, offsetY, 8, 8, IconUI.HHEART);
|
||||
offsetX += 8;
|
||||
}
|
||||
|
||||
if (iheart >= health + 1){
|
||||
DisplayUtil.renderIcon(offsetX, offsetY, 8, 8, IconUI.EHEART);
|
||||
offsetX += 8;
|
||||
}
|
||||
|
||||
if (iheart%heartsPerLine == 0){
|
||||
offsetY += 10;
|
||||
offsetX = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.overlay.OverlayRenderer;
|
||||
import mcp.mobius.waila.overlay.IconUI;
|
||||
|
||||
public class TTRenderIcon implements IWailaTooltipRenderer {
|
||||
|
||||
final String type;
|
||||
final int IconSize = 8;
|
||||
|
||||
public TTRenderIcon(String type){
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return new Dimension(IconSize, IconSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
DisplayUtil.renderIcon(0, 0, IconSize, IconSize, IconUI.bySymbol(WailaStyle + WailaIcon + type));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderProgressBar implements IWailaTooltipRenderer{
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ResourceLocation texture = new ResourceLocation("waila", "textures/sprites.png");
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return new Dimension(32,16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
int currentValue = Integer.valueOf(params[0]);
|
||||
int maxValue = Integer.valueOf(params[1]);
|
||||
|
||||
int progress = (currentValue * 28) / maxValue;
|
||||
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
|
||||
DisplayUtil.drawTexturedModalRect(4, 0, 4, 16, 28, 16, 28, 16);
|
||||
DisplayUtil.drawTexturedModalRect(4, 0, 4, 0, progress + 1, 16, progress + 1, 16);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderStack implements IWailaTooltipRenderer{
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return new Dimension(16,16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
int type = Integer.valueOf(params[0]); //0 for block, 1 for item
|
||||
String name = params[1]; //Fully qualified name
|
||||
int amount = Integer.valueOf(params[2]);
|
||||
int meta = Integer.valueOf(params[3]);
|
||||
|
||||
ItemStack stack = null;
|
||||
if (type == 0)
|
||||
stack = new ItemStack((Block)Block.blockRegistry.getObject(name), amount, meta);
|
||||
if (type == 1)
|
||||
stack = new ItemStack((Item)Item.itemRegistry.getObject(name), amount, meta);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
DisplayUtil.renderStack(0, 0, stack);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.gui.truetyper.FontHelper;
|
||||
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
import mcp.mobius.waila.overlay.OverlayConfig;
|
||||
|
||||
public class TTRenderString implements IWailaTooltipRenderer{
|
||||
|
||||
final String data;
|
||||
final Dimension size;
|
||||
|
||||
public TTRenderString(String data){
|
||||
this.data = data;
|
||||
this.size = new Dimension(DisplayUtil.getDisplayWidth(data), data.equals("") ? 0 : 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
DisplayUtil.drawString(data, 0, 0, OverlayConfig.fontcolor, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.gui.truetyper.FontHelper;
|
||||
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderTrueTyper implements IWailaTooltipRenderer{
|
||||
|
||||
final String data;
|
||||
final Dimension size;
|
||||
|
||||
public TTRenderTrueTyper(String data){
|
||||
this.data = data;
|
||||
this.size = new Dimension(DisplayUtil.getDisplayWidth(data), data.equals("") ? 0 : (int)((TrueTypeFont)Waila.proxy.getFont()).getHeight()/2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
FontHelper.drawString(data, 0f, 0f, (TrueTypeFont)Waila.proxy.getFont(), 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.addons.agriculture.AgricultureModule;
|
||||
@@ -19,14 +18,18 @@ import mcp.mobius.waila.addons.railcraft.RailcraftModule;
|
||||
import mcp.mobius.waila.addons.statues.StatuesModule;
|
||||
import mcp.mobius.waila.addons.stevescarts.StevesCartsModule;
|
||||
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
|
||||
import mcp.mobius.waila.addons.thermaldynamics.ThermalDynamicsModule;
|
||||
import mcp.mobius.waila.addons.thermalexpansion.ThermalExpansionModule;
|
||||
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
|
||||
import mcp.mobius.waila.addons.vanillamc.HUDHandlerFurnace;
|
||||
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.handlers.DecoratorFMP;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerFMP;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ProxyServer {
|
||||
|
||||
public ProxyServer() {}
|
||||
@@ -36,6 +39,7 @@ public class ProxyServer {
|
||||
public void registerMods(){
|
||||
|
||||
HUDHandlerVanilla.register();
|
||||
HUDHandlerFurnace.register();
|
||||
|
||||
/* BUILDCRAFT */
|
||||
BCModule.register();
|
||||
@@ -57,6 +61,9 @@ public class ProxyServer {
|
||||
|
||||
/* Thermal Expansion */
|
||||
ThermalExpansionModule.register();
|
||||
|
||||
/* Thermal Dynamics */
|
||||
ThermalDynamicsModule.register();
|
||||
|
||||
/* ETB */
|
||||
ETBModule.register();
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package mcp.mobius.wailacore.asm;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
|
||||
public class CoreAccessTransformer extends AccessTransformer {
|
||||
|
||||
public CoreAccessTransformer() throws IOException {
|
||||
//super("waila_at.cfg");
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package mcp.mobius.wailacore.asm;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
|
||||
public class CoreContainer extends DummyModContainer {
|
||||
|
||||
public CoreContainer()
|
||||
{
|
||||
super(new ModMetadata());
|
||||
|
||||
ModMetadata md = getMetadata();
|
||||
md.modId = "WailaCore";
|
||||
md.name = "WailaCore";
|
||||
md.version = "1.0.0";
|
||||
md.credits = "ProfMobius";
|
||||
md.authorList = Arrays.asList("ProfMobius");
|
||||
md.description = "Coremod associated with Waila to force backward compatibility with the API";
|
||||
md.url = "profmobius.blogspot.com";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
//bus.register(this);
|
||||
// this needs to return true, otherwise the mod will be deactivated by FML
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package mcp.mobius.wailacore.asm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
@IFMLLoadingPlugin.TransformerExclusions("mcp.mobius.wailacore.asm")
|
||||
public class CoreDescription implements IFMLLoadingPlugin {
|
||||
|
||||
public static final Logger log = LogManager.getLogger("WailaCore");
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[] { "mcp.mobius.wailacore.asm.CoreTransformer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return "mcp.mobius.wailacore.asm.CoreContainer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
if(data.containsKey("coremodLocation"))
|
||||
location = (File) data.get("coremodLocation");
|
||||
}
|
||||
|
||||
public static File location;
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return "mcp.mobius.wailacore.asm.CoreAccessTransformer";
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package mcp.mobius.wailacore.asm;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
public class CoreTransformer implements IClassTransformer {
|
||||
|
||||
public CoreTransformer(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String srgname, byte[] bytes) {
|
||||
|
||||
/*
|
||||
boolean changed = false;
|
||||
ClassNode classNode = new ClassNode();
|
||||
ClassReader classReader = new ClassReader(bytes);
|
||||
|
||||
classReader.accept(classNode, 0);
|
||||
|
||||
for (MethodNode methodNode : classNode.methods){
|
||||
|
||||
if (methodNode.name.equals("getNBTData")
|
||||
&& methodNode.desc.equals("(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/World;III)Lnet/minecraft/nbt/NBTTagCompound;"))
|
||||
{
|
||||
methodNode.desc = "(Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/World;III)Lnet/minecraft/nbt/NBTTagCompound;";
|
||||
changed = true;
|
||||
CoreDescription.log.info(String.format("Class %s implements outdated getNBTData signature. Updating signature to most recent API.", name));
|
||||
}
|
||||
}
|
||||
|
||||
if (changed){
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (classNode.interfaces.contains("mcp/mobius/waila/api/IWailaDataProvider")){
|
||||
|
||||
CoreDescription.log.info(String.format("Identified Waila plugin class : %s", name));
|
||||
for (MethodNode methodNode : classNode.methods){
|
||||
CoreDescription.log.info(String.format(" %s - %s | %s | %s | %s", name, methodNode.access, methodNode.name, methodNode.desc, methodNode.signature));
|
||||
|
||||
|
||||
if (methodNode.name.equals("getNBTData")
|
||||
&& methodNode.desc.equals("(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/World;III)Lnet/minecraft/nbt/NBTTagCompound;"))
|
||||
{
|
||||
methodNode.desc = "(Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/World;III)Lnet/minecraft/nbt/NBTTagCompound;";
|
||||
CoreDescription.log.info(String.format("Class %s implements outdated getNBTData signature. Updating signature to most recent API.", name));
|
||||
}
|
||||
}
|
||||
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(writer);
|
||||
|
||||
return writer.toByteArray();
|
||||
}
|
||||
*/
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
screen.button.waila=Waila
|
||||
screen.button.modules=Moduly
|
||||
screen.label.scale=Mìøítko
|
||||
screen.label.dragtuto=Chytni HUD pro nastavení jeho pozice.
|
||||
|
||||
screen.button.default=Defaultní
|
||||
screen.button.cancel=Zrušit
|
||||
screen.button.ok=Ok
|
||||
screen.button.yes=Ano
|
||||
screen.button.no=Ne
|
||||
screen.button.back=Zpìt
|
||||
screen.button.hidden=Skrytý
|
||||
screen.button.visible=Viditelný
|
||||
screen.button.maintained=Spravované
|
||||
screen.button.toggled=Pøepnuté
|
||||
|
||||
choice.showhidewaila=Zobrazit/Skrýt Wailu
|
||||
choice.showhideidmeta=Zobrazit ID:Metadata
|
||||
choice.toggledmaintained=Pøepnuté/Spravované
|
||||
choice.showliquids=Tekutiny
|
||||
choice.shifttoggledblock=Pliž se pro pøepnutí blokù
|
||||
choice.shifttoggledents=Pliž se pro pøepnutí entit
|
||||
screen.button.configureaspect=Nastavení vzhledu...
|
||||
|
||||
enchant.title.name=Jméno
|
||||
enchant.title.minlvl=Minimální lvl
|
||||
enchant.title.maxlvl=Maximální lvl
|
||||
enchant.title.weight=Hmotnost
|
||||
enchant.label.enchantability=Oèarovatelnost
|
||||
|
||||
waila.keybind.wailaconfig=[Waila] Nastavení obrazu
|
||||
waila.keybind.wailadisplay=[Waila] Zobrazit/Skrýt
|
||||
waila.keybind.liquid=[Waila] Zobrazit tekutiny
|
||||
waila.keybind.recipe=[Waila] Zobrazit recept
|
||||
waila.keybind.usage=[Waila] Zobrazit použití
|
||||
waila.keybind.testing=[Waila] Testování
|
||||
|
||||
client.msg.norecipe=Nenalezen žádný recept.
|
||||
client.msg.nousage=Nenalezeno žádné využití.
|
||||
|
||||
hud.msg.none=<Nic>
|
||||
hud.msg.empty=<Prázdný>
|
||||
hud.msg.output=Výstup
|
||||
hud.msg.input=Vstup
|
||||
hud.msg.out=Ven
|
||||
hud.msg.in=Dovnitø
|
||||
hud.msg.power=Energie
|
||||
hud.msg.storage=Úložištì
|
||||
hud.msg.stored=Uloženo
|
||||
hud.msg.any=Jakýkoliv
|
||||
hud.msg.mode=Mód
|
||||
hud.msg.maxpower=Maximální Energie
|
||||
hud.msg.trigger=Spouštìè
|
||||
hud.msg.maxio=Maximální propustnost
|
||||
|
||||
hud.msg.send=Odeslat
|
||||
hud.msg.recv=Obdržet
|
||||
hud.msg.item=Pøedmìt
|
||||
hud.msg.fluid=Tekutina
|
||||
hud.msg.energ=Energie
|
||||
hud.msg.frequency=Frekvence
|
||||
|
||||
hud.msg.owner=Vlastník
|
||||
hud.msg.public=Veøejné
|
||||
hud.msg.restricted=Omezené
|
||||
hud.msg.private=Soukromé
|
||||
|
||||
hud.msg.white=Bílá
|
||||
hud.msg.orange=Oranžová
|
||||
hud.msg.magenta=Purpurová
|
||||
hud.msg.lblue=Svìtle modrá
|
||||
hud.msg.yellow=Žlutá
|
||||
hud.msg.lime=Svìtle zelená
|
||||
hud.msg.pink=Rùžová
|
||||
hud.msg.gray=Šedá
|
||||
hud.msg.lgray=Svìtle šedá
|
||||
hud.msg.cyan=Tyrkysová
|
||||
hud.msg.purple=Fialová
|
||||
hud.msg.blue=Modrá
|
||||
hud.msg.brown=Hnìdá
|
||||
hud.msg.green=Zelená
|
||||
hud.msg.red=Èervená
|
||||
hud.msg.black=Èerná
|
||||
|
||||
hud.msg.growth=Rùst
|
||||
hud.msg.mature=Stáøí
|
||||
hud.msg.off=Vypnuto
|
||||
hud.msg.on=Zapnuto
|
||||
hud.msg.state=Stav
|
||||
hud.msg.delay=Prodleva
|
||||
hud.msg.comparator=Porovnávaè
|
||||
hud.msg.substractor=Substraktor
|
||||
hud.msg.record=Záznam
|
||||
|
||||
hud.msg.offers=Poskytuje
|
||||
hud.msg.demands=Požaduje
|
||||
|
||||
option.appeng.monitorcontent=Obsah monitoru
|
||||
option.bb.content=Obsah barelu
|
||||
option.bc.tankamount=Množství tekutiny
|
||||
option.bc.tanktype=Typ tekutiny
|
||||
option.enderstorage.colors=Barvy
|
||||
option.ic2.inputeumach=Maximální pøíjem EU [Stroje]
|
||||
option.ic2.inputeuother=Maximální pøíjem EU [Ostatní]
|
||||
option.ic2.inputeu=Maximální pøijem EU
|
||||
option.ic2.outputeu=Maximální výstup EU
|
||||
option.ic2.storage=Uloženo energie
|
||||
option.ic2.consump=Zobrazit spotøebu
|
||||
option.ic2.tradeomat=Zobrazit Trade-O-Mat požadavek
|
||||
option.thaumcraft.storedvis=Úložištì kondenzátoru
|
||||
option.thermalexpansion.energyhandler=Zobrazit úložištì RF
|
||||
option.thermalexpansion.energycell=Zobrazit ECell VSTUP/VÝSTUP
|
||||
option.thermalexpansion.fluidtype=Zobrazit typ tekutiny
|
||||
option.thermalexpansion.fluidamount=Zobrazit množství tekutiny
|
||||
option.thermalexpansion.tankmode=Zobrazit mód nádrže
|
||||
option.thermalexpansion.tesssendrecv=Tesseract mode
|
||||
option.thermalexpansion.tessfreq=Frekvence Teseraktu
|
||||
option.thermalexpansion.owner=Zobrazit majitele
|
||||
option.thermalexpansion.conditemmode=Zobrazit mód Itemduktu
|
||||
option.vanilla.spawntype=Typ spawneru
|
||||
option.vanilla.growthvalue=Hodnota rùstu
|
||||
option.vanilla.leverstate=Stav páky
|
||||
option.vanilla.repeater=Prodleva opakovaèe
|
||||
option.vanilla.comparator=Mód porovnávaèe
|
||||
option.vanilla.redstone=Ruditová energie
|
||||
option.vanilla.jukebox=Jukeboxový disk
|
||||
option.vanilla.silverfish=Skrýt rybenku
|
||||
option.etb.displaydata=Zobrazit data slotu
|
||||
option.enderio.inout=Zobrazit vstup/výstup
|
||||
option.enderio.storage=Zobrazit uskladnìné MJ
|
||||
option.enderio.owner=Zobrazit majitele bloku
|
||||
option.enderio.channel=Zobrazit kanál nadkrychle
|
||||
option.bcapi.storage=Zobrazit uskladnìné MJ
|
||||
option.bcapi.consump=Zobrazit maximální energii
|
||||
option.bcapi.trigger=Zobrazit spouštìjící se energii
|
||||
option.pr.showio=Zobrazit IO brány
|
||||
option.pr.showdata=Zobrazit data bran
|
||||
option.extrautilities.fluidamount=Zobrazit množství tekutin
|
||||
option.openblocks.fluidamount=Zobrazit množství tekutin
|
||||
option.railcraft.fluidamount=Zobrazit množství tekutin
|
||||
option.secretrooms.hide=Skrýt camo bloky
|
||||
option.carpenters.hide=Skrýt camo bloky
|
||||
option.stevescarts.showall=Zobrazit data
|
||||
option.stevescarts.colorblind=Barevný mód
|
||||
option.stevescarts.shifttoggle=Shift pro pøepnutí
|
||||
option.general.showhp=Zobrazit zdraví entit
|
||||
option.general.showcrop=Zobrazit rùst plodin
|
||||
option.thaumcraft.aspects=Zobrazit aspekty
|
||||
@@ -143,6 +143,9 @@ option.carpenters.hide=Hide camo blocks
|
||||
option.stevescarts.showall=Show data
|
||||
option.stevescarts.colorblind=Colorblind mode
|
||||
option.stevescarts.shifttoggle=Shift toggle
|
||||
option.general.showents=Show entities
|
||||
option.general.showhp=Show entities health
|
||||
option.general.showcrop=Show crop growth
|
||||
option.thaumcraft.aspects=Show aspects
|
||||
option.thaumcraft.aspects=Show aspects
|
||||
|
||||
nei.options.keys.showenchant=Show enchanting values
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 606 B |
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{
|
||||
"modid": "waila",
|
||||
"name": "Waila",
|
||||
"modid": "${modId}",
|
||||
"name": "${modName}",
|
||||
"description": "All your data are belong to us.",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"version": "${modVersion}",
|
||||
"mcversion": "${minecraftVersion}",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authors": ["ProfMobius"],
|
||||
|
||||
Reference in new issue
Block a user