Compare commits

...
20 Commits
Author SHA1 Message Date
glowredman 169e584506 Update buildscript 2023-08-15 20:01:48 +02:00
glowredman 03eeec9d23 Re-enable remapping for certain mixins 2023-08-15 18:09:59 +02:00
glowredman 4d9bb7b9a5 Enable genericInjection 2023-08-15 18:09:13 +02:00
glowredman 08e411f70b Update buildscript 2023-08-15 17:21:48 +02:00
Jason Mitchell d5a005a0ed spotless 2023-07-09 11:39:51 -07:00
Jason Mitchell 5fddbcecec Add MixinEntityRenderer
* Port over (most of) renderHand
2023-07-08 18:11:19 -07:00
Raven Szewczyk 4dfe96639e Fix recursive and relative #include handling 2023-06-22 21:40:34 +01:00
Raven Szewczyk 96e7064192 Fix NPE in ModelRenderer 2023-06-22 21:40:20 +01:00
Raven Szewczyk 1d46d0c32f Update gradle and dependencies 2023-06-22 20:49:45 +01:00
Raven Szewczyk 0b66f7a255 Mixin Tessellator 2023-06-22 20:47:36 +01:00
Caedis d63bd7a8a5 also delete the old transformer 2023-06-10 03:03:32 -05:00
Caedis 9f8477c039 Spotless 2023-06-10 02:59:47 -05:00
Caedis 6526cac45a Mixin SimpleTexture 2023-06-10 02:58:33 -05:00
Caedis c37b1020e2 Update build.gradle 2023-06-09 17:32:55 -05:00
Caedis cc5905dfbc Mixin TextureClock and TextureCompass 2023-06-09 17:20:17 -05:00
Raven Szewczyk 88af3a807a Update buildscript to use unimixins 2023-03-18 20:43:45 +00:00
Jason Mitchell 0b1cd16ed0 Mixin-ify RenderGlobal transformer 2023-02-26 21:20:16 -08:00
Jason Mitchell 7614cfc2c4 Progress
* Remove some compilerStubs, access adjustment ASM and replace with Mixin Accessors
* Renderer Mixins
2023-02-24 23:14:41 -08:00
Jason Mitchell 39e7b5b3ea Renderer Mixins & Lighting Level Mixins 2023-02-24 17:57:09 -08:00
Jason Mitchell df3ff717f0 Mixin Shaders Button 2023-02-23 23:23:35 -08:00
56 changed files with 1518 additions and 2700 deletions

No files matched your search

