Compare commits

..
Author SHA1 Message Date
FalsePattern 9d37327993 whoops 2024-03-28 19:16:53 +01:00
FalsePattern 9a1b9f7798 stop people from complaining all the time 2024-03-28 19:14:56 +01:00
FalsePattern 3dd168fc8e The Big Rename (ebs, section -> subChunk) 2023-12-28 21:30:10 +01:00
FalsePattern 83bfb89d8b ChunkAPI 0.5 port 2023-12-28 21:30:07 +01:00
FalsePattern 5d5a03486f update fplib and buildscript 2023-12-28 21:29:05 +01:00
FalsePattern 6103fe96bb update copyright year 2023-12-28 21:00:13 +01:00
FalsePattern d3334c7ca8 launchclassloader cleanup 2023-12-28 20:59:05 +01:00
FalsePattern 7fc49578ce chunkapi hotfix 2023-11-15 20:57:42 +01:00
FalsePattern 59862bb5ad better version dependencies 2023-11-15 19:58:55 +01:00
FalsePattern c052edf912 remove entity ID experiments 2023-11-15 19:52:26 +01:00
FalsePattern 79f0c06fa5 update ChunkAPI 2023-11-15 19:52:16 +01:00
FalsePattern 53f3cffb59 [ci skip] Add funding.yml 2023-09-06 16:16:28 +02:00
FalsePattern c1d8e273fc extended entity IDs 2023-09-05 09:59:57 +02:00
FalsePattern 484a9175e7 another dependency update 2023-08-12 15:04:05 +02:00
FalsePattern 1bb71d9448 nicer config printing 2023-08-12 15:04:05 +02:00
FalsePattern 11ff4a4a6a configurable performance tweak 2023-08-12 15:04:05 +02:00
FalsePattern 6b3d872fbd some tweaks 2023-08-12 15:04:04 +02:00
FalsePattern 344b788108 Fixed the registry lag 2023-08-12 15:04:04 +02:00
FalsePattern b61711280b update deps 2023-08-12 15:04:04 +02:00
FalsePattern 67badb8fcb fix dragonapi mixin 2023-07-11 18:08:40 +02:00
FalsePattern e529ad49cb Remove DragonAPI ModList compat hack. Will be fixed upstream. 2023-07-11 18:02:38 +02:00
FalsePattern 10c19feb0c [ci skip] Put dependencies at the top 2023-06-09 17:41:34 +02:00
FalsePattern fb0096350c bump fplib (fixes dev) 2023-05-08 19:17:37 +02:00
FalsePattern 1f726e42d3 update buildscript 2023-05-08 10:43:32 +02:00
FalsePattern 1944aa08f1 damn it 2023-05-08 10:39:37 +02:00
FalsePattern 0dfe4bfc2d update buildscript 2023-05-07 22:54:56 +02:00
FalsePattern fcac948f88 NEID dfu 2023-05-07 22:36:13 +02:00
FalsePattern 04fe960ca4 bump fplib 2023-05-07 22:36:01 +02:00
FalsePattern a1d13d833d cleanup constants but keep some of the informative stuff 2023-04-06 11:44:41 +02:00
FalsePattern 8ae84392ba Fix StatList regression (#114) 2023-04-06 11:42:36 +02:00
FalsePattern 76092e5c4c update buildscript 2023-04-02 14:21:31 +02:00
FalsePattern 0ecadb8563 bump deps 2023-04-02 14:20:38 +02:00
FalsePattern 147099d625 remap fixes 2023-04-02 14:01:31 +02:00
FalsePattern e699d67f4e IR3 compat (#104) 2023-04-02 13:48:06 +02:00
FalsePattern 6101766529 oops, forgot this 2023-04-02 13:22:58 +02:00
FalsePattern 8c715bd579 Restructured compat (#105) 2023-04-02 13:08:27 +02:00
FalsePattern e7340cd9b1 remove LOTR from readme until fixed 2023-04-02 12:54:24 +02:00
FalsePattern 786652504c DimDoors compat (#111) 2023-04-02 12:54:22 +02:00
FalsePattern 4ded45cc5c fix some mixin conflicts (#112) 2023-04-02 12:18:55 +02:00
FalsePattern 16be8d607c [ci skip] update publishing 2023-04-01 11:52:19 +02:00
FalsePattern 775ea5769c bleh 2023-03-31 18:23:56 +02:00
FalsePattern 93e375a07d update readme 2023-03-31 18:23:41 +02:00
FalsePattern a2c0ac2d99 whoops 2023-03-31 18:23:20 +02:00
FalsePattern de5fa2d322 migrate some spaghetti code to ChunkAPI
replaced netcode/saving logic for blocks, metadata, and biomes
2023-03-30 22:50:11 +02:00
FalsePattern 984c976b34 max item id crash fix 2023-03-03 09:38:41 +01:00
FalsePattern 0e58bf113d weaken some checks 2023-03-03 09:10:15 +01:00
FalsePattern 0b968923df reimplemented metadata storage, now it's optimized like IDs 2023-03-03 08:55:08 +01:00
FalsePattern f98d2c98e3 fix broken BC mixin 2023-03-03 07:48:37 +01:00
FalsePattern bf52cfaadf cleanup code 2023-03-02 22:52:41 +01:00
FalsePattern c321707f0e optimize imports 2023-03-02 22:43:12 +01:00
FalsePattern c8e076f6d2 update code style 2023-03-02 22:42:19 +01:00
FalsePattern 6f832f4905 optimized chunk block id memory/network usage 2023-03-02 22:41:36 +01:00
FalsePattern 818f201f30 metadata extension 2023-03-02 10:32:12 +01:00
99 changed files with 2254 additions and 1295 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
patreon: falsepattern
ko_fi: falsepattern
+2
View File
@@ -145,3 +145,5 @@ gradle-app.setting
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,forgegradle,java
!lib/*.jar
srgmap.cfg
+7
View File
@@ -1,5 +1,6 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="FORMATTER_TAGS_ENABLED" value="true" />
<JavaCodeStyleSettings>
<option name="ANNOTATION_PARAMETER_WRAP" value="2" />
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
@@ -25,6 +26,9 @@
<option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
<option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
@@ -62,5 +66,8 @@
<option name="ENUM_CONSTANTS_WRAP" value="2" />
<option name="WRAP_ON_TYPING" value="0" />
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>
+2 -2
View File
@@ -1,9 +1,9 @@
EndlessIDs
Copyright (C) 2022 FalsePattern
Copyright (C) 2022-2023 FalsePattern
All Rights Reserved
The above copyright notice, this permission notice and the word "SNEED"
The above copyright notice, this permission notice and the words "MEGA"
shall be included in all copies or substantial portions of the Software.
This program is free software: you can redistribute it and/or modify
+19 -15
View File
@@ -1,17 +1,23 @@
EndlessIDs is the unofficial successor of NotEnoughIDs, with more focus on compatibility, stability, and reaching
new limits.
## REQUIRED MODS
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
- [GasStation](https://github.com/FalsePattern/GasStation)
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
Comparison of the known limits:
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 256 right now, extension planned |
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
| | Vanilla | NotEnoughIDs | EndlessIDs |
|-----------------|----------------------------------------------------|--------------|----------------------|
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
| Entity IDs | 256 | 256 | 32,768 since 1.5 |
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
This mod also contains patches for the following mods:
@@ -29,6 +35,7 @@ This mod also contains patches for the following mods:
- Compact Machines
- CoFH Lib
- Dark World
- Dimensional Doors
- DragonAPI
- Dynamic Surroundings
- Enderlicious
@@ -40,12 +47,13 @@ This mod also contains patches for the following mods:
- GalactiCraft
- Highlands
- Immersive Cavegen
- LOTR
- Industrial Revolution by Redstone Rebooted
- More Fun Quicksand Mod
- Nature's Compass
- Netherlicious
- Nomadic Tents
- Random Things
- Restructured
- Realistic Terrain Generation
- Realistic World Generation
- Thaumcraft
@@ -64,10 +72,6 @@ Mods not listed here may or may not work.
- If a mod adds a custom world generator, it has a high chance of invoking an old vanilla method in the worldgen code.
To avoid world corruption and broken biomes, this method has been replaced with an instant crash that refers the
user to this github repo.
user to this GitHub repo.
If you find any crashes or incompatibilities, don't hesitate to open an issue.
## Dependencies
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
- [GasStation](https://github.com/FalsePattern/GasStation)
+84 -47
View File
@@ -1,4 +1,4 @@
//version: 1656003793falsepattern63
//version: 1656003793falsepattern73
/*
DO NOT CHANGE THIS FILE!
@@ -132,6 +132,8 @@ propertyDefaultIfUnset("mixinConfigs", "")
propertyDefaultIfUnset("mixinPluginPreInit", "")
propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5")
propertyDefaultIfUnset("remapStubs", false)
propertyDefaultIfUnset("apiPackages", null)
propertyDefaultIfUnset("apiPackagesNoRecurse", null)
propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthDependencies", "")
@@ -147,20 +149,31 @@ 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)
def verifyPackage(thePackage, propName) {
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"${propName}\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
verifyPackage("", "modGroup")
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)
}
verifyPackage(apiPackage, "apiPackage")
}
if (apiPackages) {
apiPackages.tokenize(';').forEach { it -> verifyPackage(it, "apiPackages")}
}
if (apiPackagesNoRecurse) {
apiPackagesNoRecurse.tokenize(';').forEach { it -> verifyPackage(it, "apiPackagesNoRecurse")}
}
if(accessTransformersFile) {
@@ -175,9 +188,9 @@ if(usesMixins.toBoolean()) {
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" 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("\\.", "/")
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
String 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)
}
@@ -281,6 +294,10 @@ if(file("addon.gradle").exists()) {
apply from: 'repositories.gradle'
if(file('repositories_override.gradle').exists()) {
apply from: 'repositories_override.gradle'
}
configurations {
for (config in [shadowImplementation, shadowCompile, shadeCompile]) {
implementation.extendsFrom(shadeCompile)
@@ -308,33 +325,45 @@ repositories {
}
}
def unimixinsVersion = "0.1.15"
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor("com.llamalad7:MixinExtras:0.1.1-gasstation")
annotationProcessor("org.spongepowered:mixin:0.8.5-gasstation_7")
compile("org.spongepowered:mixin:0.8.5-gasstation_7")
compile("com.llamalad7:MixinExtras:0.1.1-gasstation")
compile("com.falsepattern:00gasstation-mc1.7.10:0.5.1:dev")
runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
annotationProcessor("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
implementation("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
runtimeOnly('org.jetbrains:intellij-fernflower:1.2.1.16')
} else if(hasMixinDeps.toBoolean()) {
runtime("com.llamalad7:MixinExtras:0.1.1-gasstation")
runtime("org.spongepowered:mixin:0.8.5-gasstation_7")
runtime("com.falsepattern:00gasstation-mc1.7.10:0.5.1:dev")
runtimeOnly("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
}
// Latest LWJGL
compile "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
compile "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
implementation "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
implementation "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
minecraftNatives "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209"
minecraftDeps "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
minecraftDeps "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
}
if(usesMixins.toBoolean()) {
configurations.implementation.dependencies.each {
if (it instanceof ExternalModuleDependency) {
it.exclude module: "SpongeMixins"
it.exclude module: "SpongePoweredMixin"
it.exclude module: "00gasstation-mc1.7.10"
it.exclude module: "gtnhmixins"
}
}
}
apply from: 'dependencies.gradle'
if(file('dependencies_override.gradle').exists()) {
apply from: 'dependencies_override.gradle'
}
def mixinDir = new File(project.buildDir, 'mixins')
if (!mixinDir.exists()) {
mixinDir.mkdirs()
@@ -425,12 +454,6 @@ runClient {
def arguments = []
def jvmArguments = []
if (usesMixins.toBoolean()) {
arguments += [
"--mods=" + Paths.get("$projectDir").resolve(minecraft.runDir).normalize().relativize(Paths.get("$projectDir/build/libs/$archivesBaseName-${version}.jar"))
]
}
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
arguments += [
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
@@ -455,12 +478,6 @@ runServer {
def arguments = []
def jvmArguments = []
if (usesMixins.toBoolean()) {
arguments += [
"--mods=" + Paths.get("$projectDir").resolve(minecraft.runDir).normalize().relativize(Paths.get("$projectDir/build/libs/$archivesBaseName-${version}.jar"))
]
}
if (usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
arguments += [
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
@@ -602,11 +619,29 @@ task devJar(type: Jar) {
task apiJar(type: Jar) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
if (apiPackage)
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
if (apiPackages)
apiPackages.tokenize(';').forEach { pkg ->
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/**'
}
if (apiPackagesNoRecurse)
apiPackagesNoRecurse.tokenize(';').forEach { pkg ->
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/*'
}
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
if (apiPackage)
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
if (apiPackages)
apiPackages.tokenize(';').forEach { pkg ->
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/**'
}
if (apiPackagesNoRecurse)
apiPackagesNoRecurse.tokenize(';').forEach { pkg ->
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/*'
}
}
from (sourceSets.main.resources.srcDirs) {
@@ -627,7 +662,7 @@ compileJava.dependsOn(copySrgs)
artifacts {
archives sourcesJar
archives devJar
if(apiPackage) {
if(apiPackage || apiPackages || apiPackagesNoRecurse) {
archives apiJar
}
}
@@ -670,6 +705,8 @@ def getCredentials = {
}
//Publishing
tasks.publish.dependsOn(build)
publishing {
publications {
maven(MavenPublication) {
@@ -681,7 +718,7 @@ publishing {
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
if (apiPackage || apiPackages || apiPackagesNoRecurse) {
artifact source: apiJar, classifier: "api"
}
@@ -753,7 +790,7 @@ if (curseForgeProjectId != "" && System.getenv("CURSEFORGE_TOKEN") != null) {
addGameVersion project.minecraft.version
addGameVersion "Forge"
mainArtifact(jar) {
displayName = "$modName version: $modVersion"
displayName = "$modName $modVersion"
}
}
options {
@@ -775,7 +812,7 @@ if (curseForgeProjectId != "" && System.getenv("CURSEFORGE_TOKEN") != null) {
}
if (usesMixins.toBoolean()) {
addCurseForgeRelation("requiredDependency", "gasstation")
addCurseForgeRelation("requiredDependency", "unimixins")
}
tasks.curseforge.dependsOn(build)
tasks.publish.dependsOn(tasks.curseforge)
@@ -808,7 +845,7 @@ if (modrinthProjectId != "" && System.getenv("MODRINTH_TOKEN") != null) {
}
}
if (usesMixins.toBoolean()) {
addModrinthDep("required", "project", "cdeAhgfp")
addModrinthDep("required", "project", "ghjoiQAl")
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
@@ -1067,7 +1104,7 @@ def deobf(String sourceURL, String rawFileName) {
}
download.run {
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
src "https://github.com/FalsePattern/ExampleMod1.7.10/raw/main/blobs/BON2-2.5.1.jar"
dest bon2File
quiet true
overwrite false
+19 -5
View File
@@ -16,12 +16,17 @@ def deobfCurse(curseDep) {
dependencies {
////////////////Our dependencies////////////////
compileOnly("org.projectlombok:lombok:1.18.24") {
compileOnly("org.projectlombok:lombok:1.18.28") {
transitive = false
}
annotationProcessor("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.28")
compile("com.falsepattern:falsepatternlib-mc1.7.10:0.10.15:dev")
implementation("com.falsepattern:falsepatternlib-mc1.7.10:1.0.0:dev")
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api")
runtimeOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:dev")
compileOnly("org.jetbrains:annotations:24.0.1")
////////////////Patched mods////////////////
@@ -68,8 +73,11 @@ dependencies {
//Dark World 0.2
compileOnly(deobfCurse("darkworld-225075:2225172"))
//DragonAPI V31b
compileOnly(deobfCurse("dragonapi-235591:3574508"))
//DimDoors 2.2.5-test9
compileOnly(deobf("https://github.com/CannibalVox/DimDoors/releases/download/2.2.5-test9/DimensionalDoors-2.2.5-test9.jar"))
//DragonAPI V32a
compileOnly(deobfCurse("dragonapi-235591:4611379"))
//Dynamic Surroundings 1.0.6.4
compileOnly(deobfCurse("dynamicsurrounding-238891:2642381"))
@@ -105,6 +113,9 @@ dependencies {
//Immersive Cavegen 1.2g
compileOnly(deobfCurse("immersivecavegen-521557:3649411"))
//Industrial Revolution by Redstone Rebooted 1.1.1
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
//LOTR Mod 36.14
compileOnly(deobfCurse("lotrmod-423748:3646430"))
@@ -126,6 +137,9 @@ dependencies {
//Realistic Terrain Generation 1.1.1.7
compileOnly(deobfCurse("rtg-237989:2521557"))
//Restructured 1.0.4.2
compileOnly(deobfCurse("restructured-230570:2276784"))
//Thaumcraft 4.2.3.5
compileOnly(deobfCurse("thaumcraft-223628:2227552"))
+2 -2
View File
@@ -72,7 +72,7 @@ modrinthProjectId = qGHY4QGo
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech
modrinthDependencies = required-project:fplib
modrinthDependencies = required-project:fplib;required-project:chunkapi
#endregion modrinth
@@ -90,7 +90,7 @@ curseForgeProjectId = 665730
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project id of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
curseForgeRelations = requiredDependency:fplib
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi
#endregion curseforge
@@ -1,5 +1,10 @@
package com.falsepattern.endlessids;
import com.falsepattern.chunk.api.DataRegistry;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.managers.BiomeManager;
import com.falsepattern.endlessids.managers.BlockIDManager;
import com.falsepattern.endlessids.managers.BlockMetaManager;
import com.falsepattern.endlessids.patching.CommonManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,7 +20,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
version = Tags.VERSION,
name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:falsepatternlib@[0.10.13,);required-after:gasstation@[0.5.0,);after:antiidconflict")
dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
"required-after:falsepatternlib@[1.0.0,);" +
"after:antiidconflict")
public class EndlessIDs {
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
@@ -33,16 +40,59 @@ public class EndlessIDs {
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
LOG.info("---------------------------------------------------------");
LOG.info("Current EndlessIDs configuration:");
logConfig(" Biome Extension", GeneralConfig.extendBiome);
logConfig(" Block/Item Extension", GeneralConfig.extendBlockItem);
if (GeneralConfig.extendBlockItem) {
logConfig(" Extra Item Bits", GeneralConfig.extraItemIDBits);
logConfig(" Extra Block Bits", GeneralConfig.extraBlockIDBits);
}
logConfig(" DataWatcher Extension", GeneralConfig.extendDataWatcher);
logConfig(" Enchantment Extension", GeneralConfig.extendEnchantment);
logConfig(" Potion Extension", GeneralConfig.extendPotion);
logConfig(" Redstone Extension", GeneralConfig.extendRedstone);
if (GeneralConfig.extendRedstone) {
LOG.warn(" (Redstone extension is an experimental and dangerous feature, and should NEVER be used in worlds that you worry about getting corrupted!)");
logConfig(" Max redstone level", GeneralConfig.maxRedstone);
}
logConfig(" Registry performance tweak", GeneralConfig.enableRegistryPerformanceTweak);
if (GeneralConfig.enableRegistryPerformanceTweak) {
LOG.warn(" (This tweak has not gone through proper testing yet, so it might corrupt worlds. USE BACKUPS!)");
}
LOG.info("---------------------------------------------------------");
patchManager.preInit();
}
private static void logConfig(String name, boolean value) {
LOG.info(name + (value ? ": ENABLED" : ": disabled"));
}
private static void logConfig(String name, int value) {
LOG.info(name + ": " + value);
}
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
patchManager.init();
if (GeneralConfig.extendBiome) {
DataRegistry.registerDataManager(new BiomeManager());
}
if (GeneralConfig.extendBlockItem) {
DataRegistry.registerDataManager(new BlockIDManager());
DataRegistry.registerDataManager(new BlockMetaManager());
}
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
patchManager.postInit();
if (GeneralConfig.extendBiome) {
DataRegistry.disableDataManager("minecraft", "biome");
}
if (GeneralConfig.extendBlockItem) {
DataRegistry.disableDataManager("minecraft", "blockid");
DataRegistry.disableDataManager("minecraft", "metadata");
}
}
}
@@ -2,137 +2,10 @@ package com.falsepattern.endlessids;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import lombok.val;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
public class Hooks {
public static byte[] getBlockData(final IExtendedBlockStorageMixin ebs) {
val lsb = ebs.getLSB();
val msb = ebs.getMSB();
final byte[] ret = new byte[lsb.length * 3];
ByteBuffer.wrap(ret).asShortBuffer().put(lsb);
System.arraycopy(msb, 0, ret, lsb.length * 2, lsb.length);
return ret;
}
public static void setBlockData(final IExtendedBlockStorageMixin ebs, final byte[] data, final int offset) {
val lsb = ebs.getLSB();
val msb = ebs.getMSB();
val lsbBytes = lsb.length * 2;
ShortBuffer.wrap(ebs.getLSB()).put(ByteBuffer.wrap(data, offset, lsbBytes).asShortBuffer());
System.arraycopy(data, offset + lsbBytes, msb, 0, msb.length);
}
public static void writeChunkToNbt(final NBTTagCompound nbt, final IExtendedBlockStorageMixin ebs) {
val ebsLSB = ebs.getLSB();
val ebsMSB = ebs.getMSB();
val byte1Data = new byte[ebsLSB.length];
byte[] byte2BottomNibbleData = null;
byte[] byte2TopNibbleData = null;
byte[] byte3Data = null;
for (int i = 0; i < ebsLSB.length; ++i) {
if (ebsMSB[i] != 0) {
if (byte3Data == null) {
byte3Data = new byte[ebsLSB.length];
}
byte3Data[i] = ebsMSB[i];
}
val idLSB = (ebsLSB[i] & 0xFFFF);
byte1Data[i] = (byte) (idLSB & 0xFF);
if (idLSB <= 0xFF) {
continue;
}
val nibbleIndex = i >> 1;
val nibbleShift = (i & 1) * 4;
if (byte2BottomNibbleData == null) {
byte2BottomNibbleData = new byte[ebsLSB.length / 2];
}
byte2BottomNibbleData[nibbleIndex] |= ((idLSB >>> 8) & 0xF) << nibbleShift;
if (idLSB <= 0xFFF) {
continue;
}
if (byte2TopNibbleData == null) {
byte2TopNibbleData = new byte[ebsLSB.length / 2];
}
byte2TopNibbleData[nibbleIndex] |= ((idLSB >>> 12) & 0xF) << nibbleShift;
}
nbt.setByteArray("Blocks", byte1Data);
if (byte2BottomNibbleData != null) {
nbt.setByteArray("Add", byte2BottomNibbleData);
}
if (byte2TopNibbleData != null) {
nbt.setByteArray("BlocksB2Hi", byte2TopNibbleData);
}
if (byte3Data != null) {
nbt.setByteArray("BlocksB3", byte3Data);
}
}
public static void readChunkFromNbt(final IExtendedBlockStorageMixin ebs, final NBTTagCompound nbt) {
assert nbt.hasKey("Blocks");
val byte1Data = nbt.getByteArray("Blocks");
val byte2BottomNibbleData = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
val byte2TopNibbleData = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
val byte3Data = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
val lsb = ebs.getLSB();
val msb = ebs.getMSB();
for (int i = 0; i < lsb.length; i++) {
if (byte3Data != null) {
msb[i] = byte3Data[i];
}
int nibbleShift = (i & 1) * 4;
int id = byte1Data[i] & 0xFF;
if (byte2BottomNibbleData != null) {
id |= ((byte2BottomNibbleData[i >> 1] >> nibbleShift) & 0xF) << 8;
}
if (byte2TopNibbleData != null) {
id |= ((byte2TopNibbleData[i >> 1] >> nibbleShift) & 0xF) << 12;
}
lsb[i] = (short) id;
}
}
public static void removeInvalidBlocksHook(final IExtendedBlockStorageMixin ebs) {
val blkIdsLSB = ebs.getLSB();
val blkIdsMSB = ebs.getMSB();
int cntNonEmpty = 0;
int cntTicking = 0;
for (int off = 0; off < blkIdsLSB.length; ++off) {
final int id =
((blkIdsLSB[off] & 0xFFFF) | ((blkIdsMSB[off] & 0xFF) << 16)) & ExtendedConstants.blockIDMask;
if (id > 0) {
final Block block = (Block) Block.blockRegistry.getObjectById(id);
if (block == null) {
if (GeneralConfig.removeInvalidBlocks) {
blkIdsLSB[off] = 0;
}
} else if (block != Blocks.air) {
++cntNonEmpty;
if (block.getTickRandomly()) {
++cntTicking;
}
}
}
}
ebs.setBlockRefCount(cntNonEmpty);
ebs.setTickRefCount(cntTicking);
}
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
final int id = Block.getIdFromBlock(block);
if (GeneralConfig.catchUnregisteredBlocks && id == -1) {
@@ -151,8 +24,8 @@ public class Hooks {
public static void shortToByteArray(short[] shortArray, int shortOffset, byte[] byteArray, int byteOffset, int shortCount) {
for (int i = 0; i < shortCount; i++) {
short s = shortArray[shortOffset + i];
byteArray[byteOffset + i * 2] = (byte)(s & 255);
byteArray[byteOffset + i * 2 + 1] = (byte)((s >>> 8) & 255);
byteArray[byteOffset + i * 2] = (byte) (s & 255);
byteArray[byteOffset + i * 2 + 1] = (byte) ((s >>> 8) & 255);
}
}
@@ -183,47 +56,9 @@ public class Hooks {
}
}
public static void oldBiomeByteToNewShortArray(byte[] byteArray, short[] shortArray) {
for (int i = 0; i < 256; i++) {
public static void scatter(byte[] byteArray, short[] shortArray) {
for (int i = 0; i < byteArray.length; i++) {
shortArray[i] = (short) (byteArray[i] & 0xff);
}
}
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
byteToShortArray(array, offset, biomeArray, 0, biomeArray.length * 2);
return biomeArray.length * 2;
}
public static int writeBiomeArrayToPacket(Chunk chunk, byte[] array, int offset) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
shortToByteArray(biomeArray, 0, array, offset, biomeArray.length);
return biomeArray.length * 2;
}
public static void writeChunkBiomeArrayToNbt(Chunk chunk, NBTTagCompound nbt) {
byte[] byteArray = shortToByteArray(((IChunkMixin) chunk).getBiomeShortArray());
nbt.setByteArray("Biomes16v2", byteArray);
}
public static void readChunkBiomeArrayFromNbt(Chunk chunk, NBTTagCompound nbt) {
short[] data = ((IChunkMixin)chunk).getBiomeShortArray();
boolean put = false;
if (data == null) {
data = new short[16 * 16];
put = true;
}
if (nbt.hasKey("Biomes16v2", 7)) {
byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
} else if (nbt.hasKey("Biomes16", 7)) {
byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
} else if (nbt.hasKey("Biomes", 7)) {
oldBiomeByteToNewShortArray(nbt.getByteArray("Biomes"), data);
} else {
put = false;
}
if (put) {
((IChunkMixin) chunk).setBiomeShortArray(data);
}
}
}
@@ -5,6 +5,7 @@ import com.falsepattern.endlessids.config.GeneralConfig;
import lombok.SneakyThrows;
import lombok.val;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
@@ -29,8 +30,8 @@ public class IEPlugin implements IFMLLoadingPlugin {
@SneakyThrows
public String[] getASMTransformerClass() {
val cl = ((LaunchClassLoader) this.getClass().getClassLoader());
val field = cl.getClass().getDeclaredField("transformerExceptions");
val cl = Launch.classLoader;
val field = LaunchClassLoader.class.getDeclaredField("transformerExceptions");
field.setAccessible(true);
val exceptions = (Set<String>) field.get(cl);
if (exceptions.contains("code.elix_x.coremods")) {
@@ -0,0 +1,66 @@
package com.falsepattern.endlessids;
import lombok.val;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
public class Unsafer {
public static final Unsafe UNSAFE;
static {
Field unsafeField = null;
Unsafe unsafe = null;
for (val field : Unsafe.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) &&
field.getType().equals(Unsafe.class)) {
unsafeField = field;
break;
}
}
if (unsafeField != null) {
unsafeField.setAccessible(true);
try {
unsafe = (Unsafe) unsafeField.get(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
if (unsafe == null) {
UNSAFE = null;
new IllegalStateException("Could not retrieve Unsafe! Falling back to bytebuffers!").printStackTrace();
} else {
UNSAFE = unsafe;
}
}
public static void arraycopy(short[] source, int sourceOffset, byte[] target, int targetOffset, int shorts) {
if (UNSAFE != null) {
val sourceOffsetBytes = sourceOffset * 2;
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffsetBytes, target, arrayOffsetTarget + targetOffset,
(long) shorts << 1);
} else {
ByteBuffer.wrap(target, targetOffset, target.length - targetOffset)
.asShortBuffer()
.put(source, sourceOffset, shorts);
}
}
public static void arraycopy(byte[] source, int sourceOffset, short[] target, int targetOffset, int shorts) {
if (UNSAFE != null) {
val targetOffsetBytes = targetOffset * 2;
val arrayOffsetSource = UNSAFE.arrayBaseOffset(source.getClass());
val arrayOffsetTarget = UNSAFE.arrayBaseOffset(target.getClass());
UNSAFE.copyMemory(source, arrayOffsetSource + sourceOffset, target, arrayOffsetTarget + targetOffsetBytes,
(long) shorts << 1);
} else {
ShortBuffer.wrap(target, targetOffset, target.length - targetOffset)
.put(ByteBuffer.wrap(source, sourceOffset, shorts * 2).asShortBuffer());
}
}
}
@@ -1,48 +0,0 @@
package com.falsepattern.endlessids.asm;
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
import com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI.ModList;
import lombok.SneakyThrows;
import cpw.mods.fml.common.Loader;
public class ASMHooks {
@SneakyThrows
public static void DragonAPIModListConstructorTweak(ModList list) {
list.successful = false;
DragonAPIModListTryLoad(list);
}
public static boolean DragonAPIModListTryLoad(ModList list) {
if (!list.successful) {
try {
list.condition = Loader.isModLoaded(list.modLabel);
list.successful = true;
if (list.condition) {
ReikaJavaLibrary.pConsole(
"DRAGONAPI: " + list + " detected in the MC installation. Adjusting behavior accordingly.");
} else {
ReikaJavaLibrary.pConsole(
"DRAGONAPI: " + list + " not detected in the MC installation. No special action taken.");
}
if (list.condition) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Attempting to load data from " + list);
if (list.blockClasses == null) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not block class for " + list +
": Specified class was null. This may not be an error.");
}
if (list.itemClasses == null) {
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not item class for " + list +
": Specified class was null. This may not be an error.");
}
}
} catch (NullPointerException e) {
list.condition = list.successful = false;
}
}
return list.condition;
}
public static void DragonAPIModListSuppressLogging(Object obj) {
}
}
@@ -1,32 +1,38 @@
package com.falsepattern.endlessids.asm;
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
import com.falsepattern.endlessids.asm.transformer.DragonAPIModList;
import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
import com.falsepattern.endlessids.asm.transformer.GameDataAccelerator;
import com.falsepattern.endlessids.asm.transformer.SpaceCoreModInfoGenerator;
import com.falsepattern.endlessids.config.GeneralConfig;
import lombok.val;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.stream.Collectors;
public enum ClassEdit {
ChunkProviderSuperPatcher(new ChunkProviderSuperPatcher(), () -> GeneralConfig.extendBiome),
DragonAPIModList(new DragonAPIModList(), () -> true, "Reika.DragonAPI.ModList"),
FmlRegistry(new FmlRegistry(),
() -> GeneralConfig.extendBlockItem,
"cpw.mods.fml.common.registry.GameData",
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"),
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true, "com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator");
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true,
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator"),
GameDataAccelerator(new GameDataAccelerator(), () -> GeneralConfig.enableRegistryPerformanceTweak, "cpw.mods.fml.common.registry.GameData"),
;
private static final Map<String, ClassEdit> editMap;
private static final Map<String, List<ClassEdit>> editMap;
static {
editMap = new HashMap<>();
for (final ClassEdit edit : values()) {
for (final String name : edit.classNames) {
ClassEdit.editMap.put(name, edit);
ClassEdit.editMap.computeIfAbsent(name, (ignored) -> new ArrayList<>()).add(edit);
}
}
}
@@ -41,9 +47,14 @@ public enum ClassEdit {
this.classNames = classNames;
}
public static ClassEdit get(final String className) {
val ret = ClassEdit.editMap.get(className);
return ret != null && ret.cond.getAsBoolean() ? ret : null;
public static List<ClassEdit> get(final String className) {
val edit = ClassEdit.editMap.get(className);
if (edit == null) {
return Collections.emptyList();
}
return edit.stream()
.filter(r -> r.cond.getAsBoolean())
.collect(Collectors.toList());
}
public String getName() {
@@ -0,0 +1,38 @@
package com.falsepattern.endlessids.asm;
import com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry.GameData;
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
import lombok.var;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.WeakHashMap;
public class GameDataHooks {
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
if (gameData.endlessIDsItemBlockCache == null) {
gameData.endlessIDsItemBlockCache = new WeakIdentityHashMap<>();
}
return gameData.endlessIDsItemBlockCache;
}
public static void cacheItemBlock(ItemBlock itemBlock, GameData gameData) {
forGameData(gameData).put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
}
public static ItemBlock fetchCachedItemBlock(Block block, GameData gameData) {
var weakItem = forGameData(gameData).get(block);
if (weakItem != null) {
return weakItem.get();
}
return null;
}
public static Iterable<Item> fakeIterable() {
return Collections.emptyList();
}
}
@@ -4,6 +4,7 @@ import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
import com.falsepattern.endlessids.asm.transformer.DevFixer;
import lombok.val;
import lombok.var;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.ClassReader;
@@ -18,9 +19,8 @@ import java.util.List;
public class IETransformer implements IClassTransformer {
public static final Logger logger;
public static boolean isObfuscated;
private static final List<String> blacklist = new ArrayList<>();
public static boolean isObfuscated;
static {
logger = LogManager.getLogger(Tags.MODNAME + " ASM");
@@ -38,8 +38,7 @@ public class IETransformer implements IClassTransformer {
if (blacklist.contains(transformedName)) {
return bytes;
}
ClassEdit[] edits = new ClassEdit[2];
edits[0] = ClassEdit.get(transformedName);
var edits = new ArrayList<ClassEdit>(ClassEdit.get(transformedName));
ClassNode cn = new ClassNode(Opcodes.ASM5);
{
val reader = new ClassReader(bytes);
@@ -53,20 +52,15 @@ public class IETransformer implements IClassTransformer {
val reader = new ClassReader(bytes);
reader.accept(cn, ClassReader.EXPAND_FRAMES);
}
if (edits[0] == null) {
edits[0] = ClassEdit.ChunkProviderSuperPatcher;
} else {
edits[1] = ClassEdit.ChunkProviderSuperPatcher;
}
edits.add(ClassEdit.ChunkProviderSuperPatcher);
}
if (edits[0] == null) {
if (edits.size() == 0) {
return isObfuscated ? bytes : DevFixer.fixDev(bytes);
}
if (!isObfuscated) {
DevFixer.transform(cn);
}
for (int i = 0; i < edits.length; i++) {
val edit = edits[i];
for (final ClassEdit edit : edits) {
if (edit == null) {
continue;
}
@@ -84,7 +78,14 @@ public class IETransformer implements IClassTransformer {
}
}
final ClassWriter writer = new ClassWriter(expanded ? ClassWriter.COMPUTE_FRAMES : 0);
cn.accept(writer);
try {
cn.accept(writer);
} catch (Exception e) {
for (int i = 0; i < 100; i++) {
IETransformer.logger.fatal("FAILED TO TRANSFORM " + transformedName + ", WORLD MAY GET CORRUPTED!", e);
}
return bytes;
}
IETransformer.logger.debug("Patched {} successfully.", transformedName);
return writer.toByteArray();
}
@@ -1,9 +0,0 @@
package com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI;
public class ModList {
public String modLabel;
public boolean condition;
public boolean successful;
public String[] itemClasses;
public String[] blockClasses;
}
@@ -0,0 +1,12 @@
package com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry;
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import java.lang.ref.WeakReference;
public class GameData {
public WeakIdentityHashMap<Block, WeakReference<ItemBlock>> endlessIDsItemBlockCache;
}
@@ -123,87 +123,6 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
public static final String[] CLASS_Chunk;
public static final String[] FIELD_biomeID;
public static final String[] METHOD_getBiomeArray;
static {
if (IETransformer.isObfuscated) {
CLASS_BiomeGenBase = new String[]{"ahu", "net/minecraft/world/biome/BiomeGenBase"};
CLASS_IChunkProvider = new String[]{"apu", "net/minecraft/world/chunk/IChunkProvider"};
CLASS_ChunkProviderGenerate = new String[]{"aqz", "net/minecraft/world/gen/ChunkProviderGenerate"};
CLASS_Chunk = new String[]{"apx", "net/minecraft/world/chunk/Chunk"};
FIELD_biomeID = new String[]{"ay", "field_76756_M"};
METHOD_getBiomeArray = new String[]{"m", "func_76605_m"};
} else {
CLASS_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
FIELD_biomeID = new String[]{"biomeID"};
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
}
}
public static boolean shouldPatch(final ClassNode cn) {
if (!GeneralConfig.extendBiome) {
return false;
}
for (MethodNode method : cn.methods) {
if (scanForBrokenCall(method)) {
return true;
}
}
return false;
}
private static boolean scanForBrokenCall(MethodNode method) {
val instructions = method.instructions;
val insnCount = instructions.size();
for (int i = 0; i < insnCount; i++) {
val insn = instructions.get(i);
if (insn.getOpcode() != Opcodes.INVOKEVIRTUAL) {
continue;
}
val invoke = (MethodInsnNode) insn;
if (anyMatch(invoke.owner, CLASS_Chunk) &&
anyMatch(invoke.name, METHOD_getBiomeArray) &&
invoke.desc.equals("()[B")) {
return true;
}
}
return false;
}
private static boolean anyMatch(List<String> str, String[] candidates) {
for (val s: str) {
for (val candidate: candidates) {
if (s.equals(candidate)) {
return true;
}
}
}
return false;
}
private static boolean anyMatch(String str, String[] candidates) {
for (val candidate: candidates) {
if (str.equals(candidate)) {
return true;
}
}
return false;
}
private static boolean anyMatch(String str, String[] candidates, String prefix, String suffix) {
for (val candidate: candidates) {
if (str.equals(prefix + candidate + suffix)) {
return true;
}
}
return false;
}
public interface State<T extends AbstractInsnNode> extends BiFunction<T, Memory, State<AbstractInsnNode>> {}
private static State<AbstractInsnNode> STATE0 = null;
private static State<AbstractInsnNode> STATE1 = null;
private static State<AbstractInsnNode> STATE2 = null;
@@ -228,6 +147,25 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
private static State<AbstractInsnNode> STATE16 = null;
private static State<AbstractInsnNode> STATE17 = null;
private static State<AbstractInsnNode> STATE_FINAL = null;
static {
if (IETransformer.isObfuscated) {
CLASS_BiomeGenBase = new String[]{"ahu", "net/minecraft/world/biome/BiomeGenBase"};
CLASS_IChunkProvider = new String[]{"apu", "net/minecraft/world/chunk/IChunkProvider"};
CLASS_ChunkProviderGenerate = new String[]{"aqz", "net/minecraft/world/gen/ChunkProviderGenerate"};
CLASS_Chunk = new String[]{"apx", "net/minecraft/world/chunk/Chunk"};
FIELD_biomeID = new String[]{"ay", "field_76756_M"};
METHOD_getBiomeArray = new String[]{"m", "func_76605_m"};
} else {
CLASS_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
FIELD_biomeID = new String[]{"biomeID"};
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
}
}
static {
STATE_FINAL = (insn, memory) -> STATE_FINAL;
@@ -276,7 +214,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
STATE6 = typeCheck(LabelNode.class, () -> STATE7);
STATE7 = casting(FrameNode.class, (insn, memory) ->
anyMatch((String)memory.locals.get(memory.chunkIndex), CLASS_Chunk) &&
anyMatch((String) memory.locals.get(memory.chunkIndex), CLASS_Chunk) &&
memory.locals.get(memory.biomeArrayIndex).equals("[B") &&
memory.locals.get(memory.iteratorIndex).equals(1)
? STATE8 : STATE0);
@@ -291,13 +229,9 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
&& insn.var == memory.biomeArrayIndex
? STATE10 : STATE0);
STATE10 = casting(InsnNode.class, (insn) ->
insn.getOpcode() == Opcodes.ARRAYLENGTH
? STATE11 : STATE0);
STATE10 = casting(InsnNode.class, (insn) -> insn.getOpcode() == Opcodes.ARRAYLENGTH ? STATE11 : STATE0);
STATE11 = casting(JumpInsnNode.class, (insn) ->
insn.getOpcode() == Opcodes.IF_ICMPGE
? STATE12 : STATE0);
STATE11 = casting(JumpInsnNode.class, (insn) -> insn.getOpcode() == Opcodes.IF_ICMPGE ? STATE12 : STATE0);
STATE12 = typeCheck(LabelNode.class, () -> STATE13);
@@ -307,8 +241,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
? STATE14 : STATE0);
STATE14 = casting(VarInsnNode.class, (insn, memory) -> {
if (insn.getOpcode() == Opcodes.ILOAD &&
insn.var == memory.iteratorIndex) {
if (insn.getOpcode() == Opcodes.ILOAD && insn.var == memory.iteratorIndex) {
if (insn.getNext() instanceof FieldInsnNode) {
return STATE14_C1;
} else {
@@ -320,7 +253,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
STATE14_ABD1 = casting(VarInsnNode.class, (insn, memory) -> {
if (insn.getOpcode() == Opcodes.ALOAD) {
if (anyMatch((String)memory.locals.get(insn.var), CLASS_BiomeGenBase, "[L", ";")) {
if (anyMatch((String) memory.locals.get(insn.var), CLASS_BiomeGenBase, "[L", ";")) {
return STATE14_ABD1_BA2;
} else {
return STATE14_ABD1_BD1;
@@ -341,17 +274,12 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
});
STATE14_ABD1_BA2 = casting(VarInsnNode.class, (insn, memory) ->
insn.getOpcode() == Opcodes.ILOAD &&
insn.var == memory.iteratorIndex
? STATE14_ABD1_BA3 : STATE0);
insn.getOpcode() == Opcodes.ILOAD && insn.var == memory.iteratorIndex ? STATE14_ABD1_BA3 : STATE0);
STATE14_ABD1_BA3 = casting(InsnNode.class, (insn) ->
insn.getOpcode() == Opcodes.AALOAD
? STATE15 : STATE0);
STATE14_ABD1_BA3 = casting(InsnNode.class, (insn) -> insn.getOpcode() == Opcodes.AALOAD ? STATE15 : STATE0);
STATE14_C1 = casting(FieldInsnNode.class, (insn, memory) -> {
if (insn.getOpcode() == Opcodes.GETSTATIC &&
anyMatch(insn.desc, CLASS_BiomeGenBase, "L", ";")) {
if (insn.getOpcode() == Opcodes.GETSTATIC && anyMatch(insn.desc, CLASS_BiomeGenBase, "L", ";")) {
return STATE15;
}
return STATE0;
@@ -381,6 +309,65 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
});
}
public static boolean shouldPatch(final ClassNode cn) {
if (!GeneralConfig.extendBiome) {
return false;
}
for (MethodNode method : cn.methods) {
if (scanForBrokenCall(method)) {
return true;
}
}
return false;
}
private static boolean scanForBrokenCall(MethodNode method) {
val instructions = method.instructions;
val insnCount = instructions.size();
for (int i = 0; i < insnCount; i++) {
val insn = instructions.get(i);
if (insn.getOpcode() != Opcodes.INVOKEVIRTUAL) {
continue;
}
val invoke = (MethodInsnNode) insn;
if (anyMatch(invoke.owner, CLASS_Chunk) && anyMatch(invoke.name, METHOD_getBiomeArray) &&
invoke.desc.equals("()[B")) {
return true;
}
}
return false;
}
private static boolean anyMatch(List<String> str, String[] candidates) {
for (val s : str) {
for (val candidate : candidates) {
if (s.equals(candidate)) {
return true;
}
}
}
return false;
}
private static boolean anyMatch(String str, String[] candidates) {
for (val candidate : candidates) {
if (str.equals(candidate)) {
return true;
}
}
return false;
}
private static boolean anyMatch(String str, String[] candidates, String prefix, String suffix) {
for (val candidate : candidates) {
if (str.equals(prefix + candidate + suffix)) {
return true;
}
}
return false;
}
private static <T extends AbstractInsnNode> State<AbstractInsnNode> typeCheck(Class<T> clazz, Supplier<State<AbstractInsnNode>> okState) {
return casting(clazz, (insn, memory) -> okState.get());
}
@@ -401,33 +388,6 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
};
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
boolean patched = false;
for (val method: cn.methods) {
val memory = findTheTarget(method);
if (memory != null) {
patched = true;
IETransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
val insnList = method.instructions;
for (val node: method.localVariables) {
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
node.desc = "[S";
}
}
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
insnList.set(getBiomeArray, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray", "()[S", false));
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
}
}
if (!patched) {
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
"an error, because the patch might be applied by a mixin instead!");
}
}
private static Memory findTheTarget(MethodNode method) {
val insnList = method.instructions;
var currentState = STATE0;
@@ -453,20 +413,49 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
return null;
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
boolean patched = false;
for (val method : cn.methods) {
val memory = findTheTarget(method);
if (memory != null) {
patched = true;
IETransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
val insnList = method.instructions;
for (val node : method.localVariables) {
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
node.desc = "[S";
}
}
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
insnList.set(getBiomeArray,
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray",
"()[S", false));
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
}
}
if (!patched) {
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
"an error, because the patch might be applied by a mixin instead!");
}
}
public interface State<T extends AbstractInsnNode> extends BiFunction<T, Memory, State<AbstractInsnNode>> {
}
@Data
private static class Memory {
final List<Object> locals = new ArrayList<>();
int currentInsn;
int startingInsn;
int getBiomeArrayInsn;
int castInsn;
int arrayStoreInsn;
int chunkIndex;
int biomeArrayIndex;
int iteratorIndex;
final List<Object> locals = new ArrayList<>();
}
}
@@ -1,7 +1,5 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.asm.ClassEdit;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
import com.falsepattern.endlessids.asm.IETransformer;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -21,6 +19,7 @@ import java.io.IOException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DevFixer {
private static final ClassNode blocks;
static {
if (IETransformer.isObfuscated) {
blocks = null;
@@ -62,7 +61,7 @@ public final class DevFixer {
}
private static void biomeTweakerCompat(final ClassNode cn) {
for (val field: cn.fields) {
for (val field : cn.fields) {
if (field.name.startsWith("spawnable")) {
field.access &= ~Opcodes.ACC_PROTECTED;
field.access |= Opcodes.ACC_PUBLIC;
@@ -71,18 +70,16 @@ public final class DevFixer {
}
private static void remapBlocks(final ClassNode cn) {
for (val method: cn.methods) {
for (val method : cn.methods) {
val instructions = method.instructions;
int insnCount = instructions.size();
for (int i = 0; i < insnCount; i++) {
val insn = instructions.get(i);
if (insn instanceof FieldInsnNode) {
val field = (FieldInsnNode) insn;
if (field.getOpcode() == Opcodes.GETSTATIC &&
field.owner.equals("net/minecraft/init/Blocks")) {
for (val blockField: blocks.fields) {
if (blockField.name.equals(field.name) &&
!blockField.desc.equals(field.desc)) {
if (field.getOpcode() == Opcodes.GETSTATIC && field.owner.equals("net/minecraft/init/Blocks")) {
for (val blockField : blocks.fields) {
if (blockField.name.equals(field.name) && !blockField.desc.equals(field.desc)) {
field.desc = blockField.desc;
}
}
@@ -1,140 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.asm.ASMHooks;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
import lombok.val;
import lombok.var;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.FrameNode;
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.VarInsnNode;
import java.util.Arrays;
import java.util.List;
public class DragonAPIModList implements IClassNodeTransformer {
private static final List<String> fields = Arrays.asList("condition", "itemClasses", "blockClasses");
private static void tweakIsLoaded(MethodNode method) {
val iterator = method.instructions.iterator();
iterator.next();
iterator.next();
iterator.next();
iterator.next();
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ASMHooks.class),
"DragonAPIModListTryLoad", "(LReika/DragonAPI/ModList;)Z", false));
}
private static void tweakInit(MethodNode method) {
val iterator = method.instructions.iterator();
while (iterator.hasNext()) {
var insn = iterator.next();
if (insn instanceof LineNumberNode && ((LineNumberNode) insn).line == 154) {
//SRC:
// L3
// LINENUMBER 154 L3
// ALOAD 0
// ALOAD 0
// GETFIELD Reika/DragonAPI/ModList.modLabel : Ljava/lang/String;
// INVOKESTATIC cpw/mods/fml/common/Loader.isModLoaded (Ljava/lang/String;)Z
// PUTFIELD Reika/DragonAPI/ModList.condition : Z
//TGT:
// L3
// LINENUMBER 154 L3
// ALOAD 0
// ALOAD 5
// PUTFIELD Reika/DragonAPI/ModList.itemClasses : [Ljava/lang/String;
// ALOAD 0
// ALOAD 4
// PUTFIELD Reika/DragonAPI/ModList.blockClasses : [Ljava/lang/String;
// ALOAD 0
// INVOKESTATIC ASMHooks.isModLoaded (LReika/DragonAPI/ModList;)V
// FRAME FULL [Reika/DragonAPI/ModList java/lang/String I java/lang/String [Ljava/lang/String; [Ljava/lang/String;] []
// RETURN
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 5));
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "itemClasses",
"[Ljava/lang/String;"));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
iterator.add(new VarInsnNode(Opcodes.ALOAD, 4));
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "blockClasses",
"[Ljava/lang/String;"));
iterator.next();
iterator.remove();
iterator.next();
iterator.next();
iterator.remove();
var methodInsn = (MethodInsnNode) iterator.next();
methodInsn.owner = Type.getInternalName(ASMHooks.class);
methodInsn.name = "DragonAPIModListConstructorTweak";
methodInsn.desc = "(LReika/DragonAPI/ModList;)V";
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
"java/lang/String", "[Ljava/lang/String;",
"[Ljava/lang/String;"}, 0, new Object[]{}));
iterator.add(new InsnNode(Opcodes.RETURN));
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
"java/lang/String", "[Ljava/lang/String;",
"[Ljava/lang/String;"}, 0, new Object[]{}));
iterator.next();
iterator.remove();
break;
}
}
}
private void crash() {
throw new IllegalStateException("Tweaking failed!");
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
int state = 0;
for (val field : cn.fields) {
if (field.name.equals("__MARKER__FALSEPATTERN__MIXINPATCH__")) {
return;
}
}
for (val field : cn.fields) {
if (field.name.equals("condition") && field.desc.equals("Z")) {
field.access &= ~Opcodes.ACC_FINAL;
state++;
}
if (fields.contains(field.name)) {
field.access &= ~Opcodes.ACC_PRIVATE;
field.access &= ~Opcodes.ACC_PROTECTED;
field.access |= Opcodes.ACC_PUBLIC;
state++;
}
}
if (state != 4) {
crash();
}
cn.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "successful", "Z", null, 0));
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "__MARKER__FALSEPATTERN__MIXINPATCH__", "Z", null, 0));
int state2 = 0;
for (val method : cn.methods) {
if ((state2 & 1) == 0 && method.name.equals("<init>") &&
method.desc.equals("(Ljava/lang/String;ILjava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V")) {
tweakInit(method);
state2 |= 1;
}
if ((state2 & 2) == 0 && method.name.equals("isLoaded") && method.desc.equals("()Z")) {
tweakIsLoaded(method);
state2 |= 2;
}
}
if (state2 != 3) {
crash();
}
}
}
@@ -22,7 +22,7 @@ public class FmlRegistry implements IClassNodeTransformer {
}
field = AsmUtil.findField(cn, "MAX_ITEM_ID", true);
if (field != null) {
field.value = ExtendedConstants.maxBlockID;
field.value = ExtendedConstants.maxItemID;
}
boolean found = false;
for (final MethodNode method : cn.methods) {
@@ -30,7 +30,7 @@ public class FmlRegistry implements IClassNodeTransformer {
ExtendedConstants.maxBlockID, true)) {
found = true;
}
AsmUtil.transformInlinedSizeMethod(cn, method, 31999, ExtendedConstants.maxBlockID, true);
AsmUtil.transformInlinedSizeMethod(cn, method, 31999, ExtendedConstants.maxItemID, true);
}
if (!found) {
throw new AsmTransformException("can't find 4095 constant in any method");
@@ -0,0 +1,97 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
import com.falsepattern.endlessids.asm.IETransformer;
import lombok.val;
import lombok.var;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class GameDataAccelerator implements IClassNodeTransformer {
private static final int MASK_REGISTER_BLOCK = 0b1;
private static final int MASK_REGISTER_ITEM = 0b10;
@Override
public void transform(ClassNode classNode, boolean obfuscated) {
var cacheField = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "endlessIDsItemBlockCache", "Lcom/falsepattern/endlessids/util/WeakIdentityHashMap;", null, null);
classNode.fields.add(cacheField);
int tweaksLeft = MASK_REGISTER_BLOCK | MASK_REGISTER_ITEM;
for (val method: classNode.methods) {
if ((tweaksLeft & MASK_REGISTER_BLOCK) != 0 &&
method.name.equals("registerBlock") &&
method.desc.equals("(Lnet/minecraft/block/Block;Ljava/lang/String;I)I")) {
transformRegisterBlock(method);
tweaksLeft &= ~MASK_REGISTER_BLOCK;
}
if ((tweaksLeft & MASK_REGISTER_ITEM) != 0 &&
method.name.equals("registerItem") &&
method.desc.equals("(Lnet/minecraft/item/Item;Ljava/lang/String;I)I")) {
transformRegisterItem(method);
tweaksLeft &= ~MASK_REGISTER_ITEM;
}
if (tweaksLeft == 0) {
break;
}
}
if (tweaksLeft != 0) {
IETransformer.logger.error("Could not accelerate block registration!");
}
}
private void transformRegisterItem(MethodNode method) {
var iter = method.instructions.iterator();
while (iter.hasNext()) {
var insn = iter.next();
if (!(insn instanceof FieldInsnNode))
continue;
var typeInsn = (FieldInsnNode) insn;
if (!(typeInsn.owner.equals("net/minecraft/item/ItemBlock") &&
typeInsn.name.equals("field_150939_a") &&
typeInsn.desc.equals("Lnet/minecraft/block/Block;")))
continue;
iter.previous();
iter.add(new InsnNode(Opcodes.DUP));
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "cacheItemBlock", "(Lnet/minecraft/item/ItemBlock;Lcpw/mods/fml/common/registry/GameData;)V", false));
return;
}
transformError(method);
}
private static void transformError(MethodNode method) {
IETransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
}
private void transformRegisterBlock(MethodNode method) {
var iter = method.instructions.iterator();
while (iter.hasNext()) {
var insn = iter.next();
if (!(insn instanceof FieldInsnNode))
continue;
var fieldInsn = (FieldInsnNode) insn;
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
fieldInsn.name.equals("iItemRegistry") &&
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
continue;
iter.previous();
iter.previous();
iter.remove();
iter.next();
iter.remove();
iter.next();
iter.remove();
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fetchCachedItemBlock", "(Lnet/minecraft/block/Block;Lcpw/mods/fml/common/registry/GameData;)Lnet/minecraft/item/ItemBlock;", false));
iter.add(new VarInsnNode(Opcodes.ASTORE, 4));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fakeIterable", "()Ljava/lang/Iterable;", false));
return;
}
transformError(method);
}
}
@@ -12,7 +12,7 @@ public class SpaceCoreModInfoGenerator implements IClassNodeTransformer {
if (obfuscated) {
return;
}
for (val method: cn.methods) {
for (val method : cn.methods) {
if (method.name.equals("generate")) {
val iterator = method.instructions.iterator();
iterator.add(new InsnNode(Opcodes.RETURN));
@@ -5,45 +5,48 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.lib.config.Config;
import com.falsepattern.lib.config.ConfigurationManager;
@Config(modid = Tags.MODID, category = "darkworld")
@Config(modid = Tags.MODID,
category = "darkworld")
public class DarkWorldIDConfig {
static {
ConfigurationManager.selfInit();
}
@Config.Comment("Original: 100")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1100)
public static int darkOceanID;
@Config.Comment("Original: 101")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1101)
public static int darkPlainsID;
@Config.Comment("Original: 102")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1102)
public static int darkDesertID;
@Config.Comment("Original: 103")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1103)
public static int darkHillsID;
@Config.Comment("Original: 104")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1104)
public static int darkForestID;
@Config.Comment("Original: 105")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1105)
public static int darkTaigaID;
@Config.Comment("Original: 106")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(1106)
public static int darkSwampID;
static {
ConfigurationManager.selfInit();
}
}
@@ -5,13 +5,16 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.lib.config.Config;
import com.falsepattern.lib.config.ConfigurationManager;
@Config(modid = Tags.MODID, category = "futurepack")
@Config(modid = Tags.MODID,
category = "futurepack")
public class FuturepackIDConfig {
@Config.Comment("Original: 97")
@Config.RangeInt(min = 40,
max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(2097)
public static int spaceID;
static {
ConfigurationManager.selfInit();
}
@Config.Comment("Original: 97")
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
@Config.DefaultInt(2097)
public static int spaceID;
}
@@ -6,58 +6,93 @@ import com.falsepattern.lib.config.ConfigurationManager;
@Config(modid = Tags.MODID)
public class GeneralConfig {
static {
ConfigurationManager.selfInit();
}
@Config.Comment("WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
@Config.Comment(
"WARNING: THIS CONFIG IS EXTREMELY SENSITIVE TO CHANGES, DISABLING STUFF ONCE THEY HAVE BEEN ENABLED\n" +
"CAN CORRUPT YOUR WORLD! ONLY TOUCH THIS FILE IF YOU KNOW WHAT YOU'RE DOING!\n" +
"This file should only be edited by modpack developers to finetune it for the modpack. Once an option\n" +
"has been enabled, it modifies the chunk save data format, which is (partially) compatible with\n" +
"vanilla, but removing the mod might cause block/item corruption for higher IDs.\n" +
"Additional note: Every client and server must have the exact same config, this also affects netcode.")
@Config.DefaultString("")
public static String __NOTICE__;
@Config.Comment("Throw an exception when an invalid block is registered. FOR DEBUGGING PURPOSES")
@Config.DefaultBoolean(false)
public static boolean catchUnregisteredBlocks;
@Config.Comment("Remove invalid (corrupted) blocks from the game. FOR DEBUGGING PURPOSES")
@Config.DefaultBoolean(false)
public static boolean removeInvalidBlocks;
@Config.Comment("Extend Biome IDs. Vanilla limit is 256, new limit is 65536.")
@Config.DefaultBoolean(true)
public static boolean extendBiome;
@Config.Comment("Extend Block and Item IDs. Vanilla limit is 4096/32000, new limit is 16777216 for both.\n" +
"See also: countCorrectionBits")
@Config.DefaultBoolean(true)
public static boolean extendBlockItem;
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.\n" +
"Disabled by default because of uncertain/weak implementation (taken from NotEnoughIDs)")
@Config.DefaultBoolean(false)
public static boolean extendDataWatcher;
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
@Config.DefaultBoolean(true)
public static boolean extendEnchantment;
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
@Config.DefaultBoolean(true)
public static boolean extendPotion;
@Config.Comment("Extend Entity IDs. Vanilla limit is 256, new limit is 32768.")
@Config.DefaultBoolean(true)
public static boolean extendEntity;
@Config.Comment("Improves the speed of the block registry by multiple orders of magnitudes. (not thoroughly tested yet)\n" +
"It's highly recommended to leave this enabled, especially when using a lot of IDs.\n" +
"With this disabled, registering 1 million blocks on a test system took 80 minutes\n" +
"With this enabled, registering the same million blocks took 7 seconds")
@Config.DefaultBoolean(true)
public static boolean enableRegistryPerformanceTweak;
@Config.Comment(
"Use this to tune the amount of available block IDs.\n" +
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
"Notice: This does not affect ITEM IDs.\n" +
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 4k (vanilla).\n" +
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
"Extends the maximum redstone signal strength.\n" + "Only has effect with extendBlockItem enabled.\n" +
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
@Config.DefaultBoolean(false)
public static boolean extendRedstone;
@Config.Comment("Increases the max signal strength of redstone.\n" +
"Only has effect with both extendBlockItem and extendRedstone enabled.\n" + "Vanilla value is 15.")
@Config.RangeInt(min = 15,
max = 127)
@Config.DefaultInt(15)
public static int maxRedstone;
@Config.Comment("Use this to tune the amount of available block IDs.\n" +
"Minecraft contains some internal code that uses a HUGE amount of RAM with too many block IDs available.\n" +
"Notice: This does not affect ITEM IDs.\n" +
"The vanilla default is 4k block IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 4k (vanilla).\n" +
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"Effective values: (0: 4k, 1: 8k, 2: 16k, 3: 32k, 4: 64k, 5: 128k, 6: 256k, 7: 512k, 8: 1M, 9: 2M, 10: 4M, 11: 8M, 12: 16M)\n" +
"The effective value of this variable must always be smaller or equal to the effective value of extraItemIDBits")
@Config.RangeInt(min = 0,
max = 12)
@Config.DefaultInt(12)
@Config.DefaultInt(0)
public static int extraBlockIDBits;
@Config.Comment("Use this to tune the amount of available item IDs.\n" +
"The vanilla default is 32k item IDs, while the maximum is 16 million.\n" +
"The default setting sets it to 32k (vanilla).\n" +
"increase if necessary (when running out of ITEM IDs in your modpack)\n" +
"Only effective if extendBlockItem is enabled.\n" +
"Effective values: (0: 32k, 1: 64k, 2: 128k, 3: 256k, 4: 512k, 5: 1M, 6: 2M, 7: 4M, 8: 8M, 9: 16M)\n" +
"The effective value of this variable must always be equal or larger than the effective value of extraBlockIDBits")
@Config.RangeInt(min = 0,
max = 9)
@Config.DefaultInt(0)
public static int extraItemIDBits;
@Config.Comment("DEPRECATED, will be removed in the next version of EndlessIDs!\n" +
"This property does nothing.\n" +
"Use extraBlockIDBits and extraItemIDBits instead.")
@Config.DefaultInt(0)
@Deprecated
public static int countCorrectionBits;
static {
ConfigurationManager.selfInit();
}
}
@@ -2,11 +2,13 @@ package com.falsepattern.endlessids.constants;
import com.falsepattern.endlessids.config.GeneralConfig;
@SuppressWarnings("unused")
public class ExtendedConstants {
//Tunables
public static final int bitsPerID = 24;
public static final int bitsPerMetadata = 4;
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
public static final int bitsPerMetadata = 16;
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
public static final int watchableBits = 7;
public static final int bitsPerBiome = 16;
@@ -14,6 +16,9 @@ public class ExtendedConstants {
public static final int maximumPotionIDs = 65536;
public static final int maximumEnchantmentIDs = 32768;
//Align with max item metadata for spawn eggs. Will be treated as short in netcode
public static final int bitsPerEntity = 15;
//BlockItemIDs
public static final int nibblesPerID = bitsPerID / 4;
public static final int bytesPerID = (nibblesPerID + 1) / 2;
@@ -21,13 +26,16 @@ public class ExtendedConstants {
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
public static final int blockIDMask = (1 << bitsPerID) - 1;
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBlockBits);
public static final int maxBlockID = blockIDCount - 1;
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
public static final int maxItemID = itemIDCount - 1;
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
//BiomeIDs
public static final int biomeIDCount = 1 << bitsPerBiome;
@@ -40,8 +48,8 @@ public class ExtendedConstants {
public static final int maxWatchableID = watchableCount - 1;
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
//Chunk
public static final int bytesPerChunk =
(GeneralConfig.extendBiome ? bytesPerBiome : VanillaConstants.bytesPerBiome) * 256
+ (GeneralConfig.extendBlockItem ? bytesPerEBS : VanillaConstants.bytesPerEBS) * 16;
//EntityIDs
public static final int entityIDCount = 1 << bitsPerEntity;
public static final int entityIDMask = entityIDCount - 1;
public static final int maxEntityID = entityIDMask;
}
@@ -1,5 +1,6 @@
package com.falsepattern.endlessids.constants;
@SuppressWarnings("unused")
public class VanillaConstants {
//Tunables
public static final int bitsPerID = 12;
@@ -9,6 +10,8 @@ public class VanillaConstants {
public static final int watchableBits = 5;
public static final int bitsPerBiome = 8;
public static final int bitsPerEntity = 8;
//BlockItemIDs
public static final int nibblesPerID = bitsPerID / 4;
public static final int bytesPerID = (nibblesPerID + 1) / 2;
@@ -19,20 +22,26 @@ public class VanillaConstants {
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
public static final int maxBlockID = blockIDCount - 1;
public static final int itemIDCount = 32000;
public static final int maxItemID = itemIDCount - 1;
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
public static final int nibblesPerBlock = bitsPerBlock / 4;
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
//BiomeIDs
public static final int biomeIDCount = 1 << bitsPerBiome;
public static final int biomeIDMask = biomeIDCount - 1;
public static final int biomeIDNull = biomeIDMask;
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
//Chunk
public static final int bytesPerChunk = bytesPerBiome * 256 + bytesPerEBS * 16;
//DataWatcher
public static final int watchableCount = 1 << watchableBits;
public static final int maxWatchableID = watchableCount - 1;
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
//EntityIDs
public static final int entityIDCount = 1 << bitsPerEntity;
public static final int maxEntityID = entityIDCount - 1;
}
@@ -0,0 +1,108 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ArrayUtil;
import com.falsepattern.chunk.api.DataManager;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import lombok.var;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import java.nio.ByteBuffer;
public class BiomeManager implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "biome";
}
@Override
public int maxPacketSize() {
return 2 * 16 * 16;
}
@Override
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
data.asShortBuffer().put(((ChunkBiomeHook)chunk).getBiomeShortArray());
data.position(data.position() + maxPacketSize());
}
@Override
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
var arr = ((ChunkBiomeHook)chunk).getBiomeShortArray();
if (arr == null) {
arr = new short[16 * 16];
((ChunkBiomeHook)chunk).setBiomeShortArray(arr);
}
buffer.asShortBuffer().get(arr);
buffer.position(buffer.position() + maxPacketSize());
}
@Override
public boolean chunkPrivilegedAccess() {
return true;
}
@Override
public void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt) {
byte[] arr = Hooks.shortToByteArray(((ChunkBiomeHook)chunk).getBiomeShortArray());
nbt.setByteArray("Biomes16v2", arr);
}
@Override
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt) {
var data = ((ChunkBiomeHook) chunk).getBiomeShortArray();
if (data == null) {
data = new short[16 * 16];
((ChunkBiomeHook)chunk).setBiomeShortArray(data);
}
if (nbt.hasKey("Biomes16v2", 7)) {
Hooks.byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
} else if (nbt.hasKey("Biomes16", 7)) { //NotEnoughBiomes DFU
Hooks.byteToShortArrayLegacy(nbt.getByteArray("Biomes16"), data);
} else if (nbt.hasKey("Biomes", 7)) { //Vanilla DFU
Hooks.scatter(nbt.getByteArray("Biomes"), data);
}
}
@Override
public void cloneChunk(Chunk fromVanilla, Chunk toVanilla) {
val from = (ChunkBiomeHook) fromVanilla;
val to = (ChunkBiomeHook) toVanilla;
to.setBiomeShortArray(ArrayUtil.copyArray(from.getBiomeShortArray(), to.getBiomeShortArray()));
}
@Override
public @NotNull String version() {
return Tags.MODID;
}
@Override
public @Nullable String newInstallDescription() {
return "EndlessIDs extended biome data. Vanilla biome data is limited to 256 biomes. This allows for 65536 biomes.";
}
@Override
public @NotNull String uninstallMessage() {
return "EndlessIDs extended biome data has been uninstalled. Biomes are limited to 256,\n" +
"and any biomes with IDs above 255 in the save will be corrupted.";
}
@Override
public @Nullable String versionChangeMessage(String priorVersion) {
return null;
}
}
@@ -0,0 +1,213 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ArrayUtil;
import com.falsepattern.chunk.api.DataManager;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import lombok.val;
import lombok.var;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.nio.ByteBuffer;
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "blockid";
}
@Override
public int maxPacketSize() {
return 3 * 16 * 16 * 16 * 16 + 4;
}
@Override
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
val subChunkList = chunk.getBlockStorageArray();
int storageFlags = 0;
val start = data.position() + 4;
data.position(start);
for (int i = 0; i < 16; i++) {
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
continue;
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.getBlockMask() << (i * 2);
val b1 = subChunk.getB1();
data.put(b1);
val b2Low = subChunk.getB2Low();
if (b2Low == null) {
continue;
}
data.put(b2Low.data);
val b2High = subChunk.getB2High();
if (b2High == null) {
continue;
}
data.put(b2High.data);
val b3 = subChunk.getB3();
if (b3 != null) {
data.put(b3);
}
}
data.putInt(start - 4, storageFlags);
}
@Override
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
val subChunkList = chunk.getBlockStorageArray();
val storageFlags = buffer.getInt();
for (int i = 0; i < 16; i++) {
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
continue;
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val b1 = subChunk.getB1();
buffer.get(b1);
if (storageFlag == 0b00) {
subChunk.setB2Low(null);
subChunk.setB2High(null);
subChunk.setB3(null);
continue;
}
var b2Low = subChunk.getB2Low();
if (b2Low == null) {
b2Low = subChunk.createB2Low();
}
buffer.get(b2Low.data);
if (storageFlag == 0b01) {
subChunk.setB2High(null);
subChunk.setB3(null);
continue;
}
var b2High = subChunk.getB2High();
if (b2High == null) {
b2High = subChunk.createB2High();
}
buffer.get(b2High.data);
if (storageFlag == 0b10) {
subChunk.setB3(null);
continue;
}
var b3 = subChunk.getB3();
if (b3 == null) {
b3 = subChunk.createB3();
}
buffer.get(b3);
}
}
@Override
public boolean subChunkPrivilegedAccess() {
return true;
}
@Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
val b1 = subChunk.getB1();
val b2Low = subChunk.getB2Low();
val b2High = subChunk.getB2High();
val b3 = subChunk.getB3();
nbt.setByteArray("Blocks", b1);
if (b2Low != null) {
nbt.setByteArray("Add", b2Low.data);
}
if (b2High != null) {
nbt.setByteArray("BlocksB2Hi", b2High.data);
}
if (b3 != null) {
nbt.setByteArray("BlocksB3", b3);
}
}
//NotEnoughIDs world compatibility
public static void readSectionFromNBTNotEnoughIDsDFU(SubChunkBlockHook subChunk, NBTTagCompound nbt) {
val data = nbt.getByteArray("Blocks16");
val dataShort = new short[data.length >>> 1];
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
val b1 = new byte[dataShort.length];
val b2L = new byte[dataShort.length >>> 1];
val b2H = new byte[dataShort.length >>> 1];
for (int i = 0; i < dataShort.length; i++) {
val s = dataShort[i];
val nI = i >>> 1;
val mI = (i & 1) * 4;
b1[i] = (byte) (s & 0x00FF);
b2L[nI] |= ((s & 0x0F00) >>> 8) << mI;
b2H[nI] |= ((s & 0xF000) >>> 12) << mI;
}
subChunk.setB1(b1);
subChunk.setB2Low(new NibbleArray(b2L, 4));
subChunk.setB2High(new NibbleArray(b2H, 4));
}
@Override
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
if (nbt.hasKey("Blocks16")) {
readSectionFromNBTNotEnoughIDsDFU(subChunk, nbt);
return;
}
assert nbt.hasKey("Blocks");
val b1 = nbt.getByteArray("Blocks");
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
subChunk.setB1(b1);
subChunk.setB2Low(b2Low == null ? null : new NibbleArray(b2Low, 4));
subChunk.setB2High(b2High == null ? null : new NibbleArray(b2High, 4));
subChunk.setB3(b3);
}
@Override
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla;
to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
to.setB2High(ArrayUtil.copyArray(from.getB2High(), to.getB2High()));
to.setB3(ArrayUtil.copyArray(from.getB3(), to.getB3()));
}
@Override
public @NotNull String version() {
return Tags.VERSION;
}
@Override
public @Nullable String newInstallDescription() {
return "EndlessIDs extended block IDs. Vanilla worlds can be converted to EndlessIDs worlds safely.";
}
@Override
public @NotNull String uninstallMessage() {
return "EndlessIDs extended block IDs removed. Any blocks with IDs above 4095 will get corrupted.";
}
@Override
public @Nullable String versionChangeMessage(String priorVersion) {
return null;
}
}
@@ -0,0 +1,163 @@
package com.falsepattern.endlessids.managers;
import com.falsepattern.chunk.api.ArrayUtil;
import com.falsepattern.chunk.api.DataManager;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import lombok.val;
import lombok.var;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.nio.ByteBuffer;
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
@Override
public String domain() {
return Tags.MODID;
}
@Override
public String id() {
return "metadata";
}
@Override
public int maxPacketSize() {
return 2 * 16 * 16 * 16 * 16 + 4;
}
@Override
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
val subChunkList = chunk.getBlockStorageArray();
int storageFlags = 0;
val start = data.position() + 4;
data.position(start);
for (int i = 0; i < 16; i++) {
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
continue;
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
storageFlags |= subChunk.getMetadataMask() << (i * 2);
val m1Low = subChunk.getM1Low();
data.put(m1Low.data);
val m1High = subChunk.getM1High();
if (m1High == null) {
continue;
}
data.put(m1High.data);
val m2 = subChunk.getM2();
if (m2 != null) {
data.put(m2);
}
}
data.putInt(start - 4, storageFlags);
}
@Override
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
val subChunkList = chunk.getBlockStorageArray();
val storageFlags = buffer.getInt();
for (int i = 0; i < 16; i++) {
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
continue;
}
val subChunk = (SubChunkBlockHook) subChunkList[i];
val storageFlag = (storageFlags >>> (i * 2)) & 3;
val m1Low = subChunk.getM1Low();
buffer.get(m1Low.data);
if (storageFlag == 0b01) {
subChunk.setM1High(null);
subChunk.setM2(null);
continue;
}
var m1High = subChunk.getM1High();
if (m1High == null) {
m1High = subChunk.createM1High();
}
buffer.get(m1High.data);
if (storageFlag == 0b10) {
subChunk.setM2(null);
continue;
}
var m2 = subChunk.getM2();
if (m2 == null) {
m2 = subChunk.createM2();
}
buffer.get(m2);
}
}
@Override
public boolean subChunkPrivilegedAccess() {
return true;
}
@Override
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
val m1Low = subChunk.getM1Low();
val m1High = subChunk.getM1High();
val m2 = subChunk.getM2();
nbt.setByteArray("Data", m1Low.data);
if (m1High != null) {
nbt.setByteArray("Data1High", m1High.data);
}
if (m2 != null) {
nbt.setByteArray("Data2", m2);
}
}
@Override
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
val subChunk = (SubChunkBlockHook) subChunkVanilla;
assert nbt.hasKey("Data");
val m1Low = nbt.getByteArray("Data");
final byte[] m1High = nbt.hasKey("Data1High") ? nbt.getByteArray("Data1High") : null;
final byte[] m2 = nbt.hasKey("Data2") ? nbt.getByteArray("Data2") : null;
subChunk.setM1Low(new NibbleArray(m1Low, 4));
subChunk.setM1High(m1High == null ? null : new NibbleArray(m1High, 4));
subChunk.setM2(m2);
}
@Override
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
val from = (SubChunkBlockHook) fromVanilla;
val to = (SubChunkBlockHook) toVanilla;
to.setM1Low(ArrayUtil.copyArray(from.getM1Low(), to.getM1Low()));
to.setM1High(ArrayUtil.copyArray(from.getM1High(), to.getM1High()));
to.setM2(ArrayUtil.copyArray(from.getM2(), to.getM2()));
}
@Override
public @NotNull String version() {
return Tags.VERSION;
}
@Override
public @Nullable String newInstallDescription() {
return "EndlessIDs extended block metadata. Vanilla worlds can be converted to EndlessIDs worlds safely.";
}
@Override
public @NotNull String uninstallMessage() {
return "EndlessIDs extended block metadata removed. Any blocks with metadata above 15 will get corrupted.";
}
@Override
public @Nullable String versionChangeMessage(String priorVersion) {
return null;
}
}
@@ -11,7 +11,7 @@ import static com.falsepattern.endlessids.EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLA
public class BiomePatchHelper {
public static byte[] getBiomeArrayTweaked(Chunk chunk, IntFunction<BiomeGenBase> biomesForGeneration) {
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
for (int i = 0; i < chunkBiomes.length; ++i) {
chunkBiomes[i] = (short) biomesForGeneration.apply(i).biomeID;
@@ -20,7 +20,7 @@ public class BiomePatchHelper {
}
public static byte[] getBiomeArrayTweaked(Chunk chunk, BiomeGenBase[] biomesForGeneration) {
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
for (int i = 0; i < chunkBiomes.length; ++i) {
chunkBiomes[i] = (short) biomesForGeneration[i].biomeID;
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.helpers;
public interface IChunkMixin {
public interface ChunkBiomeHook {
short[] getBiomeShortArray();
void setBiomeShortArray(short[] data);
@@ -8,6 +8,7 @@ import java.lang.reflect.Field;
public class GalaxySpaceHelper {
private static final Field GSSpaceField;
static {
Class<?> clazz;
try {
@@ -1,11 +0,0 @@
package com.falsepattern.endlessids.mixin.helpers;
public interface IExtendedBlockStorageMixin {
void setBlockRefCount(int value);
void setTickRefCount(int value);
short[] getLSB();
byte[] getMSB();
}
@@ -12,7 +12,7 @@ public final class ShortUtil {
public static int[] unsignedShortToIntArray(short[] shorts) {
int[] ints = new int[shorts.length];
for(int i = 0; i < shorts.length; ++i) {
for (int i = 0; i < shorts.length; ++i) {
ints[i] = unsignedShortToInt(shorts[i]);
}
@@ -0,0 +1,49 @@
package com.falsepattern.endlessids.mixin.helpers;
import net.minecraft.world.chunk.NibbleArray;
public interface SubChunkBlockHook {
byte[] getB1();
void setB1(byte[] data);
NibbleArray getB2Low();
void setB2Low(NibbleArray data);
NibbleArray createB2Low();
NibbleArray getB2High();
void setB2High(NibbleArray data);
NibbleArray createB2High();
byte[] getB3();
void setB3(byte[] data);
byte[] createB3();
int getMetadataMask();
int getBlockMask();
int getID(int x, int y, int z);
NibbleArray getM1Low();
void setM1Low(NibbleArray m1Low);
NibbleArray getM1High();
void setM1High(NibbleArray m1High);
NibbleArray createM1High();
byte[] getM2();
void setM2(byte[] m2);
byte[] createM2();
}
@@ -1,48 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.client.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.world.chunk.Chunk;
import java.util.Iterator;
@Mixin(Chunk.class)
public abstract class ChunkMixin {
@SuppressWarnings("rawtypes")
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;clearMSBArray()V")),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void biomeData(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
Hooks.readBiomeArrayFromPacket((Chunk) (Object) this, p_76607_1_, k);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;clearMSBArray()V")),
require = 1)
private void noCopyBiome(Object src, int srcPos, Object dest, int destPos, int length) {}
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;blockBiomeArray:[B",
args = "array=length"),
require = 1)
private int noBiomeArrayLength(byte[] array) {
return 0;
}
}
@@ -1,66 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.client.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.util.Iterator;
@Mixin(Chunk.class)
public abstract class ChunkMixin {
@Shadow
private ExtendedBlockStorage[] storageArrays;
//This is needed because the array is not a field, but a local, and local arraylength overriding does not exist
private static byte[] fakeArray;
@Redirect(method = "fillChunk",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;",
args = "array=length",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getSkylightArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private int noMSBLoop(ExtendedBlockStorage[] array) {
return 0;
}
@SuppressWarnings("rawtypes")
@Inject(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private void blockData(byte[] p_76607_1_, int p_76607_2_, int p_76607_3_, boolean p_76607_4_, CallbackInfo ci, Iterator iterator, int k, boolean flag1, int l) {
Hooks.setBlockData((IExtendedBlockStorageMixin) this.storageArrays[l], p_76607_1_, k);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] fakeLSBArray(ExtendedBlockStorage instance) {
return fakeArray != null ? fakeArray : (fakeArray = new byte[16 * 16 * 16 * ExtendedConstants.bytesPerID]);
}
@Redirect(method = "fillChunk",
at = @At(value = "INVOKE",
target = "Ljava/lang/System;arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V",
ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B")),
require = 1)
private void noCopy(Object src, int srcPos, Object dest, int destPos, int length) {}
}
@@ -38,13 +38,14 @@ public abstract class NetHandlerPlayClientMixin {
short idLSB = dataInput.readShort();
byte idMSB = dataInput.readByte();
int id = (idLSB & 0xFFFF) | ((idMSB & 0xFF) << 16);
int meta = dataInput.readByte() & 15;
int meta = dataInput.readShort() & 0xFFFF;
int x = pos >> 12 & 15;
int z = pos >> 8 & 15;
int y = pos & 255;
this.clientWorldController.func_147492_c(x + chunkX, y, z + chunkZ, Block.getBlockById(id), meta);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
}
}
@@ -24,7 +24,7 @@ public abstract class NetHandlerPlayClientMixin {
at = @At("HEAD"),
require = 1)
private void grabID(S1DPacketEntityEffect packetIn, CallbackInfo ci) {
theID = ((IS1DPacketEntityEffectMixin)packetIn).getIDExtended();
theID = ((IS1DPacketEntityEffectMixin) packetIn).getIDExtended();
}
@Redirect(method = "handleEntityEffect",
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.client.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.block.BlockRedstoneWire;
@Mixin(BlockRedstoneWire.class)
public abstract class BlockRedstoneWireMixin {
@ModifyConstant(method = "randomDisplayTick",
constant = @Constant(floatValue = 15.0F),
require = 1)
private float bigRedstone(float constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.client.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.client.renderer.RenderBlocks;
@Mixin(RenderBlocks.class)
public abstract class RenderBlocksMixin {
@ModifyConstant(method = "renderBlockRedstoneWire",
constant = @Constant(floatValue = 15.0F),
require = 1)
private float bigRedstone(float constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -56,8 +56,7 @@ public abstract class BiomesManagerMixin {
}
@ModifyConstant(method = {"preinit", "setUpBiomesFolder"},
constant = {@Constant(stringValue = "\\biomes"),
@Constant(stringValue = "\\main.cfg")})
constant = {@Constant(stringValue = "\\biomes"), @Constant(stringValue = "\\main.cfg")})
private static String fixPaths(String original) {
return AIDCStringFixer.fixString(original);
}
@@ -44,25 +44,6 @@ public abstract class AbyssalCraftMixin {
@Shadow
public static int configBiomeId13;
@Inject(method = "checkBiomeIds",
at = @At("HEAD"),
require = 1)
private void cleanupBiomeArrayForAssignment(CallbackInfo ci) {
val bga = BiomeGenBase.getBiomeGenArray();
int[] biomes = new int[]{configBiomeId1, configBiomeId2, configBiomeId3, configBiomeId4, configBiomeId5,
configBiomeId6, configBiomeId7, configBiomeId8, configBiomeId9, configBiomeId10,
configBiomeId11, configBiomeId12, configBiomeId13};
for (val biome : biomes) {
if (biome < 0 || biome >= ExtendedConstants.biomeIDCount) {
continue;
}
if (bga[biome] instanceof PlaceholderBiome) {
bga[biome] = null;
}
}
}
@ModifyConstant(method = "syncConfig",
constant = {@Constant(intValue = 100, ordinal = 0),
@Constant(intValue = 101, ordinal = 0),
@@ -81,4 +62,23 @@ public abstract class AbyssalCraftMixin {
private static int shiftBiomeIDsUp(int constant) {
return constant + 8000;
}
@Inject(method = "checkBiomeIds",
at = @At("HEAD"),
require = 1)
private void cleanupBiomeArrayForAssignment(CallbackInfo ci) {
val bga = BiomeGenBase.getBiomeGenArray();
int[] biomes = new int[]{configBiomeId1, configBiomeId2, configBiomeId3, configBiomeId4, configBiomeId5,
configBiomeId6, configBiomeId7, configBiomeId8, configBiomeId9, configBiomeId10,
configBiomeId11, configBiomeId12, configBiomeId13};
for (val biome : biomes) {
if (biome < 0 || biome >= ExtendedConstants.biomeIDCount) {
continue;
}
if (bga[biome] instanceof PlaceholderBiome) {
bga[biome] = null;
}
}
}
}
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.antiqueatlas;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.falsepattern.endlessids.mixin.helpers.ShortUtil;
import hunternif.mc.atlas.core.BiomeDetectorBase;
import org.spongepowered.asm.mixin.Mixin;
@@ -16,6 +16,8 @@ import net.minecraft.world.chunk.Chunk;
@Mixin(value = BiomeDetectorBase.class,
remap = false)
public abstract class BiomeDetectorBaseMixin {
private Chunk chunk;
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
require = 2)
@@ -23,8 +25,6 @@ public abstract class BiomeDetectorBaseMixin {
return ExtendedConstants.biomeIDCount;
}
private Chunk chunk;
@Redirect(method = "getBiomeID",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B",
@@ -41,7 +41,7 @@ public abstract class BiomeDetectorBaseMixin {
require = 1)
private int[] biomeIDs(byte[] i) {
try {
return ShortUtil.unsignedShortToIntArray(((IChunkMixin)chunk).getBiomeShortArray());
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
} finally {
chunk = null;
}
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.antiqueatlas;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.falsepattern.endlessids.mixin.helpers.ShortUtil;
import hunternif.mc.atlas.core.BiomeDetectorNether;
import org.spongepowered.asm.mixin.Mixin;
@@ -30,7 +30,7 @@ public abstract class BiomeDetectorNetherMixin {
require = 1)
private int[] biomeIDs(byte[] i) {
try {
return ShortUtil.unsignedShortToIntArray(((IChunkMixin)chunk).getBiomeShortArray());
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
} finally {
chunk = null;
}
@@ -30,14 +30,6 @@ public abstract class BiomeEventHandlerMixin {
return ExtendedConstants.biomeIDCount;
}
@Inject(method = "<init>",
at = @At("RETURN"),
require = 1)
private void extendIDs2(CallbackInfo ci) {
colorCache = new int[ExtendedConstants.biomeIDCount * 3];
Arrays.fill(colorCache, -2);
}
@ModifyConstant(method = "onGetFoliageColor",
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
require = 1)
@@ -51,4 +43,12 @@ public abstract class BiomeEventHandlerMixin {
private static int extendIDs4(int constant) {
return ExtendedConstants.biomeIDCount * 2;
}
@Inject(method = "<init>",
at = @At("RETURN"),
require = 1)
private void extendIDs2(CallbackInfo ci) {
colorCache = new int[ExtendedConstants.biomeIDCount * 3];
Arrays.fill(colorCache, -2);
}
}
@@ -1,7 +1,7 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.biomewand;
import com.falsepattern.endlessids.PlaceholderBiome;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.spacechase0.minecraft.biomewand.BiomeWandMod;
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
import com.spacechase0.minecraft.spacecore.util.TranslateUtils;
@@ -42,17 +42,17 @@ public abstract class BiomeWandItemMixin {
int relBlockX = blockX & 15;
int relBlockZ = blockZ & 15;
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
short biome = ((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
short biome = ((ChunkBiomeHook) chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
tag.setShort("sampledBiomeS", biome);
} else {
short biome = tag.getShort("sampledBiomeS");
for(int ix = blockX - 3; ix <= blockX + 3; ++ix) {
for(int iz = blockZ - 3; iz <= blockZ + 3; ++iz) {
for (int ix = blockX - 3; ix <= blockX + 3; ++ix) {
for (int iz = blockZ - 3; iz <= blockZ + 3; ++iz) {
int relBlockX = ix & 15;
int relBlockZ = iz & 15;
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
((IChunkMixin)chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
((ChunkBiomeHook) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
chunk.isModified = true;
BiomeWandMod.proxy.updateRendererAt(ix, iz);
}
@@ -96,12 +96,12 @@ public abstract class BiomeWandItemMixin {
*/
@Overwrite
public void getSubItems(Item item, CreativeTabs tabs, List list) {
list.add(new ItemStack((BiomeWandItem)(Object)this, 1));
list.add(new ItemStack((BiomeWandItem) (Object) this, 1));
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (biome != null && !(biome instanceof PlaceholderBiome)) {
NBTTagCompound compound = new NBTTagCompound();
compound.setShort("sampledBiomeS", (short) biome.biomeID);
ItemStack wand = new ItemStack((BiomeWandItem)(Object)this, 1);
ItemStack wand = new ItemStack((BiomeWandItem) (Object) this, 1);
wand.setTagCompound(compound);
list.add(wand);
}
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.compactmachines;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.falsepattern.endlessids.mixin.stubpackage.org.dave.CompactMachines.tileentity.TileEntityMachine;
import org.dave.CompactMachines.handler.ConfigurationHandler;
import org.dave.CompactMachines.machines.tools.CubeTools;
@@ -27,10 +27,10 @@ public abstract class CubeToolsMixin {
WorldServer machineWorld = MinecraftServer.getServer().worldServerForDimension(ConfigurationHandler.dimensionId);
Chunk chunk = machineWorld.getChunkFromBlockCoords(coords * ConfigurationHandler.cubeDistance, 0);
if (chunk != null && chunk.isChunkLoaded) {
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
for(int x = 0; x < 15; ++x) {
for(int z = 0; z < 15; ++z) {
biomeArray[z << 4 | x] = (short)biome.biomeID;
short[] biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
for (int x = 0; x < 15; ++x) {
for (int z = 0; z < 15; ++z) {
biomeArray[z << 4 | x] = (short) biome.biomeID;
}
}
}
@@ -43,10 +43,12 @@ public abstract class CubeToolsMixin {
*/
@Overwrite
public static BiomeGenBase getMachineBiome(TileEntityMachine machine) {
short[] biomeArray = ((IChunkMixin)machine.getWorldObj().getChunkFromBlockCoords(machine.xCoord, machine.zCoord)).getBiomeShortArray();
short[] biomeArray = ((ChunkBiomeHook) machine.getWorldObj()
.getChunkFromBlockCoords(machine.xCoord,
machine.zCoord)).getBiomeShortArray();
int biomeId = biomeArray[(machine.zCoord & 15) << 4 | machine.xCoord & 15];
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length && BiomeDictionary.isBiomeRegistered(biomeId)
? BiomeGenBase.getBiome(biomeId)
: WorldUtils.getBiomeByName(ConfigurationHandler.defaultBiome);
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length &&
BiomeDictionary.isBiomeRegistered(biomeId) ? BiomeGenBase.getBiome(biomeId) : WorldUtils.getBiomeByName(
ConfigurationHandler.defaultBiome);
}
}
@@ -0,0 +1,33 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.dimdoors;
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
import com.falsepattern.endlessids.PlaceholderBiome;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import net.minecraft.world.biome.BiomeGenBase;
@Mixin(value = DDBiomeGenBase.class,
priority = 999,
remap = false)
public abstract class DDBiomeGenBaseMixin extends BiomeGenBase {
private DDBiomeGenBaseMixin(int p_i1971_1_) {
super(p_i1971_1_);
}
/**
* @author FalsePattern
* @reason Compat patch
*/
@Overwrite
public static void checkBiomes(int[] biomes) {
val arr = getBiomeGenArray();
for(int k = 0; k < biomes.length; ++k) {
val b = arr[biomes[k]];
if (b != null && !(b instanceof DDBiomeGenBase || b instanceof PlaceholderBiome)) {
throw new IllegalStateException("There is a biome ID conflict between a biome from Dimensional Doors and another biome type. Fix your configuration!");
}
}
}
}
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
import Reika.DragonAPI.Libraries.World.ReikaChunkHelper;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -13,13 +13,14 @@ import net.minecraft.world.chunk.Chunk;
remap = false)
public abstract class ReikaChunkHelperMixin {
private static short[] biomeArray;
@Redirect(method = "copyChunk",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V",
remap = true),
require = 1)
private static void customSet(Chunk chunk, byte[] p_76616_1_) {
((IChunkMixin)chunk).setBiomeShortArray(biomeArray);
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeArray);
biomeArray = null;
}
@@ -29,7 +30,7 @@ public abstract class ReikaChunkHelperMixin {
remap = true),
require = 1)
private static byte[] customGet(Chunk chunk) {
biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
return EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
}
}
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -18,6 +18,8 @@ import net.minecraft.world.chunk.Chunk;
@Mixin(value = ReikaWorldHelper.class,
remap = false)
public abstract class ReikaWorldHelperMixin {
private static int fromBiomeID;
@Redirect(method = {"setBiomeForXZ", "setBiomeAndBlocksForXZ"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B",
@@ -42,20 +44,18 @@ public abstract class ReikaWorldHelperMixin {
remap = true),
locals = LocalCapture.CAPTURE_FAILHARD,
require = 1)
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
((IChunkMixin)ch).getBiomeShortArray()[index] = (short) biome.biomeID;
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
((ChunkBiomeHook) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
}
private static int fromBiomeID;
@Inject(method = "setBiomeAndBlocksForXZ",
at = @At(value = "FIELD",
target = "Lnet/minecraft/world/biome/BiomeGenBase;biomeList:[Lnet/minecraft/world/biome/BiomeGenBase;",
remap = true),
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
require = 1)
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
fromBiomeID = ((IChunkMixin)ch).getBiomeShortArray()[index];
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
fromBiomeID = ((ChunkBiomeHook) ch).getBiomeShortArray()[index];
}
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
@@ -71,7 +71,7 @@ public abstract class ReikaWorldHelperMixin {
remap = true),
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
require = 1)
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
((IChunkMixin)ch).getBiomeShortArray()[index] = (short) biome.biomeID;
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
((ChunkBiomeHook) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
}
}
@@ -5,7 +5,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(BiomeIDs.class)
@Mixin(value = BiomeIDs.class,
remap = false)
public abstract class BiomeIDsMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = 39),
@@ -9,8 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
remap = false)
public abstract class BiomeConfigurationMixin {
@ModifyConstant(method = "init",
constant = {@Constant(intValue = 200),
@Constant(intValue = 210)},
constant = {@Constant(intValue = 200), @Constant(intValue = 210)},
require = 2)
private static int shiftBiomeIDsUp(int id) {
return id + 3000;
@@ -1,7 +1,7 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.enderlicious;
import DelirusCrux.Enderlicious.Dimension.EndChunkProvider;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -39,12 +39,12 @@ public abstract class EndChunkProviderMixin {
remap = true,
require = 1)
private byte[] setBiomesTweaked(Chunk chunk) {
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
for(int k = 0; k < chunkBiomes.length; ++k) {
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
for (int k = 0; k < chunkBiomes.length; ++k) {
if (Math.abs(xx) < 160 && Math.abs(zz) < 160) {
chunkBiomes[k] = 9;
} else {
chunkBiomes[k] = (short)this.biomesForGeneration[k].biomeID;
chunkBiomes[k] = (short) this.biomesForGeneration[k].biomeID;
}
}
return ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
@@ -71,7 +71,8 @@ public abstract class ModBiomesMixin {
constant = @Constant(stringValue = "Erebus biome IDs cannot be higher than 127 or smaller than 0!"),
require = 1)
private static String modifyWarning(String str) {
return "Erebus biome IDs cannot be higher than " + (ExtendedConstants.biomeIDCount - 129) + " or smaller than 0!";
return "Erebus biome IDs cannot be higher than " + (ExtendedConstants.biomeIDCount - 129) +
" or smaller than 0!";
}
@Inject(method = "init",
@@ -84,7 +85,7 @@ public abstract class ModBiomesMixin {
ulteriorOutbackID, fungalForestID, submergedSwampID, fieldsSubForestID,
jungleSubLakeID, jungleSubAsperGroveID, desertSubCharredForestID,
savannahSubRockyWastelandID, savannahSubAsperGroveID, savannahSubSteppeID};
for (val biome: biomes) {
for (val biome : biomes) {
if (biome <= 0 || biome >= ExtendedConstants.biomeIDCount - 129) {
continue;
}
@@ -1,7 +1,7 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.extrautilities;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -45,7 +45,7 @@ public abstract class ChunkProviderEndOfTimeMixin {
require = 1)
private void setBiomesTweaked3(byte[] bytes, byte b) {
try {
Arrays.fill(((IChunkMixin) chunk).getBiomeShortArray(), (short) id);
Arrays.fill(((ChunkBiomeHook) chunk).getBiomeShortArray(), (short) id);
} finally {
chunk = null;
id = -1;
@@ -6,7 +6,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(BiomeGenSpace.class)
@Mixin(value = BiomeGenSpace.class,
remap = false)
public abstract class BiomeGenSpaceMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = 97),
@@ -16,6 +16,7 @@ public abstract class ConfigManagerCoreMixin {
private static int shiftBiomeIDsUp(int id) {
return id + 18000;
}
@ModifyConstant(method = "syncConfig",
constant = @Constant(stringValue = "Biome ID for Moon (Mars will be this + 1, Asteroids + 2 etc). Allowed range 40-250."),
require = 1)
@@ -0,0 +1,86 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.ir3;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import jp.plusplus.ir2.IR2;
import jp.plusplus.ir2.blocks.BlockCore;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.OreGenEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@Mixin(value = IR2.class,
priority = 999,
remap = false)
public abstract class IR2Mixin {
@Shadow public static boolean oresAreGenerated;
@Shadow public static boolean generateTinOre;
@Shadow public static boolean generateCopperOre;
@Shadow public static boolean generateSilverOre;
@Shadow public static boolean generateManganeseCrust;
@Shadow public static boolean generateCobaltCrust;
/**
* @author FalsePattern
* @reason Compat
*/
@SubscribeEvent
@Overwrite
public void generateOrePre(OreGenEvent.Pre event) {
if (oresAreGenerated) {
WorldGenerator genTin = new WorldGenMinable(BlockCore.ore, 0, 8, Blocks.stone);
WorldGenerator genCopper = new WorldGenMinable(BlockCore.ore, 1, 8, Blocks.stone);
WorldGenerator genSilver = new WorldGenMinable(BlockCore.ore, 2, 8, Blocks.stone);
WorldGenerator genManganese = new WorldGenMinable(BlockCore.crust, 0, 16, Blocks.gravel);
WorldGenerator genCobalt = new WorldGenMinable(BlockCore.crust, 1, 16, Blocks.gravel);
if (generateTinOre && TerrainGen.generateOre(event.world, event.rand, genTin, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 14; ++i) {
genTin.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 30 + event.rand.nextInt(20), event.worldZ + event.rand.nextInt(16));
}
}
if (generateCopperOre && TerrainGen.generateOre(event.world, event.rand, genCopper, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 10; ++i) {
genCopper.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 20 + event.rand.nextInt(20), event.worldZ + event.rand.nextInt(16));
}
}
if (generateSilverOre && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 4; ++i) {
genSilver.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 1 + event.rand.nextInt(29), event.worldZ + event.rand.nextInt(16));
}
}
short[] bIds = ((ChunkBiomeHook)event.world.getChunkFromBlockCoords(event.worldX, event.worldZ)).getBiomeShortArray();
for(int k = 0; k < bIds.length; ++k) {
if (bIds[k] == BiomeGenBase.ocean.biomeID || bIds[k] == BiomeGenBase.deepOcean.biomeID) {
if (generateManganeseCrust && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 7; ++i) {
genManganese.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 16 + event.rand.nextInt(48), event.worldZ + event.rand.nextInt(16));
}
}
if (generateCobaltCrust && TerrainGen.generateOre(event.world, event.rand, genSilver, event.worldX, event.worldZ, OreGenEvent.GenerateMinable.EventType.CUSTOM)) {
for(int i = 0; i < 7; ++i) {
genCobalt.generate(event.world, event.rand, event.worldX + event.rand.nextInt(16), 16 + event.rand.nextInt(48), event.worldZ + event.rand.nextInt(16));
}
}
break;
}
}
}
}
}
@@ -9,8 +9,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
remap = false)
public abstract class BiomeConfigurationMixin {
@ModifyConstant(method = "init",
constant = {@Constant(intValue = 170),
@Constant(intValue = 175)},
constant = {@Constant(intValue = 170), @Constant(intValue = 175)},
require = 2)
private static int shiftBiomeIDsUp(int id) {
return id + 3000;
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.nomadictents;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.yurtmod.dimension.TentChunkProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -22,7 +22,7 @@ public abstract class TentChunkProviderMixin {
require = 1)
private void setBiomesTweaked(Chunk chunk, byte[] p_76616_1_) {
short[] biomeMap = new short[256];
Arrays.fill(biomeMap, (short)BiomeGenBase.ocean.biomeID);
((IChunkMixin)chunk).setBiomeShortArray(biomeMap);
Arrays.fill(biomeMap, (short) BiomeGenBase.ocean.biomeID);
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeMap);
}
}
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lumien.randomthings.Items.ItemBiomeCapsule;
import lumien.randomthings.Items.ItemBiomePainter;
import lumien.randomthings.Items.ModItems;
@@ -28,7 +28,7 @@ public abstract class ItemBiomePainterMixin {
} else if (par3World.isRemote) {
return true;
} else {
for(int i = 0; i < par2EntityPlayer.inventory.getSizeInventory(); ++i) {
for (int i = 0; i < par2EntityPlayer.inventory.getSizeInventory(); ++i) {
ItemStack is = par2EntityPlayer.inventory.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemBiomeCapsule && is.getItemDamage() != 0) {
NBTTagCompound nbt = is.stackTagCompound;
@@ -40,16 +40,18 @@ public abstract class ItemBiomePainterMixin {
if (charges > 0 || par2EntityPlayer.capabilities.isCreativeMode) {
Chunk c = par3World.getChunkFromBlockCoords(par4, par6);
int biomeID = is.getItemDamage() - 1;
short[] biomeArray = ((IChunkMixin)c).getBiomeShortArray(); //changed
short[] biomeArray = ((ChunkBiomeHook) c).getBiomeShortArray(); //changed
if ((biomeArray[(par6 & 15) << 4 | par4 & 15] & 255) != biomeID) {
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short)(biomeID & 0xFFFF); //changed
((IChunkMixin)c).setBiomeShortArray(biomeArray); //changed
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short) (biomeID & 0xFFFF); //changed
((ChunkBiomeHook) c).setBiomeShortArray(biomeArray); //changed
if (!par2EntityPlayer.capabilities.isCreativeMode) {
nbt.setInteger("charges", charges - 1);
par2EntityPlayer.inventoryContainer.detectAndSendChanges();
}
PacketHandler.INSTANCE.sendToDimension(new MessagePaintBiome(par4, par5, par6, par3World.provider.dimensionId, biomeID), par3World.provider.dimensionId);
PacketHandler.INSTANCE.sendToDimension(
new MessagePaintBiome(par4, par5, par6, par3World.provider.dimensionId, biomeID),
par3World.provider.dimensionId);
}
}
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lumien.randomthings.Items.ItemBiomeCapsule;
import lumien.randomthings.Network.Messages.MessagePaintBiome;
import org.spongepowered.asm.mixin.Mixin;
@@ -24,15 +24,20 @@ import java.util.Random;
remap = false)
public abstract class MessagePaintBiomeMixin {
@Shadow private int posZ;
@Shadow
private int posZ;
@Shadow private int posX;
@Shadow
private int posX;
@Shadow private int biomeID;
@Shadow
private int biomeID;
@Shadow private int dimensionID;
@Shadow
private int dimensionID;
@Shadow private int posY;
@Shadow
private int posY;
/**
* @author FalsePattern
@@ -44,18 +49,25 @@ public abstract class MessagePaintBiomeMixin {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null && player.worldObj.provider.dimensionId == this.dimensionID) {
Chunk c = player.worldObj.getChunkFromBlockCoords(this.posX, this.posZ);
short[] biomeArray = ((IChunkMixin)c).getBiomeShortArray(); //changed
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short)(this.biomeID & 0xFFFF); //changed
((IChunkMixin)c).setBiomeShortArray(biomeArray); //changed
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0, player.worldObj.getActualHeight());
short[] biomeArray = ((ChunkBiomeHook) c).getBiomeShortArray(); //changed
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short) (this.biomeID & 0xFFFF); //changed
((ChunkBiomeHook) c).setBiomeShortArray(biomeArray); //changed
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0,
player.worldObj.getActualHeight());
BiomeGenBase biome = BiomeGenBase.getBiome(this.biomeID);
int colorInt = ItemBiomeCapsule.getColorForBiome(biome);
Random rng = new Random();
Color color = new Color(colorInt);
for(int i = 0; i < 64; ++i) {
EntityFX smoke = new EntitySmokeFX(player.worldObj, (float)this.posX + rng.nextFloat(), (float)this.posY + rng.nextFloat(), (float)this.posZ + rng.nextFloat(), 0.0, 0.0, 0.0);
smoke.setRBGColorF(0.003921569F * (float)color.getRed(), 0.003921569F * (float)color.getGreen(), 0.003921569F * (float)color.getBlue());
for (int i = 0; i < 64; ++i) {
EntityFX smoke = new EntitySmokeFX(player.worldObj,
(float) this.posX + rng.nextFloat(),
(float) this.posY + rng.nextFloat(),
(float) this.posZ + rng.nextFloat(),
0.0, 0.0, 0.0);
smoke.setRBGColorF(0.003921569F * (float) color.getRed(),
0.003921569F * (float) color.getGreen(),
0.003921569F * (float) color.getBlue());
Minecraft.getMinecraft().effectRenderer.addEffect(smoke);
}
}
@@ -0,0 +1,39 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.restructured;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import org.blockartistry.mod.Restructured.world.BiomeHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import java.util.Random;
@Mixin(value = BiomeHelper.class,
priority = 999,
remap = false)
public abstract class BiomeHelperMixin {
/**
* @author FalsePattern
* @reason Compat
*/
@Overwrite
public static BiomeGenBase chunkBiomeSurvey(World world, Chunk chunk, Random rand) {
short[] biomes = ((ChunkBiomeHook)chunk).getBiomeShortArray();
int[] counts = new int[biomes.length];
int highIndex = BiomeGenBase.plains.biomeID;
int highCount = -1;
for(int i = 0; i < 32; ++i) {
int id = biomes[rand.nextInt(biomes.length)] & 65535;
if (id != 65535 && ++counts[id] > highCount) {
highIndex = id;
highCount = counts[id];
}
}
return BiomeGenBase.getBiome(highIndex);
}
}
@@ -1,6 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.thaumcraft;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import thaumcraft.common.lib.network.PacketHandler;
@@ -24,7 +24,7 @@ public abstract class UtilsMixin {
public static void setBiomeAt(World world, int x, int z, BiomeGenBase biome) {
if (biome != null) {
Chunk chunk = world.getChunkFromBlockCoords(x, z);
short[] array = ((IChunkMixin) chunk).getBiomeShortArray();
short[] array = ((ChunkBiomeHook) chunk).getBiomeShortArray();
array[(z & 15) << 4 | x & 15] = (short) (biome.biomeID);
if (!world.isRemote) {
PacketHandler.INSTANCE.sendToAllAround(new PacketBiomeChange(x, z, (short) biome.biomeID),
@@ -1,65 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
@Mixin(AnvilChunkLoader.class)
public abstract class AnvilChunkLoaderMixin {
//TODO not thread safe
private Chunk chunk;
private NBTTagCompound nbt;
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B"),
require = 1)
private byte[] grabChunkBiomeDataWrite(Chunk instance) {
chunk = instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V"),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Sections"),
to = @At(value = "FIELD",
target = "Lnet/minecraft/world/chunk/Chunk;hasEntities:Z",
ordinal = 0)),
require = 1)
private void redirectBiomeDataWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeChunkBiomeArrayToNbt(chunk, instance);
chunk = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Biomes",
ordinal = 0)),
require = 1)
private boolean grabBiomeNBTRead(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
nbt = instance;
return true;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;setBiomeArray([B)V"),
require = 1)
private void redirectBiomeDataRead(Chunk instance, byte[] p_76616_1_) {
Hooks.readChunkBiomeArrayFromNbt(instance, nbt);
nbt = null;
}
}
@@ -3,7 +3,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import lombok.val;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -23,7 +23,7 @@ import java.util.Arrays;
@Mixin(value = Chunk.class,
priority = 900)
public abstract class ChunkMixin implements IChunkMixin {
public abstract class ChunkMixin implements ChunkBiomeHook {
@Shadow
@Final
public int xPosition;
@@ -1,21 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.Chunk;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B"),
require = 1)
private static byte[] getBiomesArrayShort(Chunk instance) {
return Hooks.shortToByteArray(((IChunkMixin) instance).getBiomeShortArray());
}
}
@@ -1,20 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
@Mixin(S26PacketMapChunkBulk.class)
public abstract class S26PacketMapChunkBulkMixin {
@ModifyConstant(method = "readPacketData",
constant = @Constant(intValue = VanillaConstants.bytesPerBiome * 16 * 16),
require = 1)
private int extend2(int contant) {
return ExtendedConstants.bytesPerBiome * 16 * 16;
}
}
@@ -1,8 +1,8 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.ubc;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator;
import exterminatorJeff.undergroundBiomes.worldGen.OreUBifier;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -16,7 +16,7 @@ import java.util.logging.Logger;
remap = false)
public abstract class BiomeUndergroundDecoratorMixin {
private static NibbleArray fakeArray;
private ThreadLocal<IExtendedBlockStorageMixin> ebs;
private SubChunkBlockHook subChunk;
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
@@ -24,13 +24,10 @@ public abstract class BiomeUndergroundDecoratorMixin {
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B",
remap = true),
require = 2)
private byte[] returnMSBasLSB(ExtendedBlockStorage instance) {
if (ebs == null) {
ebs = new ThreadLocal<>();
}
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
ebs.set(iebs);
return iebs.getMSB();
private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) {
SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla;
this.subChunk = subChunk;
return subChunk.getB1();
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
@@ -50,17 +47,9 @@ public abstract class BiomeUndergroundDecoratorMixin {
remap = true),
require = 2)
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
return ebs.get().getLSB()[y << 8 | z << 4 | x] & 0xFFFF;
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier;blockReplacer(I)LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier$BlockReplacer;"),
require = 2)
private OreUBifier.BlockReplacer reshuffleID(OreUBifier instance, int blockID) {
blockID = ((blockID & 0xFF) << 16) | ((blockID & 0xFFFF00) >>> 8);
return instance.blockReplacer(blockID);
val id = subChunk.getID(x, y, z) >>> 8;
subChunk = null;
return id;
}
@Redirect(method = "correctBiomeDecorators",
@@ -1,89 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(AnvilChunkLoader.class)
public abstract class AnvilChunkLoaderMixin {
//TODO not thread safe
private IExtendedBlockStorageMixin ebs;
private NBTTagCompound nbt;
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private byte[] grabEBSBlockDataWrite(ExtendedBlockStorage instance) {
ebs = (IExtendedBlockStorageMixin) instance;
return null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setByteArray(Ljava/lang/String;[B)V"),
slice = @Slice(from = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getYLocation()I"),
to = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;")),
require = 1)
private void redirectBlockDataWrite(NBTTagCompound instance, String p_74773_1_, byte[] p_74773_2_) {
Hooks.writeChunkToNbt(instance, ebs);
ebs = null;
}
@Redirect(method = "writeChunkToNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockMSBArray()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 1)
private NibbleArray suppressVanillaBlockDataWrite(ExtendedBlockStorage instance) {
return null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;getByteArray(Ljava/lang/String;)[B",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Blocks")),
require = 1)
private byte[] grabNBTBlockDataRead(NBTTagCompound instance, String p_74770_1_) {
nbt = instance;
return null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;setBlockLSBArray([B)V"),
require = 1)
private void redirectBlockDataRead(ExtendedBlockStorage instance, byte[] p_76664_1_) {
Hooks.readChunkFromNbt((IExtendedBlockStorageMixin) instance, nbt);
nbt = null;
}
@Redirect(method = "readChunkFromNBT",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z",
ordinal = 0),
slice = @Slice(from = @At(value = "CONSTANT",
args = "stringValue=Add",
ordinal = 0)),
require = 1)
private boolean suppressVanillaBlockDataRead(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
return false;
}
}
@@ -1,68 +1,85 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.EndlessIDs;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import com.falsepattern.endlessids.Tags;
import com.falsepattern.endlessids.config.GeneralConfig;
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
import lombok.val;
import lombok.var;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(ExtendedBlockStorage.class)
public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorageMixin {
public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
@Shadow
private int blockRefCount;
@Shadow
private int tickRefCount;
private short[] lsbArray;
private byte[] msbArray;
@Override
public void setBlockRefCount(int value) {
blockRefCount = value;
}
@Shadow
private byte[] blockLSBArray;
@Shadow
private NibbleArray blockMSBArray;
private NibbleArray b2High;
private byte[] b3;
@Override
public void setTickRefCount(int value) {
tickRefCount = value;
}
@Shadow
private NibbleArray blockMetadataArray;
private NibbleArray m1High;
private byte[] m2;
@Override
public short[] getLSB() {
return lsbArray;
}
@Override
public byte[] getMSB() {
return msbArray;
}
@Inject(method = "<init>",
at = @At(value = "RETURN"),
require = 1)
private void init(CallbackInfo ci) {
lsbArray = new short[16 * 16 * 16];
msbArray = new byte[16 * 16 * 16];
}
private int getID(int x, int y, int z) {
public int getID(int x, int y, int z) {
int index = y << 8 | z << 4 | x;
int lsb = lsbArray[index] & 0xFFFF;
int msb = (msbArray[index] & 0xFF) << 16;
return lsb | msb;
int id = blockLSBArray[index] & 0xFF;
if (blockMSBArray != null) {
id |= blockMSBArray.get(x, y, z) << 8;
if (b2High != null) {
id |= b2High.get(x, y, z) << 12;
if (b3 != null) {
id |= (b3[index] & 0xFF) << 16;
}
}
}
return id;
}
private void setID(int x, int y, int z, int id) {
int index = y << 8 | z << 4 | x;
int lsb = id & 0xFFFF;
int msb = (id >>> 16) & 0xFF;
lsbArray[index] = (short) lsb;
msbArray[index] = (byte) msb;
blockLSBArray[index] = (byte) (id & 0xFF);
if (id > 0xFF) {
if (blockMSBArray == null) {
createB2Low();
}
if (id > 0xFFF) {
if (b2High == null) {
createB2High();
}
if (id > 0xFFFF && b3 == null) {
createB3();
}
}
}
if (blockMSBArray != null) {
blockMSBArray.set(x, y, z, (id >>> 8) & 0xF);
if (b2High != null) {
b2High.set(x, y, z, (id >>> 12) & 0xF);
if (b3 != null) {
b3[index] = (byte) ((id >>> 16) & 0xFF);
}
}
}
}
/**
@@ -101,10 +118,230 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
/**
* @author FalsePattern
* @reason Direct port from dumped code
* @reason meta ID extension
*/
@Overwrite
public void removeInvalidBlocks() {
Hooks.removeInvalidBlocksHook(this);
public int getExtBlockMetadata(int x, int y, int z) {
int meta = blockMetadataArray.get(x, y, z);
if (m1High != null) {
meta |= m1High.get(x, y, z) << 4;
if (m2 != null) {
meta |= (m2[(y << 8) | (z << 4) | x] & 0xFF) << 8;
}
}
return meta;
}
/**
* @author FalsePattern
* @reason meta ID extension
*/
@Overwrite
public void setExtBlockMetadata(int x, int y, int z, int meta) {
blockMetadataArray.set(x, y, z, meta & 0xF);
if (meta > 0xF) {
if (m1High == null) {
createM1High();
}
if (meta > 0xFF && m2 == null) {
createM2();
}
}
if (m1High != null) {
m1High.set(x, y, z, (meta >>> 4) & 0xF);
if (m2 != null) {
m2[(y << 8) | (z << 4) | x] = (byte) ((meta >>> 8) & 0xFF);
}
}
}
@Redirect(method = "removeInvalidBlocks",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
require = 1)
private Block removeInvalidBlocks(ExtendedBlockStorage instance, int x, int y, int z) {
var block = instance.getBlockByExtId(x, y, z);
if (block == null && GeneralConfig.removeInvalidBlocks) {
instance.func_150818_a(x, y, z, Blocks.air);
block = Blocks.air;
}
return block;
}
private UnsupportedOperationException emergencyCrash() {
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the block array of a" +
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
"Please report this issue on https://github.com/FalsePattern/EndlessIDs ASAP!";
EndlessIDs.LOG.fatal(crashMSG);
return new UnsupportedOperationException(crashMSG);
}
@Override
public byte[] getB1() {
return blockLSBArray;
}
@Override
public void setB1(byte[] data) {
blockLSBArray = data;
}
@Override
public NibbleArray getB2Low() {
return blockMSBArray;
}
@Override
public void setB2Low(NibbleArray data) {
blockMSBArray = data;
}
@Override
public NibbleArray createB2Low() {
return (blockMSBArray = new NibbleArray(blockLSBArray.length, 4));
}
@Override
public NibbleArray getB2High() {
return b2High;
}
@Override
public void setB2High(NibbleArray data) {
b2High = data;
}
@Override
public NibbleArray createB2High() {
return (b2High = new NibbleArray(blockLSBArray.length, 4));
}
@Override
public byte[] getB3() {
return b3;
}
@Override
public void setB3(byte[] data) {
b3 = data;
}
@Override
public byte[] createB3() {
return b3 = new byte[blockLSBArray.length];
}
@Override
public NibbleArray getM1Low() {
return blockMetadataArray;
}
@Override
public void setM1Low(NibbleArray m1Low) {
blockMetadataArray = m1Low;
}
@Override
public NibbleArray getM1High() {
return m1High;
}
@Override
public void setM1High(NibbleArray m1High) {
this.m1High = m1High;
}
@Override
public NibbleArray createM1High() {
return (m1High = new NibbleArray(blockLSBArray.length, 4));
}
@Override
public byte[] getM2() {
return m2;
}
@Override
public void setM2(byte[] m2) {
this.m2 = m2;
}
@Override
public byte[] createM2() {
return (m2 = new byte[blockLSBArray.length]);
}
@Override
public int getBlockMask() {
if (blockMSBArray == null) {
return 0b00;
}
if (b2High == null) {
return 0b01;
}
if (b3 == null) {
return 0b10;
}
return 0b11;
}
@Override
public int getMetadataMask() {
if (m1High == null) {
return 0b01;
}
if (m2 == null) {
return 0b10;
}
return 0b11;
}
@Inject(method = {"getBlockMSBArray", "createBlockMSBArray"},
at = @At("HEAD"),
expect = 0)
private void crashMSBArray(CallbackInfoReturnable<NibbleArray> cir) {
throw emergencyCrash();
}
@Inject(method = "clearMSBArray",
at = @At("HEAD"),
expect = 0)
private void crashMSBArray(CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "setBlockMSBArray",
at = @At("HEAD"),
expect = 0)
private void crashMSBArray(NibbleArray p_76673_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "setBlockLSBArray",
at = @At("HEAD"),
expect = 0)
private void crashLSBArray(byte[] p_76664_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "getBlockLSBArray",
at = @At("HEAD"),
expect = 0)
private void crashLSBArray(CallbackInfoReturnable<byte[]> cir) {
throw emergencyCrash();
}
@Inject(method = "setBlockMetadataArray",
at = @At("HEAD"),
expect = 0)
private void crashMetadataArray(NibbleArray p_76668_1_, CallbackInfo ci) {
throw emergencyCrash();
}
@Inject(method = "getMetadataArray",
at = @At("HEAD"),
expect = 0)
private void crashMetadataArray(CallbackInfoReturnable<NibbleArray> cir) {
throw emergencyCrash();
}
}
@@ -12,7 +12,7 @@ import net.minecraft.network.PacketBuffer;
import java.io.IOException;
@Mixin(PacketBuffer.class)
@Mixin(value = PacketBuffer.class, priority = 999)
public abstract class PacketBufferMixin {
@Shadow
@@ -1,32 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@Redirect(method = "func_149269_a",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B"),
require = 1)
private static byte[] hookGetBlockData(ExtendedBlockStorage instance) {
return Hooks.getBlockData((IExtendedBlockStorageMixin) instance);
}
@ModifyConstant(method = "readPacketData",
constant = @Constant(intValue = VanillaConstants.bytesPerEBS),
require = 1)
private int increaseReadSize(int constant) {
return ExtendedConstants.bytesPerEBS;
}
}
@@ -1,5 +1,7 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
@@ -18,13 +20,12 @@ public abstract class S22PacketMultiBlockChangeMixin {
private int id;
private int meta;
//TODO magic number
@ModifyConstant(method = "<init>(I[SLnet/minecraft/world/chunk/Chunk;)V",
constant = @Constant(intValue = 4,
constant = @Constant(intValue = 2 + VanillaConstants.bytesPerIDPlusMetadata,
ordinal = 0),
require = 1)
private int extend1(int constant) {
return 6;
return 2 + ExtendedConstants.bytesPerIDPlusMetadata;
}
@Redirect(method = "<init>(I[SLnet/minecraft/world/chunk/Chunk;)V",
@@ -46,6 +47,6 @@ public abstract class S22PacketMultiBlockChangeMixin {
private void hackWrite(DataOutputStream instance, int value) throws IOException {
instance.writeShort(id & 0xFFFF);
instance.writeByte((id >>> 16) & 0xFF);
instance.writeByte(meta);
instance.writeShort(meta);
}
}
@@ -1,19 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.network.play.server.S26PacketMapChunkBulk;
@Mixin(S26PacketMapChunkBulk.class)
public abstract class S26PacketMapChunkBulkMixin {
@ModifyConstant(method = "readPacketData",
constant = @Constant(intValue = VanillaConstants.bytesPerIDPlusMetadata * 16 * 16 * 16),
require = 1)
private int extend1(int constant) {
return ExtendedConstants.bytesPerIDPlusMetadata * 16 * 16 * 16;
}
}
@@ -11,10 +11,17 @@ import net.minecraft.stats.StatList;
@Mixin(StatList.class)
public abstract class StatListMixin {
@ModifyConstant(method = "<clinit>",
constant = {@Constant(intValue = VanillaConstants.blockIDCount), @Constant(intValue = 32000)},
require = 4)
constant = {@Constant(intValue = VanillaConstants.blockIDCount)},
require = 1)
private static int modifyMineBlockStatArraySize(int constant) {
return ExtendedConstants.blockIDCount;
}
@ModifyConstant(method = "<clinit>",
constant = {@Constant(intValue = VanillaConstants.itemIDCount)},
require = 3)
private static int modifyItemStatArraysSize(int constant) {
return ExtendedConstants.itemIDCount;
}
}
@@ -4,10 +4,13 @@ import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.sk89q.worldedit.blocks.BaseBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = BaseBlock.class,
remap = false)
public abstract class BaseBlockMixin {
@Shadow
private short data;
private int idExtended;
/**
@@ -35,4 +38,29 @@ public abstract class BaseBlockMixin {
return idExtended;
}
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
public int getData() {
return this.data & 0xFFFF;
}
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
protected final void internalSetData(int data) {
if (data > 0xFFFF) {
throw new IllegalArgumentException("Can't have a block data value above 65535 (" + data + " given)");
} else if (data < -1) {
throw new IllegalArgumentException("Can't have a block data value below -1");
} else {
this.data = (short) data;
}
}
}
@@ -0,0 +1,24 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.entity.EntityList;
@Mixin(EntityList.class)
public abstract class EntityListMixin {
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
constant = @Constant(intValue = VanillaConstants.maxEntityID),
require = 1)
private static int extendRange(int constant) {
return ExtendedConstants.maxEntityID;
}
}
@@ -0,0 +1,66 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.apache.logging.log4j.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.EntityRegistry;
import java.util.BitSet;
@Mixin(value = EntityRegistry.class,
remap = false)
public abstract class EntityRegistryMixin {
@Shadow private BitSet availableIndicies;
@ModifyConstant(method = "<init>",
constant = @Constant(intValue = VanillaConstants.entityIDCount),
require = 1)
private int extendIDs1(int constant) {
return ExtendedConstants.entityIDCount;
}
@ModifyConstant(method = "<init>",
constant = @Constant(intValue = VanillaConstants.maxEntityID),
require = 1)
private int extendIDs2(int constant) {
return ExtendedConstants.maxEntityID;
}
/**
* @author FalsePattern
* @reason Extended IDs
*/
@Overwrite
private int validateAndClaimId(int id) {
//Keeping the legacy sub-0 id workaround here...
// workaround for broken ML
int realId = id;
if (id < Byte.MIN_VALUE) {
realId += 3000;
FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId);
}
if (realId < 0) {
realId += Byte.MAX_VALUE;
}
if ((realId & ~ExtendedConstants.entityIDMask) != 0) {
FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not in the range 1-" + ExtendedConstants.entityIDMask + " and may not work", id, Loader.instance().activeModContainer().getModId());
}
if (!availableIndicies.get(realId)) {
FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id);
}
availableIndicies.clear(realId);
return realId;
}
}
@@ -0,0 +1,63 @@
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import io.netty.buffer.ByteBuf;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S0FPacketSpawnMob;
@Mixin(S0FPacketSpawnMob.class)
public abstract class S0FPacketSpawnMobMixin {
@Shadow private int field_149040_b;
@Inject(method = "<init>(Lnet/minecraft/entity/EntityLivingBase;)V",
at = @At("RETURN"),
require = 1)
private void unClampType(EntityLivingBase entity, CallbackInfo ci) {
field_149040_b = EntityList.getEntityID(entity);
}
@Redirect(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
private byte noReadByte(PacketBuffer data) {
return 0;
}
@Inject(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
private void readType(PacketBuffer data, CallbackInfo ci) {
field_149040_b = data.readShort() & ExtendedConstants.entityIDMask;
}
@Redirect(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private ByteBuf noWriteByte(PacketBuffer data, int theByte) {
return null;
}
@Inject(method = "writePacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
ordinal = 0),
require = 1)
private void writeType(PacketBuffer data, CallbackInfo ci) {
data.writeShort(field_149040_b & ExtendedConstants.entityIDMask);
}
}
@@ -13,32 +13,6 @@ import net.minecraft.potion.PotionEffect;
@Mixin(value = PotionEffect.class)
public abstract class PotionEffectMixin {
@Shadow public abstract int getPotionID();
@Shadow public abstract int getAmplifier();
@Shadow public abstract int getDuration();
@Shadow public abstract boolean getIsAmbient();
@Inject(method = "writeCustomPotionEffectToNBT",
at = @At(value = "HEAD"),
cancellable = true,
require = 1)
private void writeCustomPotionEffectToNBTExtended(NBTTagCompound nbt, CallbackInfoReturnable<NBTTagCompound> cir) {
val potionID = getPotionID();
if (potionID > 127) {
nbt.setInteger("IdExtended", potionID);
nbt.setByte("Id", (byte)-1);
} else {
nbt.setByte("Id", (byte)potionID);
}
nbt.setByte("Amplifier", (byte)this.getAmplifier());
nbt.setInteger("Duration", this.getDuration());
nbt.setBoolean("Ambient", this.getIsAmbient());
cir.setReturnValue(nbt);
}
@Inject(method = "readCustomPotionEffectFromNBT",
at = @At(value = "HEAD"),
cancellable = true,
@@ -60,4 +34,34 @@ public abstract class PotionEffectMixin {
cir.setReturnValue(null);
}
}
@Shadow
public abstract int getPotionID();
@Shadow
public abstract int getAmplifier();
@Shadow
public abstract int getDuration();
@Shadow
public abstract boolean getIsAmbient();
@Inject(method = "writeCustomPotionEffectToNBT",
at = @At(value = "HEAD"),
cancellable = true,
require = 1)
private void writeCustomPotionEffectToNBTExtended(NBTTagCompound nbt, CallbackInfoReturnable<NBTTagCompound> cir) {
val potionID = getPotionID();
if (potionID > 127) {
nbt.setInteger("IdExtended", potionID);
nbt.setByte("Id", (byte) -1);
} else {
nbt.setByte("Id", (byte) potionID);
}
nbt.setByte("Amplifier", (byte) this.getAmplifier());
nbt.setInteger("Duration", this.getDuration());
nbt.setBoolean("Ambient", this.getIsAmbient());
cir.setReturnValue(nbt);
}
}
@@ -9,7 +9,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.potion.Potion;
import java.util.Arrays;
@@ -18,7 +18,7 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
@WrapOperation(method = "<init>(ILnet/minecraft/potion/PotionEffect;)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
require = 1)
private int getPotionID(PotionEffect effect, Operation<Integer> original) {
idExtended = original.call(effect);
@@ -26,10 +26,10 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
}
@Redirect(method = "readPacketData",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
ordinal = 0),
require = 1)
private byte networkReadPacketData(PacketBuffer instance) {
idExtended = instance.readInt();
return -1;
@@ -44,9 +44,9 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
instance.writeInt(idExtended);
return null;
}
@Override
public int getIDExtended() {
@Override
public int getIDExtended() {
return this.idExtended;
}
}
@@ -13,7 +13,8 @@ import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect;
@Mixin(S1EPacketRemoveEntityEffect.class)
public abstract class S1EPacketRemoveEntityEffectMixin {
@Shadow private int field_149078_b;
@Shadow
private int field_149078_b;
@Redirect(method = "readPacketData",
at = @At(value = "INVOKE",
@@ -0,0 +1,21 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockCompressedPowered;
import net.minecraft.world.IBlockAccess;
@Mixin(BlockCompressedPowered.class)
public abstract class BlockCompressedPoweredMixin {
@Inject(method = "isProvidingWeakPower",
at = @At("HEAD"),
cancellable = true,
require = 1)
private void bigRedstone(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(GeneralConfig.maxRedstone);
}
}
@@ -0,0 +1,20 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.BlockRedstoneDiode;
import net.minecraft.world.IBlockAccess;
@Mixin(BlockRedstoneDiode.class)
public abstract class BlockRedstoneDiodeMixin {
@Inject(method = "func_149904_f",
at = @At("HEAD"),
cancellable = true)
private void bigRedstone(IBlockAccess p_149904_1_, int p_149904_2_, int p_149904_3_, int p_149904_4_, int p_149904_5_, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(GeneralConfig.maxRedstone);
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.block.BlockRedstoneTorch;
@Mixin(BlockRedstoneTorch.class)
public abstract class BlockRedstoneTorchMixin {
@ModifyConstant(method = "isProvidingWeakPower",
constant = @Constant(intValue = 15),
require = 1)
private int bigRedstone(int original) {
return GeneralConfig.maxRedstone;
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.redstone;
import com.falsepattern.endlessids.config.GeneralConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.world.World;
@Mixin(World.class)
public abstract class WorldMixin {
@ModifyConstant(method = {"getStrongestIndirectPower", "getBlockPowerInput"},
constant = @Constant(intValue = 15),
require = 8)
private int bigRedstone(int constant) {
return GeneralConfig.maxRedstone;
}
}
@@ -1,26 +0,0 @@
package com.falsepattern.endlessids.mixin.mixins.common.vanilla;
import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(S21PacketChunkData.class)
public abstract class S21PacketChunkDataMixin {
@ModifyConstant(method = {"<clinit>", "func_149275_c"},
constant = @Constant(intValue = VanillaConstants.bytesPerChunk),
require = 1)
private static int increasePacketSize(int constant) {
return ExtendedConstants.bytesPerChunk;
}
}
@@ -9,7 +9,6 @@ import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.function.Predicate;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.always;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.avoid;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.condition;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.require;
@@ -17,9 +16,6 @@ import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.require;
@RequiredArgsConstructor
public enum Mixin implements IMixin {
//region common
//region vanilla
S21PacketChunkDataMixin(Side.COMMON, always(), "vanilla.S21PacketChunkDataMixin"),
//endregion vanilla
//region AntiIDConflict
AIDCAntiIdConflictBaseMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.AntiIdConflictBaseMixin"),
AIDCBiomesGenBasePlaceholderMixin(Side.COMMON, require(TargetedMod.ANTIIDCONFLICT), "antiidconflict.BiomeGenBasePlaceholderMixin"),
@@ -31,14 +27,11 @@ public enum Mixin implements IMixin {
//endregion AntiIDConflict
//region biome
//region vanilla
AnvilChunkLoaderMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.AnvilChunkLoaderMixin"),
BiomeDictionaryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeDictionaryMixin"),
BiomeGenBaseMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.BiomeGenBaseMixin"),
ChunkMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.ChunkMixin"),
GenLayerRiverMixMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(avoid(TargetedMod.DRAGONAPI)), "biome.vanilla.GenLayerRiverMixMixin"),
GenLayerVoronoiZoomMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.GenLayerVoronoiZoomMixin"),
S21PacketChunkDataMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.S21PacketChunkDataMixin"),
S26PacketMapChunkBulkMixinBiome(Side.COMMON, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.S26PacketMapChunkBulkMixin"),
//endregion vanilla
//region AbyssalCraft
AbyssalCraftMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.ABYSSALCRAFT)), "biome.abyssalcraft.AbyssalCraftMixin"),
@@ -67,7 +60,7 @@ public enum Mixin implements IMixin {
BOPBiomesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BOP)), "biome.bop.BOPBiomesMixin"),
//endregion BoP
//region Buildcraft
BuildcraftEnergyMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BUILDCRAFT)), "buildcraft.BuildcraftEnergyMixin"),
BuildcraftEnergyMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BUILDCRAFT)), "biome.buildcraft.BuildcraftEnergyMixin"),
//endregion Buildcraft
//region CompactMachines
CMCubeToolsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.COMPACTMACHINES)), "biome.compactmachines.CubeToolsMixin"),
@@ -75,6 +68,9 @@ public enum Mixin implements IMixin {
//region DarkWorld
DarkWorldModBiomesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DARKWORLD)), "biome.darkworld.ModBiomesMixin"),
//endregion DarkWorld
//region DimDoors
DDBiomeGenBaseMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DIMDOORS)), "biome.dimdoors.DDBiomeGenBaseMixin"),
//endregion DimDoors
//region DragonAPI
DragonAPIGenLayerRiverMixVanillaMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DRAGONAPI)), "biome.dragonapi.vanilla.GenLayerRiverMixMixin"),
DragonAPIGenLayerRiverEventMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.DRAGONAPI)), "biome.dragonapi.GenLayerRiverEventMixin"),
@@ -120,6 +116,9 @@ public enum Mixin implements IMixin {
//region ICG
ICGMysteriumPatchesFixesCaveMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.ICG)), "biome.icg.MysteriumPatchesFixesCaveMixin"),
//endregion ICG
//region Industrial Revolution by Redstone Rebooted
IR3IR2Mixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.IR3)), "biome.ir3.IR2Mixin"),
//endregion Industrial Revolution by Redstone Rebooted
//region LOTR
LOTRBiomeVariantStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRBiomeVariantStorageMixin"),
LOTRChunkProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRChunkProviderMixin"),
@@ -140,6 +139,9 @@ public enum Mixin implements IMixin {
ItemBiomePainterMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.ItemBiomePainterMixin"),
MessagePaintBiomeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.MessagePaintBiomeMixin"),
//endregion RandomThings
//region Restructured
RSBiomeHelperMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RESTRUCTURED)), "biome.restructured.BiomeHelperMixin"),
//endregion Restructured
//region RTG
RTGChunkProviderRTGMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RTG)), "biome.rtg.ChunkProviderRTGMixin"),
RTGLandscapeGeneratorMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RTG)), "biome.rtg.LandscapeGeneratorMixin"),
@@ -164,16 +166,13 @@ public enum Mixin implements IMixin {
//endregion biome
//region blockitem
//region vanilla
AnvilChunkLoaderMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.AnvilChunkLoaderMixin"),
BlockFireMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockFireMixin"),
ExtendedBlockStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ExtendedBlockStorageMixin"),
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
PacketBufferMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.PacketBufferMixin"),
S21PacketChunkDataMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S21PacketChunkDataMixin"),
S22PacketMultiBlockChangeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S22PacketMultiBlockChangeMixin"),
S24PacketBlockActionMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S24PacketBlockActionMixin"),
S26PacketMapChunkBulkMixinBlockItem(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.S26PacketMapChunkBulkMixin"),
StatListMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.StatListMixin"),
WorldMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.WorldMixin"),
//endregion vanilla
@@ -216,20 +215,23 @@ public enum Mixin implements IMixin {
S1EPacketRemoveEntityEffectMixin(Side.COMMON, condition(() -> GeneralConfig.extendPotion), "potion.vanilla.network.S1EPacketRemoveEntityEffectMixin"),
//endregion vanilla
//endregion potion
//region entity
//region vanilla
EntityListMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityListMixin"),
EntityRegistryMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityRegistryMixin"),
S0FPacketSpawnMobMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.S0FPacketSpawnMobMixin"),
//endregion vanilla
//endregion entity
//endregion common
//region client
//region biome
//region vanilla
ChunkMixinClientBiome(Side.CLIENT, condition(() -> GeneralConfig.extendBiome), "biome.vanilla.ChunkMixin"),
//endregion vanilla
//region Biome Wand
BiomeWandItemClientMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.BIOMEWAND)), "biome.biomewand.BiomeWandItemMixin"),
//endregion Biome Wand
//endregion biome
//region blockitem
//region vanilla
ChunkMixinClientBlockItem(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ChunkMixin"),
NetHandlerPlayClientMixinBlockItem(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.NetHandlerPlayClientMixin"),
PlayerControllerMPMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.PlayerControllerMPMixin"),
RenderGlobalMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.RenderGlobalMixin"),
@@ -242,6 +244,19 @@ public enum Mixin implements IMixin {
//endregion potion
//endregion client
//region redstone
//region common
BlockCompressedPoweredMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockCompressedPoweredMixin"),
BlockRedstoneDiodeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneDiodeMixin"),
BlockRedstoneTorchMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneTorchMixin"),
RedstoneWorldMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.WorldMixin"),
//endregion common
//region client
BlockRedstoneWireMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.BlockRedstoneWireMixin"),
RedstoneRenderBlocksMixin(Side.CLIENT, condition(() -> GeneralConfig.extendBlockItem && GeneralConfig.extendRedstone), "redstone.RenderBlocksMixin"),
//endregion client
//endregion redstone
;
@Getter
private final Side side;
@@ -23,6 +23,7 @@ public enum TargetedMod implements ITargetedMod {
COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
COMPACTMACHINES("Compact Machines", false, startsWith("compactmachines-")),
DARKWORLD("Dark World", false, startsWith("darkworld-")),
DIMDOORS("Dimensional Doors", false, startsWith("dimensionaldoors-").or(startsWith("dimdoors-"))),
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
EB("Enhanced Biomes", false, startsWith("Enhanced Biomes").or(startsWith("enhancedbiomes"))),
ENDERLICIOUS("Enderlicious", false, startsWith("enderlicious-")),
@@ -34,12 +35,14 @@ public enum TargetedMod implements ITargetedMod {
GALAXYSPACE("GalaxySpace", false, startsWith("galaxyspace-")),
HIGHLANDS("Highlands", false, startsWith("highlands")),
ICG("Immersive Cavegen", false, startsWith("immersivecavegen")),
IR3("Industrial Revolution by Redstone Rebooted", false, startsWith("industrialrevolutionbyredstonerebooted-")),
LOTR("LOTR Mod", false, startsWith("lotrmod")),
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
NATURESCOMPASS("Nature's Compass", false, startsWith("naturescompass")),
NETHERLICIOUS("Netherlicious", false, startsWith("netherlicious-")),
NOMADICTENTS("Nomadic Tents", false, startsWith("nomadictents")),
RANDOMTHINGS("Random Things", false, startsWith("randomthings-")),
RESTRUCTURED("Restructured", false, startsWith("restructured-")),
RTG("Realistic Terrain Generation", false, startsWith("rtg-")),
RWG("Realistic World Gen", false, startsWith("rwg-")),
THAUMCRAFT("Thaumcraft", false, startsWith("thaumcraft")),
@@ -3,10 +3,10 @@ package com.falsepattern.endlessids.mixin.stubpackage.org.dave.CompactMachines.t
import net.minecraft.world.World;
public class TileEntityMachine {
public World getWorldObj()
{
return null;
}
public int xCoord;
public int zCoord;
public World getWorldObj() {
return null;
}
}
@@ -40,7 +40,7 @@ public class CommonManager {
}
private void runPatches(String stageName, Stage stage) throws Exception {
for (val patch: patches) {
for (val patch : patches) {
if (Loader.isModLoaded(patch.modid)) {
try {
if (stage.run(patch)) {
@@ -0,0 +1,71 @@
package com.falsepattern.endlessids.util;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Like WeakHashMap, but uses identity instead of equality when comparing keys.
*/
public class WeakIdentityHashMap<K,V> {
private final HashMap<WeakReference<K>,V> mMap = new HashMap<>();
private final ReferenceQueue<Object> mRefQueue = new ReferenceQueue<>();
private void cleanUp() {
Reference<?> ref;
while ((ref = mRefQueue.poll()) != null) {
mMap.remove(ref);
}
}
public void put(K key, V value) {
cleanUp();
mMap.put(new CmpWeakReference<>(key, mRefQueue), value);
}
public V get(K key) {
cleanUp();
return mMap.get(new CmpWeakReference<>(key));
}
public Collection<V> values() {
cleanUp();
return mMap.values();
}
public Set<Map.Entry<WeakReference<K>, V>> entrySet() {
return mMap.entrySet();
}
public int size() {
cleanUp();
return mMap.size();
}
public boolean isEmpty() {
cleanUp();
return mMap.isEmpty();
}
private static class CmpWeakReference<K> extends WeakReference<K> {
private final int mHashCode;
public CmpWeakReference(K key) {
super(key);
mHashCode = System.identityHashCode(key);
}
public CmpWeakReference(K key, ReferenceQueue<Object> refQueue) {
super(key, refQueue);
mHashCode = System.identityHashCode(key);
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
K k = get();
if (k != null && o instanceof CmpWeakReference) {
return ((CmpWeakReference) o).get() == k;
}
return false;
}
@Override
public int hashCode() {
return mHashCode;
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ EndlessIDs
Copyright (C) 2022 FalsePattern
All Rights Reserved
The above copyright notice, this permission notice and the word "SNEED"
The above copyright notice, this permission notice and the word "MEGA"
shall be included in all copies or substantial portions of the Software.
This program is free software: you can redistribute it and/or modify