Update build script, integrate MobiusCore (#3)

* wip-buildupdate

* update buildscript

* version
This commit is contained in:
bombcar authored and GitHub committed 2022-02-09 17:51:36 +01:00
1 parent 288d527f65
commit fb6d252c2b
48 files changed
+4221 -270

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
if [[ -d "run/crash-reports" ]]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
fi
if grep --quiet "Fatal errors were detected" server.log; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+45
View File
@@ -0,0 +1,45 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1.5 minutes
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 90 ./gradlew runServer | tee --append server.log || true
- name: Test no errors reported during server run
run: |
chmod +x .github/scripts/test-no-error-reports.sh
.github/scripts/test-no-error-reports.sh
+51
View File
@@ -0,0 +1,51 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
- name: Publish to Maven
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
+31 -11
View File
@@ -1,11 +1,31 @@
.gradle/gradle.log
.gradle/
.idea/
*.iml
debug/
classes/
output/
out/
*.bat
opis.ipr
opis.iws
.gradle
.settings
/.idea/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
*.bat
*.DS_Store
!gradlew.bat
+3
View File
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
+1 -1
View File
@@ -25,7 +25,7 @@ as I did not find any use for overlay functionality.
Subjectively, I found it too cumbersome in development to work with MobiusCore as a
separate mod and codebase whilst attempting to update Opis. I found that MobiusCore is
[not depended upon by any other mods](http://minecraft.curseforge.com/projects/mobiuscore/relations/dependents?filter-related-dependents=3),
so I thought it OK to integrate as a git submodule instead.
so I thought it OK to integrate it directly.
# Building
+648 -106
View File
@@ -1,147 +1,425 @@
//version: 1644194279
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.concurrent.TimeUnit
buildscript {
// Repositories and plugins used by this buildscript. For internal Gradle use only.
repositories {
mavenCentral()
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "jitpack.io"
name = "Scala CI dependencies"
url = "https://repo1.maven.org/maven2/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
}
}
// Applies the custom Gradle plugin Forge uses, for Forge-specific tasks
plugins {
id 'idea'
id 'eclipse'
id 'scala'
id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false
id('org.ajoberstar.grgit') version('4.1.1')
id('com.github.johnrengelman.shadow') version('4.0.4')
id('com.palantir.git-version') version('0.13.0') apply false
id('de.undercouch.download') version('5.0.1')
id('maven-publish')
}
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
apply plugin: 'forge'
// Gradle project metadata
version = "1.3.2-MAPLESS_1.7.10"
group = "mcp.mobius.opis"
def projectJavaVersion = JavaLanguageVersion.of(8)
repositories {
mavenLocal()
mavenCentral()
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
java {
toolchain {
languageVersion.set(projectJavaVersion)
}
maven {
name "Mobius Repo"
url "http://mobiusstrip.eu/maven"
}
idea {
module {
inheritOutputDirs = true
downloadJavadoc = true
downloadSources = true
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinPlugin")
checkPropertyExists("mixinsPackage")
checkPropertyExists("coreModClass")
checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
if(accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
// Make sure GregTech build won't time out
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
}
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
try {
'git config core.fileMode false'.execute()
}
catch (Exception e) {
logger.error("\u001B[31mgit isn't installed at all\u001B[0m")
}
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception e) {
logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" +
"or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" +
"clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n");
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
version = minecraftVersion + '-' + identifiedVersion
String modVersion = identifiedVersion
if( identifiedVersion.equals(versionOverride) ) {
logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n');
logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n');
}
group = modGroup
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
}
else {
archivesBaseName = modId
}
def arguments = []
def jvmArguments = []
if(usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
jvmArguments += [
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
]
}
minecraft {
// Forge version
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "debug"
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
runDir = "run"
// Replace MOD_VERSION token with one specified in Gradle
// From https://github.com/GoryMoon/MoarSigns/blob/master/build.gradle#L46
replaceIn "CoreContainer.java"
replaceIn "modOpis.java"
replace "@MOD_VERSION@", project.version
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
replace gradleTokenVersion, modVersion
}
if(gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
// Shading - https://forgegradle.readthedocs.org/en/latest/user-guide/shading/
// math3 is shaded in case another mod decides to use a differing version
srgExtra "PK: org/apache/commons/math3 opisapache/math3"
clientIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
if(developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}
serverIntellijRun {
args(arguments)
jvmArgs(jvmArguments)
}
}
if(file("addon.gradle").exists()) {
apply from: "addon.gradle"
}
apply from: 'repositories.gradle'
configurations {
deployerJars
shade
compile.extendsFrom shade
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}
repositories {
maven {
name = "Overmind forge repo mirror"
url = "https://gregtech.overminddl1.com/"
}
if(usesMixins.toBoolean()) {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public"
}
maven {
url = "https://jitpack.io"
}
}
}
dependencies {
// Custom-built Netty for Opis
shade 'io.netty-opis:Netty-opis:4.0.23'
// Standard Maven repository dependencies
shade 'org.apache.commons:commons-math3:3.2'
shade 'org.jfree:jfreechart:1.0.17'
shade 'com.miglayout:miglayout-swing:4.2'
// Necessary for deployment
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
if(usesMixins.toBoolean()) {
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: "launchwrapper"
exclude module: "guava"
exclude module: "gson"
exclude module: "commons-io"
exclude module: "log4j-core"
}
compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
}
}
// Includes MobiusCore submodule directory into the built jar as coremod
sourceSets.main {
java.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/java'
resources.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/resources'
apply from: 'dependencies.gradle'
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
"""
}
}
def commonManifest = {
// Allows Forge to find MobuisCore's coremod
attributes 'FMLCorePlugin': 'mcp.mobius.mobiuscore.asm.CoreDescription'
// Without this, Forge ignores Opis as it thinks there is only a coremod
attributes 'FMLCorePluginContainsFMLMod': 'true'
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
}
shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}
jar {
// Attach FMLCorePlugin attribute
manifest commonManifest
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
// Extra task for building a "sources" jar, for uncompiled code + comments
task sourceJar(type: Jar) {
from sourceSets.main.java
// Attaches the name 'sources' to the jar
classifier = 'sources'
reobf {
if(usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
// Extra task for building a "dev" jar; built code pre-obsfucation
task devJar(type: Jar) {
from sourceSets.main.output
// Attaches the name 'dev' to the jar
classifier = 'dev'
// Attach FMLCorePlugin attribute
manifest commonManifest
afterEvaluate {
if(usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
}
}
// Fixes issues with debugging in IntelliJ
idea.module.inheritOutputDirs = true
runClient {
if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}
// Fixes issues with µ character in source files
// From https://discuss.gradle.org/t/special-characters-in-java-string-literals-arent-interpreted-correctly/4665
tasks.withType(JavaCompile)
args(arguments)
jvmArgs(jvmArguments)
}
runServer {
args(arguments)
jvmArgs(jvmArguments)
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = projectJavaVersion
}
)
}
processResources
{
options.encoding = "UTF-8"
}
artifacts {
archives jar, sourceJar, devJar
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
expand "minecraftVersion": project.minecraft.version,
"modVersion": modVersion,
"modId": modId,
"modName": modName
}
if(usesMixins.toBoolean()) {
from refMap
}
// copy everything else, thats not the mcmod.info
@@ -150,30 +428,294 @@ processResources {
}
}
uploadArchives {
dependsOn 'reobf'
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "scp://mobiusstrip.eu/home/mobius/web/maven") {
authentication(userName: "mobius")
}
def getManifestAttributes() {
def manifestAttributes = [:]
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
pom {
groupId = project.group
version = project.version
artifactId = project.name
project {
name project.name
packaging 'jar'
description 'Opis '
url 'http://mobiusstrip.eu'
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
}
if(coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
task shadowDevJar(type: ShadowJar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
target = tasks.shadowDevJar
prefix = modGroup + ".shadow"
}
task circularResolverJar(type: Jar) {
dependsOn(relocateShadowDevJar)
dependsOn(shadowDevJar)
enabled = false
}
task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
getArchiveClassifier().set('api')
}
artifacts {
if(!noPublishedSources) {
archives sourcesJar
}
archives devJar
if(apiPackage) {
archives apiJar
}
}
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
// and isn't strictly needed with the POM so just disable it.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// publishing
publishing {
publications {
maven(MavenPublication) {
from components.java
if(usesShadowedDependencies.toBoolean()) {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
artifact source: apiJar, classifier: "api"
}
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
// Remove all non GTNH deps here.
// Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but
// it also removes all of the MC deps
pom.withXml {
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.groupId.text() != 'com.github.GTNewHorizons'
}.each() {
it.parent().remove(it)
}
}
}
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)) exclude 'META-INF', 'META-INF/**'
repositories {
maven {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
return versionLine.split(": ").last()
}
return ""
}
configure(updateBuildScript) {
group = 'forgegradle'
description = 'Updates the build script to the latest version'
}
// Deobfuscation
def deobf(String sourceURL) {
try {
URL url = new URL(sourceURL)
String fileName = url.getFile()
//get rid of directories:
int lastSlash = fileName.lastIndexOf("/")
if(lastSlash > 0) {
fileName = fileName.substring(lastSlash + 1)
}
//get rid of extension:
if(fileName.endsWith(".jar")) {
fileName = fileName.substring(0, fileName.lastIndexOf("."))
}
String hostName = url.getHost()
if(hostName.startsWith("www.")) {
hostName = hostName.substring(4)
}
List parts = Arrays.asList(hostName.split("\\."))
Collections.reverse(parts)
hostName = String.join(".", parts)
return deobf(sourceURL, hostName + "/" + fileName)
} catch(Exception e) {
return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode()))
}
}
// The method above is to be prefered. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String fileName) {
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
String bon2Dir = cacheDir + "forge_gradle/deobf"
String bon2File = bon2Dir + "/BON2-2.5.0.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)
}
download {
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
dest bon2File
quiet true
overwrite false
}
download {
src sourceURL
dest obfFile
quiet true
overwrite false
}
exec {
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch'
workingDir bon2Dir
standardOutput = new ByteArrayOutputStream()
}
return files(deobfFile)
}
// Helper methods
def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
+179
View File
@@ -0,0 +1,179 @@
buildscript {
// Repositories and plugins used by this buildscript. For internal Gradle use only.
repositories {
mavenCentral()
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "jitpack.io"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
}
}
// Applies the custom Gradle plugin Forge uses, for Forge-specific tasks
apply plugin: 'forge'
// Gradle project metadata
version = "1.3.2-MAPLESS_1.7.10"
group = "mcp.mobius.opis"
repositories {
mavenLocal()
mavenCentral()
maven {
name = "gt"
url = "https://gregtech.overminddl1.com/"
}
maven {
name "Mobius Repo"
url "http://mobiusstrip.eu/maven"
}
}
minecraft {
// Forge version
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "debug"
// Replace MOD_VERSION token with one specified in Gradle
// From https://github.com/GoryMoon/MoarSigns/blob/master/build.gradle#L46
replaceIn "CoreContainer.java"
replaceIn "modOpis.java"
replace "@MOD_VERSION@", project.version
// Shading - https://forgegradle.readthedocs.org/en/latest/user-guide/shading/
// math3 is shaded in case another mod decides to use a differing version
srgExtra "PK: org/apache/commons/math3 opisapache/math3"
}
configurations {
deployerJars
shade
compile.extendsFrom shade
}
dependencies {
// Custom-built Netty for Opis
shade 'io.netty-opis:Netty-opis:4.0.23'
// Standard Maven repository dependencies
shade 'org.apache.commons:commons-math3:3.2'
shade 'org.jfree:jfreechart:1.0.17'
shade 'com.miglayout:miglayout-swing:4.2'
// Necessary for deployment
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
// Includes MobiusCore submodule directory into the built jar as coremod
sourceSets.main {
java.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/java'
resources.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/resources'
}
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
def commonManifest = {
// Allows Forge to find MobuisCore's coremod
attributes 'FMLCorePlugin': 'mcp.mobius.mobiuscore.asm.CoreDescription'
// Without this, Forge ignores Opis as it thinks there is only a coremod
attributes 'FMLCorePluginContainsFMLMod': 'true'
}
jar {
// Attach FMLCorePlugin attribute
manifest commonManifest
}
// Extra task for building a "sources" jar, for uncompiled code + comments
task sourceJar(type: Jar) {
from sourceSets.main.java
// Attaches the name 'sources' to the jar
classifier = 'sources'
}
// Extra task for building a "dev" jar; built code pre-obsfucation
task devJar(type: Jar) {
from sourceSets.main.output
// Attaches the name 'dev' to the jar
classifier = 'dev'
// Attach FMLCorePlugin attribute
manifest commonManifest
}
// Fixes issues with debugging in IntelliJ
idea.module.inheritOutputDirs = true
// Fixes issues with µ character in source files
// From https://discuss.gradle.org/t/special-characters-in-java-string-literals-arent-interpreted-correctly/4665
tasks.withType(JavaCompile)
{
options.encoding = "UTF-8"
}
artifacts {
archives jar, sourceJar, devJar
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
uploadArchives {
dependsOn 'reobf'
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "scp://mobiusstrip.eu/home/mobius/web/maven") {
authentication(userName: "mobius")
}
pom {
groupId = project.group
version = project.version
artifactId = project.name
project {
name project.name
packaging 'jar'
description 'Opis '
url 'http://mobiusstrip.eu'
}
}
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)) exclude 'META-INF', 'META-INF/**'
}
}
}
+9
View File
@@ -0,0 +1,9 @@
// Add your dependencies here
dependencies {
shadeCompile 'io.netty-opis:Netty-opis:4.0.23'
shadowCompile 'org.apache.commons:commons-math3:3.2'
shadeCompile 'org.jfree:jfreechart:1.0.17'
shadeCompile 'com.miglayout:miglayout-swing:4.2'
}
+67
View File
@@ -0,0 +1,67 @@
modName = Opis
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
modId = Opis
modGroup = mcp.mobius.opis
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = modOpis.java
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile = mobius_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
#customArchiveBaseName =
# Optional parameter to prevent the source code from being published
# noPublishedSources =
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Vendored
+36 -12
View File
@@ -1,4 +1,20 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
@@ -28,16 +44,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -154,11 +170,19 @@ if $cygwin ; then
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
Vendored
+17 -7
View File
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -49,7 +65,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +75,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
+2
View File
@@ -0,0 +1,2 @@
before_install:
- ./gradlew setupCIWorkspace
Submodule lib/MobiusCore deleted from 5b2674a475.
+14
View File
@@ -0,0 +1,14 @@
// Add any additional repositories for your dependencies here
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'gt'
url = 'https://gregtech.overminddl1.com/'
}
maven {
name = 'Mobius Repo'
url = 'http://mobiusstrip.eu/maven'
}
}
@@ -0,0 +1,12 @@
package mcp.mobius.mobiuscore.asm;
import java.io.IOException;
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
public class CoreAccessTransformer extends AccessTransformer {
public CoreAccessTransformer() throws IOException {
super("mobius_at.cfg");
}
}
@@ -0,0 +1,34 @@
package mcp.mobius.mobiuscore.asm;
import com.google.common.eventbus.EventBus;
import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.ModMetadata;
import java.util.Arrays;
public class CoreContainer extends DummyModContainer {
public CoreContainer()
{
super(new ModMetadata());
ModMetadata md = getMetadata();
md.modId = "MobiusCore";
md.name = "MobiusCore";
md.version = "@MOD_VERSION@";
md.credits = "ProfMobius";
md.authorList = Arrays.asList("ProfMobius");
md.description = "";
md.url = "profmobius.blogspot.com";
}
@Override
public boolean registerBus(EventBus bus, LoadController controller)
{
//bus.register(this);
// this needs to return true, otherwise the mod will be deactivated by FML
return true;
}
}
@@ -0,0 +1,43 @@
package mcp.mobius.mobiuscore.asm;
import java.io.File;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.TransformerExclusions("mcp.mobius.mobiuscore.asm")
public class CoreDescription implements IFMLLoadingPlugin {
public static final Logger log = LogManager.getLogger("MobiusCore");
@Override
public String[] getASMTransformerClass() {
return new String[] { "mcp.mobius.mobiuscore.asm.CoreTransformer" };
}
@Override
public String getModContainerClass() {
return "mcp.mobius.mobiuscore.asm.CoreContainer";
}
@Override
public String getSetupClass() {
return null;
}
@Override
public void injectData(Map<String, Object> data) {
if(data.containsKey("coremodLocation"))
location = (File) data.get("coremodLocation");
}
public static File location;
@Override
public String getAccessTransformerClass() {
return "mcp.mobius.mobiuscore.asm.CoreAccessTransformer";
}
}
@@ -0,0 +1,96 @@
package mcp.mobius.mobiuscore.asm;
import mcp.mobius.mobiuscore.asm.transformers.common.*;
import mcp.mobius.mobiuscore.asm.transformers.forge.TransformerWorld;
import mcp.mobius.mobiuscore.asm.transformers.kcauldron.TransformerWorldKCauldron;
import mcp.mobius.mobiuscore.asm.transformers.mcpc.TransformerWorldCauldron;
import mcp.mobius.mobiuscore.asm.transformers.thermos.TransformerWorldThermos;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.util.TraceClassVisitor;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class CoreTransformer implements IClassTransformer {
public CoreTransformer(){
super();
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
try{
//TransformerBase.dumpChecksum(bytes, name, srgname);
if (srgname.equals("net.minecraft.world.World")) {
ObfTable.ServerType serverType = ObfTable.getServerType();
if (serverType == ObfTable.ServerType.Forge) {
bytes = new TransformerWorld().transform(name, srgname, bytes);
} else if (serverType == ObfTable.ServerType.Cauldron) {
bytes = new TransformerWorldCauldron().transform(name, srgname, bytes);
} else if (serverType == ObfTable.ServerType.KCauldron) {
bytes = new TransformerWorldKCauldron().transform(name, srgname, bytes);
} else if (serverType == ObfTable.ServerType.Thermos) {
bytes = new TransformerWorldThermos().transform(name, srgname, bytes);
}
}
if (srgname.equals("net.minecraft.world.WorldServer")){
bytes = new TransformerWorldServer().transform(name, srgname, bytes);
}
if (srgname.equals("net.minecraft.util.MessageSerializer")){
bytes = new TransformerMessageSerializer().transform(name, srgname, bytes);
}
if (srgname.equals("net.minecraft.util.MessageDeserializer")){
bytes = new TransformerMessageDeserializer().transform(name, srgname, bytes);
}
if (srgname.equals("net.minecraft.client.renderer.entity.RenderManager")){
bytes = new TransformerRenderManager().transform(name, srgname, bytes);
}
if (srgname.equals("net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher")){
bytes = new TransformerTERenderer().transform(name, srgname, bytes);
}
if (srgname.equals("cpw.mods.fml.common.FMLCommonHandler")){
bytes = new TransformerFMLCommonHandler().transform(name, srgname, bytes);
}
if (srgname.equals("cpw.mods.fml.common.network.FMLOutboundHandler")){
bytes = new TransformerFMLOutboundHandler().transform(name, srgname, bytes);
}
//if (srgname.equals("cpw.mods.fml.common.network.internal.FMLProxyPacket")){
// bytes = new TransformerFMLProxyPacket().transform(name, srgname, bytes);
//}
if (srgname.equals("cpw.mods.fml.common.eventhandler.ASMEventHandler")){
bytes = new TransformerASMEventHandler().transform(name, srgname, bytes);
}
} catch (Exception e){
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
try{
PrintWriter pw = new PrintWriter(String.format("%s.asm", srgname.replaceAll("/", ".")));
TraceClassVisitor cv = new TraceClassVisitor(pw);
classReader.accept(cv, 0);
pw.flush();
throw new RuntimeException(e);
} catch (FileNotFoundException f){
throw new RuntimeException("DERP");
}
}
return bytes;
}
}
@@ -0,0 +1,26 @@
package mcp.mobius.mobiuscore.asm;
public final class MethodDescriptor {
private final String methodName;
private final String descriptor;
//public String vanillaDesc;
//public String coremodDesc;
public MethodDescriptor(String name, String desc){
this.methodName = name;
this.descriptor = desc;
}
public String getMethodName(){ return this.methodName; }
public String getDescriptor(){ return this.descriptor; }
/*
public MethodDescriptor(String name, String vdesc, String cdesc){
this.methodName = name;
this.vanillaDesc = vdesc;
this.coremodDesc = cdesc;
}
*/
}
@@ -0,0 +1,153 @@
package mcp.mobius.mobiuscore.asm;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.launchwrapper.LaunchClassLoader;
import java.io.IOException;
public enum ObfTable {
WORLD_UPDATEENTITIES ("ahb", "h", "()V", "net/minecraft/world/World", "updateEntities", "()V"),
WORLD_UPDATEENTITY ("ahb", "g", "(Lsa;)V", "net/minecraft/world/World", "updateEntity", "(Lnet/minecraft/entity/Entity;)V"),
TILEENTITY_UPDATEENTITY ("aor", "h", "()V", "net/minecraft/tileentity/TileEntity", "updateEntity", "()V"),
WORLDSERVER_TICK ("mt", "b", "()V", "net/minecraft/world/WorldServer", "tick", "()V"),
WORLD_PROVIDER ("mt", "t", "Laqo;", "net/minecraft/world/WorldServer", "provider", "Lnet/minecraft/world/WorldProvider;"),
WORLDPROVIDER_DIMID ("aqo", "i", "I", "net/minecraft/world/WorldProvider", "dimensionId", "I"),
SERIALIZER_ENCODE ("fa", "a", "(Lio/netty/channel/ChannelHandlerContext;Lft;Lio/netty/buffer/ByteBuf;)V", "net/minecraft/util/MessageSerializer", "encode", "(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;Lio/netty/buffer/ByteBuf;)V"),
DESERIALIZER_DECODE ("ez", "decode", "(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V", "net/minecraft/util/MessageDeserializer", "decode", "(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V"),
PACKET_WRITEPACKETDATA ("ft", "b", "(Let;)V", "net/minecraft/network/Packet","writePacketData","(Lnet/minecraft/network/PacketBuffer;)V"),
PACKET_READPACKETDATA ("ft", "a", "(Let;)V", "net/minecraft/network/Packet","readPacketData", "(Lnet/minecraft/network/PacketBuffer;)V"),
PACKET_GENERATEPACKET ("ft", "a", "(Lcom/google/common/collect/BiMap;I)Lpk;", "net/minecraft/network/Packet", "generatePacket", "(Lcom/google/common/collect/BiMap;I)Lnet/minecraft/network/Packet;"),
PACKETBUFFER_READABLE ("et", "readableBytes", "()I", "net/minecraft/network/PacketBuffer", "readableBytes", "()I"),
PACKETBUFFER_CAPACITY ("et", "capacity", "()I", "net/minecraft/network/PacketBuffer", "capacity", "()I"),
RENDERMANAGER_RENDERENTITY("bnn", "a", "(Lsa;FZ)Z", "net/minecraft/client/renderer/entity/RenderManager", "renderEntityStatic", "(Lnet/minecraft/entity/Entity;FZ)Z"),
RENDERMANAGER_RENDERPOSYAW("bnn", "a", "(Lsa;DDDFF)Z", "net/minecraft/client/renderer/entity/RenderManager", "renderEntityWithPosYaw", "(Lnet/minecraft/entity/Entity;DDDFF)Z"),
RENDERMANAGER_RENDER ("bnn", "a", "(Lsa;DDDFFZ)Z", "net/minecraft/client/renderer/entity/RenderManager", "func_147939_a", "(Lnet/minecraft/entity/Entity;DDDFFZ)Z"),
TERENDER_RENDERAT ("bml", "a", "(Laor;DDDF)V", "net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer", "renderTileEntityAt", "(Lnet/minecraft/tileentity/TileEntity;DDDF)V"),
FMLCH_PREWORLDTICK ("cpw/mods/fml/common/FMLCommonHandler","onPreWorldTick","(Lahb;)V", "cpw/mods/fml/common/FMLCommonHandler","onPreWorldTick","(Lnet/minecraft/world/World;)V"),
FMLCH_POSTWORLDTICK ("cpw/mods/fml/common/FMLCommonHandler","onPostWorldTick","(Lahb;)V", "cpw/mods/fml/common/FMLCommonHandler","onPostWorldTick","(Lnet/minecraft/world/World;)V"),
FMLPP_PROCESSPACKET ("cpw/mods/fml/common/network/internal/FMLProxyPacket", "a", "(Lfb;)V", "cpw/mods/fml/common/network/internal/FMLProxyPacket", "processPacket", "(Lnet/minecraft/network/INetHandler;)V"),
WORLD_INIT ("ahb", "<init>", "(Lazc;Ljava/lang/String;Lahj;Laqo;Lqi;)V", "net/minecraft/world/World", "<init>", "(Lnet/minecraft/world/storage/ISaveHandler;Ljava/lang/String;Lnet/minecraft/world/WorldSettings;Lnet/minecraft/world/WorldProvider;Lnet/minecraft/profiler/Profiler;)V"),
WORLD_LOADEDENTS ("ahb", "e", "Ljava/util/List;", "net/minecraft/world/World", "loadedEntityList", "Ljava/util/List;"),
WORLD_LOADEDTILES ("ahb", "g", "Ljava/util/List;", "net/minecraft/world/World", "loadedTileEntityList", "Ljava/util/List;"),
/*
NETWORKLISTEN_NETWORKTICK ("nc", "c", "()V", "net/minecraft/network/NetworkSystem", "networkTick", "()V"),
TCPCONN_READPACKET ("co", "i", "()Z", "net/minecraft/network/TcpConnection", "readPacket", "()Z"),
TCPCONN_SENDPACKET ("co", "a", "(Z)Ley;", "net/minecraft/network/TcpConnection", "func_74460_a", "(Z)Lnet/minecraft/network/packet/Packet;"),
TCPCONN_NETWORKSOCKET ("co", "j", "Ljava/net/Socket;", "net/minecraft/network/TcpConnection", "networkSocket", "Ljava/net/Socket;"),
MEMCONN_ADDSENDQUEUE ("cn", "a", "(Ley;)V", "net/minecraft/network/MemoryConnection", "addToSendQueue", "(Lnet/minecraft/network/packet/Packet;)V"),
MEMCONN_PROCESSREAD ("cn", "b", "()V", "net/minecraft/network/MemoryConnection", "processReadPackets", "()V"),
MEMCONN_PAIREDCONN ("cn", "d", "Lcn;", "net/minecraft/network/MemoryConnection", "pairedConnection", "Lnet/minecraft/network/MemoryConnection;"),
MEMCONN_PROCESSORCACHE ("cn", "b", "(Ley;)V", "net/minecraft/network/MemoryConnection", "processOrCachePacket", "(Lnet/minecraft/network/packet/Packet;)V"),
MEMCONN_MYNETHANDLER ("cn", "e", "Lez;", "net/minecraft/network/MemoryConnection", "myNetHandler", "Lnet/minecraft/network/packet/NetHandler;");
*/
//PACKET_PROCESSPACKET ("ey", "a", "(Lez;)V", "net/minecraft/network/packet/Packet", "processPacket", "(Lnet/minecraft/network/packet/NetHandler;)V"),
//PACKET_WRITEPACKET ("ey", "a", "(Llp;Ljava/io/DataInput;ZLjava/net/Socket;)Ley;", "net/minecraft/network/packet/Packet", "writePacket", "(Lnet/minecraft/network/packet/Packet;Ljava/io/DataOutput;)V"),
//PACKET_READPACKET ("ey", "a", "(Llp;Ljava/io/DataInput;ZLjava/net/Socket;)Ley;", "net/minecraft/network/packet/Packet", "readPacket", "(Lnet/minecraft/logging/ILogAgent;Ljava/io/DataInput;ZLjava/net/Socket;)Lnet/minecraft/network/packet/Packet;"),
;
private static Boolean isObfuscated = null;
private static ServerType serverType;
private String clazzNameN;
private String methodNameN;
private String descriptorN;
private String clazzNameS;
private String methodNameS;
private String descriptorS;
private ObfTable(String clazzn, String namen, String descn, String clazzs, String names, String descs){
this.clazzNameN = clazzn;
this.clazzNameS = clazzs;
this.methodNameN = namen;
this.methodNameS = names;
this.descriptorN = descn;
this.descriptorS = descs;
}
public String getClazz(){
if (deobfuscatedEnvironment())
return this.clazzNameS;
else
return this.clazzNameN;
}
public String getName(){
if (deobfuscatedEnvironment())
return this.methodNameS;
else
return this.methodNameN;
}
public String getDescriptor(){
if (deobfuscatedEnvironment())
return this.descriptorS;
else
return this.descriptorN;
}
public String getFullDescriptor(){
if (deobfuscatedEnvironment())
return this.methodNameS + " " + this.descriptorS;
else
return this.methodNameN + " " + this.descriptorN;
}
public static Boolean deobfuscatedEnvironment(){
if (ObfTable.isObfuscated != null)
return ObfTable.isObfuscated;
try{
// Are we in a 'decompiled' environment?
byte[] bs = ((LaunchClassLoader)CoreContainer.class.getClassLoader()).getClassBytes("net.minecraft.world.World");
if (bs != null){
CoreDescription.log.info("Current code is UNOBFUSCATED");
ObfTable.isObfuscated = true;
} else {
CoreDescription.log.info("Current code is OBFUSCATED");
ObfTable.isObfuscated = false;
}
}catch (IOException e1){}
return ObfTable.isObfuscated;
}
public static ServerType getServerType() {
if (serverType != null) return serverType;
if (FMLCommonHandler.instance().getModName().contains("thermos")) {
serverType = ServerType.Thermos;
CoreDescription.log.info("Switching injection mode to Thermos");
} else if (FMLCommonHandler.instance().getModName().contains("kcauldron")) {
serverType = ServerType.KCauldron;
CoreDescription.log.info("Switching injection mode to KCAULDRON");
} else if (FMLCommonHandler.instance().getModName().contains("cauldron") || FMLCommonHandler.instance().getModName().contains("mcpc")) {
serverType = ServerType.Cauldron;
CoreDescription.log.info("Switching injection mode to CAULDRON");
} else {
serverType = ServerType.Forge;
CoreDescription.log.info("Switching injection mode to FORGE");
}
return serverType;
}
public enum ServerType {
Forge, Cauldron, KCauldron, Thermos
}
/*
public FieldInsnNode getFieldNode(){
return new FieldInsnNode(Opcodes.GETFIELD, this.getClazz(), this.getName(), this.getDescriptor());
}
*/
}
@@ -0,0 +1,304 @@
package mcp.mobius.mobiuscore.asm;
import java.util.HashMap;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
public class Opcode {
public static InsnNode DUP(){
return new InsnNode(Opcodes.DUP);
}
public static VarInsnNode ALOAD(int val){
return new VarInsnNode(Opcodes.ALOAD, val);
}
public static TypeInsnNode NEW(String name){
return new TypeInsnNode(Opcodes.NEW, name);
}
public static FieldInsnNode GETFIELD(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new FieldInsnNode(Opcodes.GETFIELD, clazz, field, sig);
}
public static FieldInsnNode GETFIELD(String clazz, String field, String sig){
return new FieldInsnNode(Opcodes.GETFIELD, clazz, field, sig);
}
public static FieldInsnNode PUTFIELD(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new FieldInsnNode(Opcodes.PUTFIELD, clazz, field, sig);
}
public static FieldInsnNode PUTFIELD(String clazz, String field, String sig){
return new FieldInsnNode(Opcodes.PUTFIELD, clazz, field, sig);
}
public static FieldInsnNode GETSTATIC(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new FieldInsnNode(Opcodes.GETSTATIC, clazz, field, sig);
}
public static FieldInsnNode GETSTATIC(String clazz, String field, String sig){
return new FieldInsnNode(Opcodes.GETSTATIC, clazz, field, sig);
}
public static MethodInsnNode INVOKEINTERFACE(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new MethodInsnNode(Opcodes.INVOKEINTERFACE, clazz, field, sig, true);
}
public static MethodInsnNode INVOKEINTERFACE(String clazz, String field, String sig){
return new MethodInsnNode(Opcodes.INVOKEINTERFACE, clazz, field, sig, true);
}
public static MethodInsnNode INVOKEVIRTUAL(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new MethodInsnNode(Opcodes.INVOKEVIRTUAL, clazz, field, sig, false);
}
public static MethodInsnNode INVOKEVIRTUAL(String clazz, String field, String sig){
return new MethodInsnNode(Opcodes.INVOKEVIRTUAL, clazz, field, sig, false);
}
public static MethodInsnNode INVOKESPECIAL(String name){
String clazz = name.split("\\.")[0];
String field = name.split("\\.")[1].split(" ")[0];
String sig = name.split("\\.")[1].split(" ")[1];
return new MethodInsnNode(Opcodes.INVOKESPECIAL, clazz, field, sig, false);
}
public static MethodInsnNode INVOKESPECIAL(String clazz, String field, String sig){
return new MethodInsnNode(Opcodes.INVOKESPECIAL, clazz, field, sig, false);
}
public static BiMap<String, Integer> Instructions;
static{
Instructions = HashBiMap.create();
Instructions.put("NOP",0); // visitInsn
Instructions.put("ACONST_NULL",1);
Instructions.put("ICONST_M1",2);
Instructions.put("ICONST_0",3);
Instructions.put("ICONST_1",4);
Instructions.put("ICONST_2",5);
Instructions.put("ICONST_3",6);
Instructions.put("ICONST_4",7);
Instructions.put("ICONST_5",8);
Instructions.put("LCONST_0",9);
Instructions.put("LCONST_1",10);
Instructions.put("FCONST_0",11);
Instructions.put("FCONST_1",12);
Instructions.put("FCONST_2",13);
Instructions.put("DCONST_0",14);
Instructions.put("DCONST_1",15);
Instructions.put("BIPUSH",16);
Instructions.put("SIPUSH",17);
Instructions.put("LDC",18);
Instructions.put("LDC_W",19);
Instructions.put("LDC2_W",20);
Instructions.put("ILOAD",21);
Instructions.put("LLOAD",22);
Instructions.put("FLOAD",23);
Instructions.put("DLOAD",24);
Instructions.put("ALOAD",25);
Instructions.put("ILOAD_0",26);
Instructions.put("ILOAD_1",27);
Instructions.put("ILOAD_2",28);
Instructions.put("ILOAD_3",29);
Instructions.put("LLOAD_0",30);
Instructions.put("LLOAD_1",31);
Instructions.put("LLOAD_2",32);
Instructions.put("LLOAD_3",33);
Instructions.put("FLOAD_0",34);
Instructions.put("FLOAD_1",35);
Instructions.put("FLOAD_2",36);
Instructions.put("FLOAD_3",37);
Instructions.put("DLOAD_0",38);
Instructions.put("DLOAD_1",39);
Instructions.put("DLOAD_2",40);
Instructions.put("DLOAD_3",41);
Instructions.put("ALOAD_0",42);
Instructions.put("ALOAD_1",43);
Instructions.put("ALOAD_2",44);
Instructions.put("ALOAD_3",45);
Instructions.put("IALOAD",46);
Instructions.put("LALOAD",47);
Instructions.put("FALOAD",48);
Instructions.put("DALOAD",49);
Instructions.put("AALOAD",50);
Instructions.put("BALOAD",51);
Instructions.put("CALOAD",52);
Instructions.put("SALOAD",53);
Instructions.put("ISTORE",54);
Instructions.put("LSTORE",55);
Instructions.put("FSTORE",56);
Instructions.put("DSTORE",57);
Instructions.put("ASTORE",58);
Instructions.put("ISTORE_0",59);
Instructions.put("ISTORE_1",60);
Instructions.put("ISTORE_2",61);
Instructions.put("ISTORE_3",62);
Instructions.put("LSTORE_0",63);
Instructions.put("LSTORE_1",64);
Instructions.put("LSTORE_2",65);
Instructions.put("LSTORE_3",66);
Instructions.put("FSTORE_0",67);
Instructions.put("FSTORE_1",68);
Instructions.put("FSTORE_2",69);
Instructions.put("FSTORE_3",70);
Instructions.put("DSTORE_0",71);
Instructions.put("DSTORE_1",72);
Instructions.put("DSTORE_2",73);
Instructions.put("DSTORE_3",74);
Instructions.put("ASTORE_0",75);
Instructions.put("ASTORE_1",76);
Instructions.put("ASTORE_2",77);
Instructions.put("ASTORE_3",78);
Instructions.put("IASTORE",79);
Instructions.put("LASTORE",80);
Instructions.put("FASTORE",81);
Instructions.put("DASTORE",82);
Instructions.put("AASTORE",83);
Instructions.put("BASTORE",84);
Instructions.put("CASTORE",85);
Instructions.put("SASTORE",86);
Instructions.put("POP",87);
Instructions.put("POP2",88);
Instructions.put("DUP",89);
Instructions.put("DUP_X1",90);
Instructions.put("DUP_X2",91);
Instructions.put("DUP2",92);
Instructions.put("DUP2_X1",93);
Instructions.put("DUP2_X2",94);
Instructions.put("SWAP",95);
Instructions.put("IADD",96);
Instructions.put("LADD",97);
Instructions.put("FADD",98);
Instructions.put("DADD",99);
Instructions.put("ISUB",100);
Instructions.put("LSUB",101);
Instructions.put("FSUB",102);
Instructions.put("DSUB",103);
Instructions.put("IMUL",104);
Instructions.put("LMUL",105);
Instructions.put("FMUL",106);
Instructions.put("DMUL",107);
Instructions.put("IDIV",108);
Instructions.put("LDIV",109);
Instructions.put("FDIV",110);
Instructions.put("DDIV",111);
Instructions.put("IREM",112);
Instructions.put("LREM",113);
Instructions.put("FREM",114);
Instructions.put("DREM",115);
Instructions.put("INEG",116);
Instructions.put("LNEG",117);
Instructions.put("FNEG",118);
Instructions.put("DNEG",119);
Instructions.put("ISHL",120);
Instructions.put("LSHL",121);
Instructions.put("ISHR",122);
Instructions.put("LSHR",123);
Instructions.put("IUSHR",124);
Instructions.put("LUSHR",125);
Instructions.put("IAND",126);
Instructions.put("LAND",127);
Instructions.put("IOR",128);
Instructions.put("LOR",129);
Instructions.put("IXOR",130);
Instructions.put("LXOR",131);
Instructions.put("IINC",132);
Instructions.put("I2L",133);
Instructions.put("I2F",134);
Instructions.put("I2D",135);
Instructions.put("L2I",136);
Instructions.put("L2F",137);
Instructions.put("L2D",138);
Instructions.put("F2I",139);
Instructions.put("F2L",140);
Instructions.put("F2D",141);
Instructions.put("D2I",142);
Instructions.put("D2L",143);
Instructions.put("D2F",144);
Instructions.put("I2B",145);
Instructions.put("I2C",146);
Instructions.put("I2S",147);
Instructions.put("LCMP",148);
Instructions.put("FCMPL",149);
Instructions.put("FCMPG",150);
Instructions.put("DCMPL",151);
Instructions.put("DCMPG",152);
Instructions.put("IFEQ",153);
Instructions.put("IFNE",154);
Instructions.put("IFLT",155);
Instructions.put("IFGE",156);
Instructions.put("IFGT",157);
Instructions.put("IFLE",158);
Instructions.put("IF_ICMPEQ",159);
Instructions.put("IF_ICMPNE",160);
Instructions.put("IF_ICMPLT",161);
Instructions.put("IF_ICMPGE",162);
Instructions.put("IF_ICMPGT",163);
Instructions.put("IF_ICMPLE",164);
Instructions.put("IF_ACMPEQ",165);
Instructions.put("IF_ACMPNE",166);
Instructions.put("GOTO",167);
Instructions.put("JSR",168);
Instructions.put("RET",169);
Instructions.put("TABLESWITCH",170);
Instructions.put("LOOKUPSWITCH",171);
Instructions.put("IRETURN",172);
Instructions.put("LRETURN",173);
Instructions.put("FRETURN",174);
Instructions.put("DRETURN",175);
Instructions.put("ARETURN",176);
Instructions.put("RETURN",177);
Instructions.put("GETSTATIC",178);
Instructions.put("PUTSTATIC",179);
Instructions.put("GETFIELD",180);
Instructions.put("PUTFIELD",181);
Instructions.put("INVOKEVIRTUAL",182);
Instructions.put("INVOKESPECIAL",183);
Instructions.put("INVOKESTATIC",184);
Instructions.put("INVOKEINTERFACE",185);
Instructions.put("INVOKEDYNAMIC",186);
Instructions.put("NEW",187);
Instructions.put("NEWARRAY",188);
Instructions.put("ANEWARRAY",189);
Instructions.put("ARRAYLENGTH",190);
Instructions.put("ATHROW",191);
Instructions.put("CHECKCAST",192);
Instructions.put("INSTANCEOF",193);
Instructions.put("MONITORENTER",194);
Instructions.put("MONITOREXIT",195);
Instructions.put("WIDE",196);
Instructions.put("MULTIANEWARRAY",197);
Instructions.put("IFNULL",198);
Instructions.put("IFNONNULL",199);
Instructions.put("GOTO_W",200);
Instructions.put("JSR_W",201);
}
}
@@ -0,0 +1,429 @@
package mcp.mobius.mobiuscore.asm.transformers;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import mcp.mobius.mobiuscore.asm.MethodDescriptor;
import mcp.mobius.mobiuscore.asm.Opcode;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.util.Printer;
import org.objectweb.asm.util.Textifier;
import org.objectweb.asm.util.TraceClassVisitor;
import org.objectweb.asm.util.TraceMethodVisitor;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.LabelNode;
public abstract class TransformerBase {
HashMap<String, List<MethodDescriptor>> methodsToOverwrite = new HashMap<String, List<MethodDescriptor>>();
HashMap<String, List<MethodDescriptor>> methodsToInject = new HashMap<String, List<MethodDescriptor>>();
public abstract byte[] transform(String name, String srgname, byte[] bytes);
protected ArrayList<ArrayList<AbstractInsnNode>> findPattern(MethodNode methodNode, AbstractInsnNode... pattern){
return findPattern( methodNode, false, pattern);
}
protected ArrayList<ArrayList<AbstractInsnNode>> findPattern(MethodNode methodNode, boolean dumpOpcodes, AbstractInsnNode... pattern){
InsnList instructions = methodNode.instructions;
ArrayList<ArrayList<AbstractInsnNode>> returnList = new ArrayList<ArrayList<AbstractInsnNode>>();
//We are going to check all the intructions in the method to find pattens
for (int indexFirstInst = 0; indexFirstInst < instructions.size(); indexFirstInst++){
AbstractInsnNode currNode = instructions.get(indexFirstInst);
if (dumpOpcodes)
printInsnNode(currNode);
//We found the first element of the pattern. We are starting matching all the elements
if (this.areInsnEqual(currNode, pattern[0]));{
boolean match = true;
//We are forward matching all the instructions to see if they are ok. By the end of this loop, match is false if at least one inst doesn't match
for (int indexPatternInst = 0; indexPatternInst < pattern.length; indexPatternInst++){
try{
match = match && this.areInsnEqual(instructions.get(indexFirstInst + indexPatternInst) , pattern[indexPatternInst]);
} catch (ArrayIndexOutOfBoundsException e){
return returnList; // This can only happen if there is less than the number of pattern elements in the remaining instructions. We can return the current results directly.
}
}
// All the instructions are equal, we create a new ArrayList and add it to the return list
if (match){
ArrayList<AbstractInsnNode> matchedPattern = new ArrayList<AbstractInsnNode>();
for (int indexPatternInst = 0; indexPatternInst < pattern.length; indexPatternInst++){
matchedPattern.add(instructions.get(indexFirstInst + indexPatternInst));
}
returnList.add(matchedPattern);
}
}
}
return returnList;
}
protected boolean areInsnEqual(AbstractInsnNode insn1, AbstractInsnNode insn2){
if (!insn1.getClass().equals(insn2.getClass())) return false;
if (insn1.getOpcode() != insn2.getOpcode()) return false;
if (insn1 instanceof LineNumberNode){
if ((((LineNumberNode)insn2).line == -1) || (((LineNumberNode)insn2).line == -1)) return true;
if (((LineNumberNode)insn2).line != ((LineNumberNode)insn2).line) return false;
if (((LineNumberNode)insn2).line == ((LineNumberNode)insn2).line) return true;
}
if (insn1 instanceof VarInsnNode){
if ((((VarInsnNode)insn2).var == -1) || (((VarInsnNode)insn2).var == -1)) return true;
if (((VarInsnNode)insn2).var != ((VarInsnNode)insn2).var) return false;
if (((VarInsnNode)insn2).var == ((VarInsnNode)insn2).var) return true;
}
if (insn1 instanceof MethodInsnNode){
if ((((MethodInsnNode)insn1).owner.equals(((MethodInsnNode)insn2).owner)) &&
(((MethodInsnNode)insn1).name.equals(((MethodInsnNode)insn2).name)) &&
(((MethodInsnNode)insn1).desc.equals(((MethodInsnNode)insn2).desc)))
return true;
}
if (insn1 instanceof FieldInsnNode){
if ((((FieldInsnNode)insn1).owner.equals(((FieldInsnNode)insn2).owner)) &&
(((FieldInsnNode)insn1).name.equals(((FieldInsnNode)insn2).name)) &&
(((FieldInsnNode)insn1).desc.equals(((FieldInsnNode)insn2).desc)))
return true;
}
if (insn1 instanceof InsnNode){
if (insn1.getOpcode() == insn2.getOpcode())
return true;
}
if (insn1 instanceof TypeInsnNode){
if (((TypeInsnNode)insn1).desc.equals(((TypeInsnNode)insn2).desc))
return true;
}
return false;
}
protected void printInsnNode (AbstractInsnNode insnNode){
switch(insnNode.getType()){
case AbstractInsnNode.LINE:
CoreDescription.log.info(String.format("LINE : %s", ((LineNumberNode)insnNode).line));
break;
case AbstractInsnNode.LABEL:
CoreDescription.log.info(String.format("LINE : %s", ((LabelNode)insnNode).getLabel()));
break;
case AbstractInsnNode.VAR_INSN:
CoreDescription.log.info(String.format("VAR_INSN : %s %s", Opcode.Instructions.inverse().get(insnNode.getOpcode()), ((VarInsnNode)insnNode).var));
break;
case AbstractInsnNode.METHOD_INSN:
CoreDescription.log.info(String.format("METHOD_INSN : %s %s %s %s", Opcode.Instructions.inverse().get(insnNode.getOpcode()), ((MethodInsnNode)insnNode).owner, ((MethodInsnNode)insnNode).name, ((MethodInsnNode)insnNode).desc));
break;
case AbstractInsnNode.INSN:
CoreDescription.log.info(String.format("INSN : %s", Opcode.Instructions.inverse().get(insnNode.getOpcode())));
break;
case AbstractInsnNode.TYPE_INSN:
CoreDescription.log.info(String.format("TYPE_INSN : %s %s", Opcode.Instructions.inverse().get(insnNode.getOpcode()), ((TypeInsnNode)insnNode).desc ));
break;
case AbstractInsnNode.FIELD_INSN:
CoreDescription.log.info(String.format("FIELD_INSN : %s %s %s %s", Opcode.Instructions.inverse().get(insnNode.getOpcode()), ((FieldInsnNode)insnNode).owner, ((FieldInsnNode)insnNode).name, ((FieldInsnNode)insnNode).desc));
break;
default:
CoreDescription.log.info(String.format(" %s %s", Opcode.Instructions.inverse().get(insnNode.getOpcode()), insnNode));
break;
}
}
protected void printMethod(MethodNode methodNode){
InsnList instructions = methodNode.instructions;
for (int indexFirstInst = 0; indexFirstInst < instructions.size(); indexFirstInst++){
AbstractInsnNode currNode = instructions.get(indexFirstInst);
printInsnNode(currNode);
}
}
private void applyPayloadAfter(InsnList instructions, ArrayList<AbstractInsnNode> match, AbstractInsnNode[] payload_pattern){
InsnList payload = new InsnList();
for (int i = 0; i < payload_pattern.length; i++)
payload.add(payload_pattern[i]);
instructions.insert(match.get(match.size() - 1), payload);
}
private void applyPayloadBefore(InsnList instructions, ArrayList<AbstractInsnNode> match, AbstractInsnNode[] payload_pattern){
InsnList payload = new InsnList();
for (int i = 0; i < payload_pattern.length; i++)
payload.add(payload_pattern[i]);
instructions.insertBefore(match.get(0), payload);
}
protected void applyPayloadBefore(MethodNode methodNode, AbstractInsnNode[] pattern, AbstractInsnNode[] payload){
ArrayList<ArrayList<AbstractInsnNode>> match;
match = this.findPattern(methodNode, pattern);
if (match.size() != 0){
for (ArrayList<AbstractInsnNode> sublist : match){
this.applyPayloadBefore(methodNode.instructions, sublist, payload);
}
CoreDescription.log.info(String.format("Successful injection in %s %s", methodNode.name, methodNode.desc));
return;
}
throw new RuntimeException(String.format("Pattern not found while trying to inject into %s", methodNode.name));
}
protected void applyPayloadAfter(MethodNode methodNode, AbstractInsnNode[] pattern, AbstractInsnNode[] payload){
ArrayList<ArrayList<AbstractInsnNode>> match;
match = this.findPattern(methodNode, pattern);
if (match.size() != 0){
for (ArrayList<AbstractInsnNode> sublist : match){
this.applyPayloadAfter(methodNode.instructions, sublist, payload);
}
CoreDescription.log.info(String.format("Successful injection in %s %s", methodNode.name, methodNode.desc));
return;
}
this.printMethod(methodNode);
throw new RuntimeException(String.format("Pattern not found while trying to inject into %s", methodNode.name));
}
protected void applyPayloadFirst(MethodNode methodNode, AbstractInsnNode[] payload_pattern){
InsnList instructions = methodNode.instructions;
InsnList payload = new InsnList();
for (int i = 0; i < payload_pattern.length; i++)
payload.add(payload_pattern[i]);
instructions.insertBefore(instructions.getFirst(), payload);
CoreDescription.log.info(String.format("Successful injection in %s %s", methodNode.name, methodNode.desc));
}
protected void applyPayloadLast(MethodNode methodNode, AbstractInsnNode[] payload_pattern){
InsnList instructions = methodNode.instructions;
InsnList payload = new InsnList();
for (int i = 0; i < payload_pattern.length; i++)
payload.add(payload_pattern[i]);
for (int i = instructions.size() - 1; i >= 0; i--){
if ((instructions.get(i).getOpcode() == Opcodes.RETURN) || (instructions.get(i).getOpcode() == Opcodes.IRETURN)){
instructions.insertBefore(instructions.get(i), payload);
}
}
CoreDescription.log.info(String.format("Successful injection in %s %s", methodNode.name, methodNode.desc));
}
/*
* Will return a byte array of the content of the named class in the coremod jar
*/
protected byte[] getJarClass(String transformedName){
byte[] bytes = null;
try
{
ZipFile zip = new ZipFile(CoreDescription.location);
ZipEntry entry = zip.getEntry(transformedName.replace('.', '/')+".class");
//ZipEntry entry = zip.getEntry(name.replace('.', '/')+".class");
if(entry == null)
CoreDescription.log.error(transformedName + " not found in " + CoreDescription.location.getName());
else
{
InputStream zin = zip.getInputStream(entry);
bytes = new byte[(int) entry.getSize()];
zin.read(bytes);
zin.close();
}
zip.close();
}
catch(Exception e)
{
throw new RuntimeException("Error overriding "+transformedName+" from "+CoreDescription.location.getName(), e);
}
return bytes;
}
/*
* Overwrite method X with signature Y with the method from inside the coremod jar.
*/
protected byte[] overwriteMethod(String className, MethodDescriptor methodDesc, byte[] vanillaBytes){
byte[] coremodBytes = this.getJarClass(className);
ClassNode vanillaNode = new ClassNode();
ClassReader vanillaReader = new ClassReader(vanillaBytes);
ClassNode coremodNode = new ClassNode();
ClassReader coremodReader = new ClassReader(coremodBytes);
vanillaReader.accept(vanillaNode, 0);
coremodReader.accept(coremodNode, 0);
MethodNode vanillaMethodNode = null;
for (MethodNode node: vanillaNode.methods){
try{
if (node != null && node.desc.equals(methodDesc.getDescriptor()) && (node.name.equals(methodDesc.getMethodName()))){
CoreDescription.log.info(String.format("Found method node %s.%s %s in Vanilla.", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
vanillaMethodNode = node;
}
} catch (Exception e){
//System.out.printf("Error while parsing %s %s\n", className, node);
}
}
MethodNode coremodMethodNode = null;
for (MethodNode node: coremodNode.methods){
try{
if (node != null && node.desc.equals(methodDesc.getDescriptor()) && (node.name.equals(methodDesc.getMethodName()))){
CoreDescription.log.info(String.format("Found method node %s.%s %s in Coremod.", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
coremodMethodNode = node;
}
} catch (Exception e){
//System.out.printf("Error while parsing %s %s\n", className, node);
}
}
if (vanillaMethodNode == null){
CoreDescription.log.fatal(String.format("Method node %s.%s %s not found in Vanilla ! This is going to crash !.", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
}
if (coremodMethodNode == null){
CoreDescription.log.fatal(String.format("Method node %s.%s %s not found in Coremod ! This is going to crash !.", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
}
vanillaNode.methods.remove(vanillaMethodNode);
coremodMethodNode.accept(vanillaNode);
//vanillaNode.methods.add(coremodMethodNode);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
vanillaNode.accept(writer);
return writer.toByteArray();
}
/*
* Inject a new method with a new signature to the list of methods.
*/
protected byte[] injectMethod(String className, MethodDescriptor methodDesc, byte[] vanillaBytes){
try{
byte[] coremodBytes = this.getJarClass(className);
ClassNode vanillaNode = new ClassNode();
ClassReader vanillaReader = new ClassReader(vanillaBytes);
ClassNode coremodNode = new ClassNode();
ClassReader coremodReader = new ClassReader(coremodBytes);
vanillaReader.accept(vanillaNode, 0);
coremodReader.accept(coremodNode, 0);
MethodNode coremodMethodNode = null;
for (MethodNode node: coremodNode.methods){
try{
if (node != null && node.desc.equals(methodDesc.getDescriptor()) && (node.name.equals(methodDesc.getMethodName()))){
CoreDescription.log.info(String.format("Found method node %s.%s %s in Coremod. Injecting !", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
coremodMethodNode = node;
}
} catch (Exception e){
//System.out.printf("Error while parsing %s %s\n", className, node);
}
}
if (coremodMethodNode == null){
CoreDescription.log.fatal(String.format("Method node %s.%s %s not found in Coremod ! This is going to crash !.", className, methodDesc.getMethodName(), methodDesc.getDescriptor()));
}
coremodMethodNode.accept(vanillaNode);
//vanillaNode.methods.add(coremodMethodNode);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
vanillaNode.accept(writer);
return writer.toByteArray();
} catch (ClassFormatError e){
CoreDescription.log.warn("Class already injected.");
return vanillaBytes;
}
}
public static String dumpChecksum(byte[] data, String obf, String searge){
try{
//System.out.printf("[MobiusCore] Found %s with checksum %s\n", filename, MessageDigest.getInstance("MD5").digest(data));
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(data);
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
hashtext = "0"+hashtext;
}
if (obf.equals(searge))
CoreDescription.log.info(String.format("Found %s with checksum %s", searge, hashtext.toUpperCase()));
else
CoreDescription.log.info(String.format("[MobiusCore] Found %s [ %s ] with checksum %s", searge, obf, hashtext.toUpperCase()));
return hashtext.toUpperCase();
}
catch (Exception e) {
}
return "00000000000000000000000000000000";
}
protected MethodNode getMethod(ClassNode classNode, String methodName){
for (MethodNode methodNode : classNode.methods)
if (String.format("%s %s", methodNode.name, methodNode.desc).equals(methodName))
return methodNode;
throw new RuntimeException(String.format("Method %s not found in %s\n", methodName, classNode.name));
}
protected List<MethodNode> getMethods(ClassNode classNode, String methodName){
List<MethodNode> methods = new ArrayList<MethodNode>();
for (MethodNode methodNode : classNode.methods)
if (methodNode.name.equals(methodName))
methods.add(methodNode);
if (methods.size() > 0)
return methods;
else
throw new RuntimeException(String.format("Method %s not found in %s\n", methodName, classNode.name));
}
}
@@ -0,0 +1,99 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import static org.objectweb.asm.Opcodes.*;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
public class TransformerASMEventHandler extends TransformerBase {
/* SHOULD WORK BOTH SIDES */
private static String ASMEH_INVOKE;
private static String ASMEH_INIT;
private static AbstractInsnNode[] ASMEH_INVOKE_PATTERN;
private static AbstractInsnNode[] ASMEH_INVOKE_PAYLOAD_PRE;
private static AbstractInsnNode[] ASMEH_INVOKE_PAYLOAD_POST;
private static AbstractInsnNode[] ASMEH_INIT_PAYLOAD_PRE;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
ASMEH_INVOKE = "invoke (Lcpw/mods/fml/common/eventhandler/Event;)V";
ASMEH_INIT = "<init> (Ljava/lang/Object;Ljava/lang/reflect/Method;Lcpw/mods/fml/common/ModContainer;)V";
ASMEH_INVOKE_PATTERN = new AbstractInsnNode[]
{
Opcode.ALOAD(-1),
Opcode.GETFIELD("cpw/mods/fml/common/eventhandler/ASMEventHandler.handler Lcpw/mods/fml/common/eventhandler/IEventListener;"),
Opcode.ALOAD(-1),
Opcode.INVOKEINTERFACE("cpw/mods/fml/common/eventhandler/IEventListener.invoke (Lcpw/mods/fml/common/eventhandler/Event;)V")
};
ASMEH_INIT_PAYLOAD_PRE = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL("java/lang/reflect/Method.getDeclaringClass ()Ljava/lang/Class;"),
Opcode.INVOKEVIRTUAL("java/lang/Class.getCanonicalName ()Ljava/lang/String;"),
Opcode.PUTFIELD("cpw/mods/fml/common/eventhandler/ASMEventHandler.package_ Ljava/lang/String;"),
};
ASMEH_INVOKE_PAYLOAD_PRE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.EVENT_INVOKE.name(), profilerType),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "()V")
};
ASMEH_INVOKE_PAYLOAD_POST = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.EVENT_INVOKE.name(), profilerType),
Opcode.ALOAD(1),
Opcode.ALOAD(0),
Opcode.GETFIELD("cpw/mods/fml/common/eventhandler/ASMEventHandler.package_ Ljava/lang/String;"),
Opcode.ALOAD(0),
Opcode.GETFIELD("cpw/mods/fml/common/eventhandler/ASMEventHandler.handler Lcpw/mods/fml/common/eventhandler/IEventListener;"),
Opcode.ALOAD(0),
Opcode.GETFIELD("cpw/mods/fml/common/eventhandler/ASMEventHandler.owner Lcpw/mods/fml/common/ModContainer;"),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V")
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode initNode = this.getMethod(classNode, ASMEH_INIT);
this.applyPayloadFirst(initNode, ASMEH_INIT_PAYLOAD_PRE);
MethodNode invokeNode = this.getMethod(classNode, ASMEH_INVOKE);
this.applyPayloadBefore(invokeNode, ASMEH_INVOKE_PATTERN, ASMEH_INVOKE_PAYLOAD_PRE);
this.applyPayloadAfter (invokeNode, ASMEH_INVOKE_PATTERN, ASMEH_INVOKE_PAYLOAD_POST);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
writer.visitField(ACC_PRIVATE + ACC_FINAL, "package_", "Ljava/lang/String;", null, null);
return writer.toByteArray();
}
}
@@ -0,0 +1,94 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
public class TransformerFMLCommonHandler extends TransformerBase {
//(Ljava/util/EnumSet<Lcpw/mods/fml/common/TickType;>;Lcpw/mods/fml/relauncher/Side;[Ljava/lang/Object;)V
private static String FMLCH_ONPRESERVERTICK;
private static String FMLCH_ONPOSTSERVERTICK;
private static String FMLCH_ONPREWORLDTICK;
private static String FMLCH_ONPOSTWORLDTICK;
private static AbstractInsnNode[] FMLCH_PAYLOAD_PRESERVERTICK;
private static AbstractInsnNode[] FMLCH_PAYLOAD_POSTSERVERTICK;
private static AbstractInsnNode[] FMLCH_PAYLOAD_PREWORLDTICK;
private static AbstractInsnNode[] FMLCH_PAYLOAD_POSTWORLDTICK;
private static boolean isEclipse;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
FMLCH_ONPRESERVERTICK = "onPreServerTick ()V";
FMLCH_ONPOSTSERVERTICK = "onPostServerTick ()V";
FMLCH_ONPREWORLDTICK = ObfTable.FMLCH_PREWORLDTICK.getFullDescriptor();
FMLCH_ONPOSTWORLDTICK = ObfTable.FMLCH_POSTWORLDTICK.getFullDescriptor();
FMLCH_PAYLOAD_PRESERVERTICK = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TICK.name(), profilerType),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "()V"),
};
FMLCH_PAYLOAD_POSTSERVERTICK = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TICK.name(), profilerType),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "()V"),
};
FMLCH_PAYLOAD_PREWORLDTICK = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.DIMENSION_TICK.name(), profilerType),
Opcode.ALOAD(1),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")};
FMLCH_PAYLOAD_POSTWORLDTICK = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.DIMENSION_TICK.name(), profilerType),
Opcode.ALOAD(1),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode preServerTickNode = this.getMethod(classNode, FMLCH_ONPRESERVERTICK);
this.applyPayloadFirst(preServerTickNode, FMLCH_PAYLOAD_PRESERVERTICK);
MethodNode postServerTickNode = this.getMethod(classNode, FMLCH_ONPOSTSERVERTICK);
this.applyPayloadLast(postServerTickNode, FMLCH_PAYLOAD_POSTSERVERTICK);
MethodNode preworldTick = this.getMethod(classNode, FMLCH_ONPREWORLDTICK);
this.applyPayloadFirst(preworldTick, FMLCH_PAYLOAD_PREWORLDTICK);
MethodNode postWorldTick = this.getMethod(classNode, FMLCH_ONPOSTWORLDTICK);
this.applyPayloadLast(postWorldTick, FMLCH_PAYLOAD_POSTWORLDTICK);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,58 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
public class TransformerFMLOutboundHandler extends TransformerBase {
private static String FMLOH_WRITE;
private static AbstractInsnNode[] FMLOH_WRITE_PATTERN;
private static AbstractInsnNode[] FMLOH_WRITE_PAYLOAD;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
FMLOH_WRITE = "write (Lio/netty/channel/ChannelHandlerContext;Ljava/lang/Object;Lio/netty/channel/ChannelPromise;)V";
FMLOH_WRITE_PATTERN = new AbstractInsnNode[]
{
Opcode.INVOKEVIRTUAL("cpw/mods/fml/common/network/handshake/NetworkDispatcher.sendProxy (Lcpw/mods/fml/common/network/internal/FMLProxyPacket;)V"),
};
FMLOH_WRITE_PAYLOAD = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.PACKET_OUTBOUND.name(), profilerType),
Opcode.ALOAD(4),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V"),
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode write = this.getMethod(classNode, FMLOH_WRITE);
this.applyPayloadAfter(write, FMLOH_WRITE_PATTERN, FMLOH_WRITE_PAYLOAD);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,53 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
public class TransformerFMLProxyPacket extends TransformerBase {
private static String FMLPP_PROCESS;
private static AbstractInsnNode[] FMLPP_PROCESS_PAYLOAD;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
FMLPP_PROCESS = ObfTable.FMLPP_PROCESSPACKET.getFullDescriptor();
FMLPP_PROCESS_PAYLOAD = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.PACKET_INBOUND.name(), profilerType),
Opcode.ALOAD(0),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V"),
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode process = this.getMethod(classNode, FMLPP_PROCESS);
this.applyPayloadFirst(process, FMLPP_PROCESS_PAYLOAD);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,67 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
public class TransformerMessageDeserializer extends TransformerBase {
private static String DESERIALIZER_DECODE;
private static AbstractInsnNode[] DESERIALIZER_PATTERN;
private static AbstractInsnNode[] DESERIALIZER_PAYLOAD;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
DESERIALIZER_DECODE = ObfTable.DESERIALIZER_DECODE.getFullDescriptor();
DESERIALIZER_PATTERN = new AbstractInsnNode[]
{
new VarInsnNode (Opcodes.ALOAD, -1),
new VarInsnNode (Opcodes.ALOAD, -1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ObfTable.PACKET_READPACKETDATA.getClazz(), ObfTable.PACKET_READPACKETDATA.getName(), ObfTable.PACKET_READPACKETDATA.getDescriptor(), false),
};
DESERIALIZER_PAYLOAD = new AbstractInsnNode[]
{
new FieldInsnNode (Opcodes.GETSTATIC, profilerClass, ProfilerSection.PACKET_INBOUND.name(), profilerType),
new VarInsnNode (Opcodes.ALOAD, 7),
new VarInsnNode (Opcodes.ALOAD, 5),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ObfTable.PACKETBUFFER_CAPACITY.getClazz(), ObfTable.PACKETBUFFER_CAPACITY.getName(), ObfTable.PACKETBUFFER_CAPACITY.getDescriptor(), false),
new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "start", "(Ljava/lang/Object;Ljava/lang/Object;)V", false),
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode decode = this.getMethod(classNode, DESERIALIZER_DECODE);
this.applyPayloadBefore(decode, DESERIALIZER_PATTERN, DESERIALIZER_PAYLOAD);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES |ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,66 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
public class TransformerMessageSerializer extends TransformerBase {
private static String SERIALIZER_ENCODE;
private static AbstractInsnNode[] SERIALIZER_PATTERN;
private static AbstractInsnNode[] SERIALIZER_PAYLOAD;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
SERIALIZER_ENCODE = ObfTable.SERIALIZER_ENCODE.getFullDescriptor();
SERIALIZER_PATTERN = new AbstractInsnNode[]
{
new VarInsnNode (Opcodes.ALOAD, -1),
new VarInsnNode (Opcodes.ALOAD, -1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ObfTable.PACKET_WRITEPACKETDATA.getClazz(), ObfTable.PACKET_WRITEPACKETDATA.getName(), ObfTable.PACKET_WRITEPACKETDATA.getDescriptor(), false)
};
SERIALIZER_PAYLOAD = new AbstractInsnNode[]
{
new FieldInsnNode (Opcodes.GETSTATIC, profilerClass, ProfilerSection.PACKET_OUTBOUND.name(), profilerType),
new VarInsnNode (Opcodes.ALOAD, 2),
new VarInsnNode (Opcodes.ALOAD, 5),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, ObfTable.PACKETBUFFER_READABLE.getClazz(), ObfTable.PACKETBUFFER_READABLE.getName(), ObfTable.PACKETBUFFER_READABLE.getDescriptor(), false),
new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "start", "(Ljava/lang/Object;Ljava/lang/Object;)V", false),
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode encode = this.getMethod(classNode, SERIALIZER_ENCODE);
this.applyPayloadAfter(encode, SERIALIZER_PATTERN, SERIALIZER_PAYLOAD);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES |ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,75 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.tree.AbstractInsnNode;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class TransformerRenderManager extends TransformerBase {
//private static String RM_RENDERENT;
//private static String RM_RENDERPOSYAW;
private static String RM_RENDER;
private static AbstractInsnNode[] RM_RENDER_PAYLOAD_TOP;
private static AbstractInsnNode[] RM_RENDER_PAYLOAD_BOTTOM;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
//RM_RENDERENT = ObfTable.RENDERMANAGER_RENDERENTITY.getFullDescriptor();
//RM_RENDERPOSYAW = ObfTable.RENDERMANAGER_RENDERPOSYAW.getFullDescriptor();
RM_RENDER = ObfTable.RENDERMANAGER_RENDER.getFullDescriptor();
RM_RENDER_PAYLOAD_TOP = new AbstractInsnNode[]
{new FieldInsnNode(Opcodes.GETSTATIC, profilerClass, ProfilerSection.RENDER_ENTITY.name(), profilerType),
new VarInsnNode(Opcodes.ALOAD, 1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "start", "(Ljava/lang/Object;)V", false)};
RM_RENDER_PAYLOAD_BOTTOM = new AbstractInsnNode[]
{new FieldInsnNode(Opcodes.GETSTATIC, profilerClass, ProfilerSection.RENDER_ENTITY.name(), profilerType),
new VarInsnNode(Opcodes.ALOAD, 1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "stop", "(Ljava/lang/Object;)V", false)};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode renderEntNode = this.getMethod(classNode, RM_RENDER);
this.applyPayloadFirst(renderEntNode, RM_RENDER_PAYLOAD_TOP);
this.applyPayloadLast (renderEntNode, RM_RENDER_PAYLOAD_BOTTOM);
/*
MethodNode renderPosYawNode = this.getMethod(classNode, RM_RENDERPOSYAW);
this.applyPayloadFirst(renderPosYawNode, RM_RENDER_PAYLOAD_TOP);
this.applyPayloadLast (renderPosYawNode, RM_RENDER_PAYLOAD_BOTTOM);
*/
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,63 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import org.objectweb.asm.tree.AbstractInsnNode;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class TransformerTERenderer extends TransformerBase {
private static String TER_RENDER;
private static AbstractInsnNode[] TER_RENDER_PAYLOAD_TOP;
private static AbstractInsnNode[] TER_RENDER_PAYLOAD_BOTTOM;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
//TER_RENDER = "a (Lasp;F)V";
TER_RENDER = ObfTable.TERENDER_RENDERAT.getFullDescriptor();
TER_RENDER_PAYLOAD_TOP = new AbstractInsnNode[]
{new FieldInsnNode(Opcodes.GETSTATIC, profilerClass, ProfilerSection.RENDER_TILEENTITY.name(), profilerType),
new VarInsnNode(Opcodes.ALOAD, 1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "start", "(Ljava/lang/Object;)V", false)};
TER_RENDER_PAYLOAD_BOTTOM = new AbstractInsnNode[]
{new FieldInsnNode(Opcodes.GETSTATIC, profilerClass, ProfilerSection.RENDER_TILEENTITY.name(), profilerType),
new VarInsnNode(Opcodes.ALOAD, 1),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "stop", "(Ljava/lang/Object;)V", false)};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode renderEntNode = this.getMethod(classNode, TER_RENDER);
this.applyPayloadFirst(renderEntNode, TER_RENDER_PAYLOAD_TOP);
this.applyPayloadLast (renderEntNode, TER_RENDER_PAYLOAD_BOTTOM);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,81 @@
package mcp.mobius.mobiuscore.asm.transformers.common;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class TransformerWorldServer extends TransformerBase {
private static String WORLDSERVER_TICK;
private static AbstractInsnNode[] WORLDSERVER_PAYLOAD_TICKSTART;
private static AbstractInsnNode[] WORLDSERVER_PAYLOAD_TICKEND;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
WORLDSERVER_TICK = ObfTable.WORLDSERVER_TICK.getFullDescriptor();
/*
WORLDSERVER_PAYLOAD_TICKSTART = new AbstractInsnNode[]
{
new FieldInsnNode (Opcodes.GETSTATIC, "mcp/mobius/mobiuscore/profiler/ProfilerRegistrar", "profilerWorldTick", "Lmcp/mobius/mobiuscore/profiler/IProfilerWorldTick;"),
new VarInsnNode (Opcodes.ALOAD, 0),
new FieldInsnNode (Opcodes.GETFIELD, "net/minecraft/world/WorldServer", "provider", "Lnet/minecraft/world/WorldProvider;"),
new FieldInsnNode (Opcodes.GETFIELD, "net/minecraft/world/WorldProvider", "dimensionId", "I"),
new MethodInsnNode(Opcodes.INVOKEINTERFACE, "mcp/mobius/mobiuscore/profiler/IProfilerWorldTick", "WorldTickStart", "(I)V"),
};
*/
WORLDSERVER_PAYLOAD_TICKSTART = new AbstractInsnNode[]
{
new FieldInsnNode (Opcodes.GETSTATIC, profilerClass, ProfilerSection.DIMENSION_BLOCKTICK.name(), profilerType),
new VarInsnNode (Opcodes.ALOAD, 0),
new FieldInsnNode (Opcodes.GETFIELD, ObfTable.WORLD_PROVIDER.getClazz(), ObfTable.WORLD_PROVIDER.getName(), ObfTable.WORLD_PROVIDER.getDescriptor()),
new FieldInsnNode (Opcodes.GETFIELD, ObfTable.WORLDPROVIDER_DIMID.getClazz(), ObfTable.WORLDPROVIDER_DIMID.getName(), ObfTable.WORLDPROVIDER_DIMID.getDescriptor()),
new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "start", "(Ljava/lang/Object;)V", false),
};
WORLDSERVER_PAYLOAD_TICKEND = new AbstractInsnNode[]
{
new FieldInsnNode (Opcodes.GETSTATIC, profilerClass, ProfilerSection.DIMENSION_BLOCKTICK.name(), profilerType),
new VarInsnNode (Opcodes.ALOAD, 0),
new FieldInsnNode (Opcodes.GETFIELD, ObfTable.WORLD_PROVIDER.getClazz(), ObfTable.WORLD_PROVIDER.getName(), ObfTable.WORLD_PROVIDER.getDescriptor()),
new FieldInsnNode (Opcodes.GETFIELD, ObfTable.WORLDPROVIDER_DIMID.getClazz(), ObfTable.WORLDPROVIDER_DIMID.getName(), ObfTable.WORLDPROVIDER_DIMID.getDescriptor()),
new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false),
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, profilerClass, "stop", "(Ljava/lang/Object;)V", false),
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes) {
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode tickNode = this.getMethod(classNode, WORLDSERVER_TICK);
this.applyPayloadFirst(tickNode, WORLDSERVER_PAYLOAD_TICKSTART);
this.applyPayloadLast (tickNode, WORLDSERVER_PAYLOAD_TICKEND);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES |ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,175 @@
package mcp.mobius.mobiuscore.asm.transformers.forge;
import static org.objectweb.asm.Opcodes.ACC_FINAL;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.LineNumberNode;
public class TransformerWorld extends TransformerBase{
private static String WORLD_UPDATEENTITIES;
private static String WORLD_INIT;
//tileentity.updateEntity(); World:2215
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Start(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Stop(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE;
//this.updateEntity(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Start(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Stop(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDTILES;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDTILES;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
WORLD_UPDATEENTITIES = ObfTable.WORLD_UPDATEENTITIES.getFullDescriptor(); //updateEntities.getFullDescriptor();
WORLD_INIT = ObfTable.WORLD_INIT.getFullDescriptor();
WORLD_UPDATE_PATTERN_TEUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.TILEENTITY_UPDATEENTITY.getClazz(), ObfTable.TILEENTITY_UPDATEENTITY.getName(), ObfTable.TILEENTITY_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(8),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(8),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PATTERN_ENTUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.WORLD_UPDATEENTITY.getClazz(), ObfTable.WORLD_UPDATEENTITY.getName(), ObfTable.WORLD_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_PATTERN_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PATTERN_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
WORLD_PAYLOAD_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredEntityList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredEntityList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PAYLOAD_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredTileList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredTileList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes){
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode updateEntitiesNode = this.getMethod(classNode, WORLD_UPDATEENTITIES);
CoreDescription.log.info("Found World.updateEntities()...");
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_START_TEUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE);
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_START_ENTUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE);
MethodNode initNode = this.getMethod(classNode, WORLD_INIT);
CoreDescription.log.info(String.format("Found World.%s %s", initNode.name, initNode.desc));
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDENTS, WORLD_PAYLOAD_LOADEDENTS);
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDTILES, WORLD_PAYLOAD_LOADEDTILES);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,164 @@
package mcp.mobius.mobiuscore.asm.transformers.kcauldron;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.*;
public class TransformerWorldKCauldron extends TransformerBase{
private static String WORLD_UPDATEENTITIES;
private static String WORLD_INIT;
//tileentity.updateEntity(); World:2215
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Start(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Stop(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE;
//this.updateEntity(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Start(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Stop(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDTILES;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDTILES;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
WORLD_UPDATEENTITIES = ObfTable.WORLD_UPDATEENTITIES.getFullDescriptor(); //updateEntities.getFullDescriptor();
WORLD_INIT = ObfTable.WORLD_INIT.getFullDescriptor();
WORLD_UPDATE_PATTERN_TEUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.TILEENTITY_UPDATEENTITY.getClazz(), ObfTable.TILEENTITY_UPDATEENTITY.getName(), ObfTable.TILEENTITY_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(9),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(9),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PATTERN_ENTUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.WORLD_UPDATEENTITY.getClazz(), ObfTable.WORLD_UPDATEENTITY.getName(), ObfTable.WORLD_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_PATTERN_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PATTERN_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
WORLD_PAYLOAD_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredEntityList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredEntityList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PAYLOAD_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredTileList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredTileList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes){
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode updateEntitiesNode = this.getMethod(classNode, WORLD_UPDATEENTITIES);
CoreDescription.log.info("Found World.updateEntities()...");
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_START_TEUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE);
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_START_ENTUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE);
MethodNode initNode = this.getMethod(classNode, WORLD_INIT);
CoreDescription.log.info(String.format("Found World.%s %s", initNode.name, initNode.desc));
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDENTS, WORLD_PAYLOAD_LOADEDENTS);
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDTILES, WORLD_PAYLOAD_LOADEDTILES);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,169 @@
package mcp.mobius.mobiuscore.asm.transformers.mcpc;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.LineNumberNode;
public class TransformerWorldCauldron extends TransformerBase{
private static String WORLD_UPDATEENTITIES;
private static String WORLD_INIT;
//tileentity.updateEntity(); World:2215
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Start(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Stop(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE;
//this.updateEntity(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Start(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Stop(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDTILES;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDTILES;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
WORLD_UPDATEENTITIES = ObfTable.WORLD_UPDATEENTITIES.getFullDescriptor(); //updateEntities.getFullDescriptor();
WORLD_INIT = ObfTable.WORLD_INIT.getFullDescriptor();
WORLD_UPDATE_PATTERN_TEUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.TILEENTITY_UPDATEENTITY.getClazz(), ObfTable.TILEENTITY_UPDATEENTITY.getName(), ObfTable.TILEENTITY_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(8),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(8),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PATTERN_ENTUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.WORLD_UPDATEENTITY.getClazz(), ObfTable.WORLD_UPDATEENTITY.getName(), ObfTable.WORLD_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_PATTERN_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PATTERN_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("java/util/ArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("java/util/ArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
WORLD_PAYLOAD_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredEntityList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredEntityList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PAYLOAD_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredTileList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredTileList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes){
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode updateEntitiesNode = this.getMethod(classNode, WORLD_UPDATEENTITIES);
CoreDescription.log.info("Found World.updateEntities()...");
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_START_TEUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE);
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_START_ENTUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE);
MethodNode initNode = this.getMethod(classNode, WORLD_INIT);
CoreDescription.log.info(String.format("Found World.%s %s", initNode.name, initNode.desc));
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDENTS, WORLD_PAYLOAD_LOADEDENTS);
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDTILES, WORLD_PAYLOAD_LOADEDTILES);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,164 @@
package mcp.mobius.mobiuscore.asm.transformers.thermos;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import mcp.mobius.mobiuscore.asm.ObfTable;
import mcp.mobius.mobiuscore.asm.Opcode;
import mcp.mobius.mobiuscore.asm.transformers.TransformerBase;
import mcp.mobius.mobiuscore.profiler.ProfilerSection;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.*;
public class TransformerWorldThermos extends TransformerBase{
private static String WORLD_UPDATEENTITIES;
private static String WORLD_INIT;
//tileentity.updateEntity(); World:2215
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Start(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_TEUPDATE;
//ProfilerRegistrar.profilerTileEntity.Stop(tileentity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE;
//this.updateEntity(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PATTERN_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Start(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_START_ENTUPDATE;
//ProfilerRegistrar.profilerEntity.Stop(entity);
private static AbstractInsnNode[] WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PATTERN_LOADEDTILES;
//World.loadedEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDENTS;
//World.loadedTileEntityList
private static AbstractInsnNode[] WORLD_PAYLOAD_LOADEDTILES;
static{
String profilerClass = ProfilerSection.getClassName();
String profilerType = ProfilerSection.getTypeName();
WORLD_UPDATEENTITIES = ObfTable.WORLD_UPDATEENTITIES.getFullDescriptor(); //updateEntities.getFullDescriptor();
WORLD_INIT = ObfTable.WORLD_INIT.getFullDescriptor();
WORLD_UPDATE_PATTERN_TEUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.TILEENTITY_UPDATEENTITY.getClazz(), ObfTable.TILEENTITY_UPDATEENTITY.getName(), ObfTable.TILEENTITY_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(9),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.TILEENT_UPDATETIME.name(), profilerType),
Opcode.ALOAD(9),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PATTERN_ENTUPDATE = new AbstractInsnNode[]
{
new LineNumberNode(-1, new LabelNode()),
Opcode.ALOAD(-1),
Opcode.ALOAD(-1),
Opcode.INVOKEVIRTUAL(ObfTable.WORLD_UPDATEENTITY.getClazz(), ObfTable.WORLD_UPDATEENTITY.getName(), ObfTable.WORLD_UPDATEENTITY.getDescriptor())
};
WORLD_UPDATE_PAYLOAD_START_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "start", "(Ljava/lang/Object;)V")
};
WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE = new AbstractInsnNode[]
{
Opcode.GETSTATIC(profilerClass, ProfilerSection.ENTITY_UPDATETIME.name(), profilerType),
Opcode.ALOAD(2),
Opcode.INVOKEVIRTUAL(profilerClass, "stop", "(Ljava/lang/Object;)V")
};
WORLD_PATTERN_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("thermos/chaud/HashedArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("thermos/chaud/HashedArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PATTERN_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("thermos/chaud/HashedArrayList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("thermos/chaud/HashedArrayList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
WORLD_PAYLOAD_LOADEDENTS = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredEntityList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredEntityList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDENTS.getClazz(), ObfTable.WORLD_LOADEDENTS.getName(), ObfTable.WORLD_LOADEDENTS.getDescriptor())
};
WORLD_PAYLOAD_LOADEDTILES = new AbstractInsnNode[]
{
Opcode.ALOAD(0),
Opcode.NEW("mcp/mobius/mobiuscore/monitors/MonitoredTileList"),
Opcode.DUP(),
Opcode.INVOKESPECIAL("mcp/mobius/mobiuscore/monitors/MonitoredTileList", "<init>", "()V"),
Opcode.PUTFIELD(ObfTable.WORLD_LOADEDTILES.getClazz(), ObfTable.WORLD_LOADEDTILES.getName(), ObfTable.WORLD_LOADEDTILES.getDescriptor())
};
}
@Override
public byte[] transform(String name, String srgname, byte[] bytes){
dumpChecksum(bytes, name, srgname);
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
MethodNode updateEntitiesNode = this.getMethod(classNode, WORLD_UPDATEENTITIES);
CoreDescription.log.info("Found World.updateEntities()...");
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_START_TEUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_TEUPDATE, WORLD_UPDATE_PAYLOAD_STOP_TEUPDATE);
this.applyPayloadBefore(updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_START_ENTUPDATE);
this.applyPayloadAfter (updateEntitiesNode, WORLD_UPDATE_PATTERN_ENTUPDATE, WORLD_UPDATE_PAYLOAD_STOP_ENTUPDATE);
MethodNode initNode = this.getMethod(classNode, WORLD_INIT);
CoreDescription.log.info(String.format("Found World.%s %s", initNode.name, initNode.desc));
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDENTS, WORLD_PAYLOAD_LOADEDENTS);
this.applyPayloadAfter (initNode, WORLD_PATTERN_LOADEDTILES, WORLD_PAYLOAD_LOADEDTILES);
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
}
@@ -0,0 +1,68 @@
package mcp.mobius.mobiuscore.monitors;
import java.util.HashMap;
import java.util.Map;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import net.minecraft.entity.Entity;
public class MonitoredEntityList<E> extends MonitoredList<E>{
private Map<String, Integer> count = new HashMap<String, Integer>();
@Override
protected void addCount(E e){
if (e == null) return;
String name = this.getName(e);
try{
count.put(name, count.get(name) + 1);
} catch (NullPointerException ex){
count.put(name, 1);
} catch (Exception ex){
ex.printStackTrace();
count.put(name, 1);
}
}
@Override
protected void removeCount(int index){
this.removeCount(this.get(index));
}
@Override
protected void removeCount(Object o){
if (!(o instanceof Entity)) return;
String name = this.getName(o);
try{
this.count.put(name, this.count.get(name) - 1);
} catch (NullPointerException e){
this.count.put(name, 0);
}
}
@Override
protected void clearCount(){
this.count.clear();
}
protected String getName(Object o){
try {
return ((Entity) o).getCommandSenderName();
}
catch (ClassCastException|NullPointerException suppressed) {
return "<bad object>";
}
}
@Override
public void printCount(){
for (String s : this.count.keySet())
CoreDescription.log.info(String.format("%s : %s", s, this.count.get(s)));
}
public Map<String, Integer> getCount(){
return this.count;
}
}
@@ -0,0 +1,68 @@
package mcp.mobius.mobiuscore.monitors;
import java.util.ArrayList;
import java.util.Collection;
public abstract class MonitoredList<E> extends ArrayList<E>{
abstract void addCount(E e);
abstract void removeCount(int index);
abstract void removeCount(Object o);
abstract void printCount();
abstract void clearCount();
@Override
public boolean add(E e){
this.addCount(e);
return super.add(e);
}
@Override
public void add(int index, E e){
this.addCount(e);
super.add(index, e);
}
@Override
public boolean addAll(Collection<? extends E> c){
for (E e : c)
this.addCount(e);
return super.addAll(c);
}
@Override
public boolean addAll(int index, Collection<? extends E> c){
for (E e : c)
this.addCount(e);
return super.addAll(index, c);
}
@Override
public void clear(){
this.clearCount();
super.clear();
}
@Override
public E remove(int index){
this.removeCount(index);
return super.remove(index);
}
@Override
public boolean remove(Object o){
this.removeCount(o);
return super.remove(o);
}
@Override
public boolean removeAll(Collection<?> c){
for (Object o : c)
this.removeCount(o);
return super.removeAll(c);
}
}
@@ -0,0 +1,96 @@
package mcp.mobius.mobiuscore.monitors;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.common.collect.Table.Cell;
import mcp.mobius.mobiuscore.asm.CoreDescription;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class MonitoredTileList <E> extends MonitoredList<E>{
//private Map<String, Integer> count = new HashMap<String, Integer>();
private Table<Block, Integer, Integer> count = HashBasedTable.create();
private Map<Object, BlockData> blockdata = new WeakHashMap();
private class BlockData{
public final Block block;
public final int meta;
public BlockData(Block b, int m){
this.block = b;
this.meta = m;
}
}
@Override
protected void addCount(E e){
TileEntity te = ((TileEntity)e);
if (te == null || te.getWorldObj() == null) return;
Block block = te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord);
int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord);
blockdata.put(te, new BlockData(block, meta));
try{
count.put(block, meta, count.get(block, meta) + 1);
} catch (NullPointerException ex){
count.put(block, meta, 1);
} catch (Exception ex){
ex.printStackTrace();
count.put(block, meta, 1);
}
}
@Override
protected void removeCount(int index){
this.removeCount(this.get(index));
}
@Override
protected void removeCount(Object o){
//TODO THIS IS WHERE THE CHUNK KEEP GETTING LOADED.
//TODO SHOULD STORE BLOCK/META IN A TABLE ALONG WITH THE TE IN ORDER TO DECREASE THOSE
//WITHOUT ACCESSING THE WORLD !!!!
/*
TileEntity te = ((TileEntity)o);
if (te == null || te.getWorldObj() == null) return;
Block block = te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord);
int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord, te.zCoord);
*/
if (blockdata.containsKey(o)){
BlockData d = blockdata.get(o);
try{
this.count.put(d.block, d.meta, this.count.get(d.block, d.meta) - 1);
} catch (NullPointerException e){
this.count.put(d.block, d.meta, 0);
}
}
}
@Override
protected void clearCount(){
this.count.clear();
}
@Override
public void printCount(){
for (Cell c : this.count.cellSet())
CoreDescription.log.info(String.format("%s | %s : %s", c.getRowKey(), c.getColumnKey(), c.getValue()));
}
public Table<Block, Integer, Integer> getCount(){
return this.count;
}
}
@@ -0,0 +1,38 @@
package mcp.mobius.mobiuscore.profiler;
import net.minecraft.world.World;
public class DummyProfiler implements IProfilerBase{
@Override
public void reset() {}
@Override
public void start() {}
@Override
public void stop() {}
@Override
public void start(Object key) {}
@Override
public void stop(Object key) {}
@Override
public void start(Object key1, Object key2) {}
@Override
public void stop(Object key1, Object key2) {}
@Override
public void start(Object key1, Object key2, Object key3) {}
@Override
public void stop(Object key1, Object key2, Object key3) {}
@Override
public void start(Object key1, Object key2, Object key3, Object key4) {}
@Override
public void stop(Object key1, Object key2, Object key3, Object key4) {}
}
@@ -0,0 +1,24 @@
package mcp.mobius.mobiuscore.profiler;
import net.minecraft.world.World;
public interface IProfilerBase {
public void reset();
public void start();
public void stop();
public void start(Object key);
public void stop(Object key);
public void start(Object key1, Object key2);
public void stop(Object key1, Object key2);
public void start(Object key1, Object key2, Object key3);
public void stop(Object key1, Object key2, Object key3);
public void start(Object key1, Object key2, Object key3, Object key4);
public void stop(Object key1, Object key2, Object key3, Object key4);
}
@@ -0,0 +1,129 @@
package mcp.mobius.mobiuscore.profiler;
import java.util.EnumSet;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.world.World;
public enum ProfilerSection implements IProfilerBase{
DIMENSION_TICK (RunType.REALTIME, Side.SERVER), //Global section around the ticks for each dim (Blocks & ents).
DIMENSION_BLOCKTICK(RunType.ONREQUEST, Side.SERVER), //Subsection for dimension block tick.
ENTITY_UPDATETIME (RunType.ONREQUEST, Side.SERVER), //Profiling of the entity tick time, per entity.
TICK (RunType.REALTIME, Side.SERVER), //Tick timing profiling
TILEENT_UPDATETIME (RunType.ONREQUEST, Side.SERVER), //Profiling of the TileEntity tick time, per TE.
//HANDLER_TICKSTART (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Server handler for ServerTick start.
//HANDLER_TICKSTOP (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Server handler for ServerTick stop.
PACKET_INBOUND (RunType.REALTIME, Side.SERVER), //Outbound packet analysis
PACKET_OUTBOUND (RunType.REALTIME, Side.SERVER), //Inbound packet analysis
//PACKETFML_INBOUND (RunType.REALTIME, Side.SERVER), //Outbound packet analysis
//PACKETFML_OUTBOUND (RunType.REALTIME, Side.SERVER), //Inbound packet analysis
NETWORK_TICK (RunType.ONREQUEST, Side.SERVER), //The time it takes for the server to handle the packets during a tick.
EVENT_INVOKE (RunType.ONREQUEST, EnumSet.of(Side.CLIENT, Side.SERVER)), //Timing of the event invokation
RENDER_TILEENTITY (RunType.ONREQUEST, Side.CLIENT), //Profiler for TileEnt rendering
RENDER_ENTITY (RunType.ONREQUEST, Side.CLIENT), //Profiler for Entity rendering
RENDER_BLOCK (RunType.ONREQUEST, Side.CLIENT); //Profiler for Block rendering
public enum RunType{
REALTIME,
ONREQUEST;
}
private EnumSet<Side> sides;
private RunType runType;
private IProfilerBase profiler = new DummyProfiler();;
private IProfilerBase profilerSuspended = new DummyProfiler();;
public static long timeStampLastRun;
private ProfilerSection(RunType runType, Side side){
this.runType = runType;
this.profiler = new DummyProfiler();
this.sides = EnumSet.of(side);
}
private ProfilerSection(RunType runType, EnumSet<Side> sides){
this.runType = runType;
this.profiler = new DummyProfiler();
this.sides = sides;
}
public RunType getRunType(){
return this.runType;
}
public EnumSet<Side> getSide(){
return this.sides;
}
public IProfilerBase getProfiler(){
return this.profilerSuspended;
}
public void setProfiler(IProfilerBase profiler){
this.profilerSuspended = profiler;
if (this.runType == RunType.REALTIME)
this.profiler = profiler;
}
public void activate(){
this.profiler = profilerSuspended;
this.timeStampLastRun = System.currentTimeMillis();
}
public void desactivate(){
if (this.runType == RunType.ONREQUEST)
this.profiler = new DummyProfiler();
}
public static void activateAll(Side trgside){
for (ProfilerSection section : ProfilerSection.values())
if (section.sides.contains(trgside))
section.activate();
}
public static void desactivateAll(Side trgside){
for (ProfilerSection section : ProfilerSection.values())
if (section.sides.contains(trgside))
section.desactivate();
}
public static void resetAll(Side trgside){
for (ProfilerSection section : ProfilerSection.values())
if (section.sides.contains(trgside))
section.reset();
}
public static String getClassName(){
return ProfilerSection.class.getCanonicalName().replace(".", "/");
}
public static String getTypeName(){
return "L" + ProfilerSection.getClassName() + ";";
}
@Override
public void reset() { this.profiler.reset(); this.profilerSuspended.reset(); }
@Override
public void start() { this.profiler.start(); }
@Override
public void stop() { this.profiler.stop(); }
@Override
public void start(Object key) { this.profiler.start(key); }
@Override
public void stop(Object key) { this.profiler.stop(key); }
@Override
public void start(Object key1, Object key2) { this.profiler.start(key1, key2); }
@Override
public void stop(Object key1, Object key2) { this.profiler.stop(key1, key2); }
@Override
public void start(Object key1, Object key2, Object key3) { this.profiler.start(key1, key2, key3);}
@Override
public void stop(Object key1, Object key2, Object key3) { this.profiler.stop(key1, key2, key3); }
@Override
public void start(Object key1, Object key2, Object key3, Object key4) { this.profiler.start(key1, key2, key3, key4);}
@Override
public void stop(Object key1, Object key2, Object key3, Object key4) { this.profiler.stop(key1, key2, key3, key4); }
}
+121 -123
View File
@@ -32,140 +32,138 @@ import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(modid="Opis", name="Opis", version="@MOD_VERSION@", acceptableRemoteVersions="*")
//@Mod(modid="Opis", name="Opis", version="1.3.0", dependencies="required-after:MobiusCore@[1.2.4]", acceptableRemoteVersions="*")
@Mod(modid="GRADLETOKEN_MODID", name="GRADLETOKEN_MODNAME", version="GRADLETOKEN_VERSION", acceptableRemoteVersions="*")
public class modOpis {
@Instance("Opis")
public static modOpis instance;
@Instance("Opis")
public static modOpis instance;
public static Logger log = LogManager.getLogger("Opis");
public static Logger log = LogManager.getLogger("Opis");
@SidedProxy(clientSide="mcp.mobius.opis.proxy.ProxyClient", serverSide="mcp.mobius.opis.proxy.ProxyServer")
public static ProxyServer proxy;
@SidedProxy(clientSide="mcp.mobius.opis.proxy.ProxyClient", serverSide="mcp.mobius.opis.proxy.ProxyServer")
public static ProxyServer proxy;
public static int profilerDelay = 1;
public static boolean profilerRun = false;
public static boolean profilerRunClient = false;
public static int profilerMaxTicks = 250;
public static int rconport = 25566;
public static boolean rconactive = false;
public static String rconpass = "";
public static boolean microseconds = true;
private static int lagGenID = -1;
public static CoordinatesBlock selectedBlock = null;
public static boolean swingOpen = false;
public Configuration config = null;
public static String commentTables = "Minimum access level to be able to view tables in /opis command. Valid values : NONE, PRIVILEGED, ADMIN";
public static String commentOpis = "Minimum access level to be open Opis interface. Valid values : NONE, PRIVILEGED, ADMIN";
public static String commentPrivileged = "List of players with PRIVILEGED access level.";
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
public static int profilerDelay = 1;
public static boolean profilerRun = false;
public static boolean profilerRunClient = false;
public static int profilerMaxTicks = 250;
public static int rconport = 25566;
public static boolean rconactive = false;
public static String rconpass = "";
public static boolean microseconds = true;
private static int lagGenID = -1;
public static CoordinatesBlock selectedBlock = null;
public static boolean swingOpen = false;
config = new Configuration(event.getSuggestedConfigurationFile());
public Configuration config = null;
profilerDelay = config.get(Configuration.CATEGORY_GENERAL, "profiler.delay", 1).getInt();
lagGenID = config.get(Configuration.CATEGORY_GENERAL, "laggenerator_id", -1).getInt();
profilerMaxTicks = config.get(Configuration.CATEGORY_GENERAL, "profiler.maxpts", 250).getInt();
microseconds = config.get(Configuration.CATEGORY_GENERAL, "display.microseconds", true).getBoolean(true);
rconport = config.get("REMOTE_CONSOLE", "opisrcon.port", 25566).getInt();
rconactive = config.get("REMOTE_CONSOLE", "opisrcon.active", false).getBoolean(false);
rconpass = config.get("REMOTE_CONSOLE", "opisrcon.password", "").getString();
String[] users = config.get("ACCESS_RIGHTS", "privileged", new String[]{}, commentPrivileged).getStringList();
AccessLevel minTables = AccessLevel.PRIVILEGED;
AccessLevel openOpis = AccessLevel.PRIVILEGED;
try{ openOpis = AccessLevel.valueOf(config.get("ACCESS_RIGHTS", "opis", "NONE", commentTables).getString()); } catch (IllegalArgumentException e){}
try{ minTables = AccessLevel.valueOf(config.get("ACCESS_RIGHTS", "tables", "NONE", commentTables).getString()); } catch (IllegalArgumentException e){}
public static String commentTables = "Minimum access level to be able to view tables in /opis command. Valid values : NONE, PRIVILEGED, ADMIN";
public static String commentOpis = "Minimum access level to be open Opis interface. Valid values : NONE, PRIVILEGED, ADMIN";
public static String commentPrivileged = "List of players with PRIVILEGED access level.";
Message.setTablesMinimumLevel(minTables);
Message.setOpisMinimumLevel(openOpis);
for (String s : users)
PlayerTracker.INSTANCE.addPrivilegedPlayer(s,false);
config.save();
MinecraftForge.EVENT_BUS.register(new OpisClientEventHandler());
MinecraftForge.EVENT_BUS.register(new OpisServerEventHandler());
FMLCommonHandler.instance().bus().register(OpisClientTickHandler.INSTANCE);
FMLCommonHandler.instance().bus().register(OpisServerTickHandler.INSTANCE);
FMLCommonHandler.instance().bus().register(PlayerTracker.INSTANCE);
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
PacketManager.init();
}
@EventHandler
public void load(FMLInitializationEvent event) {
config = new Configuration(event.getSuggestedConfigurationFile());
if (lagGenID != -1){
Block blockDemo = new BlockLag(Material.wood);
GameRegistry.registerBlock(blockDemo, "opis.laggen");
GameRegistry.registerTileEntity(TileLag.class, "opis.laggen");
Block blockDebug = new BlockDebug(Material.wood);
GameRegistry.registerBlock(blockDebug, "opis.debug");
GameRegistry.registerTileEntity(TileDebug.class, "opis.debug");
}
profilerDelay = config.get(Configuration.CATEGORY_GENERAL, "profiler.delay", 1).getInt();
lagGenID = config.get(Configuration.CATEGORY_GENERAL, "laggenerator_id", -1).getInt();
profilerMaxTicks = config.get(Configuration.CATEGORY_GENERAL, "profiler.maxpts", 250).getInt();
microseconds = config.get(Configuration.CATEGORY_GENERAL, "display.microseconds", true).getBoolean(true);
rconport = config.get("REMOTE_CONSOLE", "opisrcon.port", 25566).getInt();
rconactive = config.get("REMOTE_CONSOLE", "opisrcon.active", false).getBoolean(false);
rconpass = config.get("REMOTE_CONSOLE", "opisrcon.password", "").getString();
ProfilerSection.RENDER_TILEENTITY .setProfiler(new ProfilerRenderTileEntity());
ProfilerSection.RENDER_ENTITY .setProfiler(new ProfilerRenderEntity());
ProfilerSection.RENDER_BLOCK .setProfiler(new ProfilerRenderBlock());
ProfilerSection.EVENT_INVOKE .setProfiler(new ProfilerEvent());
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
String[] users = config.get("ACCESS_RIGHTS", "privileged", new String[]{}, commentPrivileged).getStringList();
AccessLevel minTables = AccessLevel.PRIVILEGED;
AccessLevel openOpis = AccessLevel.PRIVILEGED;
try{ openOpis = AccessLevel.valueOf(config.get("ACCESS_RIGHTS", "opis", "NONE", commentTables).getString()); } catch (IllegalArgumentException e){}
try{ minTables = AccessLevel.valueOf(config.get("ACCESS_RIGHTS", "tables", "NONE", commentTables).getString()); } catch (IllegalArgumentException e){}
Message.setTablesMinimumLevel(minTables);
Message.setOpisMinimumLevel(openOpis);
for (String s : users)
PlayerTracker.INSTANCE.addPrivilegedPlayer(s,false);
config.save();
MinecraftForge.EVENT_BUS.register(new OpisClientEventHandler());
MinecraftForge.EVENT_BUS.register(new OpisServerEventHandler());
FMLCommonHandler.instance().bus().register(OpisClientTickHandler.INSTANCE);
FMLCommonHandler.instance().bus().register(OpisServerTickHandler.INSTANCE);
FMLCommonHandler.instance().bus().register(PlayerTracker.INSTANCE);
PacketManager.init();
}
@EventHandler
public void load(FMLInitializationEvent event) {
if (lagGenID != -1){
Block blockDemo = new BlockLag(Material.wood);
GameRegistry.registerBlock(blockDemo, "opis.laggen");
GameRegistry.registerTileEntity(TileLag.class, "opis.laggen");
Block blockDebug = new BlockDebug(Material.wood);
GameRegistry.registerBlock(blockDebug, "opis.debug");
GameRegistry.registerTileEntity(TileDebug.class, "opis.debug");
}
ProfilerSection.RENDER_TILEENTITY .setProfiler(new ProfilerRenderTileEntity());
ProfilerSection.RENDER_ENTITY .setProfiler(new ProfilerRenderEntity());
ProfilerSection.RENDER_BLOCK .setProfiler(new ProfilerRenderBlock());
ProfilerSection.EVENT_INVOKE .setProfiler(new ProfilerEvent());
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
ModIdentification.init();
proxy.init();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event){
ProfilerSection.DIMENSION_TICK .setProfiler(new ProfilerDimTick());
ProfilerSection.DIMENSION_BLOCKTICK.setProfiler(new ProfilerDimBlockTick());
ProfilerSection.ENTITY_UPDATETIME .setProfiler(new ProfilerEntityUpdate());
ProfilerSection.TICK .setProfiler(new ProfilerTick());
ProfilerSection.TILEENT_UPDATETIME .setProfiler(new ProfilerTileEntityUpdate());
ProfilerSection.PACKET_INBOUND .setProfiler(new ProfilerPacket());
ProfilerSection.PACKET_OUTBOUND .setProfiler(new ProfilerPacket());
ProfilerSection.NETWORK_TICK .setProfiler(new ProfilerNetworkTick());
event.registerServerCommand(new CommandChunkList());
event.registerServerCommand(new CommandFrequency());
event.registerServerCommand(new CommandStart());
event.registerServerCommand(new CommandStop());
event.registerServerCommand(new CommandTimingTileEntities());
event.registerServerCommand(new CommandTicks());
event.registerServerCommand(new CommandTimingEntities());
event.registerServerCommand(new CommandAmountEntities());
event.registerServerCommand(new CommandKill());
event.registerServerCommand(new CommandKillAll());
event.registerServerCommand(new CommandReset());
event.registerServerCommand(new CommandEntityCreate());
event.registerServerCommand(new CommandOpis());
event.registerServerCommand(new CommandAddPrivileged());
event.registerServerCommand(new CommandRmPrivileged());
//event.registerServerCommand(new CommandClientTest());
//event.registerServerCommand(new CommandClientStart());
//event.registerServerCommand(new CommandClientShowRenderTick());
event.registerServerCommand(new CommandHelp());
//GameRegistry.registerPlayerTracker(PlayerTracker.instance());
//DeadManSwitch.startDeadManSwitch(MinecraftServer.getServer());
/*
for (ProfilerSection sec : ProfilerSection.values()){
System.out.printf("%s : %s\n", sec, sec.getProfiler().getClass().getSimpleName());
}
*/
}
proxy.init();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event){
ProfilerSection.DIMENSION_TICK .setProfiler(new ProfilerDimTick());
ProfilerSection.DIMENSION_BLOCKTICK.setProfiler(new ProfilerDimBlockTick());
ProfilerSection.ENTITY_UPDATETIME .setProfiler(new ProfilerEntityUpdate());
ProfilerSection.TICK .setProfiler(new ProfilerTick());
ProfilerSection.TILEENT_UPDATETIME .setProfiler(new ProfilerTileEntityUpdate());
ProfilerSection.PACKET_INBOUND .setProfiler(new ProfilerPacket());
ProfilerSection.PACKET_OUTBOUND .setProfiler(new ProfilerPacket());
ProfilerSection.NETWORK_TICK .setProfiler(new ProfilerNetworkTick());
event.registerServerCommand(new CommandChunkList());
event.registerServerCommand(new CommandFrequency());
event.registerServerCommand(new CommandStart());
event.registerServerCommand(new CommandStop());
event.registerServerCommand(new CommandTimingTileEntities());
event.registerServerCommand(new CommandTicks());
event.registerServerCommand(new CommandTimingEntities());
event.registerServerCommand(new CommandAmountEntities());
event.registerServerCommand(new CommandKill());
event.registerServerCommand(new CommandKillAll());
event.registerServerCommand(new CommandReset());
event.registerServerCommand(new CommandEntityCreate());
event.registerServerCommand(new CommandOpis());
event.registerServerCommand(new CommandAddPrivileged());
event.registerServerCommand(new CommandRmPrivileged());
//event.registerServerCommand(new CommandClientTest());
//event.registerServerCommand(new CommandClientStart());
//event.registerServerCommand(new CommandClientShowRenderTick());
event.registerServerCommand(new CommandHelp());
//GameRegistry.registerPlayerTracker(PlayerTracker.instance());
//DeadManSwitch.startDeadManSwitch(MinecraftServer.getServer());
/*
for (ProfilerSection sec : ProfilerSection.values()){
System.out.printf("%s : %s\n", sec, sec.getProfiler().getClass().getSimpleName());
}
*/
}
}
+113
View File
@@ -0,0 +1,113 @@
The current material is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode)
For any commercial usage, please contact me at profmobius@mobiusstrip.eu
////////////////////////////////////////////////////////////////////////////////////////////
== Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ==
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 – Definitions.
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 – Scope.
License grant.
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
Term. The term of this Public License is specified in Section 6(a).
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
Downstream recipients.
Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
Other rights.
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
Patent and trademark rights are not licensed under this Public License.
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
Section 3 – License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
Attribution.
If You Share the Licensed Material (including in modified form), You must:
retain the following if it is supplied by the Licensor with the Licensed Material:
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
a copyright notice;
a notice that refers to this Public License;
a notice that refers to the disclaimer of warranties;
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
ShareAlike.
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
Section 4 – Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 – Disclaimer of Warranties and Limitation of Liability.
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 – Term and Termination.
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 – Other Terms and Conditions.
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 – Interpretation.
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.
@@ -0,0 +1,2 @@
public net.minecraft.world.gen.ChunkProviderServer field_73245_g
public net.minecraft.world.World field_72993_I
+6 -8
View File
@@ -1,10 +1,9 @@
[
{
"modid": "Opis",
"name": "Opis",
[{
"modid": "${modId}",
"name": "${modName}",
"description": "Contextual server profiler",
"version": "${version}",
"mcversion": "${mcversion}",
"version": "${modVersion}",
"mcversion": "${minecraftVersion}",
"url": "",
"updateUrl": "",
"authors": ["ProfMobius", "RoyCurtis"],
@@ -12,5 +11,4 @@
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]
}]