+242 -184
View File
@@ -1,4 +1,4 @@
//version: 1677142954
//version: 1692122114
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -6,29 +6,25 @@
*/
import com.diffplug.blowdryer.Blowdryer
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import com.gtnewhorizons.retrofuturagradle.util.Distribution
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import cpw.mods.fml.relauncher.Side
import org.gradle.api.tasks.options.Option;
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.xml.XmlTransformer
import org.jetbrains.gradle.ext.*
import org.jetbrains.gradle.ext.Application
import org.jetbrains.gradle.ext.Gradle
import javax.inject.Inject
import java.nio.file.Files
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.inject.Inject
buildscript {
repositories {
@@ -65,22 +61,26 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false
id 'org.jetbrains.kotlin.kapt' version '1.8.0' apply false
id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version ,unused, available for addon.gradle
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'com.palantir.git-version' version '0.13.0' apply false // 0.13.0 is the last jvm8 supporting version
id 'de.undercouch.download' version '5.3.0'
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'com.palantir.git-version' version '3.0.0' apply false
id 'de.undercouch.download' version '5.4.0'
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
id 'com.diffplug.spotless' version '6.7.2' apply false
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.2.2'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
}
print("You might want to check out './gradlew :faq' if your build fails.\n")
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
if (settingsupdated)
throw new GradleException("Settings has been updated, please re-run task.")
if (project.file('.git/HEAD').isFile()) {
// In submodules, .git is a file pointing to the real git dir
if (project.file('.git/HEAD').isFile() || project.file('.git').isFile()) {
apply plugin: 'com.palantir.git-version'
}
@@ -115,6 +115,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", "")
@@ -132,7 +134,7 @@ propertyDefaultIfUnset("enableGenericInjection", false) // On by default for new
// this is meant to be set using the user wide property file. by default we do nothing.
propertyDefaultIfUnset("ideaOverrideBuildType", "") // Can be nothing, "gradle" or "idea"
project.extensions.add(Blowdryer, "Blowdryer", Blowdryer) // Make blowdryer available in "apply from:" scripts
project.extensions.add(com.diffplug.blowdryer.Blowdryer, "Blowdryer", com.diffplug.blowdryer.Blowdryer) // Make blowdryer available in "apply from:" scripts
if (!disableSpotless) {
apply plugin: 'com.diffplug.spotless'
apply from: Blowdryer.file('spotless.gradle')
@@ -153,13 +155,21 @@ java {
} else {
languageVersion.set(projectJavaVersion)
}
vendor.set(JvmVendorSpec.ADOPTIUM)
vendor.set(JvmVendorSpec.AZUL)
}
if (!noPublishedSources) {
withSourcesJar()
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
tasks.withType(ScalaCompile).configureEach {
options.encoding = "UTF-8"
}
pluginManager.withPlugin('org.jetbrains.kotlin.jvm') {
// If Kotlin is enabled in the project
kotlin {
@@ -193,6 +203,14 @@ configurations {
canBeConsumed = false
canBeResolved = false
}
create("devOnlyNonPublishable") {
description = "Runtime and compiletime dependencies that are not published alongside the jar (compileOnly + runtimeOnlyNonPublishable)"
canBeConsumed = false
canBeResolved = false
}
compileOnly.extendsFrom(devOnlyNonPublishable)
runtimeOnlyNonPublishable.extendsFrom(devOnlyNonPublishable)
}
if (enableModernJavaSyntax.toBoolean()) {
@@ -206,6 +224,8 @@ if (enableModernJavaSyntax.toBoolean()) {
dependencies {
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
// workaround for https://github.com/bsideup/jabel/issues/174
annotationProcessor 'net.java.dev.jna:jna-platform:5.13.0'
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') {
transitive = false // We only care about the 1 annotation class
}
@@ -222,7 +242,7 @@ if (enableModernJavaSyntax.toBoolean()) {
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.ADOPTIUM)
vendor.set(JvmVendorSpec.AZUL)
})
}
}
@@ -339,7 +359,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(
@@ -361,9 +401,13 @@ if (identifiedVersion == versionOverride) {
group = "com.github.GTNewHorizons"
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
base {
archivesName = customArchiveBaseName
}
} else {
archivesBaseName = modId
base {
archivesName = modId
}
}
@@ -391,14 +435,12 @@ minecraft {
username = developmentEnvironmentUserName.toString()
lwjgl3Version = "3.3.2-SNAPSHOT"
lwjgl3Version = "3.3.2"
// Enable assertions in the current mod
extraRunJvmArguments.add("-ea:${modGroup}")
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
extraTweakClasses.add("org.spongepowered.asm.launch.MixinTweaker")
if (usesMixinDebug.toBoolean()) {
extraRunJvmArguments.addAll([
"-Dmixin.debug.countInjections=true",
@@ -449,10 +491,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) {
@@ -463,7 +514,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)
@@ -504,23 +562,12 @@ repositories {
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
mavenContent {
excludeGroup("net.minecraftforge") // missing the `universal` artefact
}
}
maven {
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
if (usesMixinDebug.toBoolean()) {
maven {
name = "Fabric Maven"
url = "https://maven.fabricmc.net/"
}
}
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
@@ -529,13 +576,28 @@ 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/"
@@ -559,35 +621,78 @@ repositories {
}
}
def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
dependencies {
if (usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.13:processor')
annotationProcessor(mixinProviderSpec)
if (usesMixinDebug.toBoolean()) {
runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
implementation('com.gtnewhorizon:gtnhmixins:2.1.13')
if (usesMixins.toBoolean()) {
implementation(modUtils.enableMixins(mixinProviderSpec, mixingConfigRefMap))
} else if (forceEnableMixins.toBoolean()) {
runtimeOnlyNonPublishable(mixinProviderSpec)
}
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.13:processor')
kapt(mixinProviderSpec)
}
}
}
apply from: 'dependencies.gradle'
// Replace old mixin mods with unimixins
// https://docs.gradle.org/8.0.2/userguide/resolution_rules.html#sec:substitution_with_classifier
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('com.gtnewhorizon:gtnhmixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
substitute module('com.github.GTNewHorizons:Mixingasm') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
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")
}
}
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"
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")
}
}
}
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"
@@ -619,46 +724,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 {
@@ -676,7 +752,6 @@ tasks.named("processResources", ProcessResources).configure {
}
if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}
@@ -695,16 +770,16 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}
dependencies {
def lwjgl3ifyVersion = '1.1.28'
def lwjgl3ifyVersion = '1.4.0'
def asmVersion = '9.4'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.0.35')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
}
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
@@ -718,8 +793,8 @@ dependencies {
ext.java17JvmArgs = [
// Java 9+ support
"--illegal-access=warn",
"-Dfile.encoding=UTF-8",
"-Djava.security.manager=allow",
"-Dfile.encoding=UTF-8",
"--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
@@ -730,6 +805,7 @@ ext.java17JvmArgs = [
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "jdk.naming.dns/com.sun.jndi.dns=ALL-UNNAMED,java.naming",
"--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED",
"--add-modules", "jdk.dynalink",
"--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED",
@@ -774,7 +850,7 @@ public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
public boolean setEnableHotswap(boolean enable) { enableHotswap = enable }
@Inject
public RunHotswappableMinecraftTask(Side side, String superTask, org.gradle.api.invocation.Gradle gradle) {
public RunHotswappableMinecraftTask(Distribution side, String superTask, org.gradle.api.invocation.Gradle gradle) {
super(side, gradle)
this.lwjglVersion = 3
@@ -783,7 +859,7 @@ public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : []))
this.classpath(project.java17PatchDependenciesCfg)
if (side == Side.CLIENT) {
if (side == Distribution.CLIENT) {
this.classpath(project.minecraftTasks.lwjgl3Configuration)
}
// Use a raw provider instead of map to not create a dependency on the task
@@ -792,14 +868,22 @@ public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
!file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2
}
this.classpath(project.java17DependenciesCfg)
}
if (!(project.usesMixins.toBoolean() || project.forceEnableMixins.toBoolean())) {
this.extraArgs.addAll("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
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, Side.CLIENT, "runClient")
def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Distribution.CLIENT, "runClient")
runClient17Task.configure {
setup(project)
group = "Modded Minecraft"
@@ -810,7 +894,7 @@ runClient17Task.configure {
userUUID = minecraft.userUUID
}
def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Side.SERVER, "runServer")
def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Distribution.DEDICATED_SERVER, "runServer")
runServer17Task.configure {
setup(project)
group = "Modded Minecraft"
@@ -851,11 +935,6 @@ tasks.named("jar", Jar).configure {
}
if (usesShadowedDependencies.toBoolean()) {
tasks.register('relocateShadowJar', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
enabled = relocateShadowedDependencies.toBoolean()
}
tasks.named("shadowJar", ShadowJar).configure {
manifest {
attributes(getManifestAttributes())
@@ -871,7 +950,8 @@ if (usesShadowedDependencies.toBoolean()) {
]
archiveClassifier.set('dev')
if (relocateShadowedDependencies.toBoolean()) {
dependsOn(relocateShadowJar)
relocationPrefix = modGroup + ".shadow"
enableRelocation = true
}
}
configurations.runtimeElements.outgoing.artifacts.clear()
@@ -945,6 +1025,9 @@ idea {
}
}
runConfigurations {
"0. Build and Test"(Gradle) {
taskNames = ["build"]
}
"1. Run Client"(Gradle) {
taskNames = ["runClient"]
}
@@ -1005,6 +1088,7 @@ idea {
}
compiler.javac {
afterEvaluate {
javacAdditionalOptions = "-encoding utf8"
moduleJavacAdditionalOptions = [
(project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ')
]
@@ -1063,6 +1147,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
@@ -1083,12 +1175,14 @@ publishing {
}
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()) {
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"
}
}
}
}
@@ -1124,7 +1218,7 @@ if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) {
}
}
if (usesMixins.toBoolean()) {
addModrinthDep("required", "project", "gtnhmixins")
addModrinthDep("required", "project", "unimixins")
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
@@ -1168,7 +1262,7 @@ if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null
}
}
if (usesMixins.toBoolean()) {
addCurseForgeRelation("requiredDependency", "gtnhmixins")
addCurseForgeRelation("requiredDependency", "unimixins")
}
tasks.curseforge.dependsOn(build)
tasks.publish.dependsOn(tasks.curseforge)
@@ -1203,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
// Updating
def buildscriptGradleVersion = "8.0.1"
def buildscriptGradleVersion = "8.2.1"
tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
@@ -1235,6 +1329,23 @@ if (!project.getGradle().startParameter.isOffline() && !Boolean.getBoolean('DISA
}
}
// If you want to add more cases to this task, implement them as arguments if total amount to print gets too large
tasks.register('faq') {
group = 'GTNH Buildscript'
description = 'Prints frequently asked questions about building a project'
doLast {
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.")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle")
}
@@ -1292,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
@@ -1372,7 +1489,7 @@ static int replaceParams(File file, Map<String, String> params) {
return 0
}
// Dependency Deobfuscation
// Dependency Deobfuscation (Deprecated, use the new RFG API documented in dependencies.gradle)
def deobf(String sourceURL) {
try {
@@ -1414,11 +1531,7 @@ def deobfMaven(String repoURL, String mavenDep) {
}
def deobfCurse(String curseDep) {
try {
return deobfMaven("https://www.cursemaven.com/", "curse.maven:$curseDep")
} catch (Exception ignored) {
out.style(Style.Failure).println("Failed to get $curseDep from cursemaven.")
}
return dependencies.rfg.deobf("curse.maven:$curseDep")
}
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
@@ -1426,34 +1539,7 @@ def deobf(String sourceURL, String rawFileName) {
String bon2Version = "2.5.1"
String fileName = URLDecoder.decode(rawFileName, "UTF-8")
String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
String bon2Dir = "$cacheDir/forge_gradle/deobf"
String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
if (file(deobfFile).exists()) {
return files(deobfFile)
}
String mappingsVer
String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
if (remoteMappings) {
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
zipMappings(mappingsZIP, remoteMappings, bon2Dir)
mappingsVer = "snapshot_$id"
} else {
mappingsVer = "${channel}_$mappingsVersion"
}
download.run {
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
dest bon2File
quiet true
overwrite false
}
download.run {
src sourceURL
@@ -1461,50 +1547,8 @@ def deobf(String sourceURL, String rawFileName) {
quiet true
overwrite false
}
exec {
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
workingDir bon2Dir
standardOutput = new FileOutputStream("${deobfFile}.log")
}
return files(deobfFile)
return dependencies.rfg.deobf(files(obfFile))
}
def zipMappings(String zipPath, String url, String bon2Dir) {
File zipFile = new File(zipPath)
if (zipFile.exists()) {
return
}
String fieldsCache = "$bon2Dir/data/fields.csv"
String methodsCache = "$bon2Dir/data/methods.csv"
download.run {
src "${url}fields.csv"
dest fieldsCache
quiet true
}
download.run {
src "${url}methods.csv"
dest methodsCache
quiet true
}
zipFile.getParentFile().mkdirs()
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
zos.putNextEntry(new ZipEntry("fields.csv"))
Files.copy(Paths.get(fieldsCache), zos)
zos.closeEntry()
zos.putNextEntry(new ZipEntry("methods.csv"))
Files.copy(Paths.get(methodsCache), zos)
zos.closeEntry()
zos.close()
}
// Helper methods
def checkPropertyExists(String propertyName) {
@@ -1531,3 +1575,17 @@ def getSecondaryArtifacts() {
if (apiPackage) secondaryArtifacts += [apiJar]
return secondaryArtifacts
}
// 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 -2
View File
@@ -3,6 +3,5 @@ dependencies {
compileOnly(sourceSets.compileStubs.output)
compileStubs(sourceSets.compileStubsStubs.output)
runtimeOnly("com.github.GTNewHorizons:Mixingasm:v0.2.4:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.3.32-GTNH:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.3.55-GTNH:dev")
}
+5 -5
View File
@@ -34,7 +34,7 @@ enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience
# Turns most publically visible List, Map, etc. into proper List<Type>, Map<K, V> types
enableGenericInjection = false
enableGenericInjection = true
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
@@ -42,10 +42,10 @@ enableGenericInjection = false
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
generateGradleTokenClass = com.gtnewhorizons.angelica.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = VERSION
gradleTokenGroupName = GROUPNAME
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
@@ -62,7 +62,7 @@ apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a comma-separated list.
# Example value: mymodid_at.cfg,nei_at.cfg
accessTransformersFile =
accessTransformersFile = angelica_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = true
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+6 -5
View File
@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
@@ -1,10 +0,0 @@
package net.minecraft.client.model;
import java.util.List;
public class ModelRenderer {
public List childModels;
public void resetDisplayList() {}
}
@@ -1,14 +0,0 @@
package net.minecraft.client.renderer;
public class EntityRenderer {
public static int anaglyphField;
public static boolean anaglyphEnable;
/**
* Render player hand
*/
public void renderHand(float p_78476_1_, int p_78476_2_) {}
public void renderWorld(float f, long l) {}
}
@@ -1,8 +0,0 @@
package net.minecraft.client.renderer;
public class RenderGlobal {
public WorldRenderer[] worldRenderers;
public void loadRenderers() {}
}
@@ -1,182 +0,0 @@
package net.minecraft.client.renderer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import net.minecraft.client.shader.TesselatorVertexState;
public class Tessellator {
private static int nativeBufferSize;
private static int trivertsInBuffer;
public static boolean renderingWorldRenderer;
public boolean defaultTexture;
private int rawBufferSize;
public int textureID;
/** The byte buffer used for GL allocation. */
public ByteBuffer byteBuffer;
/** The same memory as byteBuffer, but referenced as an integer buffer. */
public IntBuffer intBuffer;
/** The same memory as byteBuffer, but referenced as an float buffer. */
public FloatBuffer floatBuffer;
/** The same memory as byteBuffer, but referenced as an short buffer. */
public ShortBuffer shortBuffer;
/** Raw integer array. */
public int[] rawBuffer;
/** The number of vertices to be drawn in the next draw call. Reset to 0 between draw calls. */
public int vertexCount;
/** The first coordinate to be used for the texture. */
public double textureU;
/** The second coordinate to be used for the texture. */
public double textureV;
public int brightness;
/** The color (RGBA) value to be used for the following draw call. */
public int color;
/** Whether the current draw object for this tessellator has color values. */
public boolean hasColor;
/** Whether the current draw object for this tessellator has texture coordinates. */
public boolean hasTexture;
public boolean hasBrightness;
/** Whether the current draw object for this tessellator has normal values. */
public boolean hasNormals;
/** The index into the raw buffer to be used for the next data. */
public int rawBufferIndex;
/**
* The number of vertices manually added to the given draw call. This differs from vertexCount because it adds extra
* vertices when converting quads to triangles.
*/
public int addedVertices;
/** Disables all color information for the following draw call. */
public boolean isColorDisabled;
/** The draw mode currently being used by the tessellator. */
public int drawMode;
/** An offset to be applied along the x-axis for all vertices in this draw call. */
public double xOffset;
/** An offset to be applied along the y-axis for all vertices in this draw call. */
public double yOffset;
/** An offset to be applied along the z-axis for all vertices in this draw call. */
public double zOffset;
/** The normal to be applied to the face being drawn. */
public int normal;
/** The static instance of the Tessellator. */
public static final Tessellator instance = new Tessellator();
/** Whether this tessellator is currently in draw mode. */
public boolean isDrawing;
/** The size of the buffers used (in integers). */
public int bufferSize;
public float midTextureU;
public float midTextureV;
public float normalX;
public float normalY;
public float normalZ;
public float[] vertexPos = new float[16];
private Tessellator(int p_i1250_1_) {}
public Tessellator() {}
/**
* Draws the data set up in this tessellator and resets the state to prepare for new drawing.
*/
public int draw() {
return 0;
}
public TesselatorVertexState getVertexState(float p_147564_1_, float p_147564_2_, float p_147564_3_) {
return null;
}
public void setVertexState(TesselatorVertexState p_147565_1_) {}
/**
* Clears the tessellator state in preparation for new drawing.
*/
public void reset() {}
/**
* Sets draw mode in the tessellator to draw quads.
*/
public void startDrawingQuads() {}
/**
* Resets tessellator state and prepares for drawing (with the specified draw mode).
*/
public void startDrawing(int p_78371_1_) {}
/**
* Sets the texture coordinates.
*/
public void setTextureUV(double p_78385_1_, double p_78385_3_) {}
public void setBrightness(int p_78380_1_) {}
/**
* Sets the RGB values as specified, converting from floats between 0 and 1 to integers from 0-255.
*/
public void setColorOpaque_F(float p_78386_1_, float p_78386_2_, float p_78386_3_) {}
/**
* Sets the RGBA values for the color, converting from floats between 0 and 1 to integers from 0-255.
*/
public void setColorRGBA_F(float p_78369_1_, float p_78369_2_, float p_78369_3_, float p_78369_4_) {}
/**
* Sets the RGB values as specified, and sets alpha to opaque.
*/
public void setColorOpaque(int p_78376_1_, int p_78376_2_, int p_78376_3_) {}
/**
* Sets the RGBA values for the color. Also clamps them to 0-255.
*/
public void setColorRGBA(int p_78370_1_, int p_78370_2_, int p_78370_3_, int p_78370_4_) {}
public void func_154352_a(byte p_154352_1_, byte p_154352_2_, byte p_154352_3_) {}
/**
* Adds a vertex specifying both x,y,z and the texture u,v for it.
*/
public void addVertexWithUV(double p_78374_1_, double p_78374_3_, double p_78374_5_, double p_78374_7_,
double p_78374_9_) {}
/**
* Adds a vertex with the specified x,y,z to the current draw call. It will trigger a draw() if the buffer gets
* full.
*/
public void addVertex(double p_78377_1_, double p_78377_3_, double p_78377_5_) {}
/**
* Sets the color to the given opaque value (stored as byte values packed in an integer).
*/
public void setColorOpaque_I(int p_78378_1_) {}
/**
* Sets the color to the given color (packed as bytes in integer) and alpha values.
*/
public void setColorRGBA_I(int p_78384_1_, int p_78384_2_) {}
/**
* Disables colors for the current draw call.
*/
public void disableColor() {}
/**
* Sets the normal for the current draw call.
*/
public void setNormal(float p_78375_1_, float p_78375_2_, float p_78375_3_) {}
/**
* Sets the translation for all vertices in the current draw call.
*/
public void setTranslation(double p_78373_1_, double p_78373_3_, double p_78373_5_) {}
/**
* Offsets the translation for all vertices in the current draw call.
*/
public void addTranslation(float p_78372_1_, float p_78372_2_, float p_78372_3_) {}
}
@@ -1,4 +0,0 @@
package net.minecraft.client.renderer.entity;
public abstract class Render {
}
@@ -1,10 +0,0 @@
package net.minecraft.client.renderer.entity;
import net.minecraft.client.model.ModelBase;
public abstract class RendererLivingEntity extends Render {
public ModelBase mainModel;
/** The model to be used during the render passes. */
public ModelBase renderPassModel;
}
@@ -137,16 +137,16 @@ import static org.lwjgl.opengl.GL30.glGenerateMipmap;
import static org.lwjgl.util.glu.GLU.gluErrorString;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -175,11 +175,18 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.ContextCapabilities;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GLContext;
import com.gtnewhorizons.angelica.mixins.early.accessors.RendererEntityLivingAccessor;
import com.gtnewhorizons.angelica.mixins.interfaces.IModelRenderer;
// import org.lwjgl.opengl.ARBVertexProgram;
public class Shaders {
@@ -1186,8 +1193,8 @@ public class Shaders {
if (ren instanceof RendererLivingEntity) {
RendererLivingEntity rle = (RendererLivingEntity) ren;
// System.out.format("Reset %s\n", rle.toString());
resetDisplayListModel(rle.mainModel);
resetDisplayListModel(rle.renderPassModel);
resetDisplayListModel(((RendererEntityLivingAccessor) rle).getMainModel());
resetDisplayListModel(((RendererEntityLivingAccessor) rle).getRenderPassModel());
}
}
}
@@ -1208,7 +1215,7 @@ public class Shaders {
}
public static void resetDisplayListModelRenderer(ModelRenderer mrr) {
mrr.resetDisplayList();
((IModelRenderer) mrr).resetDisplayList();
// if (mrr.compiled)
// {
// GLAllocation.deleteDisplayLists(mrr.displayList);
@@ -1366,49 +1373,62 @@ public class Shaders {
return programid;
}
private static InputStream locateShaderStream(String path) {
try {
return shaderPack.getResourceAsStream(path);
} catch (Exception e) {
try {
return FileUtils.openInputStream(new File(path));
} catch (Exception e2) {
throw new RuntimeException("Could not locate shader input " + path, e);
}
}
}
private static String getPreprocessedShaderSources(String filename) {
filename = filename.replace('\\', '/');
int lastSlash = filename.lastIndexOf('/');
final String basename = (lastSlash == -1) ? "/" : filename.substring(0, lastSlash + 1);
try (InputStream is = locateShaderStream(filename)) {
if (is == null) {
throw new FileNotFoundException(filename);
}
String source = IOUtils.toString(is, StandardCharsets.UTF_8).replace("\r\n", "\n");
StringBuffer output = new StringBuffer(2 * source.length() + 64);
final Matcher includes = INCLUDE_PATTERN.matcher(source);
while (includes.find()) {
final String relPath = includes.group(1).replace('\\', '/');
final String path = relPath.startsWith("/") ? ("/shaders" + relPath) : (basename + relPath);
final String src = getPreprocessedShaderSources(path);
includes.appendReplacement(output, src);
}
includes.appendTail(output);
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static int createVertShader(String filename) {
int vertShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
if (vertShader == 0) {
return 0;
}
StringBuilder vertexCode = new StringBuilder(1048576);
String line;
BufferedReader reader = null;
String shaderSrc;
try {
reader = new BufferedReader(new InputStreamReader(shaderPack.getResourceAsStream(filename)));
} catch (Exception e) {
try {
reader = new BufferedReader(new FileReader(new File(filename)));
} catch (Exception e2) {
// System.out.println("Couldn't open " + filename);
glDeleteObjectARB(vertShader);
return 0;
}
}
shaderSrc = getPreprocessedShaderSources(filename);
if (reader != null) try {
while ((line = reader.readLine()) != null) {
if (preprocessIncludeDirective(line, vertexCode, false)) continue;
vertexCode.append(line).append("\n");
for (String line : StringUtils.split(shaderSrc, '\n')) {
processVertShaderLine(line);
}
} catch (Exception e) {
System.out.println("Couldn't read " + filename + "!");
e.printStackTrace();
glDeleteObjectARB(vertShader);
return 0;
}
if (reader != null) try {
reader.close();
} catch (Exception e) {
System.out.println("Couldn't close " + filename + "!");
}
glShaderSourceARB(vertShader, vertexCode);
glShaderSourceARB(vertShader, shaderSrc);
glCompileShaderARB(vertShader);
printLogInfo(vertShader, filename);
return vertShader;
@@ -1431,84 +1451,28 @@ public class Shaders {
private static final Pattern gbufferMipmapEnabledPattern = Pattern
.compile("[ \t]*const[ \t]*bool[ \t]*(\\w+)MipmapEnabled[ \t]*=[ \t]*true[ \t]*;.*");
private static final Pattern INCLUDE_PATTERN = Pattern.compile("^\\s*#include\\s+\"([A-Za-z0-9_/\\.]+)\".*$");
// TODO: dirty non-recursive implementation, also does not support any includes referencing anything but shaders
// directory
private static boolean preprocessIncludeDirective(String line, StringBuilder code, boolean type) {
Matcher includePattern = INCLUDE_PATTERN.matcher(line);
if (includePattern.matches()) {
String path = includePattern.group(1);
InputStream inputStream = shaderPack.getResourceAsStream("/shaders" + path);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String l;
try {
while ((l = reader.readLine()) != null) {
code.append(l).append("\n");
// TODO: type is a dirty hack to get includes working for now, must be refactored
if (type) {
processFragShaderLine(line, path);
} else {
processVertShaderLine(line);
}
}
} catch (IOException e) {
printChatAndLogError(e.getLocalizedMessage());
e.printStackTrace();
}
return true;
}
return false;
}
private static final Pattern INCLUDE_PATTERN = Pattern
.compile("^\\s*#include\\s+\"([A-Za-z0-9_\\/\\.]+)\".*$", Pattern.MULTILINE | Pattern.UNIX_LINES);
private static int createFragShader(String filename) {
int fragShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
if (fragShader == 0) {
return 0;
}
StringBuilder fragCode = new StringBuilder(1048576);
String line;
BufferedReader reader;
String shaderSrc;
try {
reader = new BufferedReader(new InputStreamReader(shaderPack.getResourceAsStream(filename)));
} catch (Exception e) {
try {
reader = new BufferedReader(new FileReader(new File(filename)));
} catch (Exception e2) {
// System.out.println("Couldn't open " + filename);
glDeleteObjectARB(fragShader);
return 0;
}
}
shaderSrc = getPreprocessedShaderSources(filename);
if (reader != null) try {
while ((line = reader.readLine()) != null) {
if (preprocessIncludeDirective(line, fragCode, true)) continue;
fragCode.append(line).append('\n');
for (String line : StringUtils.split(shaderSrc, '\n')) {
processFragShaderLine(line, filename);
}
} catch (Exception e) {
System.out.println("Couldn't read " + filename + "!");
e.printStackTrace();
glDeleteObjectARB(fragShader);
return 0;
}
if (reader != null) try {
reader.close();
} catch (Exception e) {
System.out.println("Couldn't close " + filename + "!");
}
glShaderSourceARB(fragShader, fragCode);
glShaderSourceARB(fragShader, shaderSrc);
glCompileShaderARB(fragShader);
printLogInfo(fragShader, filename);
return fragShader;
@@ -14,6 +14,8 @@ import net.minecraft.item.ItemBlock;
import org.lwjgl.opengl.GL11;
import com.gtnewhorizons.angelica.mixins.early.accessors.WorldRenderersAccessor;
public class ShadersRender {
public static void setFrustrumPosition(Frustrum frustrum, double x, double y, double z) {
@@ -22,18 +24,17 @@ public class ShadersRender {
public static void clipRenderersByFrustrum(RenderGlobal renderGlobal, Frustrum frustrum, float par2) {
Shaders.checkGLError("pre clip");
WorldRenderer[] worldRenderers = ((WorldRenderersAccessor) renderGlobal).getWorldRenderers();
if (!Shaders.isShadowPass) {
WorldRenderer[] worldRenderers = renderGlobal.worldRenderers;
for (int i = 0; i < worldRenderers.length; ++i) {
if (!worldRenderers[i].skipAllRenderPasses()) {
worldRenderers[i].updateInFrustum(frustrum);
for (WorldRenderer worldRenderer : worldRenderers) {
if (!worldRenderer.skipAllRenderPasses()) {
worldRenderer.updateInFrustum(frustrum);
}
}
} else {
WorldRenderer[] worldRenderers = renderGlobal.worldRenderers;
for (int i = 0; i < worldRenderers.length; ++i) {
if (!worldRenderers[i].skipAllRenderPasses()) {
worldRenderers[i].isInFrustum = true;
for (WorldRenderer worldRenderer : worldRenderers) {
if (!worldRenderer.skipAllRenderPasses()) {
worldRenderer.isInFrustum = true;
}
}
}
@@ -14,6 +14,7 @@ import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import com.gtnewhorizons.angelica.mixins.interfaces.TessellatorAccessor;
import com.gtnewhorizons.angelica.transform.ALog;
public class ShadersTess {
@@ -21,6 +22,7 @@ public class ShadersTess {
public static final int vertexStride = 16;
public static int draw(Tessellator tess) {
final TessellatorAccessor tessa = (TessellatorAccessor) tess;
if (!tess.isDrawing) {
throw new IllegalStateException("Not tesselating!");
} else {
@@ -32,40 +34,42 @@ public class ShadersTess {
int realDrawMode = tess.drawMode;
while (voffset < tess.vertexCount) {
int vcount;
vcount = Math.min(tess.vertexCount - voffset, tess.byteBuffer.capacity() / (vertexStride * 4));
vcount = Math.min(
tess.vertexCount - voffset,
tessa.getAngelica$byteBuffer().capacity() / (vertexStride * 4));
if (realDrawMode == GL11.GL_QUADS) vcount = vcount / 4 * 4;
tess.floatBuffer.clear();
tess.shortBuffer.clear();
tess.intBuffer.clear();
tess.intBuffer.put(tess.rawBuffer, voffset * vertexStride, vcount * vertexStride);
tess.byteBuffer.position(0);
tess.byteBuffer.limit(vcount * (vertexStride * 4));
tessa.getAngelica$floatBuffer().clear();
tessa.getAngelica$shortBuffer().clear();
tessa.getAngelica$intBuffer().clear();
tessa.getAngelica$intBuffer().put(tess.rawBuffer, voffset * vertexStride, vcount * vertexStride);
tessa.getAngelica$byteBuffer().position(0);
tessa.getAngelica$byteBuffer().limit(vcount * (vertexStride * 4));
voffset += vcount;
if (tess.hasTexture) {
tess.floatBuffer.position(3);
GL11.glTexCoordPointer(2, (vertexStride * 4), tess.floatBuffer);
tessa.getAngelica$floatBuffer().position(3);
GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$floatBuffer());
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}
if (tess.hasBrightness) {
OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
tess.shortBuffer.position(6 * 2);
GL11.glTexCoordPointer(2, (vertexStride * 4), tess.shortBuffer);
tessa.getAngelica$shortBuffer().position(6 * 2);
GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$shortBuffer());
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
}
if (tess.hasColor) {
tess.byteBuffer.position(5 * 4);
GL11.glColorPointer(4, true, (vertexStride * 4), tess.byteBuffer);
tessa.getAngelica$byteBuffer().position(5 * 4);
GL11.glColorPointer(4, true, (vertexStride * 4), tessa.getAngelica$byteBuffer());
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
}
if (tess.hasNormals) {
tess.floatBuffer.position(9);
GL11.glNormalPointer((vertexStride * 4), tess.floatBuffer);
tessa.getAngelica$floatBuffer().position(9);
GL11.glNormalPointer((vertexStride * 4), tessa.getAngelica$floatBuffer());
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
}
tess.floatBuffer.position(0);
GL11.glVertexPointer(3, (vertexStride * 4), tess.floatBuffer);
tessa.getAngelica$floatBuffer().position(0);
GL11.glVertexPointer(3, (vertexStride * 4), tessa.getAngelica$floatBuffer());
ShadersTess.preDrawArray(tess);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
@@ -97,10 +101,11 @@ public class ShadersTess {
}
public static void preDrawArray(Tessellator tess) {
final TessellatorAccessor tessa = (TessellatorAccessor) tess;
// Shaders.checkGLError("preDrawArray");
if (Shaders.useMultiTexCoord3Attrib && tess.hasTexture) {
GL13.glClientActiveTexture(GL13.GL_TEXTURE3);
GL11.glTexCoordPointer(2, (vertexStride * 4), (FloatBuffer) tess.floatBuffer.position(12));
GL11.glTexCoordPointer(2, (vertexStride * 4), (FloatBuffer) tessa.getAngelica$floatBuffer().position(12));
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
}
@@ -110,7 +115,7 @@ public class ShadersTess {
2,
false,
vertexStride * 4,
(FloatBuffer) tess.floatBuffer.position(12));
(FloatBuffer) tessa.getAngelica$floatBuffer().position(12));
glEnableVertexAttribArrayARB(Shaders.midTexCoordAttrib);
}
if (Shaders.useEntityAttrib) {
@@ -120,7 +125,7 @@ public class ShadersTess {
false,
false,
vertexStride * 4,
(ShortBuffer) tess.shortBuffer.position(7 * 2));
(ShortBuffer) tessa.getAngelica$shortBuffer().position(7 * 2));
glEnableVertexAttribArrayARB(Shaders.entityAttrib);
}
// Shaders.checkGLError("preDrawArray");
@@ -162,6 +167,7 @@ public class ShadersTess {
}
public static void addVertex(Tessellator tess, double parx, double pary, double parz) {
final TessellatorAccessor tessa = (TessellatorAccessor) (Object) tess;
int[] rawBuffer = tess.rawBuffer;
int rbi = tess.rawBufferIndex;
float fx = (float) (parx + tess.xOffset);
@@ -190,7 +196,7 @@ public class ShadersTess {
// shaders mod calculate normal and mid UV
if (tess.drawMode == 7) {
int i = tess.addedVertices % 4;
float[] vertexPos = tess.vertexPos;
float[] vertexPos = tessa.getAngelica$vertexPos();
vertexPos[i * 4 + 0] = fx;
vertexPos[i * 4 + 1] = fy;
vertexPos[i * 4 + 2] = fz;
@@ -207,26 +213,34 @@ public class ShadersTess {
float vnz = x1 * y2 - x2 * y1;
float lensq = vnx * vnx + vny * vny + vnz * vnz;
float mult = (lensq != 0.0) ? (float) (1f / Math.sqrt(lensq)) : 1f;
float normalX = vnx * mult;
float normalY = vny * mult;
float normalZ = vnz * mult;
tessa.setAngelica$normalX(normalX);
tessa.setAngelica$normalY(normalY);
tessa.setAngelica$normalZ(normalZ);
rawBuffer[rbi + (9 - vertexStride * 3)] = rawBuffer[rbi + (9 - vertexStride * 2)] = rawBuffer[rbi
+ (9 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalX = vnx * mult);
+ (9 - vertexStride * 1)] = Float.floatToRawIntBits(normalX);
rawBuffer[rbi + (10 - vertexStride * 3)] = rawBuffer[rbi + (10 - vertexStride * 2)] = rawBuffer[rbi
+ (10 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalY = vny * mult);
+ (10 - vertexStride * 1)] = Float.floatToRawIntBits(normalY);
rawBuffer[rbi + (11 - vertexStride * 3)] = rawBuffer[rbi + (11 - vertexStride * 2)] = rawBuffer[rbi
+ (11 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalZ = vnz * mult);
+ (11 - vertexStride * 1)] = Float.floatToRawIntBits(normalZ);
tess.hasNormals = true;
// mid UV
tess.midTextureU = (Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 3)])
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 2)])
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 1)])
+ (float) tess.textureU) / 4;
tess.midTextureV = (Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 3)])
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 2)])
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 1)])
+ (float) tess.textureV) / 4;
tessa.setAngelica$midTextureU(
(Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 3)])
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 2)])
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 1)])
+ (float) tess.textureU) / 4);
tessa.setAngelica$midTextureV(
(Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 3)])
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 2)])
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 1)])
+ (float) tess.textureV) / 4);
rawBuffer[rbi + (12 - vertexStride * 3)] = rawBuffer[rbi + (12 - vertexStride * 2)] = rawBuffer[rbi
+ (12 - vertexStride * 1)] = Float.floatToRawIntBits(tess.midTextureU);
+ (12 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureU());
rawBuffer[rbi + (13 - vertexStride * 3)] = rawBuffer[rbi + (13 - vertexStride * 2)] = rawBuffer[rbi
+ (13 - vertexStride * 1)] = Float.floatToRawIntBits(tess.midTextureV);
+ (13 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureV());
}
}
// end normal and mid UV calculation
@@ -241,11 +255,11 @@ public class ShadersTess {
rawBuffer[rbi + 6] = tess.brightness;
rawBuffer[rbi + 7] = Shaders.getEntityData();
rawBuffer[rbi + 8] = Shaders.getEntityData2();
rawBuffer[rbi + 9] = Float.floatToRawIntBits((float) tess.normalX);
rawBuffer[rbi + 10] = Float.floatToRawIntBits((float) tess.normalY);
rawBuffer[rbi + 11] = Float.floatToRawIntBits((float) tess.normalZ);
rawBuffer[rbi + 12] = Float.floatToRawIntBits((float) tess.midTextureU);
rawBuffer[rbi + 13] = Float.floatToRawIntBits((float) tess.midTextureV);
rawBuffer[rbi + 9] = Float.floatToRawIntBits((float) tessa.getAngelica$normalX());
rawBuffer[rbi + 10] = Float.floatToRawIntBits((float) tessa.getAngelica$normalY());
rawBuffer[rbi + 11] = Float.floatToRawIntBits((float) tessa.getAngelica$normalZ());
rawBuffer[rbi + 12] = Float.floatToRawIntBits((float) tessa.getAngelica$midTextureU());
rawBuffer[rbi + 13] = Float.floatToRawIntBits((float) ((TessellatorAccessor) tess).getAngelica$midTextureV());
tess.rawBufferIndex = rbi += vertexStride;
++tess.vertexCount;
@@ -13,6 +13,7 @@ import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
import com.gtnewhorizons.angelica.mixins.Mixins;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.MCVersion("1.7.10")
@@ -11,6 +11,7 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
import com.gtnewhorizons.angelica.transform.AClassTransformer;
import com.gtnewhorizons.angelica.transform.ALog;
import cpw.mods.fml.common.asm.transformers.TerminalTransformer;
public class MixinCompatHackTweaker implements ITweaker {
@@ -21,6 +22,7 @@ public class MixinCompatHackTweaker implements ITweaker {
try {
Field xformersField = lcl.getClass().getDeclaredField("transformers");
xformersField.setAccessible(true);
@SuppressWarnings("unchecked")
List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
int terminalIndex;
for (terminalIndex = 1; terminalIndex < xformers.size(); terminalIndex++) {
@@ -11,7 +11,39 @@ import cpw.mods.fml.relauncher.FMLLaunchHandler;
public enum Mixins {
ANGELICA_STARTUP(new Builder("Start Angelica").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).addMixinClasses("minecraft.MixinMinecraft").setApplyIf(() -> true));
.setPhase(Phase.EARLY).addMixinClasses("shaders.MixinMinecraft").setApplyIf(() -> true)),
ANGELICA_ACCESSORS(new Builder("Angelica Accessors").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY)
.addMixinClasses(
"accessors.ModelRendererAccessor",
"accessors.RendererEntityLivingAccessor",
"accessors.WorldRenderersAccessor")
.setApplyIf(() -> true)),
ANGELICA_SHADERS_BUTTON(new Builder("Add Shaders Button").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).addMixinClasses("settings.MixinGuiVideoSettings").setApplyIf(() -> true)),
ANGELICA_LIGHTING(
new Builder("Lighting").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
.addMixinClasses("lighting.MixinBlock", "lighting.MixinRenderBlocks").setApplyIf(() -> true)),
ANGELICA_RENDERER(
new Builder("Renderer").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
.addMixinClasses(
"renderer.MixinOpenGlHelper",
"renderer.MixinEntityRender",
"renderer.MixinEntityRenderer",
"renderer.MixinRenderBlocks",
"renderer.MixinRenderGlobal",
"renderer.MixinModelRenderer",
"renderer.MixinTextureClock",
"renderer.MixinTextureCompass",
"renderer.MixinSimpleTexture",
"renderer.MixinTessellator")
.setApplyIf(() -> true))
;
public final String name;
public final List<String> mixinClasses;
@@ -0,0 +1,23 @@
package com.gtnewhorizons.angelica.mixins.early.accessors;
import net.minecraft.client.model.ModelRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ModelRenderer.class)
public interface ModelRendererAccessor {
@Accessor()
boolean getCompiled();
@Accessor()
int getDisplayList();
@Accessor()
void setCompiled(boolean compiled);
@Accessor()
void setDisplayList(int displayList);
}
@@ -0,0 +1,17 @@
package com.gtnewhorizons.angelica.mixins.early.accessors;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RendererLivingEntity.class)
public interface RendererEntityLivingAccessor {
@Accessor
ModelBase getMainModel();
@Accessor
ModelBase getRenderPassModel();
}
@@ -0,0 +1,14 @@
package com.gtnewhorizons.angelica.mixins.early.accessors;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RenderGlobal.class)
public interface WorldRenderersAccessor {
@Accessor
WorldRenderer[] getWorldRenderers();
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.early.lighting;
import net.minecraft.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(Block.class)
public class MixinBlock {
@ModifyConstant(method = "getAmbientOcclusionLightValue()F", constant = @Constant(floatValue = 0.2f))
public float angelica$blockAoLight(float constant) {
return Shaders.blockAoLight;
}
}
@@ -0,0 +1,109 @@
package com.gtnewhorizons.angelica.mixins.early.lighting;
import net.minecraft.client.renderer.RenderBlocks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Slice;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(RenderBlocks.class)
public class MixinRenderBlocks {
// All of these expect 1 replacement only
@ModifyConstant(
method = { "renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.5F),
expect = 1)
public float angelica$blockSingleLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = { "renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.6F),
expect = 1)
public float angelica$blockSingleLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = { "renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.8F),
expect = 1)
public float angelica$blockSingleLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
// Piston Extension - Differing expectations, and slicing required
@ModifyConstant(
method = "renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.5F),
expect = 3,
slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=8.0D", ordinal = 0)))
public float angelica$pistonBlockLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = "renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.6F),
expect = 12)
public float angelica$pistonBlockLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = "renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.8F),
expect = 4)
public float angelica$pistonBlockLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
// BlockWithAmbientOcclusion
@ModifyConstant(
method = { "renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.5F))
public float angelica$multipleBlockLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = { "renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.6F))
public float angelica$multipleBlockLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = { "renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.8F))
public float angelica$multipleBlockLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.entity.Render;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(Render.class)
public class MixinEntityRender {
@Inject(method = "renderShadow(Lnet/minecraft/entity/Entity;DDDFF)V", at = @At("HEAD"), cancellable = true)
public void angelica$checkSkipShadow(CallbackInfo ci) {
if (Shaders.shouldSkipDefaultShadow) ci.cancel();
}
}
@@ -0,0 +1,56 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.ItemRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.Shaders;
import com.gtnewhorizons.angelica.client.ShadersRender;
@Mixin(EntityRenderer.class)
public abstract class MixinEntityRenderer {
@Shadow
public abstract void disableLightmap(double p_78483_1_);
@Inject(
method = "Lnet/minecraft/client/renderer/EntityRenderer;renderHand(FI)V",
at = @At(
value = "INVOKE",
shift = At.Shift.BEFORE,
target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V",
remap = false))
public void angelica$applyHandDepth(CallbackInfo ci) {
Shaders.applyHandDepth();
}
@Inject(
method = "Lnet/minecraft/client/renderer/EntityRenderer;renderHand(FI)V",
at = @At(
value = "FIELD",
shift = At.Shift.BEFORE,
target = "Lnet/minecraft/client/settings/GameSettings;thirdPersonView:I",
ordinal = 1),
cancellable = true)
public void angelica$checkCompositeRendered(float p_78476_1_, int p_78476_2_, CallbackInfo ci) {
if (!Shaders.isCompositeRendered) {
ci.cancel();
}
this.disableLightmap(p_78476_1_);
}
@Redirect(
method = "Lnet/minecraft/client/renderer/EntityRenderer;renderHand(FI)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V"))
public void angelica$renderItemInFirstPerson(ItemRenderer itemRenderer, float partialTicks) {
ShadersRender.renderItemFP(itemRenderer, partialTicks);
}
}
@@ -0,0 +1,27 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GLAllocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.gtnewhorizons.angelica.mixins.interfaces.IModelRenderer;
@Mixin(ModelRenderer.class)
public class MixinModelRenderer implements IModelRenderer {
@Shadow
private boolean compiled;
@Shadow
private int displayList;
public void resetDisplayList() {
if (!compiled && displayList != 0) {
GLAllocation.deleteDisplayLists(displayList);
displayList = 0;
compiled = false;
}
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.OpenGlHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(OpenGlHelper.class)
public class MixinOpenGlHelper {
@Inject(method = "setActiveTexture(I)V", at = @At("HEAD"))
private static void angelica$setActiveTexUnit(int activeTexture, CallbackInfo ci) {
Shaders.activeTexUnit = activeTexture;
}
}
@@ -0,0 +1,68 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.Operation;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.WrapOperation;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(RenderBlocks.class)
public class MixinRenderBlocks {
// Block
@Inject(method = "renderBlockByRenderType(Lnet/minecraft/block/Block;III)Z", at = @At("HEAD"))
private void angelica$injectShadersBlockPushEntity(Block block, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.pushEntity((RenderBlocks) ((Object) this), block, x, y, z);
}
@Inject(method = "renderBlockByRenderType(Lnet/minecraft/block/Block;III)Z", at = @At("RETURN"))
private void angelica$injectShadersPopEntityBlock(Block block, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
// BlockFlowerPot
@Inject(method = "renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z", at = @At("HEAD"))
private void angelica$injectShadersFlowerpotPushEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.pushEntity((RenderBlocks) ((Object) this), blockFlowerPot, x, y, z);
}
@Inject(method = "renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z", at = @At("RETURN"))
private void angelica$injectShadersFlowerpotPopEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
@WrapOperation(
method = "renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/Block;getBlockFromItem(Lnet/minecraft/item/Item;)Lnet/minecraft/block/Block;"))
private Block angelica$injectShadersFlowerpotItemBlockPushEntity(Item itemIn, Operation<Block> original) {
final Block block = original.call(itemIn);
Shaders.pushEntity(block);
return block;
}
@Inject(
method = "renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/Tessellator;addTranslation(FFF)V",
shift = At.Shift.AFTER,
ordinal = 1))
private void angelica$injectShadersFlowerpotItemBlockPopEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
}
@@ -0,0 +1,249 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MovingObjectPosition;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.Operation;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.WrapOperation;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(RenderGlobal.class)
public class MixinRenderGlobal {
@Inject(
method = "renderEntities(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/renderer/culling/ICamera;F)V",
at = @At(
value = "INVOKE_STRING",
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
args = "ldc=entities"))
private void angelica$beginEntities(EntityLivingBase entity, ICamera camera, float p_147589_3_, CallbackInfo ci) {
Shaders.beginEntities();
}
@Inject(
method = "renderEntities(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/renderer/culling/ICamera;F)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntitySimple(Lnet/minecraft/entity/Entity;F)Z",
ordinal = 1,
shift = At.Shift.AFTER))
private void angelica$nextEntity(EntityLivingBase entity, ICamera camera, float p_147589_3_, CallbackInfo ci) {
Shaders.nextEntity();
}
@Inject(
method = "renderEntities(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/renderer/culling/ICamera;F)V",
at = @At(
value = "INVOKE_STRING",
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
args = "ldc=blockentities",
shift = At.Shift.AFTER))
private void angelica$blockEntities(EntityLivingBase entity, ICamera camera, float p_147589_3_, CallbackInfo ci) {
Shaders.endEntities();
Shaders.beginBlockEntities();
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderGlobal;renderEntities(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/renderer/culling/ICamera;F)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/EntityRenderer;disableLightmap(D)V",
shift = At.Shift.AFTER))
private void angelica$endBlockEntities(EntityLivingBase entity, ICamera camera, float p_147589_3_,
CallbackInfo ci) {
Shaders.endBlockEntities();
}
// Texture 2D
@Inject(
method = "sortAndRender(Lnet/minecraft/entity/EntityLivingBase;ID)I",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V",
remap = false,
ordinal = 0,
shift = At.Shift.AFTER),
expect = 1)
private void angelica$sortandRenderDisableTexture2D(EntityLivingBase p_72719_1_, int p_72719_2_, double p_72719_3_,
CallbackInfoReturnable<Integer> cir) {
Shaders.disableTexture2D();
}
@Inject(
method = "drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/MovingObjectPosition;IF)V",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V",
remap = false,
ordinal = 0,
shift = At.Shift.AFTER),
expect = 1)
private void angelica$drawSelectionBoxDisableTexture2D(CallbackInfo ci) {
Shaders.disableTexture2D();
}
@Inject(
method = "sortAndRender(Lnet/minecraft/entity/EntityLivingBase;ID)I",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V",
remap = false,
ordinal = 0,
shift = At.Shift.AFTER))
private void angelica$sortAndRenderEnableTexture2D(CallbackInfoReturnable<Integer> cir) {
Shaders.enableTexture2D();
}
@Inject(
method = "drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/MovingObjectPosition;IF)V",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V",
remap = false,
ordinal = 1,
shift = At.Shift.AFTER),
expect = 1)
private void angelica$drawSelectionBoxEnableTexture2D(EntityPlayer p_72731_1_, MovingObjectPosition p_72731_2_,
int p_72731_3_, float p_72731_4_, CallbackInfo ci) {
Shaders.enableTexture2D();
}
// Fog
@Inject(
method = "sortAndRender(Lnet/minecraft/entity/EntityLivingBase;ID)I",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V",
remap = false,
ordinal = 3,
shift = At.Shift.AFTER))
private void angelica$sortAndRenderDisableFog(CallbackInfoReturnable<Integer> cir) {
Shaders.disableFog();
}
@Inject(
method = "sortAndRender(Lnet/minecraft/entity/EntityLivingBase;ID)I",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V",
remap = false,
ordinal = 2,
shift = At.Shift.AFTER))
private void angelica$sortAndRenderEnableFog(CallbackInfoReturnable<Integer> cir) {
Shaders.enableFog();
}
// RenderSky
@WrapOperation(
method = "renderSky(F)V",
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", remap = false))
private void angelica$renderSkyDisable(int cap, Operation<Void> original) {
original.call(cap);
if (cap == GL11.GL_FOG) Shaders.disableFog();
else if (cap == GL11.GL_TEXTURE_2D) Shaders.disableTexture2D();
}
@WrapOperation(
method = "renderSky(F)V",
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", remap = false))
private void angelica$renderSkyEnable(int cap, Operation<Void> original) {
original.call(cap);
if (cap == GL11.GL_FOG) Shaders.enableFog();
else if (cap == GL11.GL_TEXTURE_2D) Shaders.enableTexture2D();
}
@Inject(
method = "renderSky(F)V",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glCallList(I)V",
remap = false,
ordinal = 0,
shift = At.Shift.BEFORE,
by = 2))
private void angelica$renderSkyPreSkyList(float p_72714_1_, CallbackInfo ci) {
Shaders.preSkyList();
}
@Inject(
method = "renderSky(F)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/WorldClient;getCelestialAngle(F)F",
ordinal = 1,
shift = At.Shift.BY,
by = -2))
private void angelica$renderSkyBeforeCelestialAngle(float p_72714_1_, CallbackInfo ci) {
Shaders.preCelestialRotate();
}
@Inject(
method = "renderSky(F)V",
at = @At(
value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glRotatef(FFFF)V",
remap = false,
ordinal = 9,
shift = At.Shift.AFTER))
private void angelica$renderSkyAfterCelestialAngle(float p_72714_1_, CallbackInfo ci) {
Shaders.postCelestialRotate();
}
// drawBlockDamageTexture
@WrapOperation(
method = "Lnet/minecraft/client/renderer/RenderGlobal;drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V",
remap = false,
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", remap = false))
private void angelica$drawBlockDamageTextureDisable(int cap, Operation<Void> original) {
original.call(cap);
if (cap == GL11.GL_TEXTURE_2D) Shaders.disableTexture2D();
}
@WrapOperation(
method = "Lnet/minecraft/client/renderer/RenderGlobal;drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V",
remap = false,
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", remap = false))
private void angelica$drawBlockDamageTextureSkyEnable(int cap, Operation<Void> original) {
original.call(cap);
if (cap == GL11.GL_TEXTURE_2D) Shaders.enableTexture2D();
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderGlobal;drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V",
ordinal = 0,
shift = At.Shift.BEFORE))
private void angelica$beginBlockDestroyProgress(Tessellator p_72717_1_, EntityLivingBase p_72717_2_,
float p_72717_3_, CallbackInfo ci) {
Shaders.beginBlockDestroyProgress();
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderGlobal;drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/Tessellator;setTranslation(DDD)V",
ordinal = 1,
shift = At.Shift.AFTER))
private void angelica$endBlockDestroyProgress(Tessellator p_72717_1_, EntityLivingBase p_72717_2_, float p_72717_3_,
CallbackInfo ci) {
Shaders.endBlockDestroyProgress();
}
}
@@ -0,0 +1,48 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import java.awt.image.BufferedImage;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.ShadersTex;
@Mixin(value = SimpleTexture.class)
public class MixinSimpleTexture extends AbstractTexture {
private IResourceManager passedResourceManager;
@Shadow
protected ResourceLocation textureLocation;
@Inject(method = "loadTexture(Lnet/minecraft/client/resources/IResourceManager;)V", at = @At("HEAD"))
private void getResourceManager(IResourceManager p_110551_1_, CallbackInfo cbi) {
passedResourceManager = p_110551_1_;
}
@Redirect(
method = "loadTexture(Lnet/minecraft/client/resources/IResourceManager;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/TextureUtil;uploadTextureImageAllocate(ILjava/awt/image/BufferedImage;ZZ)I"))
private int angelica$loadTexture(int textureID, BufferedImage bufferedImage, boolean flag, boolean flag1) {
ShadersTex.loadSimpleTexture(
textureID,
bufferedImage,
flag,
flag1,
passedResourceManager,
this.textureLocation,
ShadersTex.getMultiTexID(this));
return 0;
}
}
@@ -0,0 +1,261 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.util.PriorityQueue;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.shader.TesselatorVertexState;
import net.minecraft.client.util.QuadComparator;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.ShadersTess;
import com.gtnewhorizons.angelica.mixins.interfaces.TessellatorAccessor;
@Mixin(Tessellator.class)
public abstract class MixinTessellator implements TessellatorAccessor {
@Shadow(remap = false)
public boolean defaultTexture;
@Shadow(remap = false)
private int rawBufferSize;
@Shadow(remap = false)
public int textureID;
@Shadow
public int[] rawBuffer;
@Shadow
public int vertexCount;
@Shadow
public int rawBufferIndex;
@Shadow
public int addedVertices;
@Shadow
public boolean hasTexture;
@Shadow
public boolean hasBrightness;
@Shadow
public boolean hasNormals;
@Shadow
public boolean hasColor;
@Shadow
public double xOffset;
@Shadow
public double yOffset;
@Shadow
public double zOffset;
private ByteBuffer angelica$byteBuffer;
private IntBuffer angelica$intBuffer;
private FloatBuffer angelica$floatBuffer;
private ShortBuffer angelica$shortBuffer;
public float[] angelica$vertexPos;
public float angelica$normalX;
public float angelica$normalY;
public float angelica$normalZ;
public float angelica$midTextureU;
public float angelica$midTextureV;
@Inject(method = "<init>(I)V", at = @At("TAIL"))
private void angelica$extendBufferConstructor(int bufferSize, CallbackInfo ci) {
angelica$byteBuffer = GLAllocation.createDirectByteBuffer(bufferSize * 4);
angelica$intBuffer = angelica$byteBuffer.asIntBuffer();
angelica$floatBuffer = angelica$byteBuffer.asFloatBuffer();
angelica$shortBuffer = angelica$byteBuffer.asShortBuffer();
rawBuffer = new int[bufferSize];
vertexCount = 0;
angelica$vertexPos = new float[16];
}
@Inject(method = "<init>()V", at = @At("TAIL"))
private void angelica$extendEmptyConstructor(CallbackInfo ci) {
this.angelica$extendBufferConstructor(65536, null);
this.defaultTexture = false;
this.rawBufferSize = 0;
this.textureID = 0;
}
/**
* @author eigenraven
* @reason The entire drawing process must be redirected to go through an alternative renderer
*/
@Overwrite
public int draw() {
return ShadersTess.draw((Tessellator) (Object) this);
}
/**
* @author eigenraven
* @reason byteBuffer->angelica$byteBuffer
*/
@Overwrite
public void reset() {
this.vertexCount = 0;
this.angelica$byteBuffer.clear();
this.rawBufferIndex = 0;
this.addedVertices = 0;
}
/**
* @author eigenraven
* @reason The entire drawing process must be redirected to go through an alternative renderer
*/
@Overwrite
public void addVertex(double x, double y, double z) {
ShadersTess.addVertex((Tessellator) (Object) this, x, y, z);
}
/**
* @author eigenraven
* @reason Modify 32->64, ModifyConstant causes an internal mixin crash in this method
*/
@Overwrite
public TesselatorVertexState getVertexState(float x, float y, float z) {
int[] tmpCopyBuffer = new int[this.rawBufferIndex];
@SuppressWarnings("unchecked")
PriorityQueue<Integer> pQueue = new PriorityQueue<>(
this.rawBufferIndex,
new QuadComparator(
this.rawBuffer,
x + (float) this.xOffset,
y + (float) this.yOffset,
z + (float) this.zOffset));
byte batchSize = 64;
for (int vidx = 0; vidx < this.rawBufferIndex; vidx += batchSize) {
pQueue.add(vidx);
}
for (int batchVidx = 0; !pQueue.isEmpty(); batchVidx += batchSize) {
int queuedVidx = pQueue.remove();
for (int batchElement = 0; batchElement < batchSize; ++batchElement) {
tmpCopyBuffer[batchVidx + batchElement] = this.rawBuffer[queuedVidx + batchElement];
}
}
System.arraycopy(tmpCopyBuffer, 0, this.rawBuffer, 0, tmpCopyBuffer.length);
return new TesselatorVertexState(
tmpCopyBuffer,
this.rawBufferIndex,
this.vertexCount,
this.hasTexture,
this.hasBrightness,
this.hasNormals,
this.hasColor);
}
@Inject(method = "setNormal(FFF)V", at = @At("HEAD"))
private void angelica$captureNormalComponents(float x, float y, float z, CallbackInfo ci) {
this.angelica$normalX = x;
this.angelica$normalY = y;
this.angelica$normalZ = z;
}
@Override
public ByteBuffer getAngelica$byteBuffer() {
return angelica$byteBuffer;
}
@Override
public IntBuffer getAngelica$intBuffer() {
return angelica$intBuffer;
}
@Override
public FloatBuffer getAngelica$floatBuffer() {
return angelica$floatBuffer;
}
@Override
public ShortBuffer getAngelica$shortBuffer() {
return angelica$shortBuffer;
}
@Override
public float[] getAngelica$vertexPos() {
return angelica$vertexPos;
}
@Override
public float getAngelica$normalX() {
return angelica$normalX;
}
@Override
public float getAngelica$normalY() {
return angelica$normalY;
}
@Override
public float getAngelica$normalZ() {
return angelica$normalZ;
}
@Override
public float getAngelica$midTextureU() {
return angelica$midTextureU;
}
@Override
public float getAngelica$midTextureV() {
return angelica$midTextureV;
}
@Override
public void setAngelica$byteBuffer(ByteBuffer angelica$byteBuffer) {
this.angelica$byteBuffer = angelica$byteBuffer;
}
@Override
public void setAngelica$intBuffer(IntBuffer angelica$intBuffer) {
this.angelica$intBuffer = angelica$intBuffer;
}
@Override
public void setAngelica$floatBuffer(FloatBuffer angelica$floatBuffer) {
this.angelica$floatBuffer = angelica$floatBuffer;
}
@Override
public void setAngelica$shortBuffer(ShortBuffer angelica$shortBuffer) {
this.angelica$shortBuffer = angelica$shortBuffer;
}
@Override
public void setAngelica$vertexPos(float[] angelica$vertexPos) {
this.angelica$vertexPos = angelica$vertexPos;
}
@Override
public void setAngelica$normalX(float angelica$normalX) {
this.angelica$normalX = angelica$normalX;
}
@Override
public void setAngelica$normalY(float angelica$normalY) {
this.angelica$normalY = angelica$normalY;
}
@Override
public void setAngelica$normalZ(float angelica$normalZ) {
this.angelica$normalZ = angelica$normalZ;
}
@Override
public void setAngelica$midTextureU(float angelica$midTextureU) {
this.angelica$midTextureU = angelica$midTextureU;
}
@Override
public void setAngelica$midTextureV(float angelica$midTextureV) {
this.angelica$midTextureV = angelica$midTextureV;
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.texture.TextureClock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import com.gtnewhorizons.angelica.client.ShadersTex;
@Mixin(value = TextureClock.class)
public class MixinTextureClock {
@Redirect(
method = "updateAnimation()V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/TextureUtil;uploadTextureMipmap([[IIIIIZZ)V"))
private void angelica$updateAnimation(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear,
boolean clamp) {
ShadersTex.uploadTexSub(data, width, height, xoffset, yoffset, linear, clamp);
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;
import net.minecraft.client.renderer.texture.TextureCompass;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import com.gtnewhorizons.angelica.client.ShadersTex;
@Mixin(value = TextureCompass.class)
public class MixinTextureCompass {
@Redirect(
method = "updateCompass(Lnet/minecraft/world/World;DDDZZ)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/TextureUtil;uploadTextureMipmap([[IIIIIZZ)V"))
private void angelica$updateCompass(int[][] data, int width, int height, int xoffset, int yoffset, boolean linear,
boolean clamp) {
ShadersTex.uploadTexSub(data, width, height, xoffset, yoffset, linear, clamp);
}
}
@@ -0,0 +1,44 @@
package com.gtnewhorizons.angelica.mixins.early.settings;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiVideoSettings;
import net.minecraft.client.settings.GameSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.angelica.client.GuiShaders;
@Mixin(GuiVideoSettings.class)
abstract public class MixinGuiVideoSettings extends GuiScreen {
private static final int SHADER_BUTTON_ID = 190;
@Shadow
private GameSettings guiGameSettings;
@Inject(method = "initGui()V", at = @At(value = "TAIL"))
private void angelica$addShadersButton(CallbackInfo ci) {
// Add the Shaders Button to the bottom of Video Options
final GuiButton shaderButton = new GuiButton(
SHADER_BUTTON_ID,
this.width / 2 - 190,
this.height - 27,
70,
20,
"Shaders...");
this.buttonList.add(shaderButton);
}
@Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", at = @At(value = "HEAD"))
private void angelica$actionPerformed(GuiButton button, CallbackInfo ci) {
if (button.id == SHADER_BUTTON_ID) {
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiShaders(this, this.guiGameSettings));
}
}
}
@@ -1,4 +1,4 @@
package com.gtnewhorizons.angelica.mixins.early.minecraft;
package com.gtnewhorizons.angelica.mixins.early.shaders;
import net.minecraft.client.Minecraft;
import net.minecraft.profiler.IPlayerUsage;
@@ -14,7 +14,7 @@ import com.gtnewhorizons.angelica.client.Shaders;
public abstract class MixinMinecraft implements IPlayerUsage {
@Inject(
method = "Lnet/minecraft/client/Minecraft;startGame()V",
method = "startGame()V",
at = @At(
ordinal = 1,
shift = At.Shift.AFTER,
@@ -0,0 +1,6 @@
package com.gtnewhorizons.angelica.mixins.interfaces;
public interface IModelRenderer {
void resetDisplayList();
}
@@ -0,0 +1,49 @@
package com.gtnewhorizons.angelica.mixins.interfaces;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
public interface TessellatorAccessor {
ByteBuffer getAngelica$byteBuffer();
IntBuffer getAngelica$intBuffer();
FloatBuffer getAngelica$floatBuffer();
ShortBuffer getAngelica$shortBuffer();
float[] getAngelica$vertexPos();
float getAngelica$normalX();
float getAngelica$normalY();
float getAngelica$normalZ();
float getAngelica$midTextureU();
float getAngelica$midTextureV();
void setAngelica$byteBuffer(ByteBuffer angelica$byteBuffer);
void setAngelica$intBuffer(IntBuffer angelica$intBuffer);
void setAngelica$floatBuffer(FloatBuffer angelica$floatBuffer);
void setAngelica$shortBuffer(ShortBuffer angelica$shortBuffer);
void setAngelica$vertexPos(float[] angelica$vertexPos);
void setAngelica$normalX(float angelica$normalX);
void setAngelica$normalY(float angelica$normalY);
void setAngelica$normalZ(float angelica$normalZ);
void setAngelica$midTextureU(float angelica$midTextureU);
void setAngelica$midTextureV(float angelica$midTextureV);
}
@@ -1,69 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTBlock implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, 0);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
this.classname = name;
// ALog.info(" class %s",name);
super.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (Names.block_getAoLight.equalsNameDesc(name, desc)) {
// ALog.info(" patching");
return new MVgetAoLight(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVgetAoLight extends MethodVisitor {
public MVgetAoLight(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof Float) {
if (((Float) cst).floatValue() == 0.2f) {
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "blockAoLight", "F");
ALog.info(" blockAoLight");
return;
}
}
mv.visitLdcInsn(cst);
}
}
}
@@ -191,11 +191,7 @@ public class ACTEntityRenderer implements IClassTransformer {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (Names.equals("org/lwjgl/util/glu/Project", "gluPerspective", "(FFFF)V", owner, name, desc)) {
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "applyHandDepth", "()V");
mv.visitMethodInsn(opcode, owner, name, desc);
return;
} else if (Names.equals("org/lwjgl/opengl/GL11", "glPushMatrix", "()V", owner, name, desc)) {
if (Names.equals("org/lwjgl/opengl/GL11", "glPushMatrix", "()V", owner, name, desc)) {
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "isHandRendered", "Z");
mv.visitJumpInsn(IFNE, la1);
mv.visitMethodInsn(opcode, owner, name, desc);
@@ -204,26 +200,6 @@ public class ACTEntityRenderer implements IClassTransformer {
mv.visitMethodInsn(opcode, owner, name, desc);
mv.visitLabel(la1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "isCompositeRendered", "Z");
mv.visitJumpInsn(IFNE, la2);
mv.visitInsn(RETURN);
mv.visitLabel(la2);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(FLOAD, 1);
mv.visitInsn(F2D);
mv.visitMethodInsn(
INVOKEVIRTUAL,
Names.entityRenderer_disableLightmap.clas,
Names.entityRenderer_disableLightmap.name,
Names.entityRenderer_disableLightmap.desc);
return;
} else if (Names.itemRenderer_renderItemInFirstPerson.equals(owner, name, desc)) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/ShadersRender",
"renderItemFP",
"(" + Names.itemRenderer_.desc + "F)V");
return;
}
mv.visitMethodInsn(opcode, owner, name, desc);
@@ -1,185 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTGuiOptions implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
this.classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.guiOptions_initGui.equalsNameDesc(name, desc)) {
// ALog.info(" patching");
return new MVinitGui(cv.visitMethod(access, name, desc, signature, exceptions));
}
if (Names.guiOptions_actionPerformed.equalsNameDesc(name, desc)) {
// ALog.info(" patching");
return new MVactionPerformed(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVinitGui extends MethodVisitor {
int state = 0;
public MVinitGui(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitInsn(int opcode) {
super.visitInsn(opcode);
if (opcode == Opcodes.POP) {
if (state == 1) {
state = 2;
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.guiOptions_buttonList.clas,
Names.guiOptions_buttonList.name,
Names.guiOptions_buttonList.desc);
mv.visitTypeInsn(NEW, Names.guiButton_.clas);
mv.visitInsn(DUP);
mv.visitIntInsn(SIPUSH, 190);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.guiOptions_width.clas,
Names.guiOptions_width.name,
Names.guiOptions_width.desc);
mv.visitInsn(ICONST_2);
mv.visitInsn(IDIV);
mv.visitIntInsn(SIPUSH, 155);
mv.visitInsn(ISUB);
mv.visitIntInsn(BIPUSH, 76);
mv.visitInsn(IADD);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.guiOptions_height.clas,
Names.guiOptions_height.name,
Names.guiOptions_height.desc);
mv.visitIntInsn(BIPUSH, 6);
mv.visitInsn(IDIV);
mv.visitIntInsn(BIPUSH, 120);
mv.visitInsn(IADD);
mv.visitIntInsn(BIPUSH, 6);
mv.visitInsn(ISUB);
mv.visitIntInsn(BIPUSH, 74);
mv.visitIntInsn(BIPUSH, 20);
mv.visitLdcInsn("Shaders...");
mv.visitMethodInsn(INVOKESPECIAL, Names.guiButton_.clas, "<init>", "(IIIIILjava/lang/String;)V");
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z");
mv.visitInsn(POP);
ALog.finest(" add shaders button");
}
}
}
@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof String) {
if (((String) cst).equals("options.language")) {
if (state == 0) {
state = 1;
mv.visitInsn(POP);
mv.visitInsn(POP);
mv.visitIntInsn(BIPUSH, 74);
mv.visitIntInsn(BIPUSH, 20);
ALog.finest(" decrease language button size");
}
}
}
super.visitLdcInsn(cst);
}
}
private static class MVactionPerformed extends MethodVisitor {
public MVactionPerformed(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitCode() {
super.visitCode();
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(GETFIELD, Names.guiButton_id.clas, Names.guiButton_id.name, Names.guiButton_id.desc);
mv.visitIntInsn(SIPUSH, 190);
Label l1 = new Label();
mv.visitJumpInsn(IF_ICMPNE, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, Names.guiOptions_mc.clas, Names.guiOptions_mc.name, Names.guiOptions_mc.desc);
mv.visitFieldInsn(
GETFIELD,
Names.minecraft_gameSettings.clas,
Names.minecraft_gameSettings.name,
Names.minecraft_gameSettings.desc);
mv.visitMethodInsn(
INVOKEVIRTUAL,
Names.gameSettings_saveOptions.clas,
Names.gameSettings_saveOptions.name,
Names.gameSettings_saveOptions.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, Names.guiOptions_mc.clas, Names.guiOptions_mc.name, Names.guiOptions_mc.desc);
mv.visitTypeInsn(NEW, "com/gtnewhorizons/angelica/client/GuiShaders");
mv.visitInsn(DUP);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.guiOptions_options.clas,
Names.guiOptions_options.name,
Names.guiOptions_options.desc);
mv.visitMethodInsn(
INVOKESPECIAL,
"com/gtnewhorizons/angelica/client/GuiShaders",
"<init>",
"(" + Names.guiScreen_.desc + Names.gameSettings_.desc + ")V");
mv.visitMethodInsn(
INVOKEVIRTUAL,
Names.minecraft_displayGuiScreen.clas,
Names.minecraft_displayGuiScreen.name,
Names.minecraft_displayGuiScreen.desc);
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
ALog.finest(" shaders button action");
}
}
}
@@ -1,49 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
public class ACTItemBlock implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if (Names.itemBlock_block.name.equals(name)) {
access = access & ~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED) | ACC_PUBLIC;
}
return cv.visitField(access, name, desc, signature, value);
}
}
}
@@ -1,151 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTModelRenderer implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
// @Override
// public FieldVisitor visitField(int access, String name, String desc,
// String signature, Object value) {
// if (Names.modelRenderer_compiled.name.equals(name) ||
// Names.modelRenderer_displayList.name.equals(name)) {
// access = access & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED) | ACC_PUBLIC;
// }
// return cv.visitField(access, name, desc, signature, value);
// }
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
// if (Names.modelRenderer_render.equalsNameDesc(name, desc))
// {
// //ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
// return new MVrender(
// cv.visitMethod(access, name, desc, signature, exceptions));
// }
// else
// if (Names.modelRenderer_renderWithRotation.equalsNameDesc(name, desc))
// {
// //ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
// return new MVrender(
// cv.visitMethod(access, name, desc, signature, exceptions));
// }
// else
if ("resetDisplayList".equals(name) && "()V".equals(desc)
|| "getCompiled".equals(name) && "()Z".equals(desc)
|| "getDisplayList".equals(name) && "()I".equals(desc)) {
return null;
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
@Override
public void visitEnd() {
MethodVisitor mv;
{
mv = cv.visitMethod(ACC_PUBLIC, "getCompiled", "()Z", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.modelRenderer_compiled.clas,
Names.modelRenderer_compiled.name,
Names.modelRenderer_compiled.desc);
mv.visitInsn(IRETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cv.visitMethod(ACC_PUBLIC, "getDisplayList", "()I", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.modelRenderer_displayList.clas,
Names.modelRenderer_displayList.name,
Names.modelRenderer_displayList.desc);
mv.visitInsn(IRETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cv.visitMethod(ACC_PUBLIC, "resetDisplayList", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.modelRenderer_compiled.clas,
Names.modelRenderer_compiled.name,
Names.modelRenderer_compiled.desc);
Label l1 = new Label();
mv.visitJumpInsn(IFEQ, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.modelRenderer_displayList.clas,
Names.modelRenderer_displayList.name,
Names.modelRenderer_displayList.desc);
mv.visitMethodInsn(
INVOKESTATIC,
Names.glAllocation_deleteDisplayLists.clas,
Names.glAllocation_deleteDisplayLists.name,
Names.glAllocation_deleteDisplayLists.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_0);
mv.visitFieldInsn(
PUTFIELD,
Names.modelRenderer_displayList.clas,
Names.modelRenderer_displayList.name,
Names.modelRenderer_displayList.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_0);
mv.visitFieldInsn(
PUTFIELD,
Names.modelRenderer_compiled.clas,
Names.modelRenderer_compiled.name,
Names.modelRenderer_compiled.desc);
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 1);
mv.visitEnd();
}
super.visitEnd();
}
}
}
@@ -1,84 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTOpenGlHelper implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
// boolean has_activeTexUnit = false;
// @Override
// public FieldVisitor visitField(int access, String name, String desc,
// String signature, Object value) {
// //if (name.equals("activeTexUnit")) {
// // has_activeTexUnit = true;
// //}
// return cv.visitField(access, name, desc, signature, value);
// }
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// if (!has_activeTexUnit) {
// has_activeTexUnit = true;
// FieldVisitor fv = cv.visitField(ACC_PUBLIC + ACC_STATIC, "activeTexUnit", "I", null, null);
// fv.visitEnd();
// ALog.finest(" add field activeTexUnit");
// }
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.openGlHelper_setActiveTexture.equalsNameDesc(name, desc)) {
// ALog.info(" patching");
return new MVsetActiveTexture(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVsetActiveTexture extends MethodVisitor {
public MVsetActiveTexture(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitCode() {
mv.visitCode();
mv.visitVarInsn(ILOAD, 0);
mv.visitFieldInsn(PUTSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "activeTexUnit", "I");
ALog.finest(" set activeTexUnit");
}
}
}
@@ -1,72 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTRender implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.render_renderShadow.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVrenderShadow(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVrenderShadow extends MethodVisitor {
// protected MethodVisitor mv;
public MVrenderShadow(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
// this.mv = mv;
}
@Override
public void visitCode() {
mv.visitCode();
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "shouldSkipDefaultShadow", "Z");
Label l1 = new Label();
mv.visitJumpInsn(IFEQ, l1);
mv.visitInsn(RETURN);
mv.visitLabel(l1);
ALog.finer(" conditionally skip default shadow");
}
}
}
@@ -1,386 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
public class ACTRenderBlocks implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.renderBlocks_renderBlockByRenderType.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkByRenType(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderBlocks_renderBlockFlowerPot.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkFlowerPot(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderBlocks_renderStdBlockWithAOP.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderStdBlockWithAO.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkWithAO(
access,
name,
desc,
signature,
exceptions,
cv.visitMethod(access, name, desc, signature, exceptions));
} else
if (Names.renderBlocks_renderStdBlockWithCM.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockCactusImpl.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockBed.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockFluids.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockDoor.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockSandFalling.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkFVar(cv.visitMethod(access, name, desc, signature, exceptions));
} else
if (Names.renderBlocks_renderPistonExtension.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkPistonExt(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVrenBlkByRenType extends MethodVisitor {
public MVrenBlkByRenType(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int nPatch = 0;
@Override
public void visitCode() {
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 3);
mv.visitVarInsn(ILOAD, 4);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.renderBlocks_.desc + Names.block_.desc + "III)V");
// ALog.info(" pushEntity");
++nPatch;
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.IRETURN) {
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "popEntity", "()V");
// ALog.info(" popEntity");
++nPatch;
}
mv.visitInsn(opcode);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
private static class MVrenBlkFlowerPot extends MethodVisitor {
public MVrenBlkFlowerPot(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int nPatch = 0;
int state = 0;
@Override
public void visitVarInsn(int opcode, int var) {
super.visitVarInsn(opcode, var);
if (state == 1) {
++state;
mv.visitVarInsn(ALOAD, var);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.block_.desc + ")V");
}
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
super.visitMethodInsn(opcode, owner, name, desc);
switch (state) {
case 0:
if (Names.block_getBlockFromItem.equals(owner, name, desc)) {
++state;
}
break;
case 2:
if (Names.tessellator_addTranslation.equals(owner, name, desc)) {
++state;
}
break;
case 3:
if (Names.tessellator_addTranslation.equals(owner, name, desc)) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"popEntity",
"()V");
}
break;
}
}
@Override
public void visitCode() {
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 3);
mv.visitVarInsn(ILOAD, 4);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.renderBlocks_.desc + Names.block_.desc + "III)V");
// ALog.info(" pushEntity");
++nPatch;
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.IRETURN) {
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "popEntity", "()V");
// ALog.info(" popEntity");
++nPatch;
}
mv.visitInsn(opcode);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
static final String[] fieldsBlockLightLevel = { null, "blockLightLevel05", "blockLightLevel06",
"blockLightLevel08" };
private static class MVrenBlkWithAO extends MethodVisitor {
MethodVisitor mv1;
MethodNode mn;
int nPatch = 0;
public MVrenBlkWithAO(final int access, final String name, final String desc, final String signature,
final String[] exceptions, MethodVisitor mv) {
super(Opcodes.ASM4);
super.mv = this.mn = new MethodNode(access, name, desc, signature, exceptions);
this.mv1 = mv;
}
@Override
public void visitEnd() {
mn.visitEnd();
mn.accept(mv1);
// ALog.info(" %d", nPatch);
}
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0) {
int match2 = 0;
InsnList insns = mn.instructions;
AbstractInsnNode insn = insns.getLast();
if (insn != null && insn.getOpcode() == Opcodes.FLOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
match2 = match1;
}
}
}
}
}
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
match2 = match1;
}
}
}
}
if (match2 != 0) {
String fieldName = fieldsBlockLightLevel[match2];
mn.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
}
mn.visitLdcInsn(cst);
}
}
private static class MVrenBlkFVar extends MethodVisitor {
int nPatch = 0;
public MVrenBlkFVar(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int state = 0;
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0 && state < 3) {
++state;
String fieldName = fieldsBlockLightLevel[match1];
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
mv.visitLdcInsn(cst);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
private static class MVrenBlkPistonExt extends MethodVisitor {
int nPatch = 0;
public MVrenBlkPistonExt(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int state = 0;
@Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
state = 1;
mv.visitTableSwitchInsn(min, max, dflt, labels);
}
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0 && state == 1) {
String fieldName = fieldsBlockLightLevel[match1];
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
mv.visitLdcInsn(cst);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
// private static class MVNTransform extends MethodVisitor
// {
// protected MethodVisitor mv;
// protected MethodNode mn;
// public MVNTransform(MethodNode mn, MethodVisitor mv) {
// super(Opcodes.ASM4);
// super.mv = this.mn = mn;
// this.mv = mv;
// }
//
// @Override
// public void visitEnd() {
// super.visitEnd();
// Iterator<AbstractInsnNode> it = mn.instructions.iterator();
// while (it.hasNext())
// {
// AbstractInsnNode node = it.next();
// System.out.println(node.toString());
// }
// // send to target
// mn.accept(mv);
// }
// }
}
@@ -1,390 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.lwjgl.opengl.GL11;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTRenderGlobal implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if (Names.renderGlobal_worldRenderers.name.equals(name)) {
access = access & (~ACC_PRIVATE & ~ACC_PROTECTED) | ACC_PUBLIC;
}
return cv.visitField(access, name, desc, signature, value);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// String remappedName = SMCRemap.remapper.mapMethodName(classname, name, desc);
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.renderGlobal_renderEntities.equalsNameDesc(name, desc)) {
ALog.finer(" patch method %s.%s%s", classname, name, desc);
return new MVrenderEntities(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderGlobal_sortAndRender.equalsNameDesc(name, desc)) {
ALog.finer(" patch method %s.%s%s", classname, name, desc);
return new MVendisTexFog(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderGlobal_renderSky.equalsNameDesc(name, desc)) {
ALog.finer(" patch method %s.%s%s", classname, name, desc);
return new MVrenderSky(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderGlobal_drawBlockDamageTexture.equalsNameDesc(name, desc)
|| name.equals("drawBlockDamageTexture")) // Optifine
{
ALog.finer(" patch method %s.%s%s", classname, name, desc);
return new MVdrawBlockDamageTexture(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderGlobal_drawSelectionBox.equalsNameDesc(name, desc)) {
ALog.finer(" patch method %s.%s%s", classname, name, desc);
return new MVendisTexFog(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVrenderEntities extends MethodVisitor {
public MVrenderEntities(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int state = 0;
@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof String) {
String scst = (String) cst;
if (scst.equals("entities")) {
state = 1;
} else if (scst.equals("blockentities")) {
state = 4;
}
}
mv.visitLdcInsn(cst);
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (state == 2) {
if (Names.renderManager_instance.equals(owner, name, desc)) {
state = 3;
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "nextEntity", "()V");
}
}
mv.visitFieldInsn(opcode, owner, name, desc);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
mv.visitMethodInsn(opcode, owner, name, desc);
if (state == 1) {
state = 2;
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "beginEntities", "()V");
ALog.finest(" %s", "beginEntities");
} else if (state == 4) {
state = 5;
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "endEntities", "()V");
ALog.finest(" %s", "endEntities");
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"beginBlockEntities",
"()V");
ALog.finest(" %s", "beginTileEntities");
} else if (state == 5) {
if (Names.entityRenderer_disableLightmap.equals(owner, name, desc)) {
state = 6;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"endBlockEntities",
"()V");
ALog.finest(" %s", "endTileEntities");
}
}
}
}
/* detect glEnable or glDisable (TEXTURE_2D or FOG) */
private static class MVendisTexFog extends MethodVisitor {
public MVendisTexFog(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int lastInt = 0;
@Override
public void visitIntInsn(int opcode, int operand) {
mv.visitIntInsn(opcode, operand);
if (opcode == SIPUSH && (operand == 3553 || operand == 2912)) {
lastInt = operand;
} else {
lastInt = 0;
}
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
mv.visitMethodInsn(opcode, owner, name, desc);
if (owner.equals("org/lwjgl/opengl/GL11")) {
if (name.equals("glEnable")) {
if (lastInt == GL11.GL_TEXTURE_2D) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"enableTexture2D",
"()V");
ALog.finest(" %s", "enableTexture2D");
} else if (lastInt == GL11.GL_FOG) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"enableFog",
"()V");
ALog.finest(" %s", "enableFog");
}
} else if (name.equals("glDisable")) {
if (lastInt == GL11.GL_TEXTURE_2D) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"disableTexture2D",
"()V");
ALog.finest(" %s", "disableTexture2D");
} else if (lastInt == GL11.GL_FOG) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"disableFog",
"()V");
ALog.finest(" %s", "disableFog");
}
}
}
lastInt = 0;
}
}
/* extends MVenableTF */
private static class MVrenderSky extends MVendisTexFog {
public MVrenderSky(MethodVisitor mv) {
super(mv);
}
int state = 0;
boolean detectedOptifine = false;
int lastInt = 0;
int lastVar = 0;
@Override
public void visitIntInsn(int opcode, int operand) {
mv.visitIntInsn(opcode, operand);
if (opcode == SIPUSH) {
lastInt = operand;
} else {
lastInt = 0;
}
}
@Override
public void visitVarInsn(int opcode, int var) {
mv.visitVarInsn(opcode, var);
if (opcode == ALOAD) {
lastVar = var;
} else {
lastVar = 0;
}
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
switch (state) {
case 0:
if (Names.vec3_xCoord.equals(owner, name)) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"setSkyColor",
"(" + Names.vec3_.desc + ")V");
mv.visitVarInsn(ALOAD, lastVar);
break;
}
break;
case 1:
if (Names.renderGlobal_glSkyList.equals(owner, name)) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"preSkyList",
"()V");
break;
}
break;
}
mv.visitFieldInsn(opcode, owner, name, desc);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
// ALog.info(" %s.%s%s",ownerM,nameM,descM);
switch (state) {
case 0:
if (owner.equals("Config") && name.equals("isSkyEnabled")) {
detectedOptifine = true;
}
break;
case 2:
if (Names.worldClient_getRainStrength.equals(owner, name, desc)) {
++state;
}
break;
}
//
mv.visitMethodInsn(opcode, owner, name, desc);
//
if (owner.equals("org/lwjgl/opengl/GL11")) {
if (name.equals("glEnable")) {
if (lastInt == GL11.GL_TEXTURE_2D) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"enableTexture2D",
"()V");
ALog.finest(" %s", "enableTexture2D");
} else if (lastInt == GL11.GL_FOG) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"enableFog",
"()V");
ALog.finest(" %s", "enableFog");
}
} else if (name.equals("glDisable")) {
if (lastInt == GL11.GL_TEXTURE_2D) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"disableTexture2D",
"()V");
ALog.finest(" %s", "disableTexture2D");
} else if (lastInt == GL11.GL_FOG) {
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"disableFog",
"()V");
ALog.finest(" %s", "disableFog");
}
} else if (name.equals("glRotatef")) {
ALog.finest(" *%s %d", "glRotatef", state);
if (state == 3) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"preCelestialRotate",
"()V");
ALog.finest(" %s", "preCelestialRotate");
} else if (state == 4) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"postCelestialRotate",
"()V");
ALog.finest(" %s", "postCelestialRotate");
}
}
}
}
}
private static class MVdrawBlockDamageTexture extends MethodVisitor {
int state = 0;
public MVdrawBlockDamageTexture(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitIntInsn(int opcode, int operand) {
switch (state) {
case 0:
if (opcode == SIPUSH && operand == GL11.GL_ALPHA_TEST) {
++state;
}
break;
case 2:
if (opcode == SIPUSH && operand == GL11.GL_ALPHA_TEST) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"endBlockDestroyProgress",
"()V");
ALog.finest(" %s", "endBlockDestroyProgress");
}
break;
}
mv.visitIntInsn(opcode, operand);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
switch (state) {
case 1:
if (owner.equals("org/lwjgl/opengl/GL11") && name.equals("glEnable")) {
++state;
mv.visitMethodInsn(opcode, owner, name, desc);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"beginBlockDestroyProgress",
"()V");
ALog.finest(" %s", "beginBlockDestroyProgress");
return;
}
break;
}
mv.visitMethodInsn(opcode, owner, name, desc);
}
}
}
@@ -1,509 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACONST_NULL;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.BIPUSH;
import static org.objectweb.asm.Opcodes.DLOAD;
import static org.objectweb.asm.Opcodes.FLOAD;
import static org.objectweb.asm.Opcodes.GETFIELD;
import static org.objectweb.asm.Opcodes.GETSTATIC;
import static org.objectweb.asm.Opcodes.ICONST_0;
import static org.objectweb.asm.Opcodes.ICONST_1;
import static org.objectweb.asm.Opcodes.ICONST_4;
import static org.objectweb.asm.Opcodes.ILOAD;
import static org.objectweb.asm.Opcodes.IMUL;
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import static org.objectweb.asm.Opcodes.IRETURN;
import static org.objectweb.asm.Opcodes.NEWARRAY;
import static org.objectweb.asm.Opcodes.POP;
import static org.objectweb.asm.Opcodes.PUTFIELD;
import static org.objectweb.asm.Opcodes.PUTSTATIC;
import static org.objectweb.asm.Opcodes.RETURN;
import static org.objectweb.asm.Opcodes.T_FLOAT;
import static org.objectweb.asm.Opcodes.T_INT;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
/** transformer for net.minecraft.client.renderer.Tessellator */
public class ACTTessellator implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static boolean inputHasStaticBuffer = false;
private static class CVTransform extends ClassVisitor {
String classname;
boolean endFields = false;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
// ALog.fine("%x %s %s %s",access,desc,name,nameM);
if (name.equals("vertexPos") || name.equals("normalX")
|| name.equals("normalY")
|| name.equals("normalZ")
|| name.equals("midTextureU")
|| name.equals("midTextureV")) {
return null;
} else if (((access & ACC_STATIC) != 0)
&& (Names.tessellator_byteBuffer.name.equals(name) || Names.tessellator_intBuffer.name.equals(name)
|| Names.tessellator_floatBuffer.name.equals(name)
|| Names.tessellator_shortBuffer.name.equals(name)
|| Names.tessellator_vertexCount.name.equals(name)
// nameM.equals(Names.Tessellator_useVBO) ||
// nameM.equals(Names.Tessellator_vertexBuffers)
)) {
inputHasStaticBuffer = true;
// ALog.finest(" input has static buffer");
access = access & (~ACC_STATIC & ~ACC_PRIVATE & ~ACC_PROTECTED) | ACC_PUBLIC;
} else {
access = access & (~ACC_PRIVATE & ~ACC_PROTECTED) | ACC_PUBLIC;
}
return cv.visitField(access, name, desc, signature, value);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (!endFields) {
endFields = true;
FieldVisitor fv;
fv = cv.visitField(ACC_PUBLIC, "vertexPos", "[F", null, null);
fv.visitEnd();
fv = cv.visitField(ACC_PUBLIC, "normalX", "F", null, null);
fv.visitEnd();
fv = cv.visitField(ACC_PUBLIC, "normalY", "F", null, null);
fv.visitEnd();
fv = cv.visitField(ACC_PUBLIC, "normalZ", "F", null, null);
fv.visitEnd();
fv = cv.visitField(ACC_PUBLIC, "midTextureU", "F", null, null);
fv.visitEnd();
fv = cv.visitField(ACC_PUBLIC, "midTextureV", "F", null, null);
fv.visitEnd();
}
// ALog.fine(" method %s.%s%s = %s",classname,name,desc,nameM);
if (name.equals("<clinit>")) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVclinit(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (name.equals("<init>") && desc.equals("()V")) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVinit(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (name.equals("<init>") && desc.equals("(I)V")) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVinitI(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.tessellator_draw.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVdraw(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.tessellator_reset.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
access = access & ~(ACC_PRIVATE | ACC_PROTECTED) | ACC_PUBLIC;
return new MVreset(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.tessellator_addVertex.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVaddVertex(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.tessellator_setNormal.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVsetNormal(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.tessellator_sortQuad.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new MVsortQuad(cv.visitMethod(access, name, desc, signature, exceptions));
} else {
access = access & ~(ACC_PRIVATE | ACC_PROTECTED) | ACC_PUBLIC;
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
/*
* private static class MVclinit extends MethodVisitor { public MVclinit(MethodVisitor mv) { super(Opcodes.ASM4,
* mv); } } private static class MVinit extends MethodVisitor { public MVinit(MethodVisitor mv) {
* super(Opcodes.ASM4, mv); }
* @Override public void visitInsn(int opcode) { if (opcode == RETURN) { mv.visitVarInsn(ALOAD, 0);
* mv.visitIntInsn(BIPUSH, 16); mv.visitIntInsn(NEWARRAY, T_FLOAT); mv.visitFieldInsn(PUTFIELD,
* SMCNames.Tessellator_, "vertexPos", "[F"); } mv.visitInsn(opcode); } }
*/
private static class MVclinit extends MethodVisitor {
public MVclinit(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
// ALog.finest(" F %d %s.%s %s", opcode, ownerM, nameM, descM);
if (opcode == PUTSTATIC && (Names.tessellator_byteBuffer.equals(owner, name)
|| Names.tessellator_intBuffer.equals(owner, name)
|| Names.tessellator_floatBuffer.equals(owner, name)
|| Names.tessellator_shortBuffer.equals(owner, name)
|| Names.tessellator_vertexCount.equals(owner, name)
// nameM.equals(Names.Tessellator_useVBO)||
// nameM.equals(Names.Tessellator_vertexBuffers)
)) {
mv.visitInsn(POP);
return;
} else if (opcode == GETSTATIC && (Names.tessellator_byteBuffer.equals(owner, name)
// nameM.equals(Names.Tessellator_vertexBuffers)
)) {
mv.visitInsn(ACONST_NULL);
return;
// } else
// if (opcode==GETSTATIC && (
// nameM.equals(Names.Tessellator_useVBO)
// ))
// {
// mv.visitInsn(ICONST_0);
// return;
}
mv.visitFieldInsn(opcode, owner, name, desc);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
// ALog.finest(" M %d %s.%s %s", opcode, ownerM, nameM, descM);
if (Names.glAllocation_createDirectByteBuffer.equals(owner, name, desc)) {
mv.visitInsn(POP);
mv.visitInsn(ACONST_NULL);
return;
} else if (Names.glAllocation_createDirectIntBuffer.equals(owner, name, desc)) {
mv.visitInsn(POP);
mv.visitInsn(ACONST_NULL);
return;
} else
if (Names.equals("java/nio/ByteBuffer", "asIntBuffer", "()Ljava/nio/IntBuffer;", owner, name, desc)) {
mv.visitInsn(POP);
mv.visitInsn(ACONST_NULL);
return;
} else if (Names.equals(
"java/nio/ByteBuffer",
"asFloatBuffer",
"()Ljava/nio/FloatBuffer;",
owner,
name,
desc)) {
mv.visitInsn(POP);
mv.visitInsn(ACONST_NULL);
return;
} else
if (Names.equals(
"java/nio/ByteBuffer",
"asShortBuffer",
"()Ljava/nio/ShortBuffer;",
owner,
name,
desc)) {
mv.visitInsn(POP);
mv.visitInsn(ACONST_NULL);
return;
}
mv.visitMethodInsn(opcode, owner, name, desc);
}
}
private static class MVinit extends MethodVisitor {
public MVinit(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (opcode == INVOKESPECIAL && Names.equals("java/lang/Object", "<init>", "()V", owner, name, desc)) {
mv.visitLdcInsn(new Integer(65536));
mv.visitMethodInsn(INVOKESPECIAL, Names.tessellator_.clas, "<init>", "(I)V");
return;
}
mv.visitMethodInsn(opcode, owner, name, desc);
}
}
private static class MVinitI extends MethodVisitor {
public MVinitI(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitInsn(int opcode) {
if (opcode == RETURN) {
if (inputHasStaticBuffer) {
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitInsn(ICONST_4);
mv.visitInsn(IMUL);
mv.visitMethodInsn(
INVOKESTATIC,
Names.glAllocation_createDirectByteBuffer.clas,
Names.glAllocation_createDirectByteBuffer.name,
Names.glAllocation_createDirectByteBuffer.desc);
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_byteBuffer.clas,
Names.tessellator_byteBuffer.name,
Names.tessellator_byteBuffer.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.tessellator_byteBuffer.clas,
Names.tessellator_byteBuffer.name,
Names.tessellator_byteBuffer.desc);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/nio/ByteBuffer", "asIntBuffer", "()Ljava/nio/IntBuffer;");
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_intBuffer.clas,
Names.tessellator_intBuffer.name,
Names.tessellator_intBuffer.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.tessellator_byteBuffer.clas,
Names.tessellator_byteBuffer.name,
Names.tessellator_byteBuffer.desc);
mv.visitMethodInsn(
INVOKEVIRTUAL,
"java/nio/ByteBuffer",
"asFloatBuffer",
"()Ljava/nio/FloatBuffer;");
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_floatBuffer.clas,
Names.tessellator_floatBuffer.name,
Names.tessellator_floatBuffer.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.tessellator_byteBuffer.clas,
Names.tessellator_byteBuffer.name,
Names.tessellator_byteBuffer.desc);
mv.visitMethodInsn(
INVOKEVIRTUAL,
"java/nio/ByteBuffer",
"asShortBuffer",
"()Ljava/nio/ShortBuffer;");
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_shortBuffer.clas,
Names.tessellator_shortBuffer.name,
Names.tessellator_shortBuffer.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitIntInsn(NEWARRAY, T_INT);
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_rawBuffer.clas,
Names.tessellator_rawBuffer.name,
Names.tessellator_rawBuffer.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_0);
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_vertexCount.clas,
Names.tessellator_vertexCount.name,
Names.tessellator_vertexCount.desc);
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETSTATIC, Names.Tessellator_, Names.Tessellator_tryVBO, "Z");
// Label l28 = new Label();
// mv.visitJumpInsn(IFEQ, l28);
// mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/GLContext", "getCapabilities",
// "()Lorg/lwjgl/opengl/ContextCapabilities;");
// mv.visitFieldInsn(GETFIELD, "org/lwjgl/opengl/ContextCapabilities",
// "GL_ARB_vertex_buffer_object", "Z");
// mv.visitJumpInsn(IFEQ, l28);
// mv.visitInsn(ICONST_1);
// Label l29 = new Label();
// mv.visitJumpInsn(GOTO, l29);
// mv.visitLabel(l28);
// mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {Names.Tessellator_, Opcodes.INTEGER}, 1, new
// Object[] {Names.Tessellator_});
// mv.visitInsn(ICONST_0);
// mv.visitLabel(l29);
// mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {Names.Tessellator_, Opcodes.INTEGER}, 2, new
// Object[] {Names.Tessellator_, Opcodes.INTEGER});
// mv.visitFieldInsn(PUTFIELD, Names.Tessellator_, Names.Tessellator_useVBO, "Z");
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_useVBO, "Z");
// Label l31 = new Label();
// mv.visitJumpInsn(IFEQ, l31);
// mv.visitVarInsn(ALOAD, 0);
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_vboCount, "I");
// mv.visitMethodInsn(INVOKESTATIC, Names.GLAllocation_, Names.GLAllocation_createDirectIntBuffer,
// Names.GLAllocation_createDirectIntBuffer_desc);
// mv.visitFieldInsn(PUTFIELD, Names.Tessellator_, Names.Tessellator_vertexBuffers,
// "Ljava/nio/IntBuffer;");
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_vertexBuffers,
// "Ljava/nio/IntBuffer;");
// mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/ARBVertexBufferObject", "glGenBuffersARB",
// "(Ljava/nio/IntBuffer;)V");
// mv.visitLabel(l31);
// mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
}
mv.visitVarInsn(ALOAD, 0);
mv.visitIntInsn(BIPUSH, 16);
mv.visitIntInsn(NEWARRAY, T_FLOAT);
mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "vertexPos", "[F");
}
mv.visitInsn(opcode);
}
}
private static class MVdraw extends MethodVisitor {
public MVdraw(MethodVisitor mv) {
super(Opcodes.ASM4, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(185, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/ShadersTess",
"draw",
"(" + Names.tessellator_.desc + ")I");
mv.visitInsn(IRETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l1, 0);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
}
private static class MVreset extends MethodVisitor {
public MVreset(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
// ALog.finest(" F %d %s.%s %s", opcode, ownerM, nameM, descM);
if (opcode == GETSTATIC && Names.tessellator_byteBuffer.equals(owner, name)) {
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, owner, name, desc);
return;
}
mv.visitFieldInsn(opcode, owner, name, desc);
}
}
private static class MVaddVertex extends MethodVisitor {
public MVaddVertex(MethodVisitor mv) {
super(Opcodes.ASM4, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(466, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(DLOAD, 1);
mv.visitVarInsn(DLOAD, 3);
mv.visitVarInsn(DLOAD, 5);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/ShadersTess",
"addVertex",
"(" + Names.tessellator_.desc + "DDD)V");
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(467, l1);
mv.visitInsn(RETURN);
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l2, 0);
mv.visitLocalVariable("par1", "D", null, l0, l2, 1);
mv.visitLocalVariable("par3", "D", null, l0, l2, 3);
mv.visitLocalVariable("par5", "D", null, l0, l2, 5);
mv.visitMaxs(7, 7);
mv.visitEnd();
}
}
private static class MVsetNormal extends MethodVisitor {
public MVsetNormal(MethodVisitor mv) {
super(Opcodes.ASM4, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ICONST_1);
mv.visitFieldInsn(
PUTFIELD,
Names.tessellator_hasNormals.clas,
Names.tessellator_hasNormals.name,
Names.tessellator_hasNormals.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(FLOAD, 1);
mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalX", "F");
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(FLOAD, 2);
mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalY", "F");
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(FLOAD, 3);
mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalZ", "F");
mv.visitInsn(RETURN);
Label l5 = new Label();
mv.visitLabel(l5);
mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l5, 0);
mv.visitLocalVariable("par1", "F", null, l0, l5, 1);
mv.visitLocalVariable("par2", "F", null, l0, l5, 2);
mv.visitLocalVariable("par3", "F", null, l0, l5, 3);
mv.visitMaxs(2, 4);
mv.visitEnd();
}
}
private static class MVsortQuad extends MethodVisitor {
public MVsortQuad(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitIntInsn(int opcode, int operand) {
if (opcode == BIPUSH && operand == 32) {
operand = 64;
}
super.visitIntInsn(opcode, operand);
}
}
}
@@ -1,49 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTTextureClock implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.textureAtlasSpri_updateAnimation.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new ACTTextureAtlasSprite.MVanimation(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
}
@@ -1,49 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTTextureCompass implements IClassTransformer {
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.textureCompass_updateCompass.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM);
return new ACTTextureAtlasSprite.MVanimation(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
}
@@ -1,90 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTTextureSimple implements IClassTransformer {
private static final int logDetail = 0;
@Override
public byte[] transform(String par1, String par2, byte[] par3) {
ALog.fine("transforming %s %s", par1, par2);
ClassReader cr = new ClassReader(par3);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
classname = name;
// ALog.info(" class %s",name);
cv.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s%s",classname,name,desc,nameM,descM);
if (Names.iTextureObject_loadTexture.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s%s",classname,name,desc,nameM,descM);
return new MVloadTexture(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVloadTexture extends MethodVisitor {
public MVloadTexture(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (Names.textureUtil_uploadTextureImageAllocate.equals(owner, name, desc)) {
// mv.visitMethodInsn(opcode, owner, name, desc);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(
GETFIELD,
Names.simpleTexture_textureLocation.clas,
Names.simpleTexture_textureLocation.name,
Names.simpleTexture_textureLocation.desc);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(
INVOKEVIRTUAL,
Names.simpleTexture_.clas,
"getMultiTexID",
"()Lcom/gtnewhorizons/angelica/client/MultiTexID;");
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/ShadersTex",
"loadSimpleTexture",
"(ILjava/awt/image/BufferedImage;ZZ" + Names.iResourceManager_.desc
+ Names.resourceLocation_.desc
+ "Lcom/gtnewhorizons/angelica/client/MultiTexID;)I");
ALog.finer(" loadSimpleTexture");
return;
}
mv.visitMethodInsn(opcode, owner, name, desc);
}
}
}
@@ -24,16 +24,7 @@ public class AClassTransformer implements IClassTransformer {
names = new Names();
InitNames.init();
ctMap = new HashMap();
put(Names.block_, new ACTBlock());
put(Names.itemBlock_, new ACTItemBlock());
put(Names.guiOptions_, new ACTGuiOptions());
put(Names.modelRenderer_, new ACTModelRenderer());
put(Names.openGlHelper_, new ACTOpenGlHelper());
put(Names.tessellator_, new ACTTessellator());
put(Names.renderBlocks_, new ACTRenderBlocks());
put(Names.renderGlobal_, new ACTRenderGlobal());
put(Names.entityRenderer_, new ACTEntityRenderer());
put(Names.render_, new ACTRender());
put(Names.renderManager_, new ACTRenderManager());
put(Names.rendererLivingE_, new ACTRendererLivingEntity());
put(Names.renderDragon_, new ACTRenderSpider());
@@ -43,13 +34,10 @@ public class AClassTransformer implements IClassTransformer {
put(Names.textureDownload_, new ACTTextureDownload());
put(Names.abstractTexture_, new ACTTextureAbstract());
put(Names.iTextureObject_, new ACTTextureObject());
put(Names.simpleTexture_, new ACTTextureSimple());
put(Names.layeredTexture_, new ACTTextureLayered());
put(Names.dynamicTexture_, new ACTTextureDynamic());
put(Names.textureMap_, new ACTTextureMap());
put(Names.textureAtlasSpri_, new ACTTextureAtlasSprite());
put(Names.textureClock_, new ACTTextureClock());
put(Names.textureCompass_, new ACTTextureCompass());
put(Names.textureManager_, new ACTTextureManager());
ctMap.put("mrtjp.projectred.illumination.RenderHalo$", new ACTPrjRedIlluRenderHalo());
ctMap.put("net.smart.render.ModelRotationRenderer", new ACTSmartMoveModelRotationRenderer());
@@ -127,8 +127,6 @@ public class Namer1_7_10 extends Namer {
glAllocation_createDirectByteBuffer = m(glAllocation_, "c", "(I)Ljava/nio/ByteBuffer;");
glAllocation_createDirectIntBuffer = m(glAllocation_, "f", "(I)Ljava/nio/IntBuffer;");
glAllocation_deleteDisplayLists = m(glAllocation_, "b", "(I)V");
guiOptions_actionPerformed = m(guiOptions_, "a", "(" + guiButton_.desc + ")V");
guiOptions_initGui = m(guiOptions_, "b", "()V");
iCamera_setPosition = m(iCamera_, "a", "(DDD)V");
iResourceManager_getResource = m(iResourceManager_, "a", "(" + resourceLocation_.desc + ")" + iResource_.desc);
itemRenderer_renderItem = m(itemRenderer_, "a", "(" + entityLivingBase_.desc + itemStack_.desc + "I)V");
@@ -150,7 +148,6 @@ public class Namer1_7_10 extends Namer {
renderBlocks_renderBlockByRenderType = m(renderBlocks_, "b", "(" + block_.desc + "III)Z");
renderBlocks_renderBlockFlowerPot = m(renderBlocks_, "a", "(" + blockFlowerPot_.desc + "III)Z");
renderBlocks_renderStdBlockWithAOP = m(renderBlocks_, "b", "(" + block_.desc + "IIIFFF)Z");
renderBlocks_renderPistonExtension = m(renderBlocks_, "c", "(" + block_.desc + "IIIZ)Z");
renderDragon_shouldRenderPass = m(renderDragon_, "a", "(" + entityDragon_.desc + "IF)I");
renderEnderman_shouldRenderPass = m(renderEnderman_, "a", "(" + entityEnderman_.desc + "IF)I");
renderSpider_shouldRenderPass = m(renderSpider_, "a", "(" + entitySpider_.desc + "IF)I");
@@ -127,8 +127,6 @@ public class NamerSrg extends Namer {
glAllocation_createDirectByteBuffer = m(glAllocation_, "func_74524_c", "(I)Ljava/nio/ByteBuffer;");
glAllocation_createDirectIntBuffer = m(glAllocation_, "func_74527_f", "(I)Ljava/nio/IntBuffer;");
glAllocation_deleteDisplayLists = m(glAllocation_, "func_74523_b", "(I)V");
guiOptions_actionPerformed = m(guiOptions_, "func_146284_a", "(" + guiButton_.desc + ")V");
guiOptions_initGui = m(guiOptions_, "func_73866_w_", "()V");
iCamera_setPosition = m(iCamera_, "func_78547_a", "(DDD)V");
iResourceManager_getResource = m(
iResourceManager_,
@@ -159,7 +157,6 @@ public class NamerSrg extends Namer {
renderBlocks_renderBlockByRenderType = m(renderBlocks_, "func_147805_b", "(" + block_.desc + "III)Z");
renderBlocks_renderBlockFlowerPot = m(renderBlocks_, "func_147752_a", "(" + blockFlowerPot_.desc + "III)Z");
renderBlocks_renderStdBlockWithAOP = m(renderBlocks_, "func_147808_b", "(" + block_.desc + "IIIFFF)Z");
renderBlocks_renderPistonExtension = m(renderBlocks_, "func_147809_c", "(" + block_.desc + "IIIZ)Z");
renderDragon_shouldRenderPass = m(renderDragon_, "func_77032_a", "(" + entityDragon_.desc + "IF)I");
renderEnderman_shouldRenderPass = m(renderEnderman_, "func_77032_a", "(" + entityEnderman_.desc + "IF)I");
renderSpider_shouldRenderPass = m(renderSpider_, "func_77032_a", "(" + entitySpider_.desc + "IF)I");
@@ -193,8 +193,6 @@ public class Names {
static Meth glAllocation_createDirectByteBuffer;
static Meth glAllocation_createDirectIntBuffer;
static Meth glAllocation_deleteDisplayLists;
static Meth guiOptions_actionPerformed;
static Meth guiOptions_initGui;
static Meth iCamera_setPosition;
static Meth iResourceManager_getResource;
static Meth itemRenderer_renderItem;
@@ -216,7 +214,6 @@ public class Names {
static Meth renderBlocks_renderBlockByRenderType;
static Meth renderBlocks_renderBlockFlowerPot;
static Meth renderBlocks_renderStdBlockWithAOP;
static Meth renderBlocks_renderPistonExtension;
static Meth renderDragon_shouldRenderPass;
static Meth renderEnderman_shouldRenderPass;
static Meth renderSpider_shouldRenderPass;
@@ -0,0 +1,27 @@
# Make all Tessellator fields public because using accessors for these would be too much rework right now
public net.minecraft.client.renderer.Tessellator field_78394_d # byteBuffer
public net.minecraft.client.renderer.Tessellator field_147568_c # intBuffer
public net.minecraft.client.renderer.Tessellator field_147566_d # floatBuffer
public net.minecraft.client.renderer.Tessellator field_147567_e # shortBuffer
public net.minecraft.client.renderer.Tessellator field_78405_h # rawBuffer
public net.minecraft.client.renderer.Tessellator field_78406_i # vertexCount
public net.minecraft.client.renderer.Tessellator field_78403_j # textureU
public net.minecraft.client.renderer.Tessellator field_78404_k # textureV
public net.minecraft.client.renderer.Tessellator field_78401_l # brightness
public net.minecraft.client.renderer.Tessellator field_78402_m # color
public net.minecraft.client.renderer.Tessellator field_78399_n # hasColor
public net.minecraft.client.renderer.Tessellator field_78400_o # hasTexture
public net.minecraft.client.renderer.Tessellator field_78414_p # hasBrightness
public net.minecraft.client.renderer.Tessellator field_78413_q # hasNormals
public net.minecraft.client.renderer.Tessellator field_147569_p # rawBufferIndex
public net.minecraft.client.renderer.Tessellator field_78411_s # addedVertices
public net.minecraft.client.renderer.Tessellator field_78410_t # isColorDisabled
public net.minecraft.client.renderer.Tessellator field_78409_u # drawMode
public net.minecraft.client.renderer.Tessellator field_78408_v # xOffset
public net.minecraft.client.renderer.Tessellator field_78407_w # yOffset
public net.minecraft.client.renderer.Tessellator field_78417_x # zOffset
public net.minecraft.client.renderer.Tessellator field_78416_y # normal
public net.minecraft.client.renderer.Tessellator field_78415_z # isDrawing
public net.minecraft.client.renderer.Tessellator field_78388_E # bufferSize
public net.minecraft.client.renderer.Tessellator func_78379_d()V # reset
public net.minecraft.client.renderer.EntityRenderer func_78476_b(FI)V # renderHand
-1
View File
@@ -1,7 +1,6 @@
{
"required": true,
"minVersion": "0.8.3-GTNH",
"package": "com.gtnewhorizons.angelica.mixins",
"refmap": "mixins.angelica.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"