mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-14 17:14:51 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bcb9174fa | ||
|
|
fae07b5ca2 | ||
|
|
bc46b8840d | ||
|
|
7d72e0680e | ||
|
|
ee237c3a44 | ||
|
|
4c4cb95782 | ||
|
|
9698692020 | ||
|
|
e7524e80f1 |
No files matched your search
+215
-100
@@ -1,4 +1,4 @@
|
||||
//version: 1683373797
|
||||
//version: 1702141377
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -28,27 +28,12 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
// GTNH RetroFuturaGradle and ASM Fork
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
@@ -69,7 +54,7 @@ plugins {
|
||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.7'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26'
|
||||
}
|
||||
|
||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||
@@ -89,6 +74,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
|
||||
boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
|
||||
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false
|
||||
|
||||
final String CHECKSTYLE_CONFIG = """
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
|
||||
<module name="SuppressionCommentFilter"/>
|
||||
<module name="AvoidStarImport">
|
||||
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
|
||||
<property name="allowStaticMemberImports" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
"""
|
||||
|
||||
checkPropertyExists("modName")
|
||||
checkPropertyExists("modId")
|
||||
@@ -115,6 +117,8 @@ propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
|
||||
propertyDefaultIfUnset("forceEnableMixins", false)
|
||||
propertyDefaultIfUnset("channel", "stable")
|
||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||
propertyDefaultIfUnset("modrinthRelations", "")
|
||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||
@@ -138,6 +142,17 @@ if (!disableSpotless) {
|
||||
apply from: Blowdryer.file('spotless.gradle')
|
||||
}
|
||||
|
||||
if (!disableCheckstyle) {
|
||||
apply plugin: 'checkstyle'
|
||||
tasks.named("checkstylePatchedMc") { enabled = false }
|
||||
tasks.named("checkstyleMcLauncher") { enabled = false }
|
||||
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
|
||||
tasks.named("checkstyleInjectedTags") { enabled = false }
|
||||
checkstyle {
|
||||
config = resources.text.fromString(CHECKSTYLE_CONFIG)
|
||||
}
|
||||
}
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
@@ -272,7 +287,7 @@ if (apiPackage) {
|
||||
}
|
||||
|
||||
if (accessTransformersFile) {
|
||||
for (atFile in accessTransformersFile.split(",")) {
|
||||
for (atFile in accessTransformersFile.split(" ")) {
|
||||
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
|
||||
if (!getFile(targetFile).exists()) {
|
||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||
@@ -357,7 +372,27 @@ catch (Exception ignored) {
|
||||
String identifiedVersion
|
||||
String versionOverride = System.getenv("VERSION") ?: null
|
||||
try {
|
||||
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
|
||||
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
|
||||
if (versionOverride == null) {
|
||||
def gitDetails = versionDetails()
|
||||
def isDirty = gitVersion().endsWith(".dirty") // No public API for this, isCleanTag has a different meaning
|
||||
String branchName = gitDetails.branchName ?: (System.getenv('GIT_BRANCH') ?: 'git')
|
||||
if (branchName.startsWith('origin/')) {
|
||||
branchName = branchName.minus('origin/')
|
||||
}
|
||||
branchName = branchName.replaceAll("[^a-zA-Z0-9-]+", "-") // sanitize branch names for semver
|
||||
identifiedVersion = gitDetails.lastTag ?: '${gitDetails.gitHash}'
|
||||
if (gitDetails.commitDistance > 0) {
|
||||
identifiedVersion += "-${branchName}.${gitDetails.commitDistance}+${gitDetails.gitHash}"
|
||||
if (isDirty) {
|
||||
identifiedVersion += "-dirty"
|
||||
}
|
||||
} else if (isDirty) {
|
||||
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
|
||||
}
|
||||
} else {
|
||||
identifiedVersion = versionOverride
|
||||
}
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
out.style(Style.Failure).text(
|
||||
@@ -379,9 +414,13 @@ if (identifiedVersion == versionOverride) {
|
||||
|
||||
group = "com.github.GTNewHorizons"
|
||||
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
|
||||
archivesBaseName = customArchiveBaseName
|
||||
base {
|
||||
archivesName = customArchiveBaseName
|
||||
}
|
||||
} else {
|
||||
archivesBaseName = modId
|
||||
base {
|
||||
archivesName = modId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -465,10 +504,19 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
if (file('addon.gradle').exists()) {
|
||||
if (file('addon.gradle.kts').exists()) {
|
||||
apply from: 'addon.gradle.kts'
|
||||
} else if (file('addon.gradle').exists()) {
|
||||
apply from: 'addon.gradle'
|
||||
}
|
||||
|
||||
// File for local tweaks not commited to Git
|
||||
if (file('addon.local.gradle.kts').exists()) {
|
||||
apply from: 'addon.local.gradle.kts'
|
||||
} else if (file('addon.local.gradle').exists()) {
|
||||
apply from: 'addon.local.gradle'
|
||||
}
|
||||
|
||||
// Allow unsafe repos but warn
|
||||
repositories.configureEach { repo ->
|
||||
if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) {
|
||||
@@ -479,7 +527,14 @@ repositories.configureEach { repo ->
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'repositories.gradle'
|
||||
if (file('repositories.gradle.kts').exists()) {
|
||||
apply from: 'repositories.gradle.kts'
|
||||
} else if (file('repositories.gradle').exists()) {
|
||||
apply from: 'repositories.gradle'
|
||||
} else {
|
||||
logger.error("Neither repositories.gradle.kts nor repositories.gradle was found, make sure you extracted the full ExampleMod template.")
|
||||
throw new RuntimeException("Missing repositories.gradle[.kts]")
|
||||
}
|
||||
|
||||
configurations {
|
||||
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
|
||||
@@ -520,9 +575,6 @@ repositories {
|
||||
maven {
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
mavenContent {
|
||||
excludeGroup("net.minecraftforge") // missing the `universal` artefact
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
@@ -537,24 +589,34 @@ repositories {
|
||||
}
|
||||
}
|
||||
if (includeWellKnownRepositories.toBoolean()) {
|
||||
maven {
|
||||
name "CurseMaven"
|
||||
url "https://cursemaven.com"
|
||||
content {
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name "CurseMaven"
|
||||
url "https://cursemaven.com"
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = "https://maven.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
|
||||
content {
|
||||
includeGroup "net.industrial-craft"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "ic2-mirror"
|
||||
url = "https://maven2.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
@@ -569,9 +631,12 @@ repositories {
|
||||
|
||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||
def mixinProviderModule = "unimixins"
|
||||
def mixinProviderVersion = "0.1.6"
|
||||
def mixinProviderVersion = "0.1.13"
|
||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
|
||||
dependencies {
|
||||
if (usesMixins.toBoolean()) {
|
||||
@@ -584,7 +649,7 @@ dependencies {
|
||||
}
|
||||
}
|
||||
if (usesMixins.toBoolean()) {
|
||||
implementation(mixinProviderSpec)
|
||||
implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap))
|
||||
} else if (forceEnableMixins.toBoolean()) {
|
||||
runtimeOnlyNonPublishable(mixinProviderSpec)
|
||||
}
|
||||
@@ -607,15 +672,37 @@ configurations.all {
|
||||
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
||||
|
||||
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'dependencies.gradle'
|
||||
dependencies {
|
||||
constraints {
|
||||
def minGtnhLibVersion = "0.0.13"
|
||||
implementation("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
|
||||
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
|
||||
}
|
||||
runtimeOnly("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
|
||||
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
|
||||
}
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
|
||||
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
|
||||
}
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:${minGtnhLibVersion}") {
|
||||
because("fixes duplicate mod errors in java 17 configurations using old gtnhlib")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
|
||||
def refMap = "${mixinTmpDir}" + File.separator + mixingConfigRefMap
|
||||
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"
|
||||
if (file('dependencies.gradle.kts').exists()) {
|
||||
apply from: 'dependencies.gradle.kts'
|
||||
} else if (file('dependencies.gradle').exists()) {
|
||||
apply from: 'dependencies.gradle'
|
||||
} else {
|
||||
logger.error("Neither dependencies.gradle.kts nor dependencies.gradle was found, make sure you extracted the full ExampleMod template.")
|
||||
throw new RuntimeException("Missing dependencies.gradle[.kts]")
|
||||
}
|
||||
|
||||
tasks.register('generateAssets') {
|
||||
group = "GTNH Buildscript"
|
||||
@@ -647,46 +734,17 @@ tasks.register('generateAssets') {
|
||||
}
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
tasks.named("reobfJar", ReobfuscatedJar).configure {
|
||||
extraSrgFiles.from(mixinSrg)
|
||||
}
|
||||
|
||||
tasks.named("processResources").configure {
|
||||
dependsOn("generateAssets")
|
||||
}
|
||||
|
||||
tasks.named("compileJava", JavaCompile).configure {
|
||||
doFirst {
|
||||
new File(mixinTmpDir).mkdirs()
|
||||
}
|
||||
options.compilerArgs += [
|
||||
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
|
||||
"-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"
|
||||
]
|
||||
}
|
||||
|
||||
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
javacOptions {
|
||||
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
|
||||
option("-AoutSrgFile=$mixinSrg")
|
||||
option("-AoutRefMapFile=$refMap")
|
||||
}
|
||||
}
|
||||
tasks.configureEach { task ->
|
||||
if (task.name == "kaptKotlin") {
|
||||
task.doFirst {
|
||||
new File(mixinTmpDir).mkdirs()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.named("processResources", ProcessResources).configure {
|
||||
@@ -704,7 +762,6 @@ tasks.named("processResources", ProcessResources).configure {
|
||||
}
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
from refMap
|
||||
dependsOn("compileJava", "compileScala")
|
||||
}
|
||||
}
|
||||
@@ -723,23 +780,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lwjgl3ifyVersion = '1.3.5'
|
||||
def asmVersion = '9.4'
|
||||
def lwjgl3ifyVersion = '1.5.7'
|
||||
if (modId != 'lwjgl3ify') {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.8')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
|
||||
}
|
||||
|
||||
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
|
||||
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
|
||||
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
|
||||
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
|
||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||
}
|
||||
|
||||
@@ -822,6 +870,18 @@ public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
|
||||
}
|
||||
this.classpath(project.java17DependenciesCfg)
|
||||
}
|
||||
|
||||
public void setup(Project project) {
|
||||
super.setup(project)
|
||||
if (project.usesMixins.toBoolean()) {
|
||||
this.extraJvmArgs.addAll(project.provider(() -> {
|
||||
def mixinCfg = project.configurations.detachedConfiguration(project.dependencies.create(project.mixinProviderSpec))
|
||||
mixinCfg.canBeConsumed = false
|
||||
mixinCfg.transitive = false
|
||||
enableHotswap ? ["-javaagent:" + mixinCfg.singleFile.absolutePath] : []
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Distribution.CLIENT, "runClient")
|
||||
@@ -966,6 +1026,9 @@ idea {
|
||||
}
|
||||
}
|
||||
runConfigurations {
|
||||
"0. Build and Test"(Gradle) {
|
||||
taskNames = ["build"]
|
||||
}
|
||||
"1. Run Client"(Gradle) {
|
||||
taskNames = ["runClient"]
|
||||
}
|
||||
@@ -1085,6 +1148,14 @@ tasks.named("processIdeaSettings").configure {
|
||||
dependsOn("injectTags")
|
||||
}
|
||||
|
||||
tasks.named("ideVirtualMainClasses").configure {
|
||||
// Make IntelliJ "Build project" build the mod jars
|
||||
dependsOn("jar", "reobfJar")
|
||||
if (!disableSpotless) {
|
||||
dependsOn("spotlessCheck")
|
||||
}
|
||||
}
|
||||
|
||||
// workaround variable hiding in pom processing
|
||||
def projectConfigs = project.configurations
|
||||
|
||||
@@ -1103,14 +1174,15 @@ publishing {
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
|
||||
allowInsecureProtocol = true
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
||||
maven {
|
||||
url = mavenPublishUrl
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1225,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
|
||||
|
||||
// Updating
|
||||
|
||||
def buildscriptGradleVersion = "8.1.1"
|
||||
def buildscriptGradleVersion = "8.5"
|
||||
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
gradleVersion = buildscriptGradleVersion
|
||||
@@ -1263,10 +1335,14 @@ tasks.register('faq') {
|
||||
description = 'Prints frequently asked questions about building a project'
|
||||
|
||||
doLast {
|
||||
print("If your build fails to fetch dependencies, they might have been deleted and replaced by newer " +
|
||||
"versions.\nCheck if the versions you try to fetch are still on the distributing sites.\n" +
|
||||
"The links can be found in repositories.gradle and build.gradle:repositories, " +
|
||||
"not build.gradle:buildscript.repositories - this one is for gradle plugin metadata.")
|
||||
print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " +
|
||||
"Or you can manually check if the versions are still on the distributing sites - " +
|
||||
"the links can be found in repositories.gradle and build.gradle:repositories, " +
|
||||
"but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" +
|
||||
"If your build fails to recognize the syntax of new Java versions, enable Jabel in your " +
|
||||
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " +
|
||||
"However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " +
|
||||
"Java 9 or later.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1327,8 +1403,14 @@ boolean isNewBuildScriptVersionAvailable() {
|
||||
|
||||
String currentBuildScript = getFile("build.gradle").getText()
|
||||
String currentBuildScriptHash = getVersionHash(currentBuildScript)
|
||||
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
|
||||
String availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||
String availableBuildScriptHash
|
||||
try {
|
||||
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
|
||||
availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||
} catch (IOException e) {
|
||||
logger.warn("Could not check for buildscript update availability: {}", e.message)
|
||||
return false
|
||||
}
|
||||
|
||||
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
|
||||
return !isUpToDate
|
||||
@@ -1493,3 +1575,36 @@ def getSecondaryArtifacts() {
|
||||
if (apiPackage) secondaryArtifacts += [apiJar]
|
||||
return secondaryArtifacts
|
||||
}
|
||||
|
||||
def getURL(String main, String fallback) {
|
||||
return pingURL(main, 10000) ? main : fallback
|
||||
}
|
||||
|
||||
// credit: https://stackoverflow.com/a/3584332
|
||||
def pingURL(String url, int timeout) {
|
||||
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
|
||||
connection.setConnectTimeout(timeout)
|
||||
connection.setReadTimeout(timeout)
|
||||
connection.setRequestMethod("HEAD")
|
||||
int responseCode = connection.getResponseCode()
|
||||
return 200 <= responseCode && responseCode <= 399
|
||||
} catch (IOException ignored) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// For easier scripting of things that require variables defined earlier in the buildscript
|
||||
if (file('addon.late.gradle.kts').exists()) {
|
||||
apply from: 'addon.late.gradle.kts'
|
||||
} else if (file('addon.late.gradle').exists()) {
|
||||
apply from: 'addon.late.gradle'
|
||||
}
|
||||
|
||||
// File for local tweaks not commited to Git
|
||||
if (file('addon.late.local.gradle.kts').exists()) {
|
||||
apply from: 'addon.late.local.gradle.kts'
|
||||
} else if (file('addon.late.local.gradle').exists()) {
|
||||
apply from: 'addon.late.local.gradle'
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.48-GTNH:dev')
|
||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.13-GTNH:dev')
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ apiPackage = api
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# Example value: mymodid_at.cfg
|
||||
accessTransformersFile =
|
||||
accessTransformersFile = Waila_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.addons.enderio;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RESET;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.enderio;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RESET;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEBaseGenerator implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
int storage = -1;
|
||||
int production = -1;
|
||||
|
||||
if (IC2Module.TileEntityBaseGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEBG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEBG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntityGeoGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TEGG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = IC2Module.TEGG_Production.getInt(accessor.getTileEntity());
|
||||
}
|
||||
else if (IC2Module.TileEntitySemifluidGenerator.isInstance(accessor.getTileEntity())){
|
||||
storage = IC2Module.TESG_MaxStorage.getShort(accessor.getTileEntity());
|
||||
production = (int)IC2Module.TESG_Production.getDouble(accessor.getTileEntity());
|
||||
}
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
if ( stored >= 0.0 && storage > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
|
||||
//else if (stored >= 0.0)
|
||||
// currenttip.add(String.format("Stored : %d EU", stored));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEElectricBlock implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String outputStr = LangUtil.translateG("hud.msg.output");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
int storage = IC2Module.TEEB_MaxStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.outputeu")){
|
||||
int production = IC2Module.TEEB_Output.getInt(accessor.getTileEntity());
|
||||
if ( production > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", outputStr, TAB + ALIGNRIGHT, production));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTEStandardMachine implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
try{
|
||||
|
||||
IC2Upgrades upgrades = IC2Module.getUpgrades(accessor);
|
||||
int baseConsumption = IC2Module.TESM_DefaultEnergyConsume.getInt(accessor.getTileEntity());
|
||||
int baseOpTime = IC2Module.TESM_DefaultOperationLength.getInt(accessor.getTileEntity());
|
||||
int baseStorage = IC2Module.TESM_DefaultEnergyStorage.getInt(accessor.getTileEntity());
|
||||
|
||||
long consumption = Math.round(Math.min(baseConsumption * Math.pow(1.6D, upgrades.overclocker), 2147483647));
|
||||
|
||||
double stackOpLen = baseOpTime * 64.0D * Math.pow(0.7D, upgrades.overclocker);
|
||||
int opPerTick = ((int)Math.min(Math.ceil(64.0D / stackOpLen), 2147483647.0D));
|
||||
int opTime = ((int)Math.round(stackOpLen * opPerTick / 64.0D));
|
||||
|
||||
int storage = Math.round(Math.min(baseStorage + 10000 * upgrades.storage + opTime * consumption, 2147483647));;
|
||||
|
||||
|
||||
int maxinput = (Integer)IC2Module.IES_GetMaxSafeInput.invoke(accessor.getTileEntity()) * (int)Math.pow(4.0D, Math.min(4, upgrades.transform));
|
||||
double stored = IC2Module.getStoredEnergy(accessor);
|
||||
|
||||
String storedStr = LangUtil.translateG("hud.msg.stored");
|
||||
String powerStr = LangUtil.translateG("hud.msg.power");
|
||||
String maxPowerStr = LangUtil.translateG("hud.msg.maxpower");
|
||||
|
||||
/* EU Storage */
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if ( stored >= 0.0 )
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r / \u00a7f%d\u00a7r EU", storedStr, TAB + ALIGNRIGHT, Math.round(Math.min(stored,storage)), storage));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.consump")){
|
||||
if ( consumption > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", powerStr, TAB + ALIGNRIGHT, consumption ));
|
||||
}
|
||||
|
||||
if (ConfigHandler.instance().getConfig("ic2.inputeu")){
|
||||
if ( maxinput > 0)
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r EU/t", maxPowerStr, TAB + ALIGNRIGHT, maxinput ));
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.impl.ConfigHandler;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
|
||||
public class HUDHandlerTETradeOMat implements IWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack,List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
/*
|
||||
if (!ConfigHandler.instance().getConfig("ic2.tradeomat")) return currenttip;
|
||||
|
||||
NBTTagCompound slots = accessor.getNBTData().getCompoundTag("InvSlots");
|
||||
NBTTagList offer = slots.getCompoundTag("offer").getTagList("Contents");
|
||||
NBTTagList demand = slots.getCompoundTag("demand").getTagList("Contents");
|
||||
String offersStr = LangUtil.translateG("hud.msg.offers");
|
||||
String demandsStr = LangUtil.translateG("hud.msg.demands");
|
||||
|
||||
|
||||
if (offer.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)offer.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", offersStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
|
||||
if (demand.tagCount() == 1){
|
||||
NBTTagCompound subtag = (NBTTagCompound)demand.tagAt(0);
|
||||
ItemStack is = new ItemStack(subtag.getShort("id"), subtag.getByte("Count"), subtag.getShort("Damage"));
|
||||
currenttip.add(String.format("%s%s\u00a7f%d\u00a7r x \u00a7f%s\u00a7r", demandsStr, TAB + ALIGNRIGHT, is.stackSize, is.getDisplayName()));
|
||||
}
|
||||
*/
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
|
||||
if (te != null)
|
||||
te.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
|
||||
public class IC2Module {
|
||||
|
||||
public static Class TileEntityStandardMachine = null;
|
||||
public static Field TESM_DefaultEnergyStorage = null;
|
||||
public static Field TESM_DefaultEnergyConsume = null;
|
||||
public static Field TESM_DefaultOperationLength = null;
|
||||
public static Field TESM_MaxEnergy = null;
|
||||
|
||||
public static Class TileEntityBaseGenerator = null;
|
||||
public static Field TEBG_MaxStorage = null;
|
||||
public static Field TEBG_Production = null;
|
||||
|
||||
public static Class TileEntitySemifluidGenerator = null;
|
||||
public static Field TESG_MaxStorage = null;
|
||||
public static Field TESG_Production = null;
|
||||
|
||||
public static Class TileEntityGeoGenerator = null;
|
||||
public static Field TEGG_MaxStorage = null;
|
||||
public static Field TEGG_Production = null;
|
||||
|
||||
public static Class TileEntityElectricBlock = null;
|
||||
public static Field TEEB_MaxStorage = null;
|
||||
public static Field TEEB_Output = null;
|
||||
|
||||
public static Class IEnergySink = null;
|
||||
public static Method IES_GetMaxSafeInput = null;
|
||||
|
||||
public static Class TileEntityTradeOMat = null;
|
||||
|
||||
/* Some required items */
|
||||
public static Class IC2Items = null;
|
||||
public static Field TransformerUpgrade = null;
|
||||
public static ItemStack TransformerUpgradeStack = null;
|
||||
public static Field EnergyStorageUpgrade = null;
|
||||
public static ItemStack EnergyStorageUpgradeStack = null;
|
||||
public static Field OverclockerUpgrade = null;
|
||||
public static ItemStack OverclockerUpgradeStack = null;
|
||||
|
||||
public static void register(){
|
||||
/*
|
||||
|
||||
try{
|
||||
TileEntityStandardMachine = Class.forName("ic2.core.block.machine.tileentity.TileEntityStandardMachine");
|
||||
TESM_DefaultEnergyStorage = TileEntityStandardMachine.getField("defaultEnergyStorage");
|
||||
TESM_DefaultEnergyConsume = TileEntityStandardMachine.getField("defaultEnergyConsume");
|
||||
TESM_DefaultOperationLength = TileEntityStandardMachine.getField("defaultOperationLength");
|
||||
TESM_MaxEnergy = TileEntityStandardMachine.getField("maxEnergy");
|
||||
|
||||
TileEntityBaseGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityBaseGenerator");
|
||||
TEBG_MaxStorage = TileEntityBaseGenerator.getField("maxStorage");
|
||||
TEBG_Production = TileEntityBaseGenerator.getField("production");
|
||||
|
||||
TileEntitySemifluidGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator");
|
||||
TESG_MaxStorage = TileEntitySemifluidGenerator.getDeclaredField("maxStorage");
|
||||
TESG_Production = TileEntitySemifluidGenerator.getDeclaredField("production");
|
||||
TESG_MaxStorage.setAccessible(true);
|
||||
TESG_Production.setAccessible(true);
|
||||
|
||||
TileEntityGeoGenerator = Class.forName("ic2.core.block.generator.tileentity.TileEntityGeoGenerator");
|
||||
TEGG_MaxStorage = TileEntityGeoGenerator.getField("maxStorage");
|
||||
TEGG_Production = TileEntityGeoGenerator.getField("production");
|
||||
|
||||
TileEntityElectricBlock = Class.forName("ic2.core.block.wiring.TileEntityElectricBlock");
|
||||
TEEB_MaxStorage = TileEntityElectricBlock.getField("maxStorage");
|
||||
TEEB_Output = TileEntityElectricBlock.getField("output");
|
||||
|
||||
IEnergySink = Class.forName("ic2.api.energy.tile.IEnergySink");
|
||||
IES_GetMaxSafeInput = IEnergySink.getMethod("getMaxSafeInput");
|
||||
|
||||
IC2Items = Class.forName("ic2.core.Ic2Items");
|
||||
TransformerUpgrade = IC2Items.getField("transformerUpgrade");
|
||||
EnergyStorageUpgrade = IC2Items.getField("energyStorageUpgrade");
|
||||
OverclockerUpgrade = IC2Items.getField("overclockerUpgrade");
|
||||
|
||||
TransformerUpgradeStack = (ItemStack)TransformerUpgrade.get(null);
|
||||
EnergyStorageUpgradeStack = (ItemStack)EnergyStorageUpgrade.get(null);
|
||||
OverclockerUpgradeStack = (ItemStack)OverclockerUpgrade.get(null);
|
||||
|
||||
TileEntityTradeOMat = Class.forName("ic2.core.block.personal.TileEntityTradeOMat");
|
||||
|
||||
} catch (ClassNotFoundException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Class not found. " + e);
|
||||
return;
|
||||
} catch (NoSuchMethodException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Method not found." + e);
|
||||
return;
|
||||
} catch (NoSuchFieldException e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Field not found." + e);
|
||||
return;
|
||||
} catch (Exception e){
|
||||
//e.printStackTrace();
|
||||
Waila.log.log(Level.WARNING, "[IC2] Unhandled exception." + e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.storage");
|
||||
ModuleRegistrar.instance().addConfig("IndustrialCraft2", "ic2.outputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.inputeu");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.consump");
|
||||
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.tradeomat");
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEStandardMachine(), TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEBaseGenerator(), TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTEElectricBlock(), TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerTETradeOMat(), TileEntityTradeOMat);
|
||||
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityStandardMachine);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityBaseGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntitySemifluidGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityGeoGenerator);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityElectricBlock);
|
||||
ModuleRegistrar.instance().registerSyncedNBTKey("*", TileEntityTradeOMat);
|
||||
*/
|
||||
}
|
||||
|
||||
/* Retuns the current stored energy if available in the nbt and config is true */
|
||||
public static double getStoredEnergy(IWailaDataAccessor accessor){
|
||||
/*
|
||||
if (ConfigHandler.instance().getConfig("ic2.storage")){
|
||||
if (accessor.getNBTData().hasKey("energy"))
|
||||
return accessor.getNBTData().getDouble("energy");
|
||||
else if (accessor.getNBTData().hasKey("storage"))
|
||||
return accessor.getNBTData().getDouble("storage");
|
||||
}
|
||||
*/
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
public static IC2Upgrades getUpgrades(IWailaDataAccessor accessor){
|
||||
|
||||
NBTTagCompound nbt = accessor.getNBTData();
|
||||
IC2Upgrades upgrades = new IC2Upgrades();
|
||||
|
||||
/*
|
||||
if (!nbt.hasKey("InvSlots")) return null;
|
||||
|
||||
NBTTagCompound inventory = nbt.getCompoundTag("InvSlots");
|
||||
if (!inventory.hasKey("upgrade")) return null;
|
||||
|
||||
NBTTagList nbtupgrades = inventory.getCompoundTag("upgrade").getTagList("Contents");
|
||||
|
||||
//List tagList = (List)AccessHelper.getField("net.minecraft.nbt.NBTTagList", "tagList", nbtupgrades);
|
||||
List tagList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtupgrades, "field_74747_a");
|
||||
|
||||
for (Object subobj : tagList){
|
||||
NBTTagCompound subtag = (NBTTagCompound)subobj;
|
||||
int id = subtag.getShort("id");
|
||||
int meta = subtag.getShort("Damage");
|
||||
int count = subtag.getByte("Count");
|
||||
|
||||
//ItemStack is = new ItemStack(id, 1, count);
|
||||
if (TransformerUpgradeStack.getItemDamage() == meta && TransformerUpgradeStack.itemID == id)
|
||||
upgrades.transform += count;
|
||||
if (EnergyStorageUpgradeStack.getItemDamage() == meta && EnergyStorageUpgradeStack.itemID == id)
|
||||
upgrades.storage += count;
|
||||
if (OverclockerUpgradeStack.getItemDamage() == meta && OverclockerUpgradeStack.itemID == id)
|
||||
upgrades.overclocker += count;
|
||||
}
|
||||
*/
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package mcp.mobius.waila.addons.ic2;
|
||||
|
||||
public class IC2Upgrades {
|
||||
public int transform = 0;
|
||||
public int storage = 0;
|
||||
public int overclocker = 0;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.addons.projectred;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.statues;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.addons.stevescarts;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.addons.thaumcraft;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.TAB;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@@ -49,4 +49,6 @@ public interface IWailaDataAccessor {
|
||||
ForgeDirection getSide();
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
float getBlockBreakDamage();
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
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 {
|
||||
|
||||
@@ -150,6 +150,8 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
|
||||
|
||||
OverlayConfig.alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
|
||||
OverlayConfig.breakprogress = config
|
||||
.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BREAK_PROGRESS, true).getBoolean();
|
||||
OverlayConfig.bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010)
|
||||
.getInt();
|
||||
OverlayConfig.gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -21,6 +22,7 @@ import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor {
|
||||
|
||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
@@ -37,6 +39,7 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
public ItemStack stack;
|
||||
|
||||
public static DataAccessorCommon instance = new DataAccessorCommon();
|
||||
public float blockBreakDamage;
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
@@ -55,6 +58,7 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
this.entity = null;
|
||||
this.blockID = Block.getIdFromBlock(this.block);
|
||||
this.blockResource = GameData.getBlockRegistry().getNameForObject(this.block);
|
||||
this.blockBreakDamage = MC.playerController.curBlockDamageMP;
|
||||
try {
|
||||
this.stack = new ItemStack(this.block, 1, this.metadata);
|
||||
} catch (Exception e) {}
|
||||
@@ -200,6 +204,11 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockBreakDamage() {
|
||||
return this.blockBreakDamage;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time) {
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
@@ -212,5 +221,4 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
public String getBlockQualifiedName() {
|
||||
return this.blockResource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,12 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import mcp.mobius.waila.Waila;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.gui.truetyper.FontLoader;
|
||||
@@ -32,8 +35,6 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
LangUtil.loadLangDir("waila");
|
||||
|
||||
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
|
||||
|
||||
// TickRegistry.registerTickHandler(WailaTickHandler.instance(), Side.CLIENT);
|
||||
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
@@ -63,11 +64,22 @@ public class ProxyClient extends ProxyServer {
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new WorldUnloadEventHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getFont() {
|
||||
if (minecraftiaFont == null)
|
||||
minecraftiaFont = FontLoader.createFont(new ResourceLocation("waila", "fonts/Minecraftia.ttf"), 14, true);
|
||||
return this.minecraftiaFont;
|
||||
}
|
||||
|
||||
public static class WorldUnloadEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
DataAccessorCommon.instance = new DataAccessorCommon();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.IWidget;
|
||||
import mcp.mobius.waila.gui_old.widget_old.Button2States;
|
||||
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
public class BaseWailaScreen extends GuiScreen{
|
||||
|
||||
protected GuiScreen parentGui; // GUI we will return to in the case we are call from a GUI
|
||||
public ScaledResolution res;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
|
||||
/* Custom mouse handling */
|
||||
private int lastMouseButton = -1;
|
||||
private long lastMouseEvent = -1;
|
||||
private int lastMousePosX = -1;
|
||||
private int lastMousePosY = -1;
|
||||
private static int buttonCount = Mouse.getButtonCount();
|
||||
private boolean[] lastButtonStates = new boolean[buttonCount];
|
||||
private IWidget[] focusWidget = new IWidget[buttonCount];
|
||||
private IWidget mainFocusWidget = null;
|
||||
|
||||
|
||||
|
||||
public BaseWailaScreen(GuiScreen _parentGui) {
|
||||
this.parentGui = _parentGui;
|
||||
res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
Mouse.getDWheel();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we draw anything special, and super takes care of the buttons for us */
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* Here we handle key presses. Super will just close the gui on ESC, and we like it like that */
|
||||
public void keyTyped(char keyChar, int keyID)
|
||||
{
|
||||
if (keyID == 1)
|
||||
{
|
||||
if (this.parentGui == null){
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
this.mc.setIngameFocus();
|
||||
} else {
|
||||
this.mc.displayGuiScreen(this.parentGui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
if (guibutton instanceof ButtonChangeScreen)
|
||||
((ButtonChangeScreen)guibutton).pressButton();
|
||||
|
||||
else if (guibutton instanceof Button2States)
|
||||
((Button2States)guibutton).pressButton();
|
||||
}
|
||||
|
||||
protected int getXCentered(int width){
|
||||
return (this.res.getScaledWidth() - width)/ 2;
|
||||
}
|
||||
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null && widget.mouseClicked(mouseX, mouseY, buttonID)){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = widget;
|
||||
this.focusWidget[buttonID] = widget;
|
||||
}
|
||||
else
|
||||
super.mouseClicked(mouseX, mouseY, buttonID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int mouseX, int mouseY, int buttonID)
|
||||
{
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = null;
|
||||
|
||||
if (this.focusWidget[buttonID] != null){
|
||||
this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
|
||||
this.focusWidget[buttonID] = null;
|
||||
} else {
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget == null || !widget.mouseReleased(mouseX, mouseY, buttonID))
|
||||
super.mouseMovedOrUp(mouseX, mouseY, buttonID);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
}
|
||||
|
||||
public void mouseMoved(int mouseX, int mouseY){
|
||||
if (this.mainFocusWidget != null)
|
||||
this.mainFocusWidget.mouseMoved(mouseX, mouseY);
|
||||
else{
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseMoved(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public void mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
int mouseZ = Mouse.getEventDWheel();
|
||||
boolean[] buttonChanged = new boolean[buttonCount];
|
||||
|
||||
if (mouseZ != 0)
|
||||
this.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
|
||||
int changedButton = -1;
|
||||
boolean hasStateChanged = false;
|
||||
if (Mouse.getEventButtonState()){
|
||||
hasStateChanged = true;
|
||||
changedButton = Mouse.getEventButton();
|
||||
}
|
||||
for (int i = 0; i < buttonCount; i++){
|
||||
buttonChanged[i] = Mouse.isButtonDown(i) != this.lastButtonStates[i];
|
||||
this.lastButtonStates[i] = Mouse.isButtonDown(i);
|
||||
|
||||
if (buttonChanged[i] && Mouse.isButtonDown(i))
|
||||
this.mouseClicked(mouseX, mouseY, i);
|
||||
else if (buttonChanged[i] && !Mouse.isButtonDown(i))
|
||||
this.mouseMovedOrUp(mouseX, mouseY, i);
|
||||
}
|
||||
|
||||
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
|
||||
/*
|
||||
if (changedButton != -1){
|
||||
if (Mouse.isButtonDown(changedButton)){
|
||||
this.mouseClicked(mouseX, mouseY, changedButton);
|
||||
this.lastMouseButton = changedButton;
|
||||
}
|
||||
else if (!Mouse.isButtonDown(changedButton)){
|
||||
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
|
||||
this.lastMouseButton = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (hasStateChanged)
|
||||
{
|
||||
this.lastMouseButton = changedButton;
|
||||
this.lastMouseEvent = Minecraft.getSystemTime();
|
||||
this.mouseClicked(mouseX, mouseY, this.lastMouseButton);
|
||||
}
|
||||
else if (changedButton != -1)
|
||||
{
|
||||
this.lastMouseButton = -1;
|
||||
this.mouseMovedOrUp(mouseX, mouseY, changedButton);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else if (this.lastMouseButton != -1 && this.lastMouseEvent > 0L)
|
||||
{
|
||||
long deltaTime = Minecraft.getSystemTime() - this.lastMouseEvent;
|
||||
this.mouseDragged(mouseX, mouseY, this.lastMouseButton, deltaTime);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else if ((mouseX != this.lastMousePosX) || (mouseY != this.lastMousePosY)){
|
||||
this.mouseMoved(mouseX, mouseY);
|
||||
this.lastMousePosX = mouseX;
|
||||
this.lastMousePosY = mouseY;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.ContainerTable;
|
||||
import mcp.mobius.waila.gui_old.widget.Label;
|
||||
import mcp.mobius.waila.gui_old.widget.StackDisplay;
|
||||
import mcp.mobius.waila.gui_old.widget.WikiReader;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiIngameWiki extends BaseWailaScreen {
|
||||
|
||||
public WikiReader widReader = null;
|
||||
public StackDisplay widStack = null;
|
||||
public ContainerTable widTable = null;
|
||||
public Label widItemName = null;
|
||||
|
||||
public GuiIngameWiki(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
|
||||
this.widReader = new WikiReader(this);
|
||||
this.widStack = new StackDisplay(this);
|
||||
this.widTable = new ContainerTable(this);
|
||||
this.widItemName = new Label("");
|
||||
|
||||
this.widReader.setWidth(this.res.getScaledWidth()-this.res.getScaledWidth()/3 - 16);
|
||||
this.widReader.setHeight(this.res.getScaledHeight() - 24);
|
||||
this.widReader.setBackgroundColor(0x66888888);
|
||||
|
||||
this.widStack.setScale(4.0f);
|
||||
|
||||
this.widTable.setAutosize(false);
|
||||
this.widTable.setWidth(this.res.getScaledWidth()/3 - 8);
|
||||
this.widTable.setHeight(this.res.getScaledHeight() - 16 - this.widStack.getHeight());
|
||||
this.widTable.setColumns(8, "\u00a7a\u00a7oEntry", "\u00a7a\u00a7oValue");
|
||||
|
||||
this.addWidget("wikireader", this.widReader);
|
||||
this.addWidget("stackdisplay", this.widStack);
|
||||
this.addWidget("datatable", this.widTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
super.drawScreen(i, j, f);
|
||||
widTable.draw(4, this.widStack.getHeight() + 16, 1000);
|
||||
widItemName.draw(this.res.getScaledWidth()/6-widItemName.getWidth()/2, this.widStack.getHeight(), 0);
|
||||
widReader.draw(this.res.getScaledWidth()/3 + 8, 8, 0);
|
||||
widStack.draw(this.res.getScaledWidth()/6-widStack.getWidth()/2, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDefaultBackground()
|
||||
{
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old;
|
||||
|
||||
import mcp.mobius.waila.gui_old.widget.DraggableViewport;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiTechTree extends BaseWailaScreen {
|
||||
|
||||
public DraggableViewport widViewport = null;
|
||||
public int topOffset = 16;
|
||||
|
||||
public GuiTechTree(GuiScreen _parentGui) {
|
||||
super(_parentGui);
|
||||
|
||||
this.widViewport = new DraggableViewport(this);
|
||||
this.widViewport.setWidth(this.res.getScaledWidth() - 32);
|
||||
this.widViewport.setHeight(this.res.getScaledHeight() - 32);
|
||||
this.widViewport.setBackgroundColor(0x66888888);
|
||||
|
||||
this.addWidget("viewport", this.widViewport);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
super.drawScreen(i, j, f);
|
||||
this.widViewport.draw(16,topOffset,0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDefaultBackground()
|
||||
{
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0xdd000000, 0xdd000000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import codechicken.core.ReflectionManager;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.FuelRecipeHandler;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class CraftingTreeNode {
|
||||
|
||||
CraftingTreeNode topNode = null;
|
||||
LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>> bottomNodes = new LinkedHashMap<ItemStack, ArrayList<CraftingTreeNode>>();
|
||||
|
||||
//Item stacks we have in the node.
|
||||
public ArrayList<ItemStack> elements = new ArrayList<ItemStack>();
|
||||
//Item stacks we are filtering the recipes with. (Previous stacks in the tree)
|
||||
ArrayList<CachedRecipe> excRecipes = new ArrayList<CachedRecipe>();
|
||||
//List of recipes available for a given stack
|
||||
HashMap<ItemStack, ArrayList<CachedRecipe>> recipesMap = new HashMap<ItemStack, ArrayList<CachedRecipe>>();
|
||||
//Components sorted by recipes for a given item stack
|
||||
HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>> componentsMap = new HashMap<ItemStack, ArrayList<ArrayList<ItemStack>>>();
|
||||
|
||||
int layer;
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers;
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.setElements(elements);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ArrayList<ItemStack> elements, ArrayList<CachedRecipe> excluded, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.excRecipes = excluded;
|
||||
this.setElements(elements);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public CraftingTreeNode(CraftingTreeNode topNode, ItemStack stack, int layer, LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers) {
|
||||
this.topNode = topNode;
|
||||
this.layer = layer;
|
||||
this.layers = layers;
|
||||
this.addSelfToLayers();
|
||||
this.addElement(stack);
|
||||
System.out.printf("%s\n", this.toString());
|
||||
}
|
||||
|
||||
public void addSelfToLayers(){
|
||||
if (!(this.layers.containsKey(layer)))
|
||||
this.layers.put(this.layer, new ArrayList<CraftingTreeNode>());
|
||||
this.layers.get(this.layer).add(this);
|
||||
}
|
||||
|
||||
public void addElement(ItemStack stack){
|
||||
this.elements.add(stack);
|
||||
this.recipesMap.put(stack, this.getRecipes(stack, this.excRecipes));
|
||||
this.componentsMap.put(stack, new ArrayList<ArrayList<ItemStack>>());
|
||||
for (CachedRecipe recipe: this.recipesMap.get(stack)){
|
||||
this.excRecipes.add(recipe);
|
||||
ArrayList<ItemStack> subComposants = new ArrayList<ItemStack>();
|
||||
for (PositionedStack substack : recipe.getIngredients())
|
||||
subComposants.add(substack.item);
|
||||
|
||||
if (subComposants.size() > 0){
|
||||
if (!this.bottomNodes.containsKey(stack))
|
||||
this.bottomNodes.put(stack, new ArrayList<CraftingTreeNode>());
|
||||
this.bottomNodes.get(stack).add(new CraftingTreeNode(this, this.cleanupRecipe(subComposants), this.excRecipes, this.layer+1, this.layers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setElements(ArrayList<ItemStack> elements){
|
||||
for (ItemStack is : elements)
|
||||
this.addElement(is);
|
||||
}
|
||||
|
||||
public ArrayList<CachedRecipe> getRecipes(ItemStack stack, ArrayList<CachedRecipe> excluded){
|
||||
ArrayList<ICraftingHandler> craftinghandlers = ReflectionManager.getField(GuiCraftingRecipe.class, ArrayList.class, null, "craftinghandlers");
|
||||
ArrayList<CachedRecipe> cachedRecipes = new ArrayList<CachedRecipe>();
|
||||
|
||||
for (ICraftingHandler handler : craftinghandlers)
|
||||
if (handler instanceof TemplateRecipeHandler && !(handler instanceof FuelRecipeHandler)){
|
||||
((TemplateRecipeHandler) handler).arecipes = new ArrayList<CachedRecipe>();
|
||||
((TemplateRecipeHandler) handler).loadCraftingRecipes(stack);
|
||||
for (CachedRecipe recipe : ((TemplateRecipeHandler)handler).arecipes){
|
||||
boolean found = false;
|
||||
for (CachedRecipe exc : excluded)
|
||||
if (this.areRecipesIdentical(recipe, exc))
|
||||
found = true;
|
||||
if (found)
|
||||
continue;
|
||||
|
||||
cachedRecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
return cachedRecipes;
|
||||
}
|
||||
|
||||
public boolean areRecipesIdentical(CachedRecipe recipe1, CachedRecipe recipe2){
|
||||
if (recipe1.getResult().items.length != recipe2.getResult().items.length)
|
||||
return false;
|
||||
if (recipe1.getIngredients().size() != recipe1.getIngredients().size())
|
||||
return false;
|
||||
for (int i = 0; i < recipe1.getResult().items.length; i++)
|
||||
if (!recipe1.getResult().items[i].isItemEqual(recipe2.getResult().items[i]))
|
||||
return false;
|
||||
for (int i = 0; i < recipe1.getIngredients().size(); i++)
|
||||
for (int j = 0; j < recipe1.getIngredients().get(i).items.length; j++)
|
||||
if (!recipe1.getIngredients().get(i).items[j].isItemEqual(recipe2.getIngredients().get(i).items[j]))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> cleanupRecipe(ArrayList<ItemStack> stacks){
|
||||
ArrayList<ItemStack> curratedStacks = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : stacks){
|
||||
boolean found = false;
|
||||
for (ItemStack isc : curratedStacks){
|
||||
//if (OreDictionary.itemMatches(is, isc, false)){
|
||||
if ((isc.isItemEqual(is)) ||
|
||||
((OreDictionary.getOreID(isc) != -1) &&
|
||||
(OreDictionary.getOreID(is) != -1) &&
|
||||
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
)){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found){
|
||||
ItemStack isc = is.copy();
|
||||
isc.stackSize = 0;
|
||||
curratedStacks.add(isc);
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack is : stacks)
|
||||
for (ItemStack isc : curratedStacks)
|
||||
if ((isc.isItemEqual(is)) ||
|
||||
((OreDictionary.getOreID(isc) != -1) &&
|
||||
(OreDictionary.getOreID(is) != -1) &&
|
||||
(OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
))
|
||||
//if (isc.isItemEqual(is) || OreDictionary.getOreID(isc) == OreDictionary.getOreID(is))
|
||||
isc.stackSize += is.stackSize;
|
||||
|
||||
return curratedStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.elements.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.gui_old.GuiTechTree;
|
||||
import mcp.mobius.waila.gui_old.widget.ComponentDisplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.forge.IContainerInputHandler;
|
||||
|
||||
public class HandlerTechTree implements IContainerInputHandler {
|
||||
|
||||
public HandlerTechTree() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
ItemStack stackover = gui.manager.getStackMouseOver();
|
||||
if(stackover == null)
|
||||
return false;
|
||||
|
||||
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_TECH)){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GuiTechTree techScreen = new GuiTechTree(mc.currentScreen);
|
||||
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> layers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
|
||||
CraftingTreeNode tree = new CraftingTreeNode(null, stackover, 0, layers);
|
||||
|
||||
/*
|
||||
LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> curratedLayers = new LinkedHashMap<Integer, ArrayList<CraftingTreeNode>> ();
|
||||
|
||||
for (int layer : layers.keySet())
|
||||
curratedLayers.put(layer, new ArrayList<CraftingTreeNode>());
|
||||
|
||||
for (int i = 0; i < (layers.size() - 1) ; i++)
|
||||
for (CraftingTreeNode node : layers.get(i)){
|
||||
if (node.bottomNodes.size() != 0){
|
||||
curratedLayers.get(i).add(node);
|
||||
|
||||
}
|
||||
else{
|
||||
node.layer += 1;
|
||||
layers.get(i+1).add(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (CraftingTreeNode node : layers.get(layers.keySet().size()-1))
|
||||
curratedLayers.get(layers.keySet().size()-1).add(node);
|
||||
|
||||
System.out.printf("%s\n", curratedLayers);
|
||||
*/
|
||||
|
||||
/*
|
||||
for (int layer = curratedLayers.keySet().size() - 1; layer >= 0; layer--){
|
||||
int offsetX = 0;
|
||||
for (int icompo = 0; icompo < curratedLayers.get(layer).size(); icompo++){
|
||||
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, curratedLayers.get(layer).get(icompo));
|
||||
componentDisplay.setBackgroundColor(0xddeeeed1);
|
||||
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
|
||||
offsetX += componentDisplay.getWidth() + 8;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (int layer = layers.keySet().size() - 1; layer >= 0; layer--){
|
||||
int offsetX = 0;
|
||||
for (int icompo = 0; icompo < layers.get(layer).size(); icompo++){
|
||||
ComponentDisplay componentDisplay = new ComponentDisplay(techScreen, layers.get(layer).get(icompo));
|
||||
componentDisplay.setBackgroundColor(0xddeeeed1);
|
||||
if (layer != 0)
|
||||
componentDisplay.setDrawOverlay(true);
|
||||
|
||||
techScreen.widViewport.addWidget(componentDisplay, offsetX, layer*32, 0);
|
||||
offsetX += componentDisplay.getWidth() + 8;
|
||||
}
|
||||
}
|
||||
|
||||
mc.displayGuiScreen(techScreen);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
|
||||
int button, long heldTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.NEI;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.mod_Waila;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.gui_old.GuiIngameWiki;
|
||||
import mcp.mobius.waila.gui_old.widget.Label;
|
||||
import mcp.mobius.waila.handlers.SummaryProvider;
|
||||
import mcp.mobius.waila.tools.ModIdentification;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.forge.IContainerInputHandler;
|
||||
|
||||
public class HandlerWiki implements IContainerInputHandler {
|
||||
|
||||
public String getDescriptionString(String modid, String name, String meta){
|
||||
if (ModuleRegistrar.instance().hasDocTextModID(modid)){
|
||||
//Do we have an direct entry for this item ?
|
||||
if (ModuleRegistrar.instance().hasDocTextItem(modid, name)){
|
||||
//We check if we have an exact match, a wildcard match and finally, an meta 0 match
|
||||
if (ModuleRegistrar.instance().hasDocTextMeta(modid, name, meta)){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, meta);
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "*")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, "*");
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, name, "0")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, name, "0");
|
||||
}
|
||||
|
||||
} else if (ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name) != null) {
|
||||
String key = ModuleRegistrar.instance().getDoxTextWildcardMatch(modid, name);
|
||||
if (ModuleRegistrar.instance().hasDocTextMeta(modid, key, meta)){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, meta);
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "*")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, "*");
|
||||
} else if (ModuleRegistrar.instance().hasDocTextSpecificMeta(modid, key, "0")){
|
||||
return ModuleRegistrar.instance().getDocText(modid, key, "0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return String.format("No description for %s$$%s",modid, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
ItemStack stackover = gui.manager.getStackMouseOver();
|
||||
if(stackover == null)
|
||||
return false;
|
||||
|
||||
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_WIKI)){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GuiIngameWiki wikiScreen = new GuiIngameWiki(mc.currentScreen);
|
||||
|
||||
wikiScreen.widReader.setText(this.getDescriptionString(ModIdentification.idFromStack(stackover), stackover.getItemName(), String.valueOf(stackover.getItemDamage())));
|
||||
wikiScreen.widStack.setStack(stackover);
|
||||
wikiScreen.widItemName.setLabel(stackover.getDisplayName());
|
||||
|
||||
LinkedHashMap<String, String> entries = SummaryProvider.instance().getSummary(stackover, (ConfigHandler.instance()));
|
||||
int nvalidentries = 0;
|
||||
for (String s : entries.keySet())
|
||||
if (entries.get(s) != null)
|
||||
nvalidentries += 1;
|
||||
|
||||
if (nvalidentries == 0)
|
||||
for (int i = 0; i < 6; i++)
|
||||
wikiScreen.widTable.addRow(new Label(""), new Label(entries.get("")));
|
||||
else
|
||||
for (String s : entries.keySet())
|
||||
if (entries.get(s) != null)
|
||||
wikiScreen.widTable.addRow(new Label(s), new Label(entries.get(s)));
|
||||
|
||||
mc.displayGuiScreen(wikiScreen);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey,
|
||||
int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey,
|
||||
int scrolled) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey,
|
||||
int button, long heldTime) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
|
||||
public abstract class BaseWidget implements IWidget {
|
||||
|
||||
protected int width, height;
|
||||
protected String label;
|
||||
protected int posX, posY, posZ;
|
||||
protected GuiScreen parent;
|
||||
protected FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;;
|
||||
protected TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||
protected HashMap<String, IWidget> widgets = new HashMap<String, IWidget>();
|
||||
protected IWidget[] focusWidget = new IWidget[Mouse.getButtonCount()];
|
||||
protected IWidget mainFocusWidget = null;
|
||||
protected int backgroundColor = 0;
|
||||
|
||||
public BaseWidget(){}
|
||||
|
||||
@Override
|
||||
public abstract int getWidth();
|
||||
@Override
|
||||
public abstract int getHeight();
|
||||
@Override
|
||||
public void setWidth(int width) { this.width = width; }
|
||||
@Override
|
||||
public void setHeight(int height) { this.height = height; }
|
||||
|
||||
@Override
|
||||
public void setPos (int posX, int posY, int posZ){
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posZ = posZ;
|
||||
}
|
||||
@Override
|
||||
public int getPosX(){return this.posX;}
|
||||
@Override
|
||||
public int getPosY(){return this.posY;}
|
||||
|
||||
@Override
|
||||
public String getLabel(){ return this.label;}
|
||||
@Override
|
||||
public void setLabel(String label){ this.label = label; }
|
||||
|
||||
@Override
|
||||
public abstract void draw();
|
||||
@Override
|
||||
public void draw(int x, int y, int z){
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0f,0.0f, this.posZ);
|
||||
this.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@Override
|
||||
public void draw(float scale){
|
||||
int oldX = this.posX;
|
||||
int oldY = this.posY;
|
||||
this.posX /= scale;
|
||||
this.posY /= scale;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0f,0.0f, this.posZ);
|
||||
this.draw();
|
||||
GL11.glPopMatrix();
|
||||
this.posX = oldX;
|
||||
this.posY = oldY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = widget;
|
||||
this.focusWidget[buttonID] = widget;
|
||||
return widget.mouseClicked(mouseX, mouseY, buttonID);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.mainFocusWidget = null;
|
||||
|
||||
if (this.focusWidget[buttonID] != null){
|
||||
boolean retval = this.focusWidget[buttonID].mouseReleased(mouseX, mouseY, buttonID);
|
||||
this.focusWidget[buttonID] = null;
|
||||
return retval;
|
||||
}
|
||||
this.focusWidget[buttonID] = null;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseWheel(mouseX, mouseY, mouseZ);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.mainFocusWidget != null)
|
||||
return this.mainFocusWidget.mouseMoved(mouseX, mouseY);
|
||||
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseMoved(mouseX, mouseY);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime){
|
||||
IWidget widget = this.getWidgetAtCoordinates(mouseX, mouseY);
|
||||
if (widget != null)
|
||||
return widget.mouseDragged(mouseX, mouseY, buttonID, deltaTime);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
public void startScissorFilter(int posX, int posY, int width, int height){
|
||||
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft().gameSettings,
|
||||
Minecraft.getMinecraft().displayWidth,
|
||||
Minecraft.getMinecraft().displayHeight);
|
||||
int scaleFactor = res.getScaleFactor();
|
||||
|
||||
int glLeft = posX * scaleFactor;
|
||||
int glBottom = (res.getScaledHeight() - (posY + height)) * scaleFactor;
|
||||
|
||||
GL11.glScissor(posX*scaleFactor, glBottom, width*scaleFactor, height*scaleFactor);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
public void stopScissorFilter(){
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getWidgetAtCoordinates(int posX, int posY){
|
||||
for (IWidget widget : this.getWidgets())
|
||||
if ((posX >= widget.getPosX()) &&
|
||||
(posX <= widget.getPosX() + widget.getWidth()) &&
|
||||
(posY >= widget.getPosY()) &&
|
||||
(posY <= widget.getPosY() + widget.getHeight()))
|
||||
return widget;
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void addWidget(String name, IWidget widget){
|
||||
this.widgets.put(name, widget);
|
||||
}
|
||||
@Override
|
||||
public Collection<IWidget> getWidgets(){
|
||||
return this.widgets.values();
|
||||
}
|
||||
@Override
|
||||
public IWidget getWidget(String name){
|
||||
return this.widgets.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int color){
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(){
|
||||
if (this.backgroundColor != 0)
|
||||
this.drawGradientRect(this.posX, this.posY, this.posX+this.getWidth(), this.posY+this.getHeight(), 0.0, this.backgroundColor, this.backgroundColor);
|
||||
}
|
||||
|
||||
public void drawGradientRect(int left, int top, int right, int bottom, double zlevel, int colorStart, int colorStop)
|
||||
{
|
||||
float f = (colorStart >> 24 & 255) / 255.0F;
|
||||
float f1 = (colorStart >> 16 & 255) / 255.0F;
|
||||
float f2 = (colorStart >> 8 & 255) / 255.0F;
|
||||
float f3 = (colorStart & 255) / 255.0F;
|
||||
float f4 = (colorStop >> 24 & 255) / 255.0F;
|
||||
float f5 = (colorStop >> 16 & 255) / 255.0F;
|
||||
float f6 = (colorStop >> 8 & 255) / 255.0F;
|
||||
float f7 = (colorStop & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex(right, top, zlevel);
|
||||
tessellator.addVertex(left, top, zlevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex(left, bottom, zlevel);
|
||||
tessellator.addVertex(right, bottom, zlevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mcp.mobius.waila.gui_old.NEI.CraftingTreeNode;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ComponentDisplay extends BaseWidget {
|
||||
|
||||
ArrayList<ItemStack> components = null;
|
||||
CraftingTreeNode node = null;
|
||||
int spacingX = 4;
|
||||
int spacingY = 4;
|
||||
int stackDisplayWidth = 0;
|
||||
boolean drawOverlay = false;
|
||||
|
||||
public ComponentDisplay(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.components = new ArrayList<ItemStack>();
|
||||
};
|
||||
|
||||
public ComponentDisplay(GuiScreen parent, CraftingTreeNode node){
|
||||
this.parent = parent;
|
||||
this.node = node;
|
||||
this.setComponents(node.elements);
|
||||
};
|
||||
|
||||
public void setDrawOverlay(boolean value){
|
||||
for(IWidget widget : this.getWidgets())
|
||||
if(widget instanceof StackDisplay)
|
||||
((StackDisplay)widget).setDrawOverlay(value);
|
||||
}
|
||||
|
||||
public void setComponents(ArrayList<ItemStack> components){
|
||||
this.components = components;
|
||||
this.stackDisplayWidth = 0;
|
||||
|
||||
for (ItemStack component : components)
|
||||
this.addWidget(String.format("widget_%03d", this.getWidgets().size()), new StackDisplay(this.parent, component));
|
||||
|
||||
for (IWidget widget:this.getWidgets())
|
||||
this.stackDisplayWidth = Math.max(this.stackDisplayWidth, widget.getWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
int width = 0;
|
||||
for (IWidget widget:this.getWidgets())
|
||||
width += widget.getWidth();
|
||||
width += (this.getWidgets().size() + 1) * this.spacingX;
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
int height = 0;
|
||||
for (IWidget widget:this.getWidgets())
|
||||
height = Math.max(widget.getHeight(), height);
|
||||
height += this.spacingY * 2;
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
//this.drawBackground();
|
||||
int index = 0;
|
||||
for (IWidget widget: this.getWidgets()){
|
||||
widget.setPos(this.posX + (this.spacingX * (index + 1)) + ( index * this.stackDisplayWidth ), this.posY + this.spacingY, 0);
|
||||
widget.draw();
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class ContainerTable extends BaseWidget{
|
||||
int rowHeight;
|
||||
int ncolumns;
|
||||
//int viewportYPos = 0;
|
||||
int tableHeight = 0;
|
||||
int tableWidth = 0;
|
||||
int scrollWidth = 8;
|
||||
int scrollButtonHeight = 16;
|
||||
boolean isScrollActive = false;
|
||||
FontRenderer fontRender;
|
||||
int[] columnPos;
|
||||
int[] columnWidth;
|
||||
ArrayList<IWidget[]> table = new ArrayList<IWidget[]>();
|
||||
VerticalScrollBar scrollbar = new VerticalScrollBar();
|
||||
Label[] columnnames;
|
||||
boolean autosize = true;
|
||||
|
||||
public ContainerTable(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
};
|
||||
|
||||
public ContainerTable( GuiScreen parent, int height, int ncolumns, String[] columnnames) {
|
||||
this.parent = parent;
|
||||
this.height = height;
|
||||
this.rowHeight = 8;
|
||||
this.fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
this.ncolumns = ncolumns;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(columnnames[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
}
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
}
|
||||
|
||||
public void setAutosize(boolean value){
|
||||
this.autosize = value;
|
||||
}
|
||||
|
||||
public void setColumns(int rowHeight, String... header){
|
||||
this.rowHeight = rowHeight;
|
||||
this.ncolumns = header.length;
|
||||
this.columnPos = new int[this.ncolumns];
|
||||
this.columnWidth = new int[this.ncolumns];
|
||||
this.columnnames = new Label[this.ncolumns];
|
||||
|
||||
for (int i = 0; i < this.ncolumns; i++){
|
||||
Label labelHeader = new Label(header[i]);
|
||||
this.columnnames[i] = labelHeader;
|
||||
this.addWidget(String.format("header_%s", i), labelHeader);
|
||||
|
||||
this.columnWidth[i] = Math.max(labelHeader.getWidth() + 8, this.columnWidth[i]);
|
||||
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
|
||||
}
|
||||
this.columnPos[0] = 0;
|
||||
for (int i = 1; i < this.ncolumns; i++)
|
||||
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.table.size();
|
||||
}
|
||||
|
||||
public void addRow(IWidget... data){
|
||||
this.table.add(data);
|
||||
for (int i = 0; i < data.length; i++)
|
||||
this.addWidget(String.format("row_%s_%s", this.table.size(), i), data[i]);
|
||||
|
||||
for (int i = 0; i < ncolumns; i++){
|
||||
this.columnWidth[i] = Math.max(data[i].getWidth() + 8, this.columnWidth[i]);
|
||||
this.columnWidth[i] = Math.max(this.columnnames[i].getWidth() + 8, this.columnWidth[i]);
|
||||
}
|
||||
|
||||
this.columnPos[0] = 0;
|
||||
for (int i = 1; i < this.ncolumns; i++)
|
||||
this.columnPos[i] = this.columnPos[i-1] + this.columnWidth[i-1];
|
||||
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(1.0f, 1.0f, this.posZ);
|
||||
this.drawBackground();
|
||||
this.drawTitle(this.posX, this.posY);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
|
||||
this.startScissorFilter(this.posX, this.posY + this.rowHeight, this.getWidth(), this.getViewportHeight());
|
||||
|
||||
for (int i = 0; i < this.table.size(); i++)
|
||||
this.drawRow(i, this.posX, this.posY+(i+1)*this.rowHeight);
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.isScrollActive){
|
||||
this.updateScrollBar();
|
||||
this.scrollbar.draw();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void updateScrollBar(){
|
||||
int scrollbarX = this.posX + this.getWidth() - this.scrollWidth;
|
||||
int scrollbarY = this.posY + this.rowHeight;
|
||||
int scrollbarW = this.scrollWidth;
|
||||
int scrollbarH = this.getViewportHeight();
|
||||
int maxvalue = this.getTableHeight() - this.getViewportHeight();
|
||||
|
||||
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
if (!autosize)
|
||||
return this.width;
|
||||
|
||||
int width = 0;
|
||||
for (int i: this.columnWidth)
|
||||
width += i;
|
||||
|
||||
if (this.isScrollActive)
|
||||
width += this.scrollWidth;
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getTableHeight(){
|
||||
return this.rowHeight * this.getSize();
|
||||
}
|
||||
|
||||
public int getViewportHeight(){
|
||||
return this.getHeight() - this.rowHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeight(int height){
|
||||
this.height = height;
|
||||
this.isScrollActive = (this.getViewportHeight() < this.getTableHeight());
|
||||
}
|
||||
|
||||
public void drawTitle(int rowleft, int rowtop)
|
||||
{
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
this.columnnames[j].setWidth(this.columnWidth[j]);
|
||||
this.columnnames[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRow(int index, int rowleft, int rowtop)
|
||||
{
|
||||
if (index%2 == 0)
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff333333, 0xff333333);
|
||||
else
|
||||
this.parent.drawGradientRect(rowleft, rowtop, rowleft+this.getWidth(), rowtop+this.rowHeight, 0xff000000, 0xff000000);
|
||||
|
||||
IWidget[] data = this.table.get(index);
|
||||
for (int j = 0; j < this.ncolumns; j++){
|
||||
data[j].setWidth(this.columnWidth[j]);
|
||||
data[j].draw(rowleft + this.columnPos[j], rowtop, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class DraggableViewport extends BaseWidget {
|
||||
|
||||
//public StackDisplay widStack = null;;
|
||||
private int offsetX = 0;
|
||||
private int offsetY = 0;
|
||||
private int prevMouseX = 0;
|
||||
private int prevMouseY = 0;
|
||||
private float scale = 1.0f;
|
||||
private boolean dragging = false;
|
||||
|
||||
|
||||
public DraggableViewport(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
/*
|
||||
widStack = new StackDisplay(parent);
|
||||
widStack.setStack(new ItemStack(Item.axeDiamond));
|
||||
widStack.setPos(80, 80, 0);
|
||||
|
||||
this.addWidget("stackdisplay", this.widStack);
|
||||
*/
|
||||
}
|
||||
|
||||
public void addWidget(IWidget widget, int posX, int posY, int posZ){
|
||||
this.addWidget(String.format("widget_%s", this.widgets.size()), widget);
|
||||
widget.setPos(posX, posY, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(offsetX, offsetY, 0);
|
||||
GL11.glScalef(this.scale, this.scale, 1.0f);
|
||||
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getHeight());
|
||||
|
||||
for (IWidget widget : this.getWidgets())
|
||||
widget.drawBackground();
|
||||
|
||||
for (IWidget widget : this.getWidgets())
|
||||
//widget.draw(this.scale);
|
||||
widget.draw();
|
||||
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0){
|
||||
this.dragging = true;
|
||||
this.prevMouseX = mouseX;
|
||||
this.prevMouseY = mouseY;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.dragging = false;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.dragging){
|
||||
this.offsetX -= (this.prevMouseX - mouseX);
|
||||
this.offsetY -= (this.prevMouseY - mouseY);
|
||||
this.prevMouseX = mouseX;
|
||||
this.prevMouseY = mouseY;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
if (mouseZ > 0)
|
||||
this.scale *= Math.abs((mouseZ / -120)*2);
|
||||
else
|
||||
this.scale /= Math.abs((mouseZ / -120)*2);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IWidget {
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
String getLabel();
|
||||
int getPosX();
|
||||
int getPosY();
|
||||
|
||||
void setWidth(int width);
|
||||
void setHeight(int height);
|
||||
void setLabel(String label);
|
||||
void setPos(int posX, int posY, int posZ);
|
||||
|
||||
boolean mouseClicked(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseReleased(int mouseX, int mouseY, int buttonID);
|
||||
boolean mouseWheel(int mouseX, int mouseY, int mouseZ);
|
||||
boolean mouseMoved(int mouseX, int mouseY);
|
||||
//boolean mouseDragged(int mouseX, int mouseY, int buttonID, long deltaTime);
|
||||
|
||||
void draw();
|
||||
void draw(int x, int y, int z);
|
||||
void draw(float scale);
|
||||
|
||||
IWidget getWidgetAtCoordinates(int posX, int posY);
|
||||
public void addWidget(String name, IWidget widget);
|
||||
public Collection<IWidget> getWidgets();
|
||||
public IWidget getWidget(String name);
|
||||
|
||||
void drawBackground();
|
||||
void setBackgroundColor(int color);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class Label extends BaseWidget {
|
||||
|
||||
public Label(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Label(GuiScreen parent, String label){
|
||||
this.parent = parent;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public Label(String label){
|
||||
this.parent = null;
|
||||
this.setLabel(label);
|
||||
}
|
||||
|
||||
public Label(int label){
|
||||
this.parent = null;
|
||||
this.setLabel(String.valueOf(label));
|
||||
}
|
||||
|
||||
public Label(float label){
|
||||
this.parent = null;
|
||||
this.setLabel(String.valueOf(label));
|
||||
}
|
||||
|
||||
public int getCharWidth(){
|
||||
return this.fontRenderer.getCharWidth((char)32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
this.renderString(this.posX, this.posY, 0, 0xffffffff);
|
||||
}
|
||||
|
||||
public String getTrimLabel(){
|
||||
int maxchars = this.width / this.getCharWidth();
|
||||
return this.label.substring(0, Math.min(this.label.length(), maxchars));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(String label){
|
||||
this.label = label;
|
||||
this.width = this.fontRenderer.getStringWidth(this.label);
|
||||
}
|
||||
|
||||
public void renderString(int x, int y, int z, int color){
|
||||
//this.fontrender.drawString(this.getTrimLabel(), x, y, color);
|
||||
this.fontRenderer.drawString(this.getLabel(), x, y, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class StackDisplay extends BaseWidget {
|
||||
|
||||
protected static RenderItem drawItems = new RenderItem();
|
||||
protected ItemStack stack;
|
||||
protected Icon icon;
|
||||
protected float scale = 1.0F;
|
||||
protected boolean drawOverlay = false;
|
||||
|
||||
public StackDisplay(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
StackDisplay.drawItems.zLevel = 500.0f;
|
||||
};
|
||||
|
||||
public StackDisplay(GuiScreen parent, ItemStack stack){
|
||||
this.parent = parent;
|
||||
this.setStack(stack);
|
||||
};
|
||||
|
||||
public void setDrawOverlay(boolean value){
|
||||
this.drawOverlay = value;
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack){
|
||||
this.stack = stack;
|
||||
this.icon = stack.getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, 1.0f);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
drawItems.renderItemAndEffectIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale));
|
||||
if (this.drawOverlay)
|
||||
drawItems.renderItemOverlayIntoGUI(this.fontRenderer, this.renderEngine, this.stack, (int)(this.posX/scale), (int)(this.posY/scale), String.valueOf(stack.stackSize));
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWidth(){
|
||||
return (int)(16 * this.scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(){
|
||||
return (int)(16 * this.scale);
|
||||
}
|
||||
|
||||
public void setScale(float scale_){
|
||||
this.scale = scale_;
|
||||
}
|
||||
|
||||
public float getScale(){
|
||||
return this.scale;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class VerticalScrollBar extends BaseWidget {
|
||||
|
||||
private int maxvalue;
|
||||
private int currvalue = 0;
|
||||
private int buttonH;
|
||||
private int buttonTop;
|
||||
private int step = 6;
|
||||
public boolean dragging = false;
|
||||
|
||||
public VerticalScrollBar(){};
|
||||
|
||||
public void setup(GuiScreen parent, int posX, int posY, int width, int height, int buttonH, int maxvalue) {
|
||||
this.parent = parent;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.maxvalue = maxvalue;
|
||||
this.buttonH = buttonH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
this.posY,
|
||||
this.posX + this.getWidth(),
|
||||
this.posY + this.getHeight(),
|
||||
0xff999999, 0xff999999);
|
||||
|
||||
float currentRatio = (float)(this.currvalue) / (float)(this.maxvalue);
|
||||
this.buttonTop = (int)((this.getHeight() - this.buttonH) * currentRatio) + this.posY;
|
||||
|
||||
this.parent.drawGradientRect(this.posX,
|
||||
buttonTop,
|
||||
this.posX + this.getWidth(),
|
||||
buttonTop + this.buttonH,
|
||||
0xffffffff, 0xffffffff);
|
||||
|
||||
}
|
||||
|
||||
public void setCurrentValue(int currvalue){
|
||||
this.currvalue = currvalue;
|
||||
this.currvalue = Math.max(0, this.currvalue);
|
||||
this.currvalue = Math.min(this.maxvalue, this.currvalue);
|
||||
}
|
||||
|
||||
public void addCurrentValue(int value){
|
||||
this.currvalue += value;
|
||||
this.currvalue = Math.max(0, this.currvalue);
|
||||
this.currvalue = Math.min(this.maxvalue, this.currvalue);
|
||||
}
|
||||
|
||||
public int getCurrentValue(){
|
||||
return this.currvalue;
|
||||
}
|
||||
|
||||
public int getStep(){
|
||||
return this.step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int buttonID){
|
||||
if(mouseY < this.buttonTop)
|
||||
this.addCurrentValue(-1 * this.step);
|
||||
else if (mouseY > this.buttonTop + this.buttonH)
|
||||
this.addCurrentValue(this.step);
|
||||
else if (buttonID == 0)
|
||||
this.dragging = true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int buttonID){
|
||||
if (buttonID == 0)
|
||||
this.dragging = false;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseMoved(int mouseX, int mouseY){
|
||||
if (this.dragging){
|
||||
int value = (int)((float)((mouseY - this.buttonH/2) - this.posY)/(float)(this.getHeight()-this.buttonH)*this.maxvalue);
|
||||
this.setCurrentValue(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package mcp.mobius.waila.gui_old.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class WikiReader extends BaseWidget {
|
||||
|
||||
private VerticalScrollBar scrollbar = new VerticalScrollBar();
|
||||
private String text = "";
|
||||
int textHeight = 0;
|
||||
int lineHeight = 8;
|
||||
int scrollWidth = 8;
|
||||
int scrollButtonHeight = 16;
|
||||
boolean isScrollActive = false;
|
||||
|
||||
|
||||
public WikiReader(GuiScreen parent){
|
||||
this.parent = parent;
|
||||
this.addWidget("VScrollBar", this.scrollbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
if (!this.isScrollActive)
|
||||
return this.width;
|
||||
else
|
||||
return this.width - this.scrollWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.drawBackground();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, this.scrollbar.getCurrentValue() * -1.0F, 0);
|
||||
this.startScissorFilter(this.posX, this.posY, this.getWidth(), this.getViewportHeight());
|
||||
|
||||
int offset = this.posY;
|
||||
|
||||
for (String s : this.getTailoredText()){
|
||||
this.fontRenderer.drawString(s, this.posX, offset, 0xFFFFFFFF);
|
||||
offset += this.lineHeight;
|
||||
}
|
||||
|
||||
this.stopScissorFilter();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.isScrollActive){
|
||||
this.updateScrollBar();
|
||||
this.scrollbar.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String text){
|
||||
this.text = text;
|
||||
this.textHeight = this.getTailoredText().size() * this.lineHeight;
|
||||
if (this.textHeight > this.getHeight()){
|
||||
this.isScrollActive = true;
|
||||
//this.setWidth(this.getWidth() - this.scrollWidth);
|
||||
this.textHeight = this.getTailoredText().size() * this.lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextHeight(){
|
||||
return this.getTailoredText().size() * this.lineHeight;
|
||||
}
|
||||
|
||||
public String getText(){
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public ArrayList<String> getTailoredText(){
|
||||
String[] splittedText = this.text.split("\r?\n");
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
for (String s : splittedText){
|
||||
ArrayList<Integer> whiteSpaces = this.getWhiteSpaces(s);
|
||||
int lastCutIndex = 0;
|
||||
for (int i = 0; i < whiteSpaces.size(); i++){
|
||||
String substring = s.substring(lastCutIndex, whiteSpaces.get(i));
|
||||
if (this.fontRenderer.getStringWidth(substring) > this.getWidth()){
|
||||
lines.add(s.substring(lastCutIndex, whiteSpaces.get(i-1)));
|
||||
lastCutIndex = whiteSpaces.get(i-1) + 1;
|
||||
}
|
||||
}
|
||||
lines.add(s.substring(lastCutIndex));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private ArrayList<Integer> getWhiteSpaces(String input){
|
||||
ArrayList<Integer> indexes = new ArrayList<Integer>();
|
||||
int index = 0;
|
||||
while (index != -1){
|
||||
index = input.indexOf(" ", index + 1);
|
||||
if (index != -1)
|
||||
indexes.add(index);
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseWheel(int mouseX, int mouseY, int mouseZ){
|
||||
this.scrollbar.addCurrentValue((mouseZ / -120) * this.scrollbar.getStep());
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getViewportHeight(){
|
||||
return this.getHeight();
|
||||
}
|
||||
|
||||
public void updateScrollBar(){
|
||||
int scrollbarX = this.posX + this.getWidth();
|
||||
int scrollbarY = this.posY;
|
||||
int scrollbarW = this.scrollWidth;
|
||||
int scrollbarH = this.getViewportHeight();
|
||||
int maxvalue = this.getTextHeight() - this.getViewportHeight();
|
||||
|
||||
this.scrollbar.setup(this.parent, scrollbarX, scrollbarY, scrollbarW, scrollbarH, this.scrollButtonHeight, maxvalue);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.RENDER;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.BLUE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.GRAY;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WHITE;
|
||||
import static mcp.mobius.waila.api.SpecialChars.getRenderString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternMinecraft;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternRender;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternWaila;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
@@ -121,6 +124,37 @@ public class DisplayUtil {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int x, int y, double w, double 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((x + w), y, zLevel);
|
||||
tessellator.addVertex(x, y, zLevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex(x, y + h, zLevel);
|
||||
tessellator.addVertex(x + w, y + h, 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;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ public class OverlayConfig {
|
||||
public static int gradient2;
|
||||
public static int fontcolor;
|
||||
public static float scale;
|
||||
public static boolean breakprogress;
|
||||
|
||||
public static void updateColors() {
|
||||
OverlayConfig.alpha = (int) (ConfigHandler.instance()
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class OverlayRenderer {
|
||||
@@ -62,6 +63,19 @@ public class OverlayRenderer {
|
||||
OverlayConfig.gradient1,
|
||||
OverlayConfig.gradient2);
|
||||
|
||||
if (OverlayConfig.breakprogress && tooltip.accessor instanceof IWailaDataAccessor) {
|
||||
IWailaDataAccessor data = ((IWailaDataAccessor) tooltip.accessor);
|
||||
if (data.getBlockBreakDamage() > 0) {
|
||||
DisplayUtil.drawGradientRect(
|
||||
tooltip.x + 1,
|
||||
tooltip.y + tooltip.h,
|
||||
(double) (tooltip.w - 1) * (data.getBlockBreakDamage()),
|
||||
1,
|
||||
0xffffffff,
|
||||
0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tooltip.draw();
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -38,15 +35,12 @@ public class RayTracing {
|
||||
}
|
||||
|
||||
private MovingObjectPosition target = null;
|
||||
private ItemStack targetStack = null;
|
||||
private Entity targetEntity = null;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public void fire() {
|
||||
if (mc.objectMouseOver != null
|
||||
&& mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
||||
this.target = mc.objectMouseOver;
|
||||
this.targetStack = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,8 +48,6 @@ public class RayTracing {
|
||||
if (viewpoint == null) return;
|
||||
|
||||
this.target = this.rayTrace(viewpoint, mc.playerController.getBlockReachDistance(), 0);
|
||||
|
||||
if (this.target == null) return;
|
||||
}
|
||||
|
||||
public MovingObjectPosition getTarget() {
|
||||
@@ -63,19 +55,12 @@ public class RayTracing {
|
||||
}
|
||||
|
||||
public ItemStack getTargetStack() {
|
||||
if (this.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
this.targetStack = this.getIdentifierStack();
|
||||
else this.targetStack = null;
|
||||
|
||||
return this.targetStack;
|
||||
return this.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK ? this.getIdentifierStack() : null;
|
||||
}
|
||||
|
||||
public Entity getTargetEntity() {
|
||||
if (this.target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY)
|
||||
this.targetEntity = this.getIdentifierEntity();
|
||||
else this.targetEntity = null;
|
||||
|
||||
return this.targetEntity;
|
||||
return this.target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY ? this.getIdentifierEntity()
|
||||
: null;
|
||||
}
|
||||
|
||||
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3) {
|
||||
@@ -90,24 +75,17 @@ public class RayTracing {
|
||||
}
|
||||
|
||||
public ItemStack getIdentifierStack() {
|
||||
World world = mc.theWorld;
|
||||
ArrayList<ItemStack> items = this.getIdentifierItems();
|
||||
|
||||
if (items.isEmpty()) return null;
|
||||
|
||||
Collections.sort(items, new Comparator<ItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(ItemStack stack0, ItemStack stack1) {
|
||||
return stack1.getItemDamage() - stack0.getItemDamage();
|
||||
}
|
||||
});
|
||||
items.sort((stack0, stack1) -> stack1.getItemDamage() - stack0.getItemDamage());
|
||||
|
||||
return items.get(0);
|
||||
}
|
||||
|
||||
public Entity getIdentifierEntity() {
|
||||
ArrayList<Entity> ents = new ArrayList<Entity>();
|
||||
ArrayList<Entity> ents = new ArrayList<>();
|
||||
|
||||
if (this.target == null) return null;
|
||||
|
||||
@@ -120,16 +98,15 @@ public class RayTracing {
|
||||
}
|
||||
}
|
||||
|
||||
if (ents.size() > 0) return ents.get(0);
|
||||
if (!ents.isEmpty()) return ents.get(0);
|
||||
else return this.target.entityHit;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getIdentifierItems() {
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
ArrayList<ItemStack> items = new ArrayList<>();
|
||||
|
||||
if (this.target == null) return items;
|
||||
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
World world = mc.theWorld;
|
||||
|
||||
int x = this.target.blockX;
|
||||
@@ -174,7 +151,7 @@ public class RayTracing {
|
||||
}
|
||||
}
|
||||
|
||||
if (items.size() > 0) return items;
|
||||
if (!items.isEmpty()) return items;
|
||||
|
||||
if (world.getTileEntity(x, y, z) == null) {
|
||||
try {
|
||||
@@ -191,14 +168,14 @@ public class RayTracing {
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
if (items.size() > 0) return items;
|
||||
if (!items.isEmpty()) return items;
|
||||
|
||||
try {
|
||||
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, x, y, z);
|
||||
if (pick != null) items.add(pick);
|
||||
} catch (Exception e) {}
|
||||
|
||||
if (items.size() > 0) return items;
|
||||
if (!items.isEmpty()) return items;
|
||||
|
||||
/*
|
||||
* try { items.addAll(mouseoverBlock.getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0)); }
|
||||
@@ -212,7 +189,7 @@ public class RayTracing {
|
||||
}
|
||||
}
|
||||
|
||||
if (items.size() == 0) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
|
||||
if (items.isEmpty()) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNCENTER;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ALIGNRIGHT;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternIcon;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternLineSplit;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternRender;
|
||||
import static mcp.mobius.waila.api.SpecialChars.patternTab;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.overlay;
|
||||
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
import static mcp.mobius.waila.api.SpecialChars.ITALIC;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -78,7 +78,6 @@ public class WailaTickHandler {
|
||||
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 = new TipList<String, String>();
|
||||
this.currenttipHead = new TipList<String, String>();
|
||||
|
||||
@@ -30,6 +30,7 @@ public final class Constants {
|
||||
public static String CFG_WAILA_NHEARTS = "waila.cfg.heartsperline";
|
||||
public static String CFG_WAILA_MAXHP = "waila.cfg.maxhpbeforetext";
|
||||
public static String CFG_WAILA_NEWFILTERS = "waila.cfg.newfilters";
|
||||
public static String CFG_WAILA_BREAK_PROGRESS = "waila.cfg.breakprogress";
|
||||
|
||||
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
|
||||
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
public net.minecraft.client.multiplayer.PlayerControllerMP field_78770_f # curBlockDamageMP
|
||||
Reference in new issue
Block a user