mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-28 13:36:06 +00:00
Compare commits
28
Commits
1.5-alpha0010
...
1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87ff6bc0ab | ||
|
|
0a74b2494b | ||
|
|
a58bb1e202 | ||
|
|
8c77bf1110 | ||
|
|
35bd58a9d0 | ||
|
|
07474f33f9 | ||
|
|
a4868e8de8 | ||
|
|
19f11ee62e | ||
|
|
c8de7349dc | ||
|
|
410d344b84 | ||
|
|
f8e024f1bb | ||
|
|
06b033e179 | ||
|
|
a432bdeb04 | ||
|
|
d43e108513 | ||
|
|
eeaca66dd5 | ||
|
|
380841b840 | ||
|
|
9d37327993 | ||
|
|
9a1b9f7798 | ||
|
|
3dd168fc8e | ||
|
|
83bfb89d8b | ||
|
|
5d5a03486f | ||
|
|
6103fe96bb | ||
|
|
d3334c7ca8 | ||
|
|
7fc49578ce | ||
|
|
59862bb5ad | ||
|
|
c052edf912 | ||
|
|
79f0c06fa5 | ||
|
|
53f3cffb59 |
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
patreon: falsepattern
|
||||||
|
ko_fi: falsepattern
|
||||||
Generated
+3
@@ -29,6 +29,9 @@
|
|||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
|
<ScalaCodeStyleSettings>
|
||||||
|
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||||
|
</ScalaCodeStyleSettings>
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
The code is a rewrite of NotEnoughIDs, created by fewizz and Player,
|
The code is a rewrite of NotEnoughIDs, created by fewizz and Player,
|
||||||
which was released under the MIT license on CurseForge at https://www.curseforge.com/minecraft/mc-mods/notenoughids
|
which was released under the MIT license on CurseForge at
|
||||||
|
https://www.curseforge.com/minecraft/mc-mods/notenoughids
|
||||||
|
|
||||||
Original License text of NotEnoughIDs:
|
Original License text of NotEnoughIDs:
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@@ -19,3 +20,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Some patches have been adapted from the GTNH fork of NotEnoughIDs,
|
||||||
|
its license is as follows:
|
||||||
|
|
||||||
|
GTNH modifications Copyright (c) 2021-2022 The GTNH Team
|
||||||
|
|
||||||
|
This code is licensed LGPL v3.0 or later. Feel free to use our changes,
|
||||||
|
just give back any changes you make to the community as well!
|
||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
@@ -1,6 +1,6 @@
|
|||||||
EndlessIDs
|
EndlessIDs
|
||||||
|
|
||||||
Copyright (C) 2022 FalsePattern
|
Copyright (C) 2022-2023 FalsePattern
|
||||||
All Rights Reserved
|
All Rights Reserved
|
||||||
|
|
||||||
The above copyright notice, this permission notice and the words "MEGA"
|
The above copyright notice, this permission notice and the words "MEGA"
|
||||||
|
|||||||
@@ -1,23 +1,34 @@
|
|||||||
|
# EndlessIDs <img src="EIDSico.png" align="right" width=150>
|
||||||
|
|
||||||
|
<sup>**[CurseForge](https://www.curseforge.com/minecraft/mc-mods/endlessids) | [Modrinth](https://modrinth.com/mod/endlessids)**</sup>
|
||||||
|
|
||||||
EndlessIDs is the unofficial successor of NotEnoughIDs, with more focus on compatibility, stability, and reaching
|
EndlessIDs is the unofficial successor of NotEnoughIDs, with more focus on compatibility, stability, and reaching
|
||||||
new limits.
|
new limits.
|
||||||
|
|
||||||
## REQUIRED MODS
|
## REQUIRED MODS
|
||||||
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
|
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
|
||||||
- [GasStation](https://github.com/FalsePattern/GasStation)
|
- [UniMixins](https://github.com/LegacyModdingMC/UniMixins)
|
||||||
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
|
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
|
||||||
|
|
||||||
Comparison of the known limits:
|
## NotEnoughIDs
|
||||||
|
EndlessIDs can open and upgrade worlds created with NotEnoughIDs without any problems (both the original and the Unofficial version).
|
||||||
|
If you notice any problems when opening NEID worlds with EndlessIDs, please open an issue!
|
||||||
|
|
||||||
| | Vanilla | NotEnoughIDs | EndlessIDs |
|
## Comparison of the known limits
|
||||||
|-----------------|----------------------------------------------------|--------------|----------------------|
|
|
||||||
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
|
| | Vanilla | NotEnoughIDs | NEID Unofficial | EndlessIDs |
|
||||||
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
|
|-----------------|----------------------------------------------------|--------------|-----------------|------------|
|
||||||
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
|
| Block IDs | 4,096 | 32,000 | 65,536 | 16,777,216 |
|
||||||
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
|
| Block Metadata | 16 | 16 | 65,536 | 65,536 |
|
||||||
| Entity IDs | 256 | 256 | 32,768 since 1.5 |
|
| Item IDs | 32,000 | 32,000 | 65,536 | 16,777,216 |
|
||||||
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
|
| Biome IDs | 256 | 256 | 256 | 65,536 |
|
||||||
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
|
| Entity IDs | 256 | 256 | 256 | 32,768 |
|
||||||
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
|
| Potion IDs | 32 | 32 | 32 | 65,536 |
|
||||||
|
| Enchantment IDs | 256 | 256 | 256 | 32,768 |
|
||||||
|
| DataWatcher IDs | 32 | 127 (Broken) | 127 (Broken) | 65,536 |
|
||||||
|
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same | Same |
|
||||||
|
|
||||||
|
## Mod compat
|
||||||
|
|
||||||
This mod also contains patches for the following mods:
|
This mod also contains patches for the following mods:
|
||||||
|
|
||||||
@@ -57,6 +68,7 @@ This mod also contains patches for the following mods:
|
|||||||
- Realistic Terrain Generation
|
- Realistic Terrain Generation
|
||||||
- Realistic World Generation
|
- Realistic World Generation
|
||||||
- Thaumcraft
|
- Thaumcraft
|
||||||
|
- The Lord of the Rings Mod: Legacy
|
||||||
- Tropicraft
|
- Tropicraft
|
||||||
- Twilight Forest
|
- Twilight Forest
|
||||||
- Underground Biomes Constructs
|
- Underground Biomes Constructs
|
||||||
|
|||||||
+93
-46
@@ -1,4 +1,4 @@
|
|||||||
//version: 1656003793falsepattern67
|
//version: 1656003793falsepattern76
|
||||||
/*
|
/*
|
||||||
DO NOT CHANGE THIS FILE!
|
DO NOT CHANGE THIS FILE!
|
||||||
|
|
||||||
@@ -132,6 +132,8 @@ propertyDefaultIfUnset("mixinConfigs", "")
|
|||||||
propertyDefaultIfUnset("mixinPluginPreInit", "")
|
propertyDefaultIfUnset("mixinPluginPreInit", "")
|
||||||
propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5")
|
propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5")
|
||||||
propertyDefaultIfUnset("remapStubs", false)
|
propertyDefaultIfUnset("remapStubs", false)
|
||||||
|
propertyDefaultIfUnset("apiPackages", null)
|
||||||
|
propertyDefaultIfUnset("apiPackagesNoRecurse", null)
|
||||||
|
|
||||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||||
propertyDefaultIfUnset("modrinthDependencies", "")
|
propertyDefaultIfUnset("modrinthDependencies", "")
|
||||||
@@ -147,20 +149,31 @@ String javaSourceDir = "src/main/java/"
|
|||||||
String scalaSourceDir = "src/main/scala/"
|
String scalaSourceDir = "src/main/scala/"
|
||||||
String kotlinSourceDir = "src/main/kotlin/"
|
String kotlinSourceDir = "src/main/kotlin/"
|
||||||
|
|
||||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
def verifyPackage(thePackage, propName) {
|
||||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
String javaSourceDir = "src/main/java/"
|
||||||
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
String scalaSourceDir = "src/main/scala/"
|
||||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
String kotlinSourceDir = "src/main/kotlin/"
|
||||||
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
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) {
|
if(apiPackage) {
|
||||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
verifyPackage(apiPackage, "apiPackage")
|
||||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
}
|
||||||
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
|
||||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
|
||||||
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
if (apiPackages) {
|
||||||
}
|
apiPackages.tokenize(';').forEach { it -> verifyPackage(it, "apiPackages")}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apiPackagesNoRecurse) {
|
||||||
|
apiPackagesNoRecurse.tokenize(';').forEach { it -> verifyPackage(it, "apiPackagesNoRecurse")}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(accessTransformersFile) {
|
if(accessTransformersFile) {
|
||||||
@@ -175,9 +188,9 @@ if(usesMixins.toBoolean()) {
|
|||||||
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
|
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
|
||||||
}
|
}
|
||||||
|
|
||||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||||
targetPackageKotlin = kotlinSourceDir + 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())) {
|
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)
|
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'
|
apply from: 'repositories.gradle'
|
||||||
|
|
||||||
|
if(file('repositories_override.gradle').exists()) {
|
||||||
|
apply from: 'repositories_override.gradle'
|
||||||
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
for (config in [shadowImplementation, shadowCompile, shadeCompile]) {
|
for (config in [shadowImplementation, shadowCompile, shadeCompile]) {
|
||||||
implementation.extendsFrom(shadeCompile)
|
implementation.extendsFrom(shadeCompile)
|
||||||
@@ -294,7 +311,11 @@ configurations {
|
|||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "Overmind forge repo mirror"
|
name = "Overmind forge repo mirror"
|
||||||
url = "https://gregtech.overminddl1.com/"
|
url = "https://mvn.falsepattern.com/overmind"
|
||||||
|
content {
|
||||||
|
includeGroup("net.minecraftforge")
|
||||||
|
includeGroup("org.scala-lang")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
||||||
maven {
|
maven {
|
||||||
@@ -305,36 +326,52 @@ repositories {
|
|||||||
name = "sponge2"
|
name = "sponge2"
|
||||||
url = "https://mvn.falsepattern.com/sponge"
|
url = "https://mvn.falsepattern.com/sponge"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = "jitpack"
|
||||||
|
url = "https://mvn.falsepattern.com/jitpack/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def unimixinsVersion = "0.1.15"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
if(usesMixins.toBoolean()) {
|
if(usesMixins.toBoolean()) {
|
||||||
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||||
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||||
annotationProcessor("com.llamalad7:MixinExtras:0.1.1-gasstation")
|
annotationProcessor("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||||
annotationProcessor("org.spongepowered:mixin:0.8.5-gasstation_7")
|
implementation("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||||
compile("org.spongepowered:mixin:0.8.5-gasstation_7")
|
runtimeOnly('org.jetbrains:intellij-fernflower:1.2.1.16')
|
||||||
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')
|
|
||||||
} else if(hasMixinDeps.toBoolean()) {
|
} else if(hasMixinDeps.toBoolean()) {
|
||||||
runtime("com.llamalad7:MixinExtras:0.1.1-gasstation")
|
runtimeOnly("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||||
runtime("org.spongepowered:mixin:0.8.5-gasstation_7")
|
|
||||||
runtime("com.falsepattern:00gasstation-mc1.7.10:0.5.1:dev")
|
|
||||||
}
|
}
|
||||||
// Latest LWJGL
|
// Latest LWJGL
|
||||||
compile "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
|
implementation "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_util:2.9.4-nightly-20150209"
|
||||||
minecraftNatives "org.lwjgl.lwjgl:lwjgl-platform: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:2.9.4-nightly-20150209"
|
||||||
minecraftDeps "org.lwjgl.lwjgl:lwjgl_util: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'
|
apply from: 'dependencies.gradle'
|
||||||
|
|
||||||
|
if(file('dependencies_override.gradle').exists()) {
|
||||||
|
apply from: 'dependencies_override.gradle'
|
||||||
|
}
|
||||||
|
|
||||||
def mixinDir = new File(project.buildDir, 'mixins')
|
def mixinDir = new File(project.buildDir, 'mixins')
|
||||||
if (!mixinDir.exists()) {
|
if (!mixinDir.exists()) {
|
||||||
mixinDir.mkdirs()
|
mixinDir.mkdirs()
|
||||||
@@ -425,12 +462,6 @@ runClient {
|
|||||||
def arguments = []
|
def arguments = []
|
||||||
def jvmArguments = []
|
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()) {
|
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
||||||
arguments += [
|
arguments += [
|
||||||
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
||||||
@@ -455,12 +486,6 @@ runServer {
|
|||||||
def arguments = []
|
def arguments = []
|
||||||
def jvmArguments = []
|
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()) {
|
if (usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
||||||
arguments += [
|
arguments += [
|
||||||
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
||||||
@@ -602,11 +627,29 @@ task devJar(type: Jar) {
|
|||||||
|
|
||||||
task apiJar(type: Jar) {
|
task apiJar(type: Jar) {
|
||||||
from (sourceSets.main.allSource) {
|
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) {
|
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) {
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
@@ -627,7 +670,7 @@ compileJava.dependsOn(copySrgs)
|
|||||||
artifacts {
|
artifacts {
|
||||||
archives sourcesJar
|
archives sourcesJar
|
||||||
archives devJar
|
archives devJar
|
||||||
if(apiPackage) {
|
if(apiPackage || apiPackages || apiPackagesNoRecurse) {
|
||||||
archives apiJar
|
archives apiJar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -683,7 +726,7 @@ publishing {
|
|||||||
artifact source: sourcesJar, classifier: "sources"
|
artifact source: sourcesJar, classifier: "sources"
|
||||||
}
|
}
|
||||||
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||||
if (apiPackage) {
|
if (apiPackage || apiPackages || apiPackagesNoRecurse) {
|
||||||
artifact source: apiJar, classifier: "api"
|
artifact source: apiJar, classifier: "api"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +820,7 @@ if (curseForgeProjectId != "" && System.getenv("CURSEFORGE_TOKEN") != null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (usesMixins.toBoolean()) {
|
if (usesMixins.toBoolean()) {
|
||||||
addCurseForgeRelation("requiredDependency", "gasstation")
|
addCurseForgeRelation("requiredDependency", "unimixins")
|
||||||
}
|
}
|
||||||
tasks.curseforge.dependsOn(build)
|
tasks.curseforge.dependsOn(build)
|
||||||
tasks.publish.dependsOn(tasks.curseforge)
|
tasks.publish.dependsOn(tasks.curseforge)
|
||||||
@@ -810,7 +853,7 @@ if (modrinthProjectId != "" && System.getenv("MODRINTH_TOKEN") != null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (usesMixins.toBoolean()) {
|
if (usesMixins.toBoolean()) {
|
||||||
addModrinthDep("required", "project", "cdeAhgfp")
|
addModrinthDep("required", "project", "ghjoiQAl")
|
||||||
}
|
}
|
||||||
tasks.modrinth.dependsOn(build)
|
tasks.modrinth.dependsOn(build)
|
||||||
tasks.publish.dependsOn(tasks.modrinth)
|
tasks.publish.dependsOn(tasks.modrinth)
|
||||||
@@ -995,6 +1038,10 @@ configure(deobfParams) {
|
|||||||
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
|
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
// Dependency Deobfuscation
|
// Dependency Deobfuscation
|
||||||
|
|
||||||
def deobfMaven(mavenDep) {
|
def deobfMaven(mavenDep) {
|
||||||
|
|||||||
+11
-6
@@ -16,14 +16,19 @@ def deobfCurse(curseDep) {
|
|||||||
dependencies {
|
dependencies {
|
||||||
////////////////Our dependencies////////////////
|
////////////////Our dependencies////////////////
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.28") {
|
compileOnly("org.projectlombok:lombok:1.18.32") {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||||
|
|
||||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:0.12.1:dev")
|
compileOnly("com.falsepattern:falsepatternlib-mc1.7.10:1.2.4:api")
|
||||||
|
runtimeOnly("com.falsepattern:falsepatternlib-mc1.7.10:1.2.4:dev")
|
||||||
|
implementation("it.unimi.dsi:fastutil:8.5.13")
|
||||||
|
|
||||||
implementation("com.falsepattern:chunkapi-mc1.7.10:0.3.2:dev")
|
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api")
|
||||||
|
runtimeOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:dev")
|
||||||
|
|
||||||
|
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||||
|
|
||||||
////////////////Patched mods////////////////
|
////////////////Patched mods////////////////
|
||||||
|
|
||||||
@@ -113,8 +118,8 @@ dependencies {
|
|||||||
//Industrial Revolution by Redstone Rebooted 1.1.1
|
//Industrial Revolution by Redstone Rebooted 1.1.1
|
||||||
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
|
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
|
||||||
|
|
||||||
//LOTR Mod 36.14
|
//LOTR Mod 36.15
|
||||||
compileOnly(deobfCurse("lotrmod-423748:3646430"))
|
implementation(deobfCurse("lotrmod-423748:4091561"))
|
||||||
|
|
||||||
//More Fun Quicksands Mod 1.0.8.8-fixed
|
//More Fun Quicksands Mod 1.0.8.8-fixed
|
||||||
compileOnly(deobfCurse("more-fun-quicksand-mod-321960:2717318"))
|
compileOnly(deobfCurse("more-fun-quicksand-mod-321960:2717318"))
|
||||||
|
|||||||
+12
-3
@@ -14,6 +14,15 @@ modGroup = com.falsepattern.endlessids
|
|||||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||||
apiPackage =
|
apiPackage =
|
||||||
|
|
||||||
|
# Same thing, but for multi-pockage APIs, if said API packages cannot be easily split from internals.
|
||||||
|
# Packages separated by semicolons
|
||||||
|
# ExampleValue: apiPackages = foo;bar;baz
|
||||||
|
# ... foo;bar;baz -> com.myname.mymodid.foo;com.myname.mymodid.bar;com.myname.mymodid.baz
|
||||||
|
apiPackages =
|
||||||
|
|
||||||
|
# Same as apiPackages, but does not pull in inner packages
|
||||||
|
apiPackagesNoRecurse =
|
||||||
|
|
||||||
# WHY is there no version field?
|
# WHY is there no version field?
|
||||||
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
||||||
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
||||||
@@ -72,7 +81,7 @@ modrinthProjectId = qGHY4QGo
|
|||||||
# type can be one of [project, version],
|
# type can be one of [project, version],
|
||||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
# 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
|
# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech
|
||||||
modrinthDependencies = required-project:fplib;required-project:chunkapi
|
modrinthDependencies = required-project:fplib;required-project:chunkapi;incompatible-project:notenoughids-unofficial
|
||||||
|
|
||||||
#endregion modrinth
|
#endregion modrinth
|
||||||
|
|
||||||
@@ -90,7 +99,7 @@ curseForgeProjectId = 665730
|
|||||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||||
# and the name is the CurseForge project id of the other mod.
|
# and the name is the CurseForge project id of the other mod.
|
||||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||||
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi
|
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi;incompatible:notenoughids-unofficial-1-7-10;incompatible:notenoughids
|
||||||
|
|
||||||
#endregion curseforge
|
#endregion curseforge
|
||||||
|
|
||||||
@@ -163,7 +172,7 @@ accessTransformersFile =
|
|||||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||||
# This parameter is for legacy compatibility only
|
# This parameter is for legacy compatibility only
|
||||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||||
coreModClass = IEPlugin
|
coreModClass = asm.EndlessIDsCore
|
||||||
|
|
||||||
#endregion core
|
#endregion core
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids;
|
package com.falsepattern.endlessids;
|
||||||
|
|
||||||
import com.falsepattern.chunk.api.ChunkDataRegistry;
|
import com.falsepattern.chunk.api.DataRegistry;
|
||||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
import com.falsepattern.endlessids.managers.BiomeManager;
|
import com.falsepattern.endlessids.managers.BiomeManager;
|
||||||
import com.falsepattern.endlessids.managers.BlockIDManager;
|
import com.falsepattern.endlessids.managers.BlockIDManager;
|
||||||
@@ -20,7 +20,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|||||||
version = Tags.VERSION,
|
version = Tags.VERSION,
|
||||||
name = Tags.MODNAME,
|
name = Tags.MODNAME,
|
||||||
acceptedMinecraftVersions = "[1.7.10]",
|
acceptedMinecraftVersions = "[1.7.10]",
|
||||||
dependencies = "required-after:chunkapi@[0.3.2,);required-after:falsepatternlib@[0.12.1,);required-after:gasstation@[0.5.0,);after:antiidconflict")
|
dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
|
||||||
|
"required-after:falsepatternlib@[1.2.0,);" +
|
||||||
|
"after:antiidconflict")
|
||||||
public class EndlessIDs {
|
public class EndlessIDs {
|
||||||
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
|
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
|
||||||
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
|
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
|
||||||
@@ -74,11 +76,11 @@ public class EndlessIDs {
|
|||||||
public void init(FMLInitializationEvent e) {
|
public void init(FMLInitializationEvent e) {
|
||||||
patchManager.init();
|
patchManager.init();
|
||||||
if (GeneralConfig.extendBiome) {
|
if (GeneralConfig.extendBiome) {
|
||||||
ChunkDataRegistry.registerDataManager(new BiomeManager());
|
DataRegistry.registerDataManager(new BiomeManager());
|
||||||
}
|
}
|
||||||
if (GeneralConfig.extendBlockItem) {
|
if (GeneralConfig.extendBlockItem) {
|
||||||
ChunkDataRegistry.registerDataManager(new BlockIDManager());
|
DataRegistry.registerDataManager(new BlockIDManager());
|
||||||
ChunkDataRegistry.registerDataManager(new BlockMetaManager());
|
DataRegistry.registerDataManager(new BlockMetaManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,11 +88,11 @@ public class EndlessIDs {
|
|||||||
public void postInit(FMLPostInitializationEvent e) {
|
public void postInit(FMLPostInitializationEvent e) {
|
||||||
patchManager.postInit();
|
patchManager.postInit();
|
||||||
if (GeneralConfig.extendBiome) {
|
if (GeneralConfig.extendBiome) {
|
||||||
ChunkDataRegistry.disableDataManager("minecraft", "biome");
|
DataRegistry.disableDataManager("minecraft", "biome");
|
||||||
}
|
}
|
||||||
if (GeneralConfig.extendBlockItem) {
|
if (GeneralConfig.extendBlockItem) {
|
||||||
ChunkDataRegistry.disableDataManager("minecraft", "blockid");
|
DataRegistry.disableDataManager("minecraft", "blockid");
|
||||||
ChunkDataRegistry.disableDataManager("minecraft", "metadata");
|
DataRegistry.disableDataManager("minecraft", "metadata");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
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,67 +0,0 @@
|
|||||||
package com.falsepattern.endlessids.asm;
|
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
|
|
||||||
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),
|
|
||||||
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"),
|
|
||||||
GameDataAccelerator(new GameDataAccelerator(), () -> GeneralConfig.enableRegistryPerformanceTweak, "cpw.mods.fml.common.registry.GameData"),
|
|
||||||
;
|
|
||||||
|
|
||||||
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.computeIfAbsent(name, (ignored) -> new ArrayList<>()).add(edit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final IClassNodeTransformer transformer;
|
|
||||||
private final BooleanSupplier cond;
|
|
||||||
private final String[] classNames;
|
|
||||||
|
|
||||||
ClassEdit(final IClassNodeTransformer transformer, BooleanSupplier cond, final String... classNames) {
|
|
||||||
this.transformer = transformer;
|
|
||||||
this.cond = cond;
|
|
||||||
this.classNames = classNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
|
||||||
return this.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IClassNodeTransformer getTransformer() {
|
|
||||||
return this.transformer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+14
-12
@@ -1,10 +1,11 @@
|
|||||||
package com.falsepattern.endlessids;
|
package com.falsepattern.endlessids.asm;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.IETransformer;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
|
import net.minecraft.launchwrapper.Launch;
|
||||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||||
@@ -18,29 +19,31 @@ import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
|||||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||||
|
|
||||||
@MCVersion("1.7.10")
|
@MCVersion("1.7.10")
|
||||||
@Name(Tags.MODID)
|
@Name(Tags.MODID + "_core")
|
||||||
@TransformerExclusions({"com.falsepattern.endlessids.asm", "com.falsepattern.endlessids.config.GeneralConfig"})
|
@TransformerExclusions({"com.falsepattern.endlessids.asm", "com.falsepattern.endlessids.config.GeneralConfig"})
|
||||||
@DependsOn("falsepatternlib")
|
@DependsOn("falsepatternlib")
|
||||||
public class IEPlugin implements IFMLLoadingPlugin {
|
public class EndlessIDsCore implements IFMLLoadingPlugin {
|
||||||
|
public static boolean deobfuscated;
|
||||||
public IEPlugin() {
|
public EndlessIDsCore() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public String[] getASMTransformerClass() {
|
public String[] getASMTransformerClass() {
|
||||||
val cl = ((LaunchClassLoader) this.getClass().getClassLoader());
|
deobfuscated = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||||
val field = cl.getClass().getDeclaredField("transformerExceptions");
|
val cl = Launch.classLoader;
|
||||||
|
val field = LaunchClassLoader.class.getDeclaredField("transformerExceptions");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
val exceptions = (Set<String>) field.get(cl);
|
val exceptions = (Set<String>) field.get(cl);
|
||||||
if (exceptions.contains("code.elix_x.coremods")) {
|
if (exceptions.contains("code.elix_x.coremods")) {
|
||||||
IETransformer.logger.info("AntiIDConflict detected!");
|
EndlessIDsTransformer.logger.info("AntiIDConflict detected!");
|
||||||
IETransformer.logger.info("Removing ASM protections so that we can fix its code.");
|
EndlessIDsTransformer.logger.info("Removing ASM protections so that we can fix its code.");
|
||||||
exceptions.remove("code.elix_x.coremods");
|
exceptions.remove("code.elix_x.coremods");
|
||||||
exceptions.add("code.elix_x.coremods.antiidconflict.core");
|
exceptions.add("code.elix_x.coremods.antiidconflict.core");
|
||||||
exceptions.add("code.elix_x.coremods.antiidconflict.ByteCodeTester");
|
exceptions.add("code.elix_x.coremods.antiidconflict.ByteCodeTester");
|
||||||
}
|
}
|
||||||
return new String[]{IETransformer.class.getName()};
|
return new String[]{EndlessIDsTransformer.class.getName()};
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModContainerClass() {
|
public String getModContainerClass() {
|
||||||
@@ -67,7 +70,6 @@ public class IEPlugin implements IFMLLoadingPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void injectData(final Map<String, Object> data) {
|
public void injectData(final Map<String, Object> data) {
|
||||||
IETransformer.isObfuscated = (Boolean) data.get("runtimeDeobfuscationEnabled");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessTransformerClass() {
|
public String getAccessTransformerClass() {
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.falsepattern.endlessids.asm;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.Tags;
|
||||||
|
import com.falsepattern.endlessids.asm.transformer.DevFixer;
|
||||||
|
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.asm.transformer.chunk.ChunkProviderSuperPatcher;
|
||||||
|
import com.falsepattern.endlessids.asm.transformer.chunk.LOTRFieldExposer;
|
||||||
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
|
import com.falsepattern.lib.turboasm.MergeableTurboTransformer;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
|
import lombok.val;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EndlessIDsTransformer extends MergeableTurboTransformer {
|
||||||
|
public static final Logger logger = LogManager.getLogger(Tags.MODNAME + " ASM");
|
||||||
|
|
||||||
|
private static List<TurboClassTransformer> transformers() {
|
||||||
|
val result = new ArrayList<TurboClassTransformer>();
|
||||||
|
if (GeneralConfig.extendBiome) {
|
||||||
|
result.add(new ChunkProviderSuperPatcher());
|
||||||
|
result.add(new LOTRFieldExposer());
|
||||||
|
}
|
||||||
|
if (GeneralConfig.extendBlockItem) {
|
||||||
|
result.add(new FmlRegistry());
|
||||||
|
}
|
||||||
|
if (GeneralConfig.enableRegistryPerformanceTweak) {
|
||||||
|
new GameDataAccelerator();
|
||||||
|
}
|
||||||
|
if (EndlessIDsCore.deobfuscated) {
|
||||||
|
result.add(new SpaceCoreModInfoGenerator());
|
||||||
|
result.add(new DevFixer());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EndlessIDsTransformer() {
|
||||||
|
super(transformers());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ import java.lang.ref.WeakReference;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
//Used by ASM
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class GameDataHooks {
|
public class GameDataHooks {
|
||||||
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
|
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
|
||||||
if (gameData.endlessIDsItemBlockCache == null) {
|
if (gameData.endlessIDsItemBlockCache == null) {
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.falsepattern.endlessids.asm;
|
|
||||||
|
|
||||||
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;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import net.minecraft.launchwrapper.IClassTransformer;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class IETransformer implements IClassTransformer {
|
|
||||||
public static final Logger logger;
|
|
||||||
private static final List<String> blacklist = new ArrayList<>();
|
|
||||||
public static boolean isObfuscated;
|
|
||||||
|
|
||||||
static {
|
|
||||||
logger = LogManager.getLogger(Tags.MODNAME + " ASM");
|
|
||||||
blacklist.add("net.minecraft.world.chunk.storage.AnvilChunkLoader");
|
|
||||||
}
|
|
||||||
|
|
||||||
public IETransformer() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] transform(final String name, final String transformedName, final byte[] bytes) {
|
|
||||||
if (bytes == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (blacklist.contains(transformedName)) {
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
var edits = new ArrayList<ClassEdit>(ClassEdit.get(transformedName));
|
|
||||||
ClassNode cn = new ClassNode(Opcodes.ASM5);
|
|
||||||
{
|
|
||||||
val reader = new ClassReader(bytes);
|
|
||||||
reader.accept(cn, 0);
|
|
||||||
}
|
|
||||||
boolean expanded = false;
|
|
||||||
if (ChunkProviderSuperPatcher.shouldPatch(cn)) {
|
|
||||||
expanded = true;
|
|
||||||
{
|
|
||||||
cn = new ClassNode(Opcodes.ASM5);
|
|
||||||
val reader = new ClassReader(bytes);
|
|
||||||
reader.accept(cn, ClassReader.EXPAND_FRAMES);
|
|
||||||
}
|
|
||||||
edits.add(ClassEdit.ChunkProviderSuperPatcher);
|
|
||||||
}
|
|
||||||
if (edits.size() == 0) {
|
|
||||||
return isObfuscated ? bytes : DevFixer.fixDev(bytes);
|
|
||||||
}
|
|
||||||
if (!isObfuscated) {
|
|
||||||
DevFixer.transform(cn);
|
|
||||||
}
|
|
||||||
for (final ClassEdit edit : edits) {
|
|
||||||
if (edit == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IETransformer.logger.debug("Patching {} with {}...", transformedName, edit.getName());
|
|
||||||
try {
|
|
||||||
edit.getTransformer().transform(cn, IETransformer.isObfuscated);
|
|
||||||
} catch (AsmTransformException t) {
|
|
||||||
IETransformer.logger.error("Error transforming {} with {}: {}", transformedName, edit.getName(),
|
|
||||||
t.getMessage());
|
|
||||||
throw t;
|
|
||||||
} catch (Throwable t2) {
|
|
||||||
IETransformer.logger.error("Error transforming {} with {}: {}", transformedName, edit.getName(),
|
|
||||||
t2.getMessage());
|
|
||||||
throw new RuntimeException(t2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final ClassWriter writer = new ClassWriter(expanded ? ClassWriter.COMPUTE_FRAMES : 0);
|
|
||||||
cn.accept(writer);
|
|
||||||
IETransformer.logger.debug("Patched {} successfully.", transformedName);
|
|
||||||
return writer.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +1,25 @@
|
|||||||
package com.falsepattern.endlessids.asm.transformer;
|
package com.falsepattern.endlessids.asm.transformer;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.IETransformer;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import lombok.AccessLevel;
|
import com.falsepattern.endlessids.asm.EndlessIDsCore;
|
||||||
import lombok.NoArgsConstructor;
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
import lombok.SneakyThrows;
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.FieldInsnNode;
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
import org.objectweb.asm.util.CheckClassAdapter;
|
|
||||||
|
|
||||||
import net.minecraft.launchwrapper.Launch;
|
import net.minecraft.launchwrapper.Launch;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
public class DevFixer implements TurboClassTransformer {
|
||||||
public final class DevFixer {
|
|
||||||
private static final ClassNode blocks;
|
private static final ClassNode blocks;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (IETransformer.isObfuscated) {
|
if (!EndlessIDsCore.deobfuscated) {
|
||||||
blocks = null;
|
blocks = null;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -35,41 +33,20 @@ public final class DevFixer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] fixDev(byte[] classBytes) {
|
private static boolean biomeTweakerCompat(final ClassNode cn) {
|
||||||
if (IETransformer.isObfuscated) {
|
boolean modified = false;
|
||||||
return classBytes;
|
|
||||||
}
|
|
||||||
val cn = new ClassNode(Opcodes.ASM5);
|
|
||||||
val reader = new ClassReader(classBytes);
|
|
||||||
reader.accept(cn, 0);
|
|
||||||
transform(cn);
|
|
||||||
val writer = new ClassWriter(0);
|
|
||||||
val check = new CheckClassAdapter(writer);
|
|
||||||
cn.accept(check);
|
|
||||||
return writer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public static void transform(final ClassNode cn) {
|
|
||||||
if (IETransformer.isObfuscated) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
remapBlocks(cn);
|
|
||||||
if (cn.name.equals("net/minecraft/world/biome/BiomeGenBase")) {
|
|
||||||
biomeTweakerCompat(cn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void biomeTweakerCompat(final ClassNode cn) {
|
|
||||||
for (val field : cn.fields) {
|
for (val field : cn.fields) {
|
||||||
if (field.name.startsWith("spawnable")) {
|
if (field.name.startsWith("spawnable")) {
|
||||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||||
field.access |= Opcodes.ACC_PUBLIC;
|
field.access |= Opcodes.ACC_PUBLIC;
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void remapBlocks(final ClassNode cn) {
|
private static boolean remapBlocks(final ClassNode cn) {
|
||||||
|
boolean modified = false;
|
||||||
for (val method : cn.methods) {
|
for (val method : cn.methods) {
|
||||||
val instructions = method.instructions;
|
val instructions = method.instructions;
|
||||||
int insnCount = instructions.size();
|
int insnCount = instructions.size();
|
||||||
@@ -81,11 +58,41 @@ public final class DevFixer {
|
|||||||
for (val blockField : blocks.fields) {
|
for (val blockField : blocks.fields) {
|
||||||
if (blockField.name.equals(field.name) && !blockField.desc.equals(field.desc)) {
|
if (blockField.name.equals(field.name) && !blockField.desc.equals(field.desc)) {
|
||||||
field.desc = blockField.desc;
|
field.desc = blockField.desc;
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String owner() {
|
||||||
|
return Tags.MODNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "DevFixer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
return EndlessIDsCore.deobfuscated && !"net.minecraft.world.chunk.storage.AnvilChunkLoader".equals(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
|
boolean modified = false;
|
||||||
|
modified |= remapBlocks(cn);
|
||||||
|
if (className.equals("net.minecraft.world.biome.BiomeGenBase")) {
|
||||||
|
modified |= biomeTweakerCompat(cn);
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,46 @@
|
|||||||
package com.falsepattern.endlessids.asm.transformer;
|
package com.falsepattern.endlessids.asm.transformer;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.asm.AsmTransformException;
|
import com.falsepattern.endlessids.asm.AsmTransformException;
|
||||||
import com.falsepattern.endlessids.asm.AsmUtil;
|
import com.falsepattern.endlessids.asm.AsmUtil;
|
||||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||||
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||||
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
|
|
||||||
public class FmlRegistry implements IClassNodeTransformer {
|
public class FmlRegistry implements TurboClassTransformer {
|
||||||
public FmlRegistry() {
|
public FmlRegistry() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
public String owner() {
|
||||||
|
return Tags.MODNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "FMLRegistry";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
return GeneralConfig.extendBlockItem && ("cpw.mods.fml.common.registry.GameData".equals(className) ||
|
||||||
|
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry".equals(className));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
var field = AsmUtil.findField(cn, "MAX_BLOCK_ID", true);
|
var field = AsmUtil.findField(cn, "MAX_BLOCK_ID", true);
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
field.value = ExtendedConstants.maxBlockID;
|
field.value = ExtendedConstants.maxBlockID;
|
||||||
@@ -35,5 +60,6 @@ public class FmlRegistry implements IClassNodeTransformer {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
throw new AsmTransformException("can't find 4095 constant in any method");
|
throw new AsmTransformException("can't find 4095 constant in any method");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+67
-36
@@ -1,11 +1,15 @@
|
|||||||
package com.falsepattern.endlessids.asm.transformer;
|
package com.falsepattern.endlessids.asm.transformer;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.asm.IETransformer;
|
import com.falsepattern.endlessids.asm.AsmTransformException;
|
||||||
|
import com.falsepattern.endlessids.asm.EndlessIDsTransformer;
|
||||||
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
import org.objectweb.asm.tree.FieldInsnNode;
|
import org.objectweb.asm.tree.FieldInsnNode;
|
||||||
import org.objectweb.asm.tree.FieldNode;
|
import org.objectweb.asm.tree.FieldNode;
|
||||||
import org.objectweb.asm.tree.InsnNode;
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
@@ -13,35 +17,9 @@ import org.objectweb.asm.tree.MethodInsnNode;
|
|||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import org.objectweb.asm.tree.VarInsnNode;
|
import org.objectweb.asm.tree.VarInsnNode;
|
||||||
|
|
||||||
public class GameDataAccelerator implements IClassNodeTransformer {
|
public class GameDataAccelerator implements TurboClassTransformer {
|
||||||
private static final int MASK_REGISTER_BLOCK = 0b1;
|
private static final int MASK_REGISTER_BLOCK = 0b1;
|
||||||
private static final int MASK_REGISTER_ITEM = 0b10;
|
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) {
|
private void transformRegisterItem(MethodNode method) {
|
||||||
var iter = method.instructions.iterator();
|
var iter = method.instructions.iterator();
|
||||||
@@ -64,26 +42,37 @@ public class GameDataAccelerator implements IClassNodeTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void transformError(MethodNode method) {
|
private static void transformError(MethodNode method) {
|
||||||
IETransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
|
EndlessIDsTransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformRegisterBlock(MethodNode method) {
|
private void transformRegisterBlock(MethodNode method) {
|
||||||
var iter = method.instructions.iterator();
|
var iter = method.instructions.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
var insn = iter.next();
|
var insn = iter.next();
|
||||||
if (!(insn instanceof FieldInsnNode))
|
if ((insn.getOpcode() != Opcodes.GETFIELD) && !(insn instanceof FieldInsnNode))
|
||||||
continue;
|
continue;
|
||||||
var fieldInsn = (FieldInsnNode) insn;
|
var fieldInsn = (FieldInsnNode) insn;
|
||||||
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
|
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
|
||||||
fieldInsn.name.equals("iItemRegistry") &&
|
fieldInsn.name.equals("iItemRegistry") &&
|
||||||
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
|
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
|
||||||
continue;
|
continue;
|
||||||
iter.previous();
|
|
||||||
iter.previous();
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
iter.next();
|
{
|
||||||
|
val testInsn = iter.previous();
|
||||||
|
if (testInsn.getOpcode() != Opcodes.ALOAD || ((VarInsnNode)testInsn).var != 0)
|
||||||
|
throw new AsmTransformException("Opcode assertion 1 failed!");
|
||||||
|
}
|
||||||
iter.remove();
|
iter.remove();
|
||||||
iter.next();
|
{
|
||||||
|
val testInsn = iter.next();
|
||||||
|
if (testInsn.getOpcode() != Opcodes.INVOKEVIRTUAL)
|
||||||
|
throw new AsmTransformException("Opcodes assertion 2 failed!");
|
||||||
|
|
||||||
|
val testInvoke = (MethodInsnNode)testInsn;
|
||||||
|
if (!testInvoke.owner.equals("cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry") ||
|
||||||
|
!testInvoke.name.equals("typeSafeIterable"))
|
||||||
|
throw new AsmTransformException("Opcodes assertion 3 failed!");
|
||||||
|
}
|
||||||
iter.remove();
|
iter.remove();
|
||||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
@@ -94,4 +83,46 @@ public class GameDataAccelerator implements IClassNodeTransformer {
|
|||||||
}
|
}
|
||||||
transformError(method);
|
transformError(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String owner() {
|
||||||
|
return Tags.MODNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "GameDataAccelerator";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
return GeneralConfig.enableRegistryPerformanceTweak && "cpw.mods.fml.common.registry.GameData".equals(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
|
var cacheField = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "endlessIDsItemBlockCache", "Lcom/falsepattern/endlessids/util/WeakIdentityHashMap;", null, null);
|
||||||
|
cn.fields.add(cacheField);
|
||||||
|
int tweaksLeft = MASK_REGISTER_BLOCK | MASK_REGISTER_ITEM;
|
||||||
|
for (val method: cn.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;
|
||||||
|
} else 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) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new AsmTransformException("Failed to accelerate block registration! Disable enableRegistryPerformanceTweak in the EndlessIDs config!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+28
-7
@@ -1,22 +1,43 @@
|
|||||||
package com.falsepattern.endlessids.asm.transformer;
|
package com.falsepattern.endlessids.asm.transformer;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
import com.falsepattern.endlessids.Tags;
|
||||||
|
import com.falsepattern.endlessids.asm.EndlessIDsCore;
|
||||||
|
import com.falsepattern.endlessids.asm.EndlessIDsTransformer;
|
||||||
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
import org.objectweb.asm.tree.InsnNode;
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
|
||||||
public class SpaceCoreModInfoGenerator implements IClassNodeTransformer {
|
public class SpaceCoreModInfoGenerator implements TurboClassTransformer {
|
||||||
@Override
|
@Override
|
||||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
public String owner() {
|
||||||
if (obfuscated) {
|
return Tags.MODNAME;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "SpaceCoreModInfoGenerator";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
return EndlessIDsCore.deobfuscated && "com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator".equals(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
for (val method : cn.methods) {
|
for (val method : cn.methods) {
|
||||||
if (method.name.equals("generate")) {
|
if (method.name.equals("generate")) {
|
||||||
val iterator = method.instructions.iterator();
|
val iterator = method.instructions.iterator();
|
||||||
iterator.add(new InsnNode(Opcodes.RETURN));
|
iterator.add(new InsnNode(Opcodes.RETURN));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+224
-50
@@ -1,11 +1,14 @@
|
|||||||
package com.falsepattern.endlessids.asm.transformer;
|
package com.falsepattern.endlessids.asm.transformer.chunk;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.asm.IETransformer;
|
import com.falsepattern.endlessids.asm.EndlessIDsCore;
|
||||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
import com.falsepattern.endlessids.asm.EndlessIDsTransformer;
|
||||||
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
@@ -21,6 +24,7 @@ import org.objectweb.asm.tree.VarInsnNode;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -116,7 +120,7 @@ import java.util.function.Supplier;
|
|||||||
* L6
|
* L6
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
public class ChunkProviderSuperPatcher implements TurboClassTransformer {
|
||||||
public static final String[] CLASS_BiomeGenBase;
|
public static final String[] CLASS_BiomeGenBase;
|
||||||
public static final String[] CLASS_IChunkProvider;
|
public static final String[] CLASS_IChunkProvider;
|
||||||
public static final String[] CLASS_ChunkProviderGenerate;
|
public static final String[] CLASS_ChunkProviderGenerate;
|
||||||
@@ -149,20 +153,20 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
private static State<AbstractInsnNode> STATE_FINAL = null;
|
private static State<AbstractInsnNode> STATE_FINAL = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (IETransformer.isObfuscated) {
|
if (EndlessIDsCore.deobfuscated) {
|
||||||
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_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
|
||||||
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
|
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
|
||||||
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
|
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||||
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
|
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
|
||||||
FIELD_biomeID = new String[]{"biomeID"};
|
FIELD_biomeID = new String[]{"biomeID"};
|
||||||
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
|
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
|
||||||
|
} else {
|
||||||
|
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"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +174,10 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
STATE_FINAL = (insn, memory) -> STATE_FINAL;
|
STATE_FINAL = (insn, memory) -> STATE_FINAL;
|
||||||
|
|
||||||
STATE0 = casting(VarInsnNode.class, (insn, memory) -> {
|
STATE0 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||||
|
memory.reset();
|
||||||
if (insn.getOpcode() == Opcodes.ALOAD) {
|
if (insn.getOpcode() == Opcodes.ALOAD) {
|
||||||
memory.chunkIndex = insn.var;
|
memory.chunkIndex = insn.var;
|
||||||
memory.startingInsn = memory.currentInsn;
|
memory.startingInsn = insn;
|
||||||
return STATE1;
|
return STATE1;
|
||||||
}
|
}
|
||||||
return STATE0;
|
return STATE0;
|
||||||
@@ -183,7 +188,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
anyMatch(insn.owner, CLASS_Chunk) &&
|
anyMatch(insn.owner, CLASS_Chunk) &&
|
||||||
anyMatch(insn.name, METHOD_getBiomeArray) &&
|
anyMatch(insn.name, METHOD_getBiomeArray) &&
|
||||||
insn.desc.equals("()[B")) {
|
insn.desc.equals("()[B")) {
|
||||||
memory.getBiomeArrayInsn = memory.currentInsn;
|
memory.getBiomeArrayInsn = insn;
|
||||||
return STATE2;
|
return STATE2;
|
||||||
}
|
}
|
||||||
return STATE0;
|
return STATE0;
|
||||||
@@ -192,6 +197,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
STATE2 = casting(VarInsnNode.class, (insn, memory) -> {
|
STATE2 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||||
if (insn.getOpcode() == Opcodes.ASTORE) {
|
if (insn.getOpcode() == Opcodes.ASTORE) {
|
||||||
memory.biomeArrayIndex = insn.var;
|
memory.biomeArrayIndex = insn.var;
|
||||||
|
memory.startPatchingFrames();
|
||||||
return STATE3;
|
return STATE3;
|
||||||
}
|
}
|
||||||
return STATE0;
|
return STATE0;
|
||||||
@@ -294,7 +300,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
|
|
||||||
STATE16 = casting(InsnNode.class, (insn, memory) -> {
|
STATE16 = casting(InsnNode.class, (insn, memory) -> {
|
||||||
if (insn.getOpcode() == Opcodes.I2B) {
|
if (insn.getOpcode() == Opcodes.I2B) {
|
||||||
memory.castInsn = memory.currentInsn;
|
memory.castInsn = insn;
|
||||||
return STATE17;
|
return STATE17;
|
||||||
}
|
}
|
||||||
return STATE0;
|
return STATE0;
|
||||||
@@ -302,25 +308,13 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
|
|
||||||
STATE17 = casting(InsnNode.class, (insn, memory) -> {
|
STATE17 = casting(InsnNode.class, (insn, memory) -> {
|
||||||
if (insn.getOpcode() == Opcodes.BASTORE) {
|
if (insn.getOpcode() == Opcodes.BASTORE) {
|
||||||
memory.arrayStoreInsn = memory.currentInsn;
|
memory.arrayStoreInsn = insn;
|
||||||
return STATE_FINAL;
|
return STATE_FINAL;
|
||||||
}
|
}
|
||||||
return STATE0;
|
return STATE0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
private static boolean scanForBrokenCall(MethodNode method) {
|
||||||
val instructions = method.instructions;
|
val instructions = method.instructions;
|
||||||
val insnCount = instructions.size();
|
val insnCount = instructions.size();
|
||||||
@@ -388,23 +382,28 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Memory findTheTarget(MethodNode method) {
|
private static Memory findTheTarget(MethodNode method, ClassNode cn) {
|
||||||
val insnList = method.instructions;
|
val insnList = method.instructions;
|
||||||
var currentState = STATE0;
|
var currentState = STATE0;
|
||||||
val memory = new Memory();
|
val memory = new Memory();
|
||||||
for (int insnIndex = 0; insnIndex < insnList.size(); insnIndex++) {
|
memory.initLocals(method, cn);
|
||||||
memory.currentInsn = insnIndex;
|
val iter = insnList.iterator();
|
||||||
val insn = insnList.get(insnIndex);
|
while (iter.hasNext()) {
|
||||||
|
val insn = iter.next();
|
||||||
if (insn instanceof FrameNode) {
|
if (insn instanceof FrameNode) {
|
||||||
val frame = (FrameNode) insn;
|
val frame = (FrameNode) insn;
|
||||||
if (frame.type == Opcodes.F_NEW) {
|
memory.recordFrame(frame);
|
||||||
memory.locals.clear();
|
memory.updateLocalsState(frame);
|
||||||
memory.locals.addAll(frame.local);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val newState = currentState.apply(insn, memory);
|
val newState = currentState.apply(insn, memory);
|
||||||
if (newState != null) {
|
if (newState != null) {
|
||||||
if (newState == STATE_FINAL) {
|
if (newState == STATE_FINAL) {
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
val insn2 = iter.next();
|
||||||
|
if (insn2 instanceof FrameNode) {
|
||||||
|
memory.recordFrame((FrameNode) insn2);
|
||||||
|
}
|
||||||
|
}
|
||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
@@ -414,30 +413,93 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
public String owner() {
|
||||||
|
return Tags.MODNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "ChunkProviderSuperPatcher";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
if ("net.minecraft.world.chunk.storage.AnvilChunkLoader".equals(className))
|
||||||
|
return false;
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
|
for (MethodNode method : cn.methods) {
|
||||||
|
if (scanForBrokenCall(method)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
boolean patched = false;
|
boolean patched = false;
|
||||||
for (val method : cn.methods) {
|
for (val method : cn.methods) {
|
||||||
val memory = findTheTarget(method);
|
val memory = findTheTarget(method, cn);
|
||||||
if (memory != null) {
|
if (memory != null) {
|
||||||
patched = true;
|
patched = true;
|
||||||
IETransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
|
EndlessIDsTransformer.logger.debug("[ChunkProvider patcher]: Match found in method " + method.name);
|
||||||
val insnList = method.instructions;
|
val insnList = method.instructions;
|
||||||
for (val node : method.localVariables) {
|
for (val node : method.localVariables) {
|
||||||
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
|
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
|
||||||
node.desc = "[S";
|
node.desc = "[S";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
|
val getBiomeArray = memory.getBiomeArrayInsn;
|
||||||
insnList.set(getBiomeArray,
|
insnList.set(getBiomeArray,
|
||||||
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray",
|
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray",
|
||||||
"()[S", false));
|
"()[S", false));
|
||||||
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
|
insnList.set(memory.castInsn, new InsnNode(Opcodes.I2S));
|
||||||
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
|
insnList.set(memory.arrayStoreInsn, new InsnNode(Opcodes.SASTORE));
|
||||||
|
patchStackFrames(memory, method, cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!patched) {
|
if (!patched) {
|
||||||
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
|
EndlessIDsTransformer.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!");
|
"an error, because the patch might be applied by a mixin instead!");
|
||||||
|
}
|
||||||
|
return patched;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void patchStackFrames(Memory memory, MethodNode method, ClassNode owner) {
|
||||||
|
memory.locals.clear();
|
||||||
|
memory.initLocals(method, owner);
|
||||||
|
for (val frame: memory.framesLeaveUnpatched)
|
||||||
|
memory.updateLocalsState(frame);
|
||||||
|
|
||||||
|
int localToPatch = memory.biomeArrayIndex;
|
||||||
|
for (val frame: memory.framesToPatch) {
|
||||||
|
int currentLocalIndex = memory.locals.size() - 1;
|
||||||
|
if (frame.local != null) {
|
||||||
|
switch (frame.type) {
|
||||||
|
case Opcodes.F_NEW:
|
||||||
|
case Opcodes.F_FULL:
|
||||||
|
if (frame.local.size() > localToPatch &&
|
||||||
|
"[B".equals(frame.local.get(localToPatch))) {
|
||||||
|
frame.local.set(localToPatch, "[S");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Opcodes.F_APPEND:
|
||||||
|
if (currentLocalIndex < localToPatch &&
|
||||||
|
(currentLocalIndex + frame.local.size()) >= localToPatch) {
|
||||||
|
int indexInFrame = localToPatch - currentLocalIndex - 1;
|
||||||
|
if ("[B".equals(frame.local.get(indexInFrame))) {
|
||||||
|
frame.local.set(indexInFrame, "[S");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memory.updateLocalsState(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,13 +511,125 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
|||||||
private static class Memory {
|
private static class Memory {
|
||||||
|
|
||||||
final List<Object> locals = new ArrayList<>();
|
final List<Object> locals = new ArrayList<>();
|
||||||
int currentInsn;
|
List<Object> localsAtPatchStart;
|
||||||
int startingInsn;
|
List<FrameNode> framesLeaveUnpatched = new ArrayList<>();
|
||||||
int getBiomeArrayInsn;
|
List<FrameNode> framesToPatch = new ArrayList<>();
|
||||||
int castInsn;
|
boolean patchingFrames;
|
||||||
int arrayStoreInsn;
|
VarInsnNode startingInsn;
|
||||||
|
MethodInsnNode getBiomeArrayInsn;
|
||||||
|
InsnNode castInsn;
|
||||||
|
InsnNode arrayStoreInsn;
|
||||||
int chunkIndex;
|
int chunkIndex;
|
||||||
int biomeArrayIndex;
|
int biomeArrayIndex;
|
||||||
int iteratorIndex;
|
int iteratorIndex;
|
||||||
|
|
||||||
|
public void startPatchingFrames() {
|
||||||
|
localsAtPatchStart = new ArrayList<>(locals);
|
||||||
|
patchingFrames = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recordFrame(FrameNode frame) {
|
||||||
|
if (patchingFrames)
|
||||||
|
framesToPatch.add(frame);
|
||||||
|
else
|
||||||
|
framesLeaveUnpatched.add(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
localsAtPatchStart = null;
|
||||||
|
framesLeaveUnpatched.addAll(framesToPatch);
|
||||||
|
framesToPatch.clear();
|
||||||
|
patchingFrames = false;
|
||||||
|
startingInsn = null;
|
||||||
|
getBiomeArrayInsn = null;
|
||||||
|
castInsn = null;
|
||||||
|
arrayStoreInsn = null;
|
||||||
|
chunkIndex = 0;
|
||||||
|
biomeArrayIndex = 0;
|
||||||
|
iteratorIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getDescriptorNameEnd(String desc, int index) {
|
||||||
|
val c = desc.charAt(index);
|
||||||
|
switch (c) {
|
||||||
|
case '[':
|
||||||
|
return getDescriptorNameEnd(desc, index + 1);
|
||||||
|
case 'L':
|
||||||
|
do {
|
||||||
|
index++;
|
||||||
|
} while (desc.charAt(index) != ';');
|
||||||
|
default:
|
||||||
|
return index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Object> parseDesc(String desc) {
|
||||||
|
val result = new ArrayList<Object>();
|
||||||
|
desc = desc.substring(1, desc.indexOf(')'));
|
||||||
|
for (int i = 0; i < desc.length(); i++) {
|
||||||
|
val end = getDescriptorNameEnd(desc, i);
|
||||||
|
val name = desc.substring(i, end);
|
||||||
|
switch (name) {
|
||||||
|
case "I":
|
||||||
|
case "S":
|
||||||
|
case "B":
|
||||||
|
case "Z":
|
||||||
|
result.add(Opcodes.INTEGER);
|
||||||
|
break;
|
||||||
|
case "F":
|
||||||
|
result.add(Opcodes.FLOAT);
|
||||||
|
break;
|
||||||
|
case "D":
|
||||||
|
result.add(Opcodes.DOUBLE);
|
||||||
|
result.add(Opcodes.DOUBLE);
|
||||||
|
break;
|
||||||
|
case "J":
|
||||||
|
result.add(Opcodes.LONG);
|
||||||
|
result.add(Opcodes.LONG);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result.add(name);
|
||||||
|
}
|
||||||
|
i = end - 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initLocals(MethodNode method, ClassNode owner) {
|
||||||
|
locals.clear();
|
||||||
|
if ((method.access & Opcodes.ACC_STATIC) == 0) {
|
||||||
|
locals.add("L" + owner.name + ";");
|
||||||
|
}
|
||||||
|
locals.addAll(parseDesc(method.desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLocalsState(FrameNode frame) {
|
||||||
|
switch (frame.type) {
|
||||||
|
case Opcodes.F_NEW:
|
||||||
|
case Opcodes.F_FULL:
|
||||||
|
locals.clear();
|
||||||
|
case Opcodes.F_APPEND:
|
||||||
|
if (frame.local != null) {
|
||||||
|
for (val local : frame.local) {
|
||||||
|
if (Objects.equals(local, Opcodes.DOUBLE) || Objects.equals(local, Opcodes.LONG))
|
||||||
|
locals.add(local);
|
||||||
|
locals.add(local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Opcodes.F_CHOP: {
|
||||||
|
int removeCount = frame.local.size();
|
||||||
|
for (int i = removeCount - 1; i >= 0 && !locals.isEmpty(); i--) {
|
||||||
|
val removed = locals.remove(locals.size() - 1);
|
||||||
|
if (Objects.equals(removed, Opcodes.DOUBLE) || Objects.equals(removed, Opcodes.LONG))
|
||||||
|
locals.remove(locals.size() - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Opcodes.F_SAME:
|
||||||
|
case Opcodes.F_SAME1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.falsepattern.endlessids.asm.transformer.chunk;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.Tags;
|
||||||
|
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||||
|
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||||
|
import lombok.val;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
||||||
|
public class LOTRFieldExposer implements TurboClassTransformer {
|
||||||
|
@Override
|
||||||
|
public String owner() {
|
||||||
|
return Tags.MODNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "LOTRFieldExposer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
return "lotr.common.network.LOTRPacketBiomeVariantsWatch".equals(className);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||||
|
val cn = classNode.getNode();
|
||||||
|
if (cn == null)
|
||||||
|
return false;
|
||||||
|
for (val field: cn.fields) {
|
||||||
|
if ("chunkX".equals(field.name) ||
|
||||||
|
"chunkZ".equals(field.name) ||
|
||||||
|
"variants".equals(field.name)) {
|
||||||
|
field.access &= ~Opcodes.ACC_PRIVATE;
|
||||||
|
field.access |= Opcodes.ACC_PUBLIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,9 +28,8 @@ public class GeneralConfig {
|
|||||||
"See also: countCorrectionBits")
|
"See also: countCorrectionBits")
|
||||||
@Config.DefaultBoolean(true)
|
@Config.DefaultBoolean(true)
|
||||||
public static boolean extendBlockItem;
|
public static boolean extendBlockItem;
|
||||||
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.\n" +
|
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 32, new limit is 65536.\n")
|
||||||
"Disabled by default because of uncertain/weak implementation (taken from NotEnoughIDs)")
|
@Config.DefaultBoolean(true)
|
||||||
@Config.DefaultBoolean(false)
|
|
||||||
public static boolean extendDataWatcher;
|
public static boolean extendDataWatcher;
|
||||||
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
|
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
|
||||||
@Config.DefaultBoolean(true)
|
@Config.DefaultBoolean(true)
|
||||||
|
|||||||
@@ -10,12 +10,15 @@ public class ExtendedConstants {
|
|||||||
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
|
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
|
||||||
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
|
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
|
||||||
|
|
||||||
public static final int watchableBits = 7;
|
public static final int watchableBits = 16;
|
||||||
public static final int bitsPerBiome = 16;
|
public static final int bitsPerBiome = 16;
|
||||||
|
|
||||||
public static final int maximumPotionIDs = 65536;
|
public static final int maximumPotionIDs = 65536;
|
||||||
public static final int maximumEnchantmentIDs = 32768;
|
public static final int maximumEnchantmentIDs = 32768;
|
||||||
|
|
||||||
|
public static final int blocksPerSubChunk = 16 * 16 * 16;
|
||||||
|
public static final int subChunkNibbleArraySize = 16 * 16 * 16;
|
||||||
|
|
||||||
//Align with max item metadata for spawn eggs. Will be treated as short in netcode
|
//Align with max item metadata for spawn eggs. Will be treated as short in netcode
|
||||||
public static final int bitsPerEntity = 15;
|
public static final int bitsPerEntity = 15;
|
||||||
|
|
||||||
@@ -34,8 +37,8 @@ public class ExtendedConstants {
|
|||||||
|
|
||||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
|
||||||
|
|
||||||
//BiomeIDs
|
//BiomeIDs
|
||||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||||
@@ -46,7 +49,6 @@ public class ExtendedConstants {
|
|||||||
//DataWatcher
|
//DataWatcher
|
||||||
public static final int watchableCount = 1 << watchableBits;
|
public static final int watchableCount = 1 << watchableBits;
|
||||||
public static final int maxWatchableID = watchableCount - 1;
|
public static final int maxWatchableID = watchableCount - 1;
|
||||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
|
||||||
|
|
||||||
//EntityIDs
|
//EntityIDs
|
||||||
public static final int entityIDCount = 1 << bitsPerEntity;
|
public static final int entityIDCount = 1 << bitsPerEntity;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public class VanillaConstants {
|
|||||||
|
|
||||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
|
||||||
|
|
||||||
//BiomeIDs
|
//BiomeIDs
|
||||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
package com.falsepattern.endlessids.managers;
|
package com.falsepattern.endlessids.managers;
|
||||||
|
|
||||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
import com.falsepattern.chunk.api.ArrayUtil;
|
||||||
|
import com.falsepattern.chunk.api.DataManager;
|
||||||
import com.falsepattern.endlessids.Hooks;
|
import com.falsepattern.endlessids.Hooks;
|
||||||
import com.falsepattern.endlessids.Tags;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.ChunkNBTDataManager {
|
public class BiomeManager implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String domain() {
|
public String domain() {
|
||||||
@@ -29,17 +33,17 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||||
data.asShortBuffer().put(((IChunkMixin)chunk).getBiomeShortArray());
|
data.asShortBuffer().put(((ChunkBiomeHook)chunk).getBiomeShortArray());
|
||||||
data.position(data.position() + maxPacketSize());
|
data.position(data.position() + maxPacketSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||||
var arr = ((IChunkMixin)chunk).getBiomeShortArray();
|
var arr = ((ChunkBiomeHook)chunk).getBiomeShortArray();
|
||||||
if (arr == null) {
|
if (arr == null) {
|
||||||
arr = new short[16 * 16];
|
arr = new short[16 * 16];
|
||||||
((IChunkMixin)chunk).setBiomeShortArray(arr);
|
((ChunkBiomeHook)chunk).setBiomeShortArray(arr);
|
||||||
}
|
}
|
||||||
buffer.asShortBuffer().get(arr);
|
buffer.asShortBuffer().get(arr);
|
||||||
buffer.position(buffer.position() + maxPacketSize());
|
buffer.position(buffer.position() + maxPacketSize());
|
||||||
@@ -52,16 +56,16 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt) {
|
public void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt) {
|
||||||
byte[] arr = Hooks.shortToByteArray(((IChunkMixin)chunk).getBiomeShortArray());
|
byte[] arr = Hooks.shortToByteArray(((ChunkBiomeHook)chunk).getBiomeShortArray());
|
||||||
nbt.setByteArray("Biomes16v2", arr);
|
nbt.setByteArray("Biomes16v2", arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt) {
|
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt) {
|
||||||
var data = ((IChunkMixin) chunk).getBiomeShortArray();
|
var data = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = new short[16 * 16];
|
data = new short[16 * 16];
|
||||||
((IChunkMixin)chunk).setBiomeShortArray(data);
|
((ChunkBiomeHook)chunk).setBiomeShortArray(data);
|
||||||
}
|
}
|
||||||
if (nbt.hasKey("Biomes16v2", 7)) {
|
if (nbt.hasKey("Biomes16v2", 7)) {
|
||||||
Hooks.byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
|
Hooks.byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
|
||||||
@@ -72,4 +76,33 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.falsepattern.endlessids.managers;
|
package com.falsepattern.endlessids.managers;
|
||||||
|
|
||||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
import com.falsepattern.chunk.api.ArrayUtil;
|
||||||
|
import com.falsepattern.chunk.api.DataManager;
|
||||||
import com.falsepattern.endlessids.Tags;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||||
|
import com.falsepattern.endlessids.util.DataUtil;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -13,7 +17,10 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class BlockIDManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||||
|
import static com.falsepattern.endlessids.util.DataUtil.*;
|
||||||
|
|
||||||
|
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String domain() {
|
public String domain() {
|
||||||
@@ -31,35 +38,35 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||||
val ebsList = chunk.getBlockStorageArray();
|
val subChunkList = chunk.getBlockStorageArray();
|
||||||
int storageFlags = 0;
|
int storageFlags = 0;
|
||||||
val start = data.position() + 4;
|
val start = data.position() + 4;
|
||||||
data.position(start);
|
data.position(start);
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||||
|
|
||||||
storageFlags |= ebs.getEBSMSBMask() << (i * 2);
|
storageFlags |= subChunk.getBlockMask() << (i * 2);
|
||||||
|
|
||||||
val b1 = ebs.getB1();
|
val b1 = subChunk.getB1();
|
||||||
data.put(b1);
|
data.put(b1);
|
||||||
|
|
||||||
val b2Low = ebs.getB2Low();
|
val b2Low = subChunk.getB2Low();
|
||||||
if (b2Low == null) {
|
if (b2Low == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data.put(b2Low.data);
|
data.put(b2Low.data);
|
||||||
|
|
||||||
val b2High = ebs.getB2High();
|
val b2High = subChunk.getB2High();
|
||||||
if (b2High == null) {
|
if (b2High == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data.put(b2High.data);
|
data.put(b2High.data);
|
||||||
|
|
||||||
val b3 = ebs.getB3();
|
val b3 = subChunk.getB3();
|
||||||
if (b3 != null) {
|
if (b3 != null) {
|
||||||
data.put(b3);
|
data.put(b3);
|
||||||
}
|
}
|
||||||
@@ -68,119 +75,143 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||||
val ebsList = chunk.getBlockStorageArray();
|
val subChunkList = chunk.getBlockStorageArray();
|
||||||
val storageFlags = buffer.getInt();
|
val storageFlags = buffer.getInt();
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||||
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
||||||
val b1 = ebs.getB1();
|
val b1 = subChunk.getB1();
|
||||||
buffer.get(b1);
|
buffer.get(b1);
|
||||||
if (storageFlag == 0b00) {
|
if (storageFlag == 0b00) {
|
||||||
ebs.clearB2Low();
|
subChunk.setB2Low(null);
|
||||||
ebs.clearB2High();
|
subChunk.setB2High(null);
|
||||||
ebs.clearB3();
|
subChunk.setB3(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var b2Low = ebs.getB2Low();
|
var b2Low = subChunk.getB2Low();
|
||||||
if (b2Low == null) {
|
if (b2Low == null) {
|
||||||
b2Low = ebs.createB2Low();
|
b2Low = subChunk.createB2Low();
|
||||||
}
|
}
|
||||||
buffer.get(b2Low.data);
|
buffer.get(b2Low.data);
|
||||||
if (storageFlag == 0b01) {
|
if (storageFlag == 0b01) {
|
||||||
ebs.clearB2High();
|
subChunk.setB2High(null);
|
||||||
ebs.clearB3();
|
subChunk.setB3(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var b2High = ebs.getB2High();
|
var b2High = subChunk.getB2High();
|
||||||
if (b2High == null) {
|
if (b2High == null) {
|
||||||
b2High = ebs.createB2High();
|
b2High = subChunk.createB2High();
|
||||||
}
|
}
|
||||||
buffer.get(b2High.data);
|
buffer.get(b2High.data);
|
||||||
if (storageFlag == 0b10) {
|
if (storageFlag == 0b10) {
|
||||||
ebs.clearB3();
|
subChunk.setB3(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var b3 = ebs.getB3();
|
var b3 = subChunk.getB3();
|
||||||
if (b3 == null) {
|
if (b3 == null) {
|
||||||
b3 = ebs.createB3();
|
b3 = subChunk.createB3();
|
||||||
}
|
}
|
||||||
buffer.get(b3);
|
buffer.get(b3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sectionPrivilegedAccess() {
|
public boolean subChunkPrivilegedAccess() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||||
val b1 = ebs.getB1();
|
val b1 = subChunk.getB1();
|
||||||
val b2Low = ebs.getB2Low();
|
val b2Low = subChunk.getB2Low();
|
||||||
val b2High = ebs.getB2High();
|
val b2High = subChunk.getB2High();
|
||||||
val b3 = ebs.getB3();
|
val b3 = subChunk.getB3();
|
||||||
section.setByteArray("Blocks", b1);
|
nbt.setByteArray("Blocks", b1);
|
||||||
if (b2Low != null) {
|
if (b2Low != null) {
|
||||||
section.setByteArray("Add", b2Low.data);
|
nbt.setByteArray("Add", b2Low.data);
|
||||||
}
|
}
|
||||||
if (b2High != null) {
|
if (b2High != null) {
|
||||||
section.setByteArray("BlocksB2Hi", b2High.data);
|
nbt.setByteArray("BlocksB2Hi", b2High.data);
|
||||||
}
|
}
|
||||||
if (b3 != null) {
|
if (b3 != null) {
|
||||||
section.setByteArray("BlocksB3", b3);
|
nbt.setByteArray("BlocksB3", b3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//NotEnoughIDs world compatibility
|
//NotEnoughIDs world compatibility
|
||||||
public static void readSectionFromNBTNotEnoughIDsDFU(IExtendedBlockStorageMixin ebs, NBTTagCompound section) {
|
public static void readSubChunkFromNBTNotEnoughIDsDFU(SubChunkBlockHook subChunk, NBTTagCompound nbt) {
|
||||||
val data = section.getByteArray("Blocks16");
|
val data = nbt.getByteArray("Blocks16");
|
||||||
val dataShort = new short[data.length >>> 1];
|
val dataShort = new short[data.length >>> 1];
|
||||||
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
|
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
|
||||||
val b1 = new byte[dataShort.length];
|
val b1 = new byte[blocksPerSubChunk];
|
||||||
val b2L = new byte[dataShort.length >>> 1];
|
val b2L = new byte[blocksPerSubChunk >>> 1];
|
||||||
val b2H = new byte[dataShort.length >>> 1];
|
val b2H = new byte[blocksPerSubChunk >>> 1];
|
||||||
for (int i = 0; i < dataShort.length; i++) {
|
for (int i = 0; i < dataShort.length; i++) {
|
||||||
val s = dataShort[i];
|
val s = dataShort[i];
|
||||||
val nI = i >>> 1;
|
val nI = i >>> 1;
|
||||||
val mI = (i & 1) * 4;
|
val mI = (i & 1) * 4;
|
||||||
b1[i] = (byte) (s & 0x00FF);
|
b1[i] = (byte) (s & 0x00FF);
|
||||||
b2L[nI] |= ((s & 0x0F00) >>> 8) << mI;
|
b2L[nI] |= (byte) (((s & 0x0F00) >>> 8) << mI);
|
||||||
b2H[nI] |= ((s & 0xF000) >>> 12) << mI;
|
b2H[nI] |= (byte) (((s & 0xF000) >>> 12) << mI);
|
||||||
}
|
}
|
||||||
ebs.setB1(b1);
|
subChunk.setB1(b1);
|
||||||
ebs.setB2Low(new NibbleArray(b2L, 4));
|
subChunk.setB2Low(new NibbleArray(b2L, 4));
|
||||||
ebs.setB2High(new NibbleArray(b2H, 4));
|
subChunk.setB2High(new NibbleArray(b2H, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||||
if (section.hasKey("Blocks16")) {
|
if (nbt.hasKey("Blocks16")) {
|
||||||
readSectionFromNBTNotEnoughIDsDFU(ebs, section);
|
readSubChunkFromNBTNotEnoughIDsDFU(subChunk, nbt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert section.hasKey("Blocks");
|
assert nbt.hasKey("Blocks");
|
||||||
val b1 = section.getByteArray("Blocks");
|
val b1 = nbt.getByteArray("Blocks");
|
||||||
final byte[] b2Low = section.hasKey("Add") ? section.getByteArray("Add") : null;
|
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
|
||||||
final byte[] b2High = section.hasKey("BlocksB2Hi") ? section.getByteArray("BlocksB2Hi") : null;
|
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
|
||||||
final byte[] b3 = section.hasKey("BlocksB3") ? section.getByteArray("BlocksB3") : null;
|
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
|
||||||
|
|
||||||
ebs.setB1(b1);
|
subChunk.setB1(ensureSubChunkByteArray(b1));
|
||||||
if (b2Low == null) {
|
subChunk.setB2Low(ensureSubChunkNibbleArray(b2Low));
|
||||||
ebs.clearB2Low();
|
subChunk.setB2High(ensureSubChunkNibbleArray(b2High));
|
||||||
} else {
|
subChunk.setB3(ensureSubChunkByteArray(b3));
|
||||||
ebs.setB2Low(new NibbleArray(b2Low, 4));
|
}
|
||||||
}
|
|
||||||
if (b2High == null) {
|
@Override
|
||||||
ebs.clearB2High();
|
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
|
||||||
} else {
|
val from = (SubChunkBlockHook) fromVanilla;
|
||||||
ebs.setB2High(new NibbleArray(b2High, 4));
|
val to = (SubChunkBlockHook) toVanilla;
|
||||||
}
|
|
||||||
ebs.setB3(b3);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.falsepattern.endlessids.managers;
|
package com.falsepattern.endlessids.managers;
|
||||||
|
|
||||||
import com.falsepattern.chunk.api.ChunkDataManager;
|
import com.falsepattern.chunk.api.ArrayUtil;
|
||||||
|
import com.falsepattern.chunk.api.DataManager;
|
||||||
import com.falsepattern.endlessids.Tags;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||||
|
import com.falsepattern.endlessids.util.DataUtil;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -13,7 +17,9 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||||
|
|
||||||
|
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String domain() {
|
public String domain() {
|
||||||
@@ -31,29 +37,29 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||||
val ebsList = chunk.getBlockStorageArray();
|
val subChunkList = chunk.getBlockStorageArray();
|
||||||
int storageFlags = 0;
|
int storageFlags = 0;
|
||||||
val start = data.position() + 4;
|
val start = data.position() + 4;
|
||||||
data.position(start);
|
data.position(start);
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||||
|
|
||||||
storageFlags |= ebs.getEBSMask() << (i * 2);
|
storageFlags |= subChunk.getMetadataMask() << (i * 2);
|
||||||
|
|
||||||
val m1Low = ebs.getM1Low();
|
val m1Low = subChunk.getM1Low();
|
||||||
data.put(m1Low.data);
|
data.put(m1Low.data);
|
||||||
|
|
||||||
val m1High = ebs.getM1High();
|
val m1High = subChunk.getM1High();
|
||||||
if (m1High == null) {
|
if (m1High == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data.put(m1High.data);
|
data.put(m1High.data);
|
||||||
|
|
||||||
val m2 = ebs.getM2();
|
val m2 = subChunk.getM2();
|
||||||
if (m2 != null) {
|
if (m2 != null) {
|
||||||
data.put(m2);
|
data.put(m2);
|
||||||
}
|
}
|
||||||
@@ -62,73 +68,124 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||||
val ebsList = chunk.getBlockStorageArray();
|
val subChunkList = chunk.getBlockStorageArray();
|
||||||
val storageFlags = buffer.getInt();
|
val storageFlags = buffer.getInt();
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||||
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
||||||
val m1Low = ebs.getM1Low();
|
val m1Low = subChunk.getM1Low();
|
||||||
buffer.get(m1Low.data);
|
buffer.get(m1Low.data);
|
||||||
if (storageFlag == 0b01) {
|
if (storageFlag == 0b01) {
|
||||||
ebs.clearM1High();
|
subChunk.setM1High(null);
|
||||||
ebs.clearM2();
|
subChunk.setM2(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var m1High = ebs.getM1High();
|
var m1High = subChunk.getM1High();
|
||||||
if (m1High == null) {
|
if (m1High == null) {
|
||||||
m1High = ebs.createM1High();
|
m1High = subChunk.createM1High();
|
||||||
}
|
}
|
||||||
buffer.get(m1High.data);
|
buffer.get(m1High.data);
|
||||||
if (storageFlag == 0b10) {
|
if (storageFlag == 0b10) {
|
||||||
ebs.clearM2();
|
subChunk.setM2(null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var m2 = ebs.getM2();
|
var m2 = subChunk.getM2();
|
||||||
if (m2 == null) {
|
if (m2 == null) {
|
||||||
m2 = ebs.createM2();
|
m2 = subChunk.createM2();
|
||||||
}
|
}
|
||||||
buffer.get(m2);
|
buffer.get(m2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sectionPrivilegedAccess() {
|
public boolean subChunkPrivilegedAccess() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||||
val m1Low = ebs.getM1Low();
|
val m1Low = subChunk.getM1Low();
|
||||||
val m1High = ebs.getM1High();
|
val m1High = subChunk.getM1High();
|
||||||
val m2 = ebs.getM2();
|
val m2 = subChunk.getM2();
|
||||||
section.setByteArray("Data", m1Low.data);
|
nbt.setByteArray("Data", m1Low.data);
|
||||||
if (m1High != null) {
|
if (m1High != null) {
|
||||||
section.setByteArray("Data1High", m1High.data);
|
nbt.setByteArray("Data1High", m1High.data);
|
||||||
}
|
}
|
||||||
if (m2 != null) {
|
if (m2 != null) {
|
||||||
section.setByteArray("Data2", m2);
|
nbt.setByteArray("Data2", m2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NotEnoughIDs world compatibility
|
||||||
|
private void readSubChunkFromNBTNotEnoughIDsDFU(SubChunkBlockHook subChunk, NBTTagCompound nbt) {
|
||||||
|
val data = nbt.getByteArray("Data16");
|
||||||
|
val dataShort = new short[data.length >>> 1];
|
||||||
|
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
|
||||||
|
val m1Low = new byte[blocksPerSubChunk >>> 1];
|
||||||
|
val m1High = new byte[blocksPerSubChunk >>> 1];
|
||||||
|
val m2 = new byte[blocksPerSubChunk];
|
||||||
|
for (int i = 0; i < dataShort.length; i++) {
|
||||||
|
val s = dataShort[i];
|
||||||
|
val nI = i >>> 1;
|
||||||
|
val mI = (i & 1) * 4;
|
||||||
|
m1Low[nI] |= (byte) ((s & 0x000F) << mI);
|
||||||
|
m1High[nI] |= (byte) (((s & 0x00F0) >>> 4) << mI);
|
||||||
|
m2[i] = (byte) ((s & 0xFF00) >>> 8);
|
||||||
|
}
|
||||||
|
subChunk.setM1Low(new NibbleArray(m1Low, 4));
|
||||||
|
subChunk.setM1High(new NibbleArray(m1High, 4));
|
||||||
|
subChunk.setM2(m2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||||
assert section.hasKey("Data");
|
if (nbt.hasKey("Data16")) {
|
||||||
val m1Low = section.getByteArray("Data");
|
readSubChunkFromNBTNotEnoughIDsDFU(subChunk, nbt);
|
||||||
final byte[] m1High = section.hasKey("Data1High") ? section.getByteArray("Data1High") : null;
|
return;
|
||||||
final byte[] m2 = section.hasKey("Data2") ? section.getByteArray("Data2") : null;
|
|
||||||
|
|
||||||
ebs.setM1Low(new NibbleArray(m1Low, 4));
|
|
||||||
if (m1High == null) {
|
|
||||||
ebs.clearM1High();
|
|
||||||
} else {
|
|
||||||
ebs.setM1High(new NibbleArray(m1High, 4));
|
|
||||||
}
|
}
|
||||||
ebs.setM2(m2);
|
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(DataUtil.ensureSubChunkNibbleArray(m1Low));
|
||||||
|
subChunk.setM1High(DataUtil.ensureSubChunkNibbleArray(m1High));
|
||||||
|
subChunk.setM2(DataUtil.ensureSubChunkByteArray(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 class BiomePatchHelper {
|
||||||
public static byte[] getBiomeArrayTweaked(Chunk chunk, IntFunction<BiomeGenBase> biomesForGeneration) {
|
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) {
|
for (int i = 0; i < chunkBiomes.length; ++i) {
|
||||||
chunkBiomes[i] = (short) biomesForGeneration.apply(i).biomeID;
|
chunkBiomes[i] = (short) biomesForGeneration.apply(i).biomeID;
|
||||||
@@ -20,7 +20,7 @@ public class BiomePatchHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getBiomeArrayTweaked(Chunk chunk, BiomeGenBase[] biomesForGeneration) {
|
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) {
|
for (int i = 0; i < chunkBiomes.length; ++i) {
|
||||||
chunkBiomes[i] = (short) biomesForGeneration[i].biomeID;
|
chunkBiomes[i] = (short) biomesForGeneration[i].biomeID;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.helpers;
|
package com.falsepattern.endlessids.mixin.helpers;
|
||||||
|
|
||||||
public interface IChunkMixin {
|
public interface ChunkBiomeHook {
|
||||||
short[] getBiomeShortArray();
|
short[] getBiomeShortArray();
|
||||||
|
|
||||||
void setBiomeShortArray(short[] data);
|
void setBiomeShortArray(short[] data);
|
||||||
+3
-13
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.helpers;
|
|||||||
|
|
||||||
import net.minecraft.world.chunk.NibbleArray;
|
import net.minecraft.world.chunk.NibbleArray;
|
||||||
|
|
||||||
public interface IExtendedBlockStorageMixin {
|
public interface SubChunkBlockHook {
|
||||||
byte[] getB1();
|
byte[] getB1();
|
||||||
|
|
||||||
void setB1(byte[] data);
|
void setB1(byte[] data);
|
||||||
@@ -11,29 +11,23 @@ public interface IExtendedBlockStorageMixin {
|
|||||||
|
|
||||||
void setB2Low(NibbleArray data);
|
void setB2Low(NibbleArray data);
|
||||||
|
|
||||||
void clearB2Low();
|
|
||||||
|
|
||||||
NibbleArray createB2Low();
|
NibbleArray createB2Low();
|
||||||
|
|
||||||
NibbleArray getB2High();
|
NibbleArray getB2High();
|
||||||
|
|
||||||
void setB2High(NibbleArray data);
|
void setB2High(NibbleArray data);
|
||||||
|
|
||||||
void clearB2High();
|
|
||||||
|
|
||||||
NibbleArray createB2High();
|
NibbleArray createB2High();
|
||||||
|
|
||||||
byte[] getB3();
|
byte[] getB3();
|
||||||
|
|
||||||
void setB3(byte[] data);
|
void setB3(byte[] data);
|
||||||
|
|
||||||
void clearB3();
|
|
||||||
|
|
||||||
byte[] createB3();
|
byte[] createB3();
|
||||||
|
|
||||||
int getEBSMask();
|
int getMetadataMask();
|
||||||
|
|
||||||
int getEBSMSBMask();
|
int getBlockMask();
|
||||||
|
|
||||||
int getID(int x, int y, int z);
|
int getID(int x, int y, int z);
|
||||||
|
|
||||||
@@ -45,15 +39,11 @@ public interface IExtendedBlockStorageMixin {
|
|||||||
|
|
||||||
void setM1High(NibbleArray m1High);
|
void setM1High(NibbleArray m1High);
|
||||||
|
|
||||||
void clearM1High();
|
|
||||||
|
|
||||||
NibbleArray createM1High();
|
NibbleArray createM1High();
|
||||||
|
|
||||||
byte[] getM2();
|
byte[] getM2();
|
||||||
|
|
||||||
void setM2(byte[] m2);
|
void setM2(byte[] m2);
|
||||||
|
|
||||||
void clearM2();
|
|
||||||
|
|
||||||
byte[] createM2();
|
byte[] createM2();
|
||||||
}
|
}
|
||||||
+2
-2
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.antiqueatlas;
|
|||||||
|
|
||||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
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 com.falsepattern.endlessids.mixin.helpers.ShortUtil;
|
||||||
import hunternif.mc.atlas.core.BiomeDetectorBase;
|
import hunternif.mc.atlas.core.BiomeDetectorBase;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -41,7 +41,7 @@ public abstract class BiomeDetectorBaseMixin {
|
|||||||
require = 1)
|
require = 1)
|
||||||
private int[] biomeIDs(byte[] i) {
|
private int[] biomeIDs(byte[] i) {
|
||||||
try {
|
try {
|
||||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
|
||||||
} finally {
|
} finally {
|
||||||
chunk = null;
|
chunk = null;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.antiqueatlas;
|
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 com.falsepattern.endlessids.mixin.helpers.ShortUtil;
|
||||||
import hunternif.mc.atlas.core.BiomeDetectorNether;
|
import hunternif.mc.atlas.core.BiomeDetectorNether;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -30,7 +30,7 @@ public abstract class BiomeDetectorNetherMixin {
|
|||||||
require = 1)
|
require = 1)
|
||||||
private int[] biomeIDs(byte[] i) {
|
private int[] biomeIDs(byte[] i) {
|
||||||
try {
|
try {
|
||||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
|
||||||
} finally {
|
} finally {
|
||||||
chunk = null;
|
chunk = null;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.biomewand;
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.biomewand;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
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.BiomeWandMod;
|
||||||
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
|
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
|
||||||
import com.spacechase0.minecraft.spacecore.util.TranslateUtils;
|
import com.spacechase0.minecraft.spacecore.util.TranslateUtils;
|
||||||
@@ -42,7 +42,7 @@ public abstract class BiomeWandItemMixin {
|
|||||||
int relBlockX = blockX & 15;
|
int relBlockX = blockX & 15;
|
||||||
int relBlockZ = blockZ & 15;
|
int relBlockZ = blockZ & 15;
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
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);
|
tag.setShort("sampledBiomeS", biome);
|
||||||
} else {
|
} else {
|
||||||
short biome = tag.getShort("sampledBiomeS");
|
short biome = tag.getShort("sampledBiomeS");
|
||||||
@@ -52,7 +52,7 @@ public abstract class BiomeWandItemMixin {
|
|||||||
int relBlockX = ix & 15;
|
int relBlockX = ix & 15;
|
||||||
int relBlockZ = iz & 15;
|
int relBlockZ = iz & 15;
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||||
((IChunkMixin) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
((ChunkBiomeHook) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||||
chunk.isModified = true;
|
chunk.isModified = true;
|
||||||
BiomeWandMod.proxy.updateRendererAt(ix, iz);
|
BiomeWandMod.proxy.updateRendererAt(ix, iz);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public abstract class BiomeWandItemMixin {
|
|||||||
* @reason Biome ID extension
|
* @reason Biome ID extension
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
String str = TranslateUtils.translate("biomewand.tooltip.biome") + ": ";
|
String str = TranslateUtils.translate("biomewand.tooltip.biome") + ": ";
|
||||||
if (tag == null || !tag.hasKey("sampledBiomeS")) {
|
if (tag == null || !tag.hasKey("sampledBiomeS")) {
|
||||||
@@ -95,7 +95,7 @@ public abstract class BiomeWandItemMixin {
|
|||||||
* @reason Biome ID extension
|
* @reason Biome ID extension
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public void getSubItems(Item item, CreativeTabs tabs, List list) {
|
public void getSubItems(Item item, CreativeTabs tabs, List<ItemStack> list) {
|
||||||
list.add(new ItemStack((BiomeWandItem) (Object) this, 1));
|
list.add(new ItemStack((BiomeWandItem) (Object) this, 1));
|
||||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||||
if (biome != null && !(biome instanceof PlaceholderBiome)) {
|
if (biome != null && !(biome instanceof PlaceholderBiome)) {
|
||||||
|
|||||||
+11
-7
@@ -1,14 +1,16 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.compactmachines;
|
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 lombok.val;
|
||||||
import org.dave.CompactMachines.handler.ConfigurationHandler;
|
import org.dave.CompactMachines.handler.ConfigurationHandler;
|
||||||
import org.dave.CompactMachines.machines.tools.CubeTools;
|
import org.dave.CompactMachines.machines.tools.CubeTools;
|
||||||
|
import org.dave.CompactMachines.tileentity.TileEntityMachine;
|
||||||
import org.dave.CompactMachines.utility.WorldUtils;
|
import org.dave.CompactMachines.utility.WorldUtils;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -27,7 +29,7 @@ public abstract class CubeToolsMixin {
|
|||||||
WorldServer machineWorld = MinecraftServer.getServer().worldServerForDimension(ConfigurationHandler.dimensionId);
|
WorldServer machineWorld = MinecraftServer.getServer().worldServerForDimension(ConfigurationHandler.dimensionId);
|
||||||
Chunk chunk = machineWorld.getChunkFromBlockCoords(coords * ConfigurationHandler.cubeDistance, 0);
|
Chunk chunk = machineWorld.getChunkFromBlockCoords(coords * ConfigurationHandler.cubeDistance, 0);
|
||||||
if (chunk != null && chunk.isChunkLoaded) {
|
if (chunk != null && chunk.isChunkLoaded) {
|
||||||
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
short[] biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||||
for (int x = 0; x < 15; ++x) {
|
for (int x = 0; x < 15; ++x) {
|
||||||
for (int z = 0; z < 15; ++z) {
|
for (int z = 0; z < 15; ++z) {
|
||||||
biomeArray[z << 4 | x] = (short) biome.biomeID;
|
biomeArray[z << 4 | x] = (short) biome.biomeID;
|
||||||
@@ -43,10 +45,12 @@ public abstract class CubeToolsMixin {
|
|||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static BiomeGenBase getMachineBiome(TileEntityMachine machine) {
|
public static BiomeGenBase getMachineBiome(TileEntityMachine machine) {
|
||||||
short[] biomeArray = ((IChunkMixin) machine.getWorldObj()
|
val TE = (TileEntity)machine;
|
||||||
.getChunkFromBlockCoords(machine.xCoord,
|
val x = TE.xCoord;
|
||||||
machine.zCoord)).getBiomeShortArray();
|
val z = TE.zCoord;
|
||||||
int biomeId = biomeArray[(machine.zCoord & 15) << 4 | machine.xCoord & 15];
|
short[] biomeArray = ((ChunkBiomeHook) TE.getWorldObj()
|
||||||
|
.getChunkFromBlockCoords(x, z)).getBiomeShortArray();
|
||||||
|
int biomeId = biomeArray[(z & 15) << 4 | x & 15];
|
||||||
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length &&
|
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length &&
|
||||||
BiomeDictionary.isBiomeRegistered(biomeId) ? BiomeGenBase.getBiome(biomeId) : WorldUtils.getBiomeByName(
|
BiomeDictionary.isBiomeRegistered(biomeId) ? BiomeGenBase.getBiome(biomeId) : WorldUtils.getBiomeByName(
|
||||||
ConfigurationHandler.defaultBiome);
|
ConfigurationHandler.defaultBiome);
|
||||||
|
|||||||
+3
-3
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
|
|||||||
|
|
||||||
import Reika.DragonAPI.Libraries.World.ReikaChunkHelper;
|
import Reika.DragonAPI.Libraries.World.ReikaChunkHelper;
|
||||||
import com.falsepattern.endlessids.EndlessIDs;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@@ -20,7 +20,7 @@ public abstract class ReikaChunkHelperMixin {
|
|||||||
remap = true),
|
remap = true),
|
||||||
require = 1)
|
require = 1)
|
||||||
private static void customSet(Chunk chunk, byte[] p_76616_1_) {
|
private static void customSet(Chunk chunk, byte[] p_76616_1_) {
|
||||||
((IChunkMixin) chunk).setBiomeShortArray(biomeArray);
|
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeArray);
|
||||||
biomeArray = null;
|
biomeArray = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public abstract class ReikaChunkHelperMixin {
|
|||||||
remap = true),
|
remap = true),
|
||||||
require = 1)
|
require = 1)
|
||||||
private static byte[] customGet(Chunk chunk) {
|
private static byte[] customGet(Chunk chunk) {
|
||||||
biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||||
return EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
|
return EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
|
|||||||
|
|
||||||
import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
|
import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
|
||||||
import com.falsepattern.endlessids.EndlessIDs;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -45,7 +45,7 @@ public abstract class ReikaWorldHelperMixin {
|
|||||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||||
require = 1)
|
require = 1)
|
||||||
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) {
|
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) {
|
||||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
((ChunkBiomeHook) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "setBiomeAndBlocksForXZ",
|
@Inject(method = "setBiomeAndBlocksForXZ",
|
||||||
@@ -55,7 +55,7 @@ public abstract class ReikaWorldHelperMixin {
|
|||||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||||
require = 1)
|
require = 1)
|
||||||
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) {
|
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 = ((IChunkMixin) ch).getBiomeShortArray()[index];
|
fromBiomeID = ((ChunkBiomeHook) ch).getBiomeShortArray()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
|
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
|
||||||
@@ -72,6 +72,6 @@ public abstract class ReikaWorldHelperMixin {
|
|||||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||||
require = 1)
|
require = 1)
|
||||||
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) {
|
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) {
|
||||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
((ChunkBiomeHook) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -31,7 +31,8 @@ public abstract class GenLayerEBHillsMixin {
|
|||||||
|
|
||||||
@Redirect(method = "getInts",
|
@Redirect(method = "getInts",
|
||||||
at = @At(value = "INVOKE",
|
at = @At(value = "INVOKE",
|
||||||
target = "Lorg/apache/logging/log4j/Logger;debug(Ljava/lang/String;)V"),
|
target = "Lorg/apache/logging/log4j/Logger;debug(Ljava/lang/String;)V",
|
||||||
|
remap = false),
|
||||||
remap = true,
|
remap = true,
|
||||||
require = 1)
|
require = 1)
|
||||||
private void noLog(Logger instance, String s) {
|
private void noLog(Logger instance, String s) {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.enderlicious;
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.enderlicious;
|
||||||
|
|
||||||
import DelirusCrux.Enderlicious.Dimension.EndChunkProvider;
|
import DelirusCrux.Enderlicious.Dimension.EndChunkProvider;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -39,7 +39,7 @@ public abstract class EndChunkProviderMixin {
|
|||||||
remap = true,
|
remap = true,
|
||||||
require = 1)
|
require = 1)
|
||||||
private byte[] setBiomesTweaked(Chunk chunk) {
|
private byte[] setBiomesTweaked(Chunk chunk) {
|
||||||
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||||
for (int k = 0; k < chunkBiomes.length; ++k) {
|
for (int k = 0; k < chunkBiomes.length; ++k) {
|
||||||
if (Math.abs(xx) < 160 && Math.abs(zz) < 160) {
|
if (Math.abs(xx) < 160 && Math.abs(zz) < 160) {
|
||||||
chunkBiomes[k] = 9;
|
chunkBiomes[k] = 9;
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.extrautilities;
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.extrautilities;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.EndlessIDs;
|
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 com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -45,7 +45,7 @@ public abstract class ChunkProviderEndOfTimeMixin {
|
|||||||
require = 1)
|
require = 1)
|
||||||
private void setBiomesTweaked3(byte[] bytes, byte b) {
|
private void setBiomesTweaked3(byte[] bytes, byte b) {
|
||||||
try {
|
try {
|
||||||
Arrays.fill(((IChunkMixin) chunk).getBiomeShortArray(), (short) id);
|
Arrays.fill(((ChunkBiomeHook) chunk).getBiomeShortArray(), (short) id);
|
||||||
} finally {
|
} finally {
|
||||||
chunk = null;
|
chunk = null;
|
||||||
id = -1;
|
id = -1;
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.ir3;
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.ir3;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
import jp.plusplus.ir2.IR2;
|
import jp.plusplus.ir2.IR2;
|
||||||
import jp.plusplus.ir2.blocks.BlockCore;
|
import jp.plusplus.ir2.blocks.BlockCore;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -62,7 +62,7 @@ public abstract class IR2Mixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short[] bIds = ((IChunkMixin)event.world.getChunkFromBlockCoords(event.worldX, event.worldZ)).getBiomeShortArray();
|
short[] bIds = ((ChunkBiomeHook)event.world.getChunkFromBlockCoords(event.worldX, event.worldZ)).getBiomeShortArray();
|
||||||
|
|
||||||
for(int k = 0; k < bIds.length; ++k) {
|
for(int k = 0; k < bIds.length; ++k) {
|
||||||
if (bIds[k] == BiomeGenBase.ocean.biomeID || bIds[k] == BiomeGenBase.deepOcean.biomeID) {
|
if (bIds[k] == BiomeGenBase.ocean.biomeID || bIds[k] == BiomeGenBase.deepOcean.biomeID) {
|
||||||
|
|||||||
+6
-6
@@ -10,17 +10,17 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
|
|
||||||
@Mixin(value = LOTRChunkProvider.class,
|
@Mixin(value = LOTRChunkProvider.class)
|
||||||
remap = false)
|
public abstract class LOTRChunkProviderMixin implements IChunkProvider {
|
||||||
public abstract class LOTRChunkProviderMixin {
|
@Shadow(remap = false)
|
||||||
@Shadow
|
|
||||||
private LOTRBiomeVariant[] variantsForGeneration;
|
private LOTRBiomeVariant[] variantsForGeneration;
|
||||||
|
|
||||||
@Redirect(method = "provideChunk",
|
@Redirect(method = "provideChunk",
|
||||||
at = @At(value = "INVOKE",
|
at = @At(value = "INVOKE",
|
||||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V"),
|
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V",
|
||||||
remap = true,
|
remap = false),
|
||||||
require = 1)
|
require = 1)
|
||||||
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
||||||
short[] variants = new short[256];
|
short[] variants = new short[256];
|
||||||
|
|||||||
+6
-6
@@ -10,17 +10,17 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
|
|
||||||
@Mixin(value = LOTRChunkProviderUtumno.class,
|
@Mixin(value = LOTRChunkProviderUtumno.class)
|
||||||
remap = false)
|
public abstract class LOTRChunkProviderUtumnoMixin implements IChunkProvider {
|
||||||
public abstract class LOTRChunkProviderUtumnoMixin {
|
@Shadow(remap = false)
|
||||||
@Shadow
|
|
||||||
private LOTRBiomeVariant[] variantsForGeneration;
|
private LOTRBiomeVariant[] variantsForGeneration;
|
||||||
|
|
||||||
@Redirect(method = "provideChunk",
|
@Redirect(method = "provideChunk",
|
||||||
at = @At(value = "INVOKE",
|
at = @At(value = "INVOKE",
|
||||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V"),
|
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V",
|
||||||
remap = true,
|
remap = false),
|
||||||
require = 1)
|
require = 1)
|
||||||
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
||||||
short[] variants = new short[256];
|
short[] variants = new short[256];
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.lotr;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
|
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||||
|
import lotr.common.LOTRDimension;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Constant;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||||
|
|
||||||
|
@Mixin(value = LOTRDimension.class,
|
||||||
|
remap = false)
|
||||||
|
public abstract class LOTRDimensionMixin {
|
||||||
|
@ModifyConstant(method = "<init>",
|
||||||
|
constant = @Constant(intValue = VanillaConstants.biomeIDCount),
|
||||||
|
require = 1)
|
||||||
|
private int extendBiomes(int constant) {
|
||||||
|
return ExtendedConstants.biomeIDCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -12,11 +12,12 @@ import net.minecraft.world.ChunkCoordIntPair;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
|
||||||
@Mixin(value = LOTRPacketBiomeVariantsWatch.Handler.class,
|
@Mixin(value = LOTRPacketBiomeVariantsWatch.Handler.class,
|
||||||
remap = false)
|
remap = false)
|
||||||
public abstract class LOTRPacketBiomeVariantsWatchHandler {
|
public abstract class LOTRPacketBiomeVariantsWatchHandlerMixin implements IMessageHandler<LOTRPacketBiomeVariantsWatch, IMessage> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FalsePattern
|
* @author FalsePattern
|
||||||
+6
-6
@@ -8,23 +8,23 @@ import org.spongepowered.asm.mixin.Overwrite;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.WorldChunkManager;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
|
||||||
@Mixin(value = LOTRWorldChunkManager.class,
|
@Mixin(value = LOTRWorldChunkManager.class)
|
||||||
remap = false)
|
public abstract class LOTRWorldChunkManagerMixin extends WorldChunkManager {
|
||||||
public abstract class LOTRWorldChunkManagerMixin {
|
@Shadow(remap = false)
|
||||||
@Shadow
|
|
||||||
private World worldObj;
|
private World worldObj;
|
||||||
|
|
||||||
@Shadow
|
@Shadow(remap = false)
|
||||||
public abstract LOTRBiomeVariant[] getBiomeVariants(LOTRBiomeVariant[] variants, int i, int k, int xSize, int zSize);
|
public abstract LOTRBiomeVariant[] getBiomeVariants(LOTRBiomeVariant[] variants, int i, int k, int xSize, int zSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FalsePattern
|
* @author FalsePattern
|
||||||
* @reason fix stuff
|
* @reason fix stuff
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite(remap = false)
|
||||||
public LOTRBiomeVariant getBiomeVariantAt(int i, int k) {
|
public LOTRBiomeVariant getBiomeVariantAt(int i, int k) {
|
||||||
short[] variants;
|
short[] variants;
|
||||||
Chunk chunk = this.worldObj.getChunkFromBlockCoords(i, k);
|
Chunk chunk = this.worldObj.getChunkFromBlockCoords(i, k);
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.lotr;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
|
import lombok.val;
|
||||||
|
import lotr.common.LOTRDimension;
|
||||||
|
import lotr.common.world.LOTRWorldProvider;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import net.minecraft.world.WorldProvider;
|
||||||
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import static com.falsepattern.endlessids.constants.ExtendedConstants.biomeIDMask;
|
||||||
|
|
||||||
|
@Mixin(LOTRWorldProvider.class)
|
||||||
|
public abstract class LOTRWorldProviderMixin extends WorldProvider {
|
||||||
|
@Shadow(remap = false) public abstract LOTRDimension getLOTRDimension();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author FalsePattern
|
||||||
|
* @reason ID extension
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
|
||||||
|
if (worldObj.blockExists(x, 0, z)) {
|
||||||
|
val chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||||
|
if (chunk != null) {
|
||||||
|
val extendedChunk = (ChunkBiomeHook)chunk;
|
||||||
|
val biomeArray = extendedChunk.getBiomeShortArray();
|
||||||
|
int chunkX = x & 15;
|
||||||
|
int chunkZ = z & 15;
|
||||||
|
int biomeID = biomeArray[chunkZ << 4 | chunkX] & biomeIDMask;
|
||||||
|
if (biomeID == 255) {
|
||||||
|
val biome = worldChunkMgr.getBiomeGenAt((chunk.xPosition << 4) + chunkX, (chunk.zPosition << 4) + chunkZ);
|
||||||
|
biomeID = biome.biomeID;
|
||||||
|
biomeArray[chunkZ << 4 | chunkX] = (short)(biomeID & biomeIDMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
val dim = this.getLOTRDimension();
|
||||||
|
return dim.biomeList[biomeID] == null ? dim.biomeList[0] : dim.biomeList[biomeID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.worldChunkMgr.getBiomeGenAt(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.nomadictents;
|
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 com.yurtmod.dimension.TentChunkProvider;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -23,6 +23,6 @@ public abstract class TentChunkProviderMixin {
|
|||||||
private void setBiomesTweaked(Chunk chunk, byte[] p_76616_1_) {
|
private void setBiomesTweaked(Chunk chunk, byte[] p_76616_1_) {
|
||||||
short[] biomeMap = new short[256];
|
short[] biomeMap = new short[256];
|
||||||
Arrays.fill(biomeMap, (short) BiomeGenBase.ocean.biomeID);
|
Arrays.fill(biomeMap, (short) BiomeGenBase.ocean.biomeID);
|
||||||
((IChunkMixin) chunk).setBiomeShortArray(biomeMap);
|
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
|
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.ItemBiomeCapsule;
|
||||||
import lumien.randomthings.Items.ItemBiomePainter;
|
import lumien.randomthings.Items.ItemBiomePainter;
|
||||||
import lumien.randomthings.Items.ModItems;
|
import lumien.randomthings.Items.ModItems;
|
||||||
@@ -40,10 +40,10 @@ public abstract class ItemBiomePainterMixin {
|
|||||||
if (charges > 0 || par2EntityPlayer.capabilities.isCreativeMode) {
|
if (charges > 0 || par2EntityPlayer.capabilities.isCreativeMode) {
|
||||||
Chunk c = par3World.getChunkFromBlockCoords(par4, par6);
|
Chunk c = par3World.getChunkFromBlockCoords(par4, par6);
|
||||||
int biomeID = is.getItemDamage() - 1;
|
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) {
|
if ((biomeArray[(par6 & 15) << 4 | par4 & 15] & 255) != biomeID) {
|
||||||
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short) (biomeID & 0xFFFF); //changed
|
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short) (biomeID & 0xFFFF); //changed
|
||||||
((IChunkMixin) c).setBiomeShortArray(biomeArray); //changed
|
((ChunkBiomeHook) c).setBiomeShortArray(biomeArray); //changed
|
||||||
if (!par2EntityPlayer.capabilities.isCreativeMode) {
|
if (!par2EntityPlayer.capabilities.isCreativeMode) {
|
||||||
nbt.setInteger("charges", charges - 1);
|
nbt.setInteger("charges", charges - 1);
|
||||||
par2EntityPlayer.inventoryContainer.detectAndSendChanges();
|
par2EntityPlayer.inventoryContainer.detectAndSendChanges();
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
|
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.ItemBiomeCapsule;
|
||||||
import lumien.randomthings.Network.Messages.MessagePaintBiome;
|
import lumien.randomthings.Network.Messages.MessagePaintBiome;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -49,9 +49,9 @@ public abstract class MessagePaintBiomeMixin {
|
|||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
if (player != null && player.worldObj.provider.dimensionId == this.dimensionID) {
|
if (player != null && player.worldObj.provider.dimensionId == this.dimensionID) {
|
||||||
Chunk c = player.worldObj.getChunkFromBlockCoords(this.posX, this.posZ);
|
Chunk c = player.worldObj.getChunkFromBlockCoords(this.posX, this.posZ);
|
||||||
short[] biomeArray = ((IChunkMixin) c).getBiomeShortArray(); //changed
|
short[] biomeArray = ((ChunkBiomeHook) c).getBiomeShortArray(); //changed
|
||||||
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short) (this.biomeID & 0xFFFF); //changed
|
biomeArray[(this.posZ & 15) << 4 | this.posX & 15] = (short) (this.biomeID & 0xFFFF); //changed
|
||||||
((IChunkMixin) c).setBiomeShortArray(biomeArray); //changed
|
((ChunkBiomeHook) c).setBiomeShortArray(biomeArray); //changed
|
||||||
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0,
|
Minecraft.getMinecraft().thePlayer.worldObj.markBlocksDirtyVertical(this.posX, this.posZ, 0,
|
||||||
player.worldObj.getActualHeight());
|
player.worldObj.getActualHeight());
|
||||||
BiomeGenBase biome = BiomeGenBase.getBiome(this.biomeID);
|
BiomeGenBase biome = BiomeGenBase.getBiome(this.biomeID);
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.restructured;
|
package com.falsepattern.endlessids.mixin.mixins.common.biome.restructured;
|
||||||
|
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
import org.blockartistry.mod.Restructured.world.BiomeHelper;
|
import org.blockartistry.mod.Restructured.world.BiomeHelper;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
@@ -21,7 +21,7 @@ public abstract class BiomeHelperMixin {
|
|||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static BiomeGenBase chunkBiomeSurvey(World world, Chunk chunk, Random rand) {
|
public static BiomeGenBase chunkBiomeSurvey(World world, Chunk chunk, Random rand) {
|
||||||
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
|
short[] biomes = ((ChunkBiomeHook)chunk).getBiomeShortArray();
|
||||||
int[] counts = new int[biomes.length];
|
int[] counts = new int[biomes.length];
|
||||||
int highIndex = BiomeGenBase.plains.biomeID;
|
int highIndex = BiomeGenBase.plains.biomeID;
|
||||||
int highCount = -1;
|
int highCount = -1;
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.thaumcraft;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import thaumcraft.common.lib.network.PacketHandler;
|
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) {
|
public static void setBiomeAt(World world, int x, int z, BiomeGenBase biome) {
|
||||||
if (biome != null) {
|
if (biome != null) {
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
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);
|
array[(z & 15) << 4 | x & 15] = (short) (biome.biomeID);
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
PacketHandler.INSTANCE.sendToAllAround(new PacketBiomeChange(x, z, (short) biome.biomeID),
|
PacketHandler.INSTANCE.sendToAllAround(new PacketBiomeChange(x, z, (short) biome.biomeID),
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
|
|||||||
import com.falsepattern.endlessids.EndlessIDs;
|
import com.falsepattern.endlessids.EndlessIDs;
|
||||||
import com.falsepattern.endlessids.Tags;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -23,7 +23,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
@Mixin(value = Chunk.class,
|
@Mixin(value = Chunk.class,
|
||||||
priority = 900)
|
priority = 900)
|
||||||
public abstract class ChunkMixin implements IChunkMixin {
|
public abstract class ChunkMixin implements ChunkBiomeHook {
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
public int xPosition;
|
public int xPosition;
|
||||||
|
|||||||
+8
-8
@@ -1,6 +1,6 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.ubc;
|
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.BiomeUndergroundDecorator;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -16,7 +16,7 @@ import java.util.logging.Logger;
|
|||||||
remap = false)
|
remap = false)
|
||||||
public abstract class BiomeUndergroundDecoratorMixin {
|
public abstract class BiomeUndergroundDecoratorMixin {
|
||||||
private static NibbleArray fakeArray;
|
private static NibbleArray fakeArray;
|
||||||
private IExtendedBlockStorageMixin ebs;
|
private SubChunkBlockHook subChunk;
|
||||||
|
|
||||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||||
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
|
"replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
|
||||||
@@ -24,10 +24,10 @@ public abstract class BiomeUndergroundDecoratorMixin {
|
|||||||
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B",
|
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B",
|
||||||
remap = true),
|
remap = true),
|
||||||
require = 2)
|
require = 2)
|
||||||
private byte[] returnLSB(ExtendedBlockStorage instance) {
|
private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) {
|
||||||
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
|
SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||||
ebs = iebs;
|
this.subChunk = subChunk;
|
||||||
return iebs.getB1();
|
return subChunk.getB1();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||||
@@ -47,8 +47,8 @@ public abstract class BiomeUndergroundDecoratorMixin {
|
|||||||
remap = true),
|
remap = true),
|
||||||
require = 2)
|
require = 2)
|
||||||
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
|
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
|
||||||
val id = ebs.getID(x, y, z) >>> 8;
|
val id = subChunk.getID(x, y, z) >>> 8;
|
||||||
ebs = null;
|
subChunk = null;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This mixin exists to completely re-work the way that block harvestability is calculated. Forge adds this system
|
||||||
|
* on-top of vanilla, which creates a pre-populated array on each block with the size of the maximum metadata value. For
|
||||||
|
* instance, in vanilla we get a String array, and an int array both of size 16, pre-populated with null and -1,
|
||||||
|
* respectively. This is awful for scalability with adding more possible Blocks, and increasing the metadata to 16-bits
|
||||||
|
* from 4. This uproots the under-workings of that system to use a default and dynamic HashMaps for metadata specific
|
||||||
|
* values, so we only use the memory we need, because most things don't even take advantage of this system, especially
|
||||||
|
* based on block metadatas. The public methods of this system maintain API compatibility, so anything using those
|
||||||
|
* should still function perfectly the same. The only potential breakage is if something were to reflect/ASM/mixin with
|
||||||
|
* the private values/methods we're overwriting.
|
||||||
|
*/
|
||||||
|
@Mixin(Block.class)
|
||||||
|
public abstract class BlockMixin {
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private String eid$defaultHarvestTool = null;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private int eid$defaultHarvestLevel = -1;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private final Int2ObjectOpenHashMap<String> eid$harvestToolMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private final Int2IntOpenHashMap eid$harvestLevelMap = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private String[] harvestTool = null;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Shadow(remap = false)
|
||||||
|
private int[] harvestLevel = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cleptomania
|
||||||
|
* @reason Support 16-bit metadata without using GBs of memory.
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public void setHarvestLevel(String toolClass, int level) {
|
||||||
|
this.eid$defaultHarvestTool = toolClass;
|
||||||
|
this.eid$defaultHarvestLevel = level;
|
||||||
|
this.eid$harvestToolMap.clear();
|
||||||
|
this.eid$harvestLevelMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cleptomania
|
||||||
|
* @reason Support 16-bit metadata without using GBs of memory.
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public void setHarvestLevel(String toolClass, int level, int metadata) {
|
||||||
|
this.eid$harvestToolMap.put(metadata, toolClass);
|
||||||
|
this.eid$harvestLevelMap.put(metadata, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cleptomania
|
||||||
|
* @reason Support 16-bit metadata without using GBs of memory.
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public String getHarvestTool(int metadata) {
|
||||||
|
return this.eid$harvestToolMap.getOrDefault(metadata, this.eid$defaultHarvestTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cleptmania
|
||||||
|
* @reason Support 16-bit metadata without using GBs of memory.
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public int getHarvestLevel(int metadata) {
|
||||||
|
return this.eid$harvestLevelMap.getOrDefault(metadata, this.eid$defaultHarvestLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cleptomania
|
||||||
|
* @reason Support 16-bit metadata without using GBs of memory.
|
||||||
|
*/
|
||||||
|
@Overwrite(remap = false)
|
||||||
|
public boolean isToolEffective(String type, int metadata) {
|
||||||
|
Block self = ((Block) (Object) this);
|
||||||
|
if ("pickaxe".equals(type) &&
|
||||||
|
(self == Blocks.redstone_ore || self == Blocks.lit_redstone_ore || self == Blocks.obsidian)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String harvestTool = this.getHarvestTool(metadata);
|
||||||
|
if (harvestTool == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return harvestTool.equals(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+11
-34
@@ -4,7 +4,7 @@ import com.falsepattern.endlessids.EndlessIDs;
|
|||||||
import com.falsepattern.endlessids.Hooks;
|
import com.falsepattern.endlessids.Hooks;
|
||||||
import com.falsepattern.endlessids.Tags;
|
import com.falsepattern.endlessids.Tags;
|
||||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import lombok.var;
|
import lombok.var;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -21,8 +21,10 @@ import net.minecraft.init.Blocks;
|
|||||||
import net.minecraft.world.chunk.NibbleArray;
|
import net.minecraft.world.chunk.NibbleArray;
|
||||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||||
|
|
||||||
|
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||||
|
|
||||||
@Mixin(ExtendedBlockStorage.class)
|
@Mixin(ExtendedBlockStorage.class)
|
||||||
public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorageMixin {
|
public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
|
||||||
@Shadow
|
@Shadow
|
||||||
private int blockRefCount;
|
private int blockRefCount;
|
||||||
@Shadow
|
@Shadow
|
||||||
@@ -196,14 +198,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
blockMSBArray = data;
|
blockMSBArray = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearB2Low() {
|
|
||||||
blockMSBArray = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NibbleArray createB2Low() {
|
public NibbleArray createB2Low() {
|
||||||
return (blockMSBArray = new NibbleArray(blockLSBArray.length, 4));
|
return (blockMSBArray = new NibbleArray(blocksPerSubChunk, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -216,14 +213,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
b2High = data;
|
b2High = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearB2High() {
|
|
||||||
b2High = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NibbleArray createB2High() {
|
public NibbleArray createB2High() {
|
||||||
return (b2High = new NibbleArray(blockLSBArray.length, 4));
|
return (b2High = new NibbleArray(blocksPerSubChunk, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -236,14 +228,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
b3 = data;
|
b3 = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearB3() {
|
|
||||||
b3 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] createB3() {
|
public byte[] createB3() {
|
||||||
return b3 = new byte[blockLSBArray.length];
|
return b3 = new byte[blocksPerSubChunk];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -266,14 +253,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
this.m1High = m1High;
|
this.m1High = m1High;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearM1High() {
|
|
||||||
m1High = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NibbleArray createM1High() {
|
public NibbleArray createM1High() {
|
||||||
return (m1High = new NibbleArray(blockLSBArray.length, 4));
|
return (m1High = new NibbleArray(blocksPerSubChunk, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,18 +268,13 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
this.m2 = m2;
|
this.m2 = m2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearM2() {
|
|
||||||
m2 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] createM2() {
|
public byte[] createM2() {
|
||||||
return (m2 = new byte[blockLSBArray.length]);
|
return (m2 = new byte[blocksPerSubChunk]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEBSMSBMask() {
|
public int getBlockMask() {
|
||||||
if (blockMSBArray == null) {
|
if (blockMSBArray == null) {
|
||||||
return 0b00;
|
return 0b00;
|
||||||
}
|
}
|
||||||
@@ -311,7 +288,7 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEBSMask() {
|
public int getMetadataMask() {
|
||||||
if (m1High == null) {
|
if (m1High == null) {
|
||||||
return 0b01;
|
return 0b01;
|
||||||
}
|
}
|
||||||
|
|||||||
+79
-40
@@ -1,98 +1,86 @@
|
|||||||
package com.falsepattern.endlessids.mixin.mixins.common.datawatcher.vanilla;
|
package com.falsepattern.endlessids.mixin.mixins.common.datawatcher.vanilla;
|
||||||
|
|
||||||
|
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.val;
|
||||||
|
import lombok.var;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Constant;
|
import org.spongepowered.asm.mixin.injection.Constant;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import net.minecraft.entity.DataWatcher;
|
import net.minecraft.entity.DataWatcher;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Mixin(DataWatcher.class)
|
@Mixin(DataWatcher.class)
|
||||||
public abstract class DataWatcherMixin {
|
public abstract class DataWatcherMixin {
|
||||||
@ModifyConstant(method = {"addObject", "writeWatchedListToPacketBuffer", "func_151509_a",
|
|
||||||
"writeWatchableObjectToPacketBuffer"},
|
@Shadow @Final private Map watchedObjects;
|
||||||
|
|
||||||
|
@ModifyConstant(method = {"addObject", "func_151509_a"},
|
||||||
constant = @Constant(intValue = VanillaConstants.maxWatchableID),
|
constant = @Constant(intValue = VanillaConstants.maxWatchableID),
|
||||||
require = 3)
|
require = 2)
|
||||||
private static int extend1(int constant) {
|
private int extend1d(int constant) {
|
||||||
return ExtendedConstants.maxWatchableID;
|
return ExtendedConstants.maxWatchableID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyConstant(method = "writeWatchableObjectToPacketBuffer",
|
|
||||||
constant = @Constant(intValue = VanillaConstants.watchableBits,
|
|
||||||
ordinal = 0),
|
|
||||||
require = 1)
|
|
||||||
private static int extend2(int constant) {
|
|
||||||
return ExtendedConstants.watchableBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyConstant(method = "writeWatchableObjectToPacketBuffer",
|
|
||||||
constant = @Constant(intValue = VanillaConstants.watchableMask,
|
|
||||||
ordinal = 0),
|
|
||||||
require = 1)
|
|
||||||
private static int extend3(int constant) {
|
|
||||||
return ExtendedConstants.watchableMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "writeWatchableObjectToPacketBuffer",
|
|
||||||
at = @At(value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;"),
|
|
||||||
require = 1)
|
|
||||||
private static ByteBuf extendWrite(PacketBuffer instance, int p_writeByte_1_) {
|
|
||||||
return instance.writeShort(p_writeByte_1_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author FalsePattern
|
* @author FalsePattern
|
||||||
* @reason Direct port from dumped code
|
* @reason Extend IDs
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static List<DataWatcher.WatchableObject> readWatchedListFromPacketBuffer(PacketBuffer packet)
|
public static List<DataWatcher.WatchableObject> readWatchedListFromPacketBuffer(PacketBuffer packet)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ArrayList<DataWatcher.WatchableObject> watchables = null;
|
ArrayList<DataWatcher.WatchableObject> watchables = null;
|
||||||
|
|
||||||
for (short id = packet.readShort(); id != 32767; id = packet.readShort()) {
|
for (int type = packet.readByte() & 0xFF; type != 0x7F; type = packet.readByte() & 0xFF) {
|
||||||
if (watchables == null) {
|
if (watchables == null) {
|
||||||
watchables = new ArrayList<>();
|
watchables = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int flag = (id >> ExtendedConstants.watchableBits) & 0x7;
|
boolean shortID = (type & 0x80) != 0;
|
||||||
int watchableID = id & ExtendedConstants.maxWatchableID;
|
type &= 0x7F;
|
||||||
|
int id = shortID
|
||||||
|
? packet.readShort() & 0xFFFF
|
||||||
|
: packet.readByte() & 0xFF;
|
||||||
DataWatcher.WatchableObject watchable = null;
|
DataWatcher.WatchableObject watchable = null;
|
||||||
switch (flag) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readByte());
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readByte());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readShort());
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readShort());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readInt());
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readInt());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readFloat());
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readFloat());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readStringFromBuffer(32767));
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readStringFromBuffer(32767));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readItemStackFromBuffer());
|
watchable = new DataWatcher.WatchableObject(type, id, packet.readItemStackFromBuffer());
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
int x = packet.readInt();
|
int x = packet.readInt();
|
||||||
int y = packet.readInt();
|
int y = packet.readInt();
|
||||||
int z = packet.readInt();
|
int z = packet.readInt();
|
||||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, new ChunkCoordinates(x, y, z));
|
watchable = new DataWatcher.WatchableObject(type, id, new ChunkCoordinates(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
watchables.add(watchable);
|
watchables.add(watchable);
|
||||||
@@ -100,4 +88,55 @@ public abstract class DataWatcherMixin {
|
|||||||
|
|
||||||
return watchables;
|
return watchables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a watchable object (entity attribute of type {byte, short, int, float, string, ItemStack,
|
||||||
|
* ChunkCoordinates}) to the specified PacketBuffer
|
||||||
|
*
|
||||||
|
* @author FalsePattern
|
||||||
|
* @reason Extend IDs
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Overwrite
|
||||||
|
private static void writeWatchableObjectToPacketBuffer(PacketBuffer buf, DataWatcher.WatchableObject watcher)
|
||||||
|
throws IOException {
|
||||||
|
var type = watcher.getObjectType() & 0x7F;
|
||||||
|
val id = watcher.getDataValueId() & 0xFFFF;
|
||||||
|
if (id > 255)
|
||||||
|
type |= 0x80;
|
||||||
|
buf.writeByte(type);
|
||||||
|
if (id > 255) {
|
||||||
|
buf.writeShort(id & 0xFFFF);
|
||||||
|
} else {
|
||||||
|
buf.writeByte(id & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
buf.writeByte((byte) watcher.getObject());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
buf.writeShort((short) watcher.getObject());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
buf.writeInt((int) watcher.getObject());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
buf.writeFloat((float) watcher.getObject());
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
buf.writeStringToBuffer((String) watcher.getObject());
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ItemStack itemstack = (ItemStack) watcher.getObject();
|
||||||
|
buf.writeItemStackToBuffer(itemstack);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) watcher.getObject();
|
||||||
|
buf.writeInt(chunkcoordinates.posX);
|
||||||
|
buf.writeInt(chunkcoordinates.posY);
|
||||||
|
buf.writeInt(chunkcoordinates.posZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
-25
@@ -14,14 +14,6 @@ import net.minecraft.entity.EntityList;
|
|||||||
|
|
||||||
@Mixin(EntityList.class)
|
@Mixin(EntityList.class)
|
||||||
public abstract class EntityListMixin {
|
public abstract class EntityListMixin {
|
||||||
@Shadow
|
|
||||||
public static void addMapping(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public static void addMapping(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
|
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
|
||||||
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
||||||
@@ -29,21 +21,4 @@ public abstract class EntityListMixin {
|
|||||||
private static int extendRange(int constant) {
|
private static int extendRange(int constant) {
|
||||||
return ExtendedConstants.maxEntityID;
|
return ExtendedConstants.maxEntityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "<clinit>",
|
|
||||||
at = @At(value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;I)V"),
|
|
||||||
require = 1)
|
|
||||||
private static void messUpMappings1(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
|
|
||||||
addMapping(p_75618_0_, p_75618_1_, p_75618_2_ * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Redirect(method = "<clinit>",
|
|
||||||
at = @At(value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;III)V"),
|
|
||||||
require = 1)
|
|
||||||
private static void messUpMappings2(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
|
|
||||||
addMapping(p_75614_0_, p_75614_1_, p_75614_2_ * 100, p_75614_3_, p_75614_4_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,10 @@ public enum Mixin implements IMixin {
|
|||||||
LOTRBiomeVariantStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRBiomeVariantStorageMixin"),
|
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"),
|
LOTRChunkProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRChunkProviderMixin"),
|
||||||
LOTRChunkProviderUtumnoMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRChunkProviderUtumnoMixin"),
|
LOTRChunkProviderUtumnoMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRChunkProviderUtumnoMixin"),
|
||||||
|
LOTRDimensionMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRDimensionMixin"),
|
||||||
LOTRPacketBiomeVariantsWatchHandlerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRPacketBiomeVariantsWatchHandlerMixin"),
|
LOTRPacketBiomeVariantsWatchHandlerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRPacketBiomeVariantsWatchHandlerMixin"),
|
||||||
LOTRWorldChunkManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRWorldChunkManagerMixin"),
|
LOTRWorldChunkManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRWorldChunkManagerMixin"),
|
||||||
|
LOTRWorldProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.LOTR)), "biome.lotr.LOTRWorldProviderMixin"),
|
||||||
//endregion LOTR
|
//endregion LOTR
|
||||||
//region NaturesCompass
|
//region NaturesCompass
|
||||||
NaturesCompassBiomeUtilsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.NATURESCOMPASS)), "biome.naturescompass.BiomeUtilsMixin"),
|
NaturesCompassBiomeUtilsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.NATURESCOMPASS)), "biome.naturescompass.BiomeUtilsMixin"),
|
||||||
@@ -167,6 +169,7 @@ public enum Mixin implements IMixin {
|
|||||||
//region blockitem
|
//region blockitem
|
||||||
//region vanilla
|
//region vanilla
|
||||||
BlockFireMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockFireMixin"),
|
BlockFireMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockFireMixin"),
|
||||||
|
BlockMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockMixin"),
|
||||||
ExtendedBlockStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ExtendedBlockStorageMixin"),
|
ExtendedBlockStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ExtendedBlockStorageMixin"),
|
||||||
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
|
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
|
||||||
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
|
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package com.falsepattern.endlessids.mixin.stubpackage.org.dave.CompactMachines.tileentity;
|
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class TileEntityMachine {
|
|
||||||
public int xCoord;
|
|
||||||
public int zCoord;
|
|
||||||
|
|
||||||
public World getWorldObj() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.falsepattern.endlessids.util;
|
||||||
|
|
||||||
|
import net.minecraft.world.chunk.NibbleArray;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||||
|
|
||||||
|
public class DataUtil {
|
||||||
|
public static byte[] ensureSubChunkByteArray(byte[] arr) {
|
||||||
|
return arr == null ? null : arr.length == blocksPerSubChunk ? arr : Arrays.copyOf(arr, blocksPerSubChunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NibbleArray ensureSubChunkNibbleArray(byte[] data) {
|
||||||
|
return data == null ? null : new NibbleArray(data.length == (blocksPerSubChunk >>> 1) ? data : Arrays.copyOf(data, (blocksPerSubChunk >>> 1)), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"identifier": "falsepatternlib_dependencies",
|
||||||
|
"repositories": [
|
||||||
|
"https://repo1.maven.org/maven2/"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"always": {
|
||||||
|
"common": [
|
||||||
|
"it.unimi.dsi:fastutil:8.5.13"
|
||||||
|
],
|
||||||
|
"client": [],
|
||||||
|
"server": []
|
||||||
|
},
|
||||||
|
"obf": {
|
||||||
|
"common": [],
|
||||||
|
"client": [],
|
||||||
|
"server": []
|
||||||
|
},
|
||||||
|
"dev": {
|
||||||
|
"common": [],
|
||||||
|
"client": [],
|
||||||
|
"server": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user