mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2acbb60547 | ||
|
|
098254dc82 | ||
|
|
0f810afe90 | ||
|
|
fa66c21a8a | ||
|
|
2b90b7688b | ||
|
|
ca5f27dffc | ||
|
|
6eeafe5a23 | ||
|
|
22d269eda5 | ||
|
|
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 | ||
|
|
c1d8e273fc | ||
|
|
484a9175e7 | ||
|
|
1bb71d9448 | ||
|
|
11ff4a4a6a | ||
|
|
6b3d872fbd | ||
|
|
344b788108 | ||
|
|
b61711280b |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
patreon: falsepattern
|
||||
ko_fi: falsepattern
|
||||
Generated
+3
@@ -29,6 +29,9 @@
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_LINE_BREAKS" 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,
|
||||
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:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -18,4 +19,12 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
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
|
||||
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
|
||||
|
||||
Copyright (C) 2022 FalsePattern
|
||||
Copyright (C) 2022-2023 FalsePattern
|
||||
All Rights Reserved
|
||||
|
||||
The above copyright notice, this permission notice and the words "MEGA"
|
||||
|
||||
@@ -1,26 +1,40 @@
|
||||
# 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
|
||||
new limits.
|
||||
|
||||
## REQUIRED MODS
|
||||
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
|
||||
- [GasStation](https://github.com/FalsePattern/GasStation)
|
||||
- [UniMixins](https://github.com/LegacyModdingMC/UniMixins)
|
||||
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
|
||||
|
||||
Comparison of the known limits:
|
||||
## NotEnoughIDs world compatibility
|
||||
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 |
|
||||
|-----------------|----------------------------------------------------|--------------|----------------------------------|
|
||||
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
|
||||
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
|
||||
| Entity IDs | 256 | 256 | 256 right now, extension planned |
|
||||
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
|
||||
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
|
||||
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
|
||||
## Comparison of the known limits
|
||||
|
||||
| | Vanilla | NotEnoughIDs | NEID Unofficial | EndlessIDs |
|
||||
|-----------------|----------------------------------------------------|--------------|-----------------|------------|
|
||||
| Block IDs | 4,096 | 32,000 | 65,536 | 16,777,216 |
|
||||
| Block Metadata | 16 | 16 | 65,536 | 65,536 |
|
||||
| Item IDs | 32,000 | 32,000 | 65,536 | 16,777,216 |
|
||||
| Biome IDs | 256 | 256 | 256 | 65,536 |
|
||||
| Entity IDs | 256 | 256 | 256 | 32,768 |
|
||||
| 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:
|
||||
|
||||
<details>
|
||||
<summary>Mod list</summary>
|
||||
|
||||
- AbyssalCraft
|
||||
- Advanced Rocketry
|
||||
- Alternate Terrain Generation
|
||||
@@ -48,21 +62,29 @@ This mod also contains patches for the following mods:
|
||||
- Highlands
|
||||
- Immersive Cavegen
|
||||
- Industrial Revolution by Redstone Rebooted
|
||||
- Matter Overdrive
|
||||
- More Fun Quicksand Mod
|
||||
- Nature's Compass
|
||||
- Netherlicious
|
||||
- Nomadic Tents
|
||||
- Nostalgic World Generation
|
||||
- Old World Gen
|
||||
- Random Things
|
||||
- Restructured
|
||||
- Realistic Terrain Generation
|
||||
- Realistic World Generation
|
||||
- Thaumcraft
|
||||
- The Lord of the Rings Mod: Legacy
|
||||
- ThutCore/ThutMods
|
||||
- Tropicraft
|
||||
- Twilight Forest
|
||||
- Underground Biomes Constructs
|
||||
- Witchery
|
||||
- WorldEdit
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
Mods not listed here may or may not work.
|
||||
|
||||
- For item/block IDs:
|
||||
|
||||
+93
-46
@@ -1,4 +1,4 @@
|
||||
//version: 1656003793falsepattern67
|
||||
//version: 1656003793falsepattern76
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
@@ -132,6 +132,8 @@ propertyDefaultIfUnset("mixinConfigs", "")
|
||||
propertyDefaultIfUnset("mixinPluginPreInit", "")
|
||||
propertyDefaultIfUnset("mixinPluginMinimumVersion", "0.8.5")
|
||||
propertyDefaultIfUnset("remapStubs", false)
|
||||
propertyDefaultIfUnset("apiPackages", null)
|
||||
propertyDefaultIfUnset("apiPackagesNoRecurse", null)
|
||||
|
||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||
propertyDefaultIfUnset("modrinthDependencies", "")
|
||||
@@ -147,20 +149,31 @@ String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
|
||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
def verifyPackage(thePackage, propName) {
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
|
||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
|
||||
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + thePackage.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"${propName}\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
}
|
||||
|
||||
verifyPackage("", "modGroup")
|
||||
|
||||
if(apiPackage) {
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
verifyPackage(apiPackage, "apiPackage")
|
||||
}
|
||||
|
||||
|
||||
if (apiPackages) {
|
||||
apiPackages.tokenize(';').forEach { it -> verifyPackage(it, "apiPackages")}
|
||||
}
|
||||
|
||||
if (apiPackagesNoRecurse) {
|
||||
apiPackagesNoRecurse.tokenize(';').forEach { it -> verifyPackage(it, "apiPackagesNoRecurse")}
|
||||
}
|
||||
|
||||
if(accessTransformersFile) {
|
||||
@@ -175,9 +188,9 @@ if(usesMixins.toBoolean()) {
|
||||
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
|
||||
}
|
||||
|
||||
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
|
||||
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
|
||||
}
|
||||
@@ -281,6 +294,10 @@ if(file("addon.gradle").exists()) {
|
||||
|
||||
apply from: 'repositories.gradle'
|
||||
|
||||
if(file('repositories_override.gradle').exists()) {
|
||||
apply from: 'repositories_override.gradle'
|
||||
}
|
||||
|
||||
configurations {
|
||||
for (config in [shadowImplementation, shadowCompile, shadeCompile]) {
|
||||
implementation.extendsFrom(shadeCompile)
|
||||
@@ -294,7 +311,11 @@ configurations {
|
||||
repositories {
|
||||
maven {
|
||||
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()) {
|
||||
maven {
|
||||
@@ -305,36 +326,52 @@ repositories {
|
||||
name = "sponge2"
|
||||
url = "https://mvn.falsepattern.com/sponge"
|
||||
}
|
||||
maven {
|
||||
name = "jitpack"
|
||||
url = "https://mvn.falsepattern.com/jitpack/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def unimixinsVersion = "0.1.15"
|
||||
|
||||
dependencies {
|
||||
if(usesMixins.toBoolean()) {
|
||||
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||
annotationProcessor("com.llamalad7:MixinExtras:0.1.1-gasstation")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8.5-gasstation_7")
|
||||
compile("org.spongepowered:mixin:0.8.5-gasstation_7")
|
||||
compile("com.llamalad7:MixinExtras:0.1.1-gasstation")
|
||||
compile("com.falsepattern:00gasstation-mc1.7.10:0.5.1:dev")
|
||||
runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
|
||||
testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
|
||||
annotationProcessor("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||
implementation("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||
runtimeOnly('org.jetbrains:intellij-fernflower:1.2.1.16')
|
||||
} else if(hasMixinDeps.toBoolean()) {
|
||||
runtime("com.llamalad7:MixinExtras:0.1.1-gasstation")
|
||||
runtime("org.spongepowered:mixin:0.8.5-gasstation_7")
|
||||
runtime("com.falsepattern:00gasstation-mc1.7.10:0.5.1:dev")
|
||||
runtimeOnly("com.github.LegacyModdingMC.UniMixins:unimixins-all-1.7.10:$unimixinsVersion:dev")
|
||||
}
|
||||
// Latest LWJGL
|
||||
compile "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
|
||||
compile "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
|
||||
implementation "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
|
||||
implementation "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
|
||||
minecraftNatives "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209"
|
||||
minecraftDeps "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209"
|
||||
minecraftDeps "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209"
|
||||
}
|
||||
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
configurations.implementation.dependencies.each {
|
||||
if (it instanceof ExternalModuleDependency) {
|
||||
it.exclude module: "SpongeMixins"
|
||||
it.exclude module: "SpongePoweredMixin"
|
||||
it.exclude module: "00gasstation-mc1.7.10"
|
||||
it.exclude module: "gtnhmixins"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'dependencies.gradle'
|
||||
|
||||
if(file('dependencies_override.gradle').exists()) {
|
||||
apply from: 'dependencies_override.gradle'
|
||||
}
|
||||
|
||||
def mixinDir = new File(project.buildDir, 'mixins')
|
||||
if (!mixinDir.exists()) {
|
||||
mixinDir.mkdirs()
|
||||
@@ -425,12 +462,6 @@ runClient {
|
||||
def arguments = []
|
||||
def jvmArguments = []
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=" + Paths.get("$projectDir").resolve(minecraft.runDir).normalize().relativize(Paths.get("$projectDir/build/libs/$archivesBaseName-${version}.jar"))
|
||||
]
|
||||
}
|
||||
|
||||
if(usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
||||
arguments += [
|
||||
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
||||
@@ -455,12 +486,6 @@ runServer {
|
||||
def arguments = []
|
||||
def jvmArguments = []
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--mods=" + Paths.get("$projectDir").resolve(minecraft.runDir).normalize().relativize(Paths.get("$projectDir/build/libs/$archivesBaseName-${version}.jar"))
|
||||
]
|
||||
}
|
||||
|
||||
if (usesMixins.toBoolean() || hasMixinDeps.toBoolean()) {
|
||||
arguments += [
|
||||
"--tweakClass", "org.spongepowered.asm.launch.MixinTweaker"
|
||||
@@ -602,11 +627,29 @@ task devJar(type: Jar) {
|
||||
|
||||
task apiJar(type: Jar) {
|
||||
from (sourceSets.main.allSource) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
if (apiPackage)
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
if (apiPackages)
|
||||
apiPackages.tokenize(';').forEach { pkg ->
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/**'
|
||||
}
|
||||
if (apiPackagesNoRecurse)
|
||||
apiPackagesNoRecurse.tokenize(';').forEach { pkg ->
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/*'
|
||||
}
|
||||
}
|
||||
|
||||
from (sourceSets.main.output) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
if (apiPackage)
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
if (apiPackages)
|
||||
apiPackages.tokenize(';').forEach { pkg ->
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/**'
|
||||
}
|
||||
if (apiPackagesNoRecurse)
|
||||
apiPackagesNoRecurse.tokenize(';').forEach { pkg ->
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + pkg.toString().replaceAll("\\.", "/") + '/*'
|
||||
}
|
||||
}
|
||||
|
||||
from (sourceSets.main.resources.srcDirs) {
|
||||
@@ -627,7 +670,7 @@ compileJava.dependsOn(copySrgs)
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives devJar
|
||||
if(apiPackage) {
|
||||
if(apiPackage || apiPackages || apiPackagesNoRecurse) {
|
||||
archives apiJar
|
||||
}
|
||||
}
|
||||
@@ -683,7 +726,7 @@ publishing {
|
||||
artifact source: sourcesJar, classifier: "sources"
|
||||
}
|
||||
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||
if (apiPackage) {
|
||||
if (apiPackage || apiPackages || apiPackagesNoRecurse) {
|
||||
artifact source: apiJar, classifier: "api"
|
||||
}
|
||||
|
||||
@@ -777,7 +820,7 @@ if (curseForgeProjectId != "" && System.getenv("CURSEFORGE_TOKEN") != null) {
|
||||
}
|
||||
|
||||
if (usesMixins.toBoolean()) {
|
||||
addCurseForgeRelation("requiredDependency", "gasstation")
|
||||
addCurseForgeRelation("requiredDependency", "unimixins")
|
||||
}
|
||||
tasks.curseforge.dependsOn(build)
|
||||
tasks.publish.dependsOn(tasks.curseforge)
|
||||
@@ -810,7 +853,7 @@ if (modrinthProjectId != "" && System.getenv("MODRINTH_TOKEN") != null) {
|
||||
}
|
||||
}
|
||||
if (usesMixins.toBoolean()) {
|
||||
addModrinthDep("required", "project", "cdeAhgfp")
|
||||
addModrinthDep("required", "project", "ghjoiQAl")
|
||||
}
|
||||
tasks.modrinth.dependsOn(build)
|
||||
tasks.publish.dependsOn(tasks.modrinth)
|
||||
@@ -995,6 +1038,10 @@ configure(deobfParams) {
|
||||
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
// Dependency Deobfuscation
|
||||
|
||||
def deobfMaven(mavenDep) {
|
||||
|
||||
+21
-6
@@ -16,14 +16,19 @@ def deobfCurse(curseDep) {
|
||||
dependencies {
|
||||
////////////////Our dependencies////////////////
|
||||
|
||||
compileOnly("org.projectlombok:lombok:[1.18, 1.19)") {
|
||||
compileOnly("org.projectlombok:lombok:1.18.32") {
|
||||
transitive = false
|
||||
}
|
||||
annotationProcessor("org.projectlombok:lombok:[1.18, 1.19)")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:[0.11,):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.1.1: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////////////////
|
||||
|
||||
@@ -113,8 +118,11 @@ dependencies {
|
||||
//Industrial Revolution by Redstone Rebooted 1.1.1
|
||||
compileOnly(deobfCurse("industrialrevolutionbyredstonerebooted-241812:2538035"))
|
||||
|
||||
//LOTR Mod 36.14
|
||||
compileOnly(deobfCurse("lotrmod-423748:3646430"))
|
||||
//LOTR Mod 36.15
|
||||
compileOnly(deobfCurse("lotrmod-423748:4091561"))
|
||||
|
||||
//Matter Overdrive 0.4.2-hotfix1
|
||||
compileOnly(deobfCurse("matteroverdrive-229694:2331162"))
|
||||
|
||||
//More Fun Quicksands Mod 1.0.8.8-fixed
|
||||
compileOnly(deobfCurse("more-fun-quicksand-mod-321960:2717318"))
|
||||
@@ -128,6 +136,9 @@ dependencies {
|
||||
//Nomadic Tents 1.12.1
|
||||
compileOnly(deobfCurse("nomadictents-238794:2679476"))
|
||||
|
||||
//Nostalgic World Generation 1.0.0
|
||||
compileOnly(deobfCurse("nostalgiagenerator-927053:4816167"))
|
||||
|
||||
//RandomThings 2.2.4
|
||||
compileOnly(deobfCurse("randomthings-59816:2225310"))
|
||||
|
||||
@@ -140,6 +151,10 @@ dependencies {
|
||||
//Thaumcraft 4.2.3.5
|
||||
compileOnly(deobfCurse("thaumcraft-223628:2227552"))
|
||||
|
||||
//ThutCore 2.0
|
||||
//Only available on dropbox
|
||||
compileOnly(deobf("https://mvn.falsepattern.com/releases/mirror/mirror/thutcore-2.0.jar"))
|
||||
|
||||
//Tropicraft 6.0.5
|
||||
//This is from a mirror file, because the file on curseforge is a zip containing other files too.
|
||||
//Source: https://www.curseforge.com/minecraft/mc-mods/tropicraft/files/2353906
|
||||
|
||||
+12
-3
@@ -14,6 +14,15 @@ modGroup = com.falsepattern.endlessids
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
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?
|
||||
# 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/
|
||||
@@ -72,7 +81,7 @@ modrinthProjectId = qGHY4QGo
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:spongemixin1710;incompatible-project:gregtech
|
||||
modrinthDependencies = required-project:fplib;required-project:chunkapi
|
||||
modrinthDependencies = required-project:fplib;required-project:chunkapi;incompatible-project:notenoughids-unofficial
|
||||
|
||||
#endregion modrinth
|
||||
|
||||
@@ -90,7 +99,7 @@ curseForgeProjectId = 665730
|
||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||
# and the name is the CurseForge project id of the other mod.
|
||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi
|
||||
curseForgeRelations = requiredDependency:fplib;requiredDependency:chunkapi;incompatible:notenoughids-unofficial-1-7-10;incompatible:notenoughids
|
||||
|
||||
#endregion curseforge
|
||||
|
||||
@@ -163,7 +172,7 @@ accessTransformersFile =
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass = IEPlugin
|
||||
coreModClass = asm.EndlessIDsCore
|
||||
|
||||
#endregion core
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.managers.BiomeManager;
|
||||
import com.falsepattern.endlessids.managers.BlockIDManager;
|
||||
@@ -20,7 +20,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
version = Tags.VERSION,
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:falsepatternlib@[0.11.0,);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 static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
|
||||
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
|
||||
@@ -38,18 +40,47 @@ public class EndlessIDs {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
LOG.info("---------------------------------------------------------");
|
||||
LOG.info("Current EndlessIDs configuration:");
|
||||
logConfig(" Biome Extension", GeneralConfig.extendBiome);
|
||||
logConfig(" Block/Item Extension", GeneralConfig.extendBlockItem);
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
logConfig(" Extra Item Bits", GeneralConfig.extraItemIDBits);
|
||||
logConfig(" Extra Block Bits", GeneralConfig.extraBlockIDBits);
|
||||
}
|
||||
logConfig(" DataWatcher Extension", GeneralConfig.extendDataWatcher);
|
||||
logConfig(" Enchantment Extension", GeneralConfig.extendEnchantment);
|
||||
logConfig(" Potion Extension", GeneralConfig.extendPotion);
|
||||
logConfig(" Redstone Extension", GeneralConfig.extendRedstone);
|
||||
if (GeneralConfig.extendRedstone) {
|
||||
LOG.warn(" (Redstone extension is an experimental and dangerous feature, and should NEVER be used in worlds that you worry about getting corrupted!)");
|
||||
logConfig(" Max redstone level", GeneralConfig.maxRedstone);
|
||||
}
|
||||
logConfig(" Registry performance tweak", GeneralConfig.enableRegistryPerformanceTweak);
|
||||
if (GeneralConfig.enableRegistryPerformanceTweak) {
|
||||
LOG.warn(" (This tweak has not gone through proper testing yet, so it might corrupt worlds. USE BACKUPS!)");
|
||||
}
|
||||
LOG.info("---------------------------------------------------------");
|
||||
patchManager.preInit();
|
||||
}
|
||||
|
||||
private static void logConfig(String name, boolean value) {
|
||||
LOG.info(name + (value ? ": ENABLED" : ": disabled"));
|
||||
}
|
||||
|
||||
private static void logConfig(String name, int value) {
|
||||
LOG.info(name + ": " + value);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
patchManager.init();
|
||||
if (GeneralConfig.extendBiome) {
|
||||
ChunkDataRegistry.registerDataManager(new BiomeManager());
|
||||
DataRegistry.registerDataManager(new BiomeManager());
|
||||
}
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
ChunkDataRegistry.registerDataManager(new BlockIDManager());
|
||||
ChunkDataRegistry.registerDataManager(new BlockMetaManager());
|
||||
DataRegistry.registerDataManager(new BlockIDManager());
|
||||
DataRegistry.registerDataManager(new BlockMetaManager());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,11 +88,11 @@ public class EndlessIDs {
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
patchManager.postInit();
|
||||
if (GeneralConfig.extendBiome) {
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "biome");
|
||||
DataRegistry.disableDataManager("minecraft", "biome");
|
||||
}
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "blockid");
|
||||
ChunkDataRegistry.disableDataManager("minecraft", "metadata");
|
||||
DataRegistry.disableDataManager("minecraft", "blockid");
|
||||
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,55 +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.SpaceCoreModInfoGenerator;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import lombok.val;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
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");
|
||||
|
||||
private static final Map<String, ClassEdit> editMap;
|
||||
|
||||
static {
|
||||
editMap = new HashMap<>();
|
||||
for (final ClassEdit edit : values()) {
|
||||
for (final String name : edit.classNames) {
|
||||
ClassEdit.editMap.put(name, 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 ClassEdit get(final String className) {
|
||||
val ret = ClassEdit.editMap.get(className);
|
||||
return ret != null && ret.cond.getAsBoolean() ? ret : null;
|
||||
}
|
||||
|
||||
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 lombok.SneakyThrows;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
@@ -18,29 +19,31 @@ import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
|
||||
@MCVersion("1.7.10")
|
||||
@Name(Tags.MODID)
|
||||
@Name(Tags.MODID + "_core")
|
||||
@TransformerExclusions({"com.falsepattern.endlessids.asm", "com.falsepattern.endlessids.config.GeneralConfig"})
|
||||
@DependsOn("falsepatternlib")
|
||||
public class IEPlugin implements IFMLLoadingPlugin {
|
||||
|
||||
public IEPlugin() {
|
||||
public class EndlessIDsCore implements IFMLLoadingPlugin {
|
||||
public static boolean deobfuscated;
|
||||
public EndlessIDsCore() {
|
||||
super();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public String[] getASMTransformerClass() {
|
||||
val cl = ((LaunchClassLoader) this.getClass().getClassLoader());
|
||||
val field = cl.getClass().getDeclaredField("transformerExceptions");
|
||||
deobfuscated = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
val cl = Launch.classLoader;
|
||||
val field = LaunchClassLoader.class.getDeclaredField("transformerExceptions");
|
||||
field.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
val exceptions = (Set<String>) field.get(cl);
|
||||
if (exceptions.contains("code.elix_x.coremods")) {
|
||||
IETransformer.logger.info("AntiIDConflict detected!");
|
||||
IETransformer.logger.info("Removing ASM protections so that we can fix its code.");
|
||||
EndlessIDsTransformer.logger.info("AntiIDConflict detected!");
|
||||
EndlessIDsTransformer.logger.info("Removing ASM protections so that we can fix its code.");
|
||||
exceptions.remove("code.elix_x.coremods");
|
||||
exceptions.add("code.elix_x.coremods.antiidconflict.core");
|
||||
exceptions.add("code.elix_x.coremods.antiidconflict.ByteCodeTester");
|
||||
}
|
||||
return new String[]{IETransformer.class.getName()};
|
||||
return new String[]{EndlessIDsTransformer.class.getName()};
|
||||
}
|
||||
|
||||
public String getModContainerClass() {
|
||||
@@ -67,7 +70,6 @@ public class IEPlugin implements IFMLLoadingPlugin {
|
||||
}
|
||||
|
||||
public void injectData(final Map<String, Object> data) {
|
||||
IETransformer.isObfuscated = (Boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.falsepattern.endlessids.asm;
|
||||
|
||||
import com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry.GameData;
|
||||
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
|
||||
import lombok.var;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
//Used by ASM
|
||||
@SuppressWarnings("unused")
|
||||
public class GameDataHooks {
|
||||
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
|
||||
if (gameData.endlessIDsItemBlockCache == null) {
|
||||
gameData.endlessIDsItemBlockCache = new WeakIdentityHashMap<>();
|
||||
}
|
||||
return gameData.endlessIDsItemBlockCache;
|
||||
}
|
||||
|
||||
public static void cacheItemBlock(ItemBlock itemBlock, GameData gameData) {
|
||||
forGameData(gameData).put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
|
||||
}
|
||||
|
||||
public static ItemBlock fetchCachedItemBlock(Block block, GameData gameData) {
|
||||
var weakItem = forGameData(gameData).get(block);
|
||||
if (weakItem != null) {
|
||||
return weakItem.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Iterable<Item> fakeIterable() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +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 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;
|
||||
}
|
||||
ClassEdit[] edits = new ClassEdit[2];
|
||||
edits[0] = 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);
|
||||
}
|
||||
if (edits[0] == null) {
|
||||
edits[0] = ClassEdit.ChunkProviderSuperPatcher;
|
||||
} else {
|
||||
edits[1] = ClassEdit.ChunkProviderSuperPatcher;
|
||||
}
|
||||
}
|
||||
if (edits[0] == null) {
|
||||
return isObfuscated ? bytes : DevFixer.fixDev(bytes);
|
||||
}
|
||||
if (!isObfuscated) {
|
||||
DevFixer.transform(cn);
|
||||
}
|
||||
for (int i = 0; i < edits.length; i++) {
|
||||
val edit = edits[i];
|
||||
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();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry;
|
||||
|
||||
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class GameData {
|
||||
public WeakIdentityHashMap<Block, WeakReference<ItemBlock>> endlessIDsItemBlockCache;
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.asm.EndlessIDsCore;
|
||||
import com.falsepattern.lib.turboasm.ClassNodeHandle;
|
||||
import com.falsepattern.lib.turboasm.TurboClassTransformer;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.util.CheckClassAdapter;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class DevFixer {
|
||||
public class DevFixer implements TurboClassTransformer {
|
||||
private static final ClassNode blocks;
|
||||
|
||||
static {
|
||||
if (IETransformer.isObfuscated) {
|
||||
if (!EndlessIDsCore.deobfuscated) {
|
||||
blocks = null;
|
||||
} else {
|
||||
try {
|
||||
@@ -35,41 +33,20 @@ public final class DevFixer {
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] fixDev(byte[] classBytes) {
|
||||
if (IETransformer.isObfuscated) {
|
||||
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) {
|
||||
private static boolean biomeTweakerCompat(final ClassNode cn) {
|
||||
boolean modified = false;
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.startsWith("spawnable")) {
|
||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||
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) {
|
||||
val instructions = method.instructions;
|
||||
int insnCount = instructions.size();
|
||||
@@ -81,11 +58,41 @@ public final class DevFixer {
|
||||
for (val blockField : blocks.fields) {
|
||||
if (blockField.name.equals(field.name) && !blockField.desc.equals(field.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;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.asm.AsmTransformException;
|
||||
import com.falsepattern.endlessids.asm.AsmUtil;
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public class FmlRegistry implements IClassNodeTransformer {
|
||||
public class FmlRegistry implements TurboClassTransformer {
|
||||
public FmlRegistry() {
|
||||
super();
|
||||
}
|
||||
|
||||
@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);
|
||||
if (field != null) {
|
||||
field.value = ExtendedConstants.maxBlockID;
|
||||
@@ -35,5 +60,6 @@ public class FmlRegistry implements IClassNodeTransformer {
|
||||
if (!found) {
|
||||
throw new AsmTransformException("can't find 4095 constant in any method");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
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.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public class GameDataAccelerator implements TurboClassTransformer {
|
||||
private static final int MASK_REGISTER_BLOCK = 0b1;
|
||||
private static final int MASK_REGISTER_ITEM = 0b10;
|
||||
|
||||
private void transformRegisterItem(MethodNode method) {
|
||||
var iter = method.instructions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var insn = iter.next();
|
||||
if (!(insn instanceof FieldInsnNode))
|
||||
continue;
|
||||
var typeInsn = (FieldInsnNode) insn;
|
||||
if (!(typeInsn.owner.equals("net/minecraft/item/ItemBlock") &&
|
||||
typeInsn.name.equals("field_150939_a") &&
|
||||
typeInsn.desc.equals("Lnet/minecraft/block/Block;")))
|
||||
continue;
|
||||
iter.previous();
|
||||
iter.add(new InsnNode(Opcodes.DUP));
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "cacheItemBlock", "(Lnet/minecraft/item/ItemBlock;Lcpw/mods/fml/common/registry/GameData;)V", false));
|
||||
return;
|
||||
}
|
||||
transformError(method);
|
||||
}
|
||||
|
||||
private static void transformError(MethodNode method) {
|
||||
EndlessIDsTransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
|
||||
}
|
||||
|
||||
private void transformRegisterBlock(MethodNode method) {
|
||||
var iter = method.instructions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var insn = iter.next();
|
||||
if ((insn.getOpcode() != Opcodes.GETFIELD) && !(insn instanceof FieldInsnNode))
|
||||
continue;
|
||||
var fieldInsn = (FieldInsnNode) insn;
|
||||
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
|
||||
fieldInsn.name.equals("iItemRegistry") &&
|
||||
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
|
||||
continue;
|
||||
iter.remove();
|
||||
{
|
||||
val testInsn = iter.previous();
|
||||
if (testInsn.getOpcode() != Opcodes.ALOAD || ((VarInsnNode)testInsn).var != 0)
|
||||
throw new AsmTransformException("Opcode assertion 1 failed!");
|
||||
}
|
||||
iter.remove();
|
||||
{
|
||||
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.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fetchCachedItemBlock", "(Lnet/minecraft/block/Block;Lcpw/mods/fml/common/registry/GameData;)Lnet/minecraft/item/ItemBlock;", false));
|
||||
iter.add(new VarInsnNode(Opcodes.ASTORE, 4));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fakeIterable", "()Ljava/lang/Iterable;", false));
|
||||
return;
|
||||
}
|
||||
transformError(method);
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
|
||||
public class SpaceCoreModInfoGenerator implements IClassNodeTransformer {
|
||||
public class SpaceCoreModInfoGenerator implements TurboClassTransformer {
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
if (obfuscated) {
|
||||
return;
|
||||
}
|
||||
public String owner() {
|
||||
return Tags.MODNAME;
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (method.name.equals("generate")) {
|
||||
val iterator = method.instructions.iterator();
|
||||
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.asm.IETransformer;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
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.Data;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -21,6 +24,7 @@ import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@@ -116,7 +120,7 @@ import java.util.function.Supplier;
|
||||
* L6
|
||||
* </pre>
|
||||
*/
|
||||
public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
public class ChunkProviderSuperPatcher implements TurboClassTransformer {
|
||||
public static final String[] CLASS_BiomeGenBase;
|
||||
public static final String[] CLASS_IChunkProvider;
|
||||
public static final String[] CLASS_ChunkProviderGenerate;
|
||||
@@ -149,20 +153,20 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
private static State<AbstractInsnNode> STATE_FINAL = null;
|
||||
|
||||
static {
|
||||
if (IETransformer.isObfuscated) {
|
||||
CLASS_BiomeGenBase = new String[]{"ahu", "net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"apu", "net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"aqz", "net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"apx", "net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"ay", "field_76756_M"};
|
||||
METHOD_getBiomeArray = new String[]{"m", "func_76605_m"};
|
||||
} else {
|
||||
if (EndlessIDsCore.deobfuscated) {
|
||||
CLASS_BiomeGenBase = new String[]{"net/minecraft/world/biome/BiomeGenBase"};
|
||||
CLASS_IChunkProvider = new String[]{"net/minecraft/world/chunk/IChunkProvider"};
|
||||
CLASS_ChunkProviderGenerate = new String[]{"net/minecraft/world/gen/ChunkProviderGenerate"};
|
||||
CLASS_Chunk = new String[]{"net/minecraft/world/chunk/Chunk"};
|
||||
FIELD_biomeID = new String[]{"biomeID"};
|
||||
METHOD_getBiomeArray = new String[]{"getBiomeArray"};
|
||||
} 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;
|
||||
|
||||
STATE0 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||
memory.reset();
|
||||
if (insn.getOpcode() == Opcodes.ALOAD) {
|
||||
memory.chunkIndex = insn.var;
|
||||
memory.startingInsn = memory.currentInsn;
|
||||
memory.startingInsn = insn;
|
||||
return STATE1;
|
||||
}
|
||||
return STATE0;
|
||||
@@ -183,7 +188,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
anyMatch(insn.owner, CLASS_Chunk) &&
|
||||
anyMatch(insn.name, METHOD_getBiomeArray) &&
|
||||
insn.desc.equals("()[B")) {
|
||||
memory.getBiomeArrayInsn = memory.currentInsn;
|
||||
memory.getBiomeArrayInsn = insn;
|
||||
return STATE2;
|
||||
}
|
||||
return STATE0;
|
||||
@@ -192,6 +197,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
STATE2 = casting(VarInsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.ASTORE) {
|
||||
memory.biomeArrayIndex = insn.var;
|
||||
memory.startPatchingFrames();
|
||||
return STATE3;
|
||||
}
|
||||
return STATE0;
|
||||
@@ -294,7 +300,7 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
|
||||
STATE16 = casting(InsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.I2B) {
|
||||
memory.castInsn = memory.currentInsn;
|
||||
memory.castInsn = insn;
|
||||
return STATE17;
|
||||
}
|
||||
return STATE0;
|
||||
@@ -302,25 +308,13 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
|
||||
STATE17 = casting(InsnNode.class, (insn, memory) -> {
|
||||
if (insn.getOpcode() == Opcodes.BASTORE) {
|
||||
memory.arrayStoreInsn = memory.currentInsn;
|
||||
memory.arrayStoreInsn = insn;
|
||||
return STATE_FINAL;
|
||||
}
|
||||
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) {
|
||||
val instructions = method.instructions;
|
||||
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;
|
||||
var currentState = STATE0;
|
||||
val memory = new Memory();
|
||||
for (int insnIndex = 0; insnIndex < insnList.size(); insnIndex++) {
|
||||
memory.currentInsn = insnIndex;
|
||||
val insn = insnList.get(insnIndex);
|
||||
memory.initLocals(method, cn);
|
||||
val iter = insnList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
val insn = iter.next();
|
||||
if (insn instanceof FrameNode) {
|
||||
val frame = (FrameNode) insn;
|
||||
if (frame.type == Opcodes.F_NEW) {
|
||||
memory.locals.clear();
|
||||
memory.locals.addAll(frame.local);
|
||||
}
|
||||
memory.recordFrame(frame);
|
||||
memory.updateLocalsState(frame);
|
||||
}
|
||||
val newState = currentState.apply(insn, memory);
|
||||
if (newState != null) {
|
||||
if (newState == STATE_FINAL) {
|
||||
while (iter.hasNext()) {
|
||||
val insn2 = iter.next();
|
||||
if (insn2 instanceof FrameNode) {
|
||||
memory.recordFrame((FrameNode) insn2);
|
||||
}
|
||||
}
|
||||
return memory;
|
||||
}
|
||||
currentState = newState;
|
||||
@@ -414,30 +413,93 @@ public class ChunkProviderSuperPatcher implements IClassNodeTransformer {
|
||||
}
|
||||
|
||||
@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;
|
||||
for (val method : cn.methods) {
|
||||
val memory = findTheTarget(method);
|
||||
val memory = findTheTarget(method, cn);
|
||||
if (memory != null) {
|
||||
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;
|
||||
for (val node : method.localVariables) {
|
||||
if (node.desc.equals("[B") && node.index == memory.biomeArrayIndex) {
|
||||
node.desc = "[S";
|
||||
}
|
||||
}
|
||||
val getBiomeArray = (MethodInsnNode) insnList.get(memory.getBiomeArrayInsn);
|
||||
val getBiomeArray = memory.getBiomeArrayInsn;
|
||||
insnList.set(getBiomeArray,
|
||||
new MethodInsnNode(Opcodes.INVOKEVIRTUAL, getBiomeArray.owner, "getBiomeShortArray",
|
||||
"()[S", false));
|
||||
insnList.set(insnList.get(memory.castInsn), new InsnNode(Opcodes.I2S));
|
||||
insnList.set(insnList.get(memory.arrayStoreInsn), new InsnNode(Opcodes.SASTORE));
|
||||
insnList.set(memory.castInsn, new InsnNode(Opcodes.I2S));
|
||||
insnList.set(memory.arrayStoreInsn, new InsnNode(Opcodes.SASTORE));
|
||||
patchStackFrames(memory, method, cn);
|
||||
}
|
||||
}
|
||||
if (!patched) {
|
||||
IETransformer.logger.debug("[ChunkProvider patcher]: No matches found in class! This is not explicitly " +
|
||||
"an error, because the patch might be applied by a mixin instead!");
|
||||
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!");
|
||||
}
|
||||
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 {
|
||||
|
||||
final List<Object> locals = new ArrayList<>();
|
||||
int currentInsn;
|
||||
int startingInsn;
|
||||
int getBiomeArrayInsn;
|
||||
int castInsn;
|
||||
int arrayStoreInsn;
|
||||
List<Object> localsAtPatchStart;
|
||||
List<FrameNode> framesLeaveUnpatched = new ArrayList<>();
|
||||
List<FrameNode> framesToPatch = new ArrayList<>();
|
||||
boolean patchingFrames;
|
||||
VarInsnNode startingInsn;
|
||||
MethodInsnNode getBiomeArrayInsn;
|
||||
InsnNode castInsn;
|
||||
InsnNode arrayStoreInsn;
|
||||
int chunkIndex;
|
||||
int biomeArrayIndex;
|
||||
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")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendBlockItem;
|
||||
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.\n" +
|
||||
"Disabled by default because of uncertain/weak implementation (taken from NotEnoughIDs)")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 32, new limit is 65536.\n")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendDataWatcher;
|
||||
@Config.Comment("Extend Enchantment IDs. Vanilla limit is 256, new limit is 32768.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@@ -38,6 +37,16 @@ public class GeneralConfig {
|
||||
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendPotion;
|
||||
@Config.Comment("Extend Entity IDs. Vanilla limit is 256, new limit is 32768.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendEntity;
|
||||
|
||||
@Config.Comment("Improves the speed of the block registry by multiple orders of magnitudes. (not thoroughly tested yet)\n" +
|
||||
"It's highly recommended to leave this enabled, especially when using a lot of IDs.\n" +
|
||||
"With this disabled, registering 1 million blocks on a test system took 80 minutes\n" +
|
||||
"With this enabled, registering the same million blocks took 7 seconds")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableRegistryPerformanceTweak;
|
||||
@Config.Comment(
|
||||
"Extends the maximum redstone signal strength.\n" + "Only has effect with extendBlockItem enabled.\n" +
|
||||
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
|
||||
@@ -56,10 +65,30 @@ public class GeneralConfig {
|
||||
"The default setting sets it to 4k (vanilla).\n" +
|
||||
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
|
||||
"Only effective if extendBlockItem is enabled.\n" +
|
||||
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
|
||||
"Effective values: (0: 4k, 1: 8k, 2: 16k, 3: 32k, 4: 64k, 5: 128k, 6: 256k, 7: 512k, 8: 1M, 9: 2M, 10: 4M, 11: 8M, 12: 16M)\n" +
|
||||
"The effective value of this variable must always be smaller or equal to the effective value of extraItemIDBits")
|
||||
@Config.RangeInt(min = 0,
|
||||
max = 12)
|
||||
@Config.DefaultInt(12)
|
||||
@Config.DefaultInt(0)
|
||||
public static int extraBlockIDBits;
|
||||
@Config.Comment("Use this to tune the amount of available item IDs.\n" +
|
||||
"The vanilla default is 32k item IDs, while the maximum is 16 million.\n" +
|
||||
"The default setting sets it to 32k (vanilla).\n" +
|
||||
"increase if necessary (when running out of ITEM IDs in your modpack)\n" +
|
||||
"Only effective if extendBlockItem is enabled.\n" +
|
||||
"Effective values: (0: 32k, 1: 64k, 2: 128k, 3: 256k, 4: 512k, 5: 1M, 6: 2M, 7: 4M, 8: 8M, 9: 16M)\n" +
|
||||
"The effective value of this variable must always be equal or larger than the effective value of extraBlockIDBits")
|
||||
@Config.RangeInt(min = 0,
|
||||
max = 9)
|
||||
@Config.DefaultInt(0)
|
||||
public static int extraItemIDBits;
|
||||
|
||||
|
||||
@Config.Comment("DEPRECATED, will be removed in the next version of EndlessIDs!\n" +
|
||||
"This property does nothing.\n" +
|
||||
"Use extraBlockIDBits and extraItemIDBits instead.")
|
||||
@Config.DefaultInt(0)
|
||||
@Deprecated
|
||||
public static int countCorrectionBits;
|
||||
|
||||
static {
|
||||
|
||||
@@ -7,14 +7,21 @@ public class ExtendedConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 24;
|
||||
public static final int bitsPerMetadata = 16;
|
||||
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
|
||||
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
|
||||
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
|
||||
|
||||
public static final int watchableBits = 7;
|
||||
public static final int watchableBits = 16;
|
||||
public static final int bitsPerBiome = 16;
|
||||
|
||||
public static final int maximumPotionIDs = 65536;
|
||||
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
|
||||
public static final int bitsPerEntity = 15;
|
||||
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
@@ -22,16 +29,16 @@ public class ExtendedConstants {
|
||||
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
|
||||
|
||||
public static final int blockIDMask = (1 << bitsPerID) - 1;
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBlockBits);
|
||||
public static final int maxBlockID = blockIDCount - 1;
|
||||
|
||||
public static final int itemIDCount = 1 << (bitsPerID);
|
||||
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
|
||||
public static final int maxItemID = itemIDCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
||||
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
|
||||
|
||||
//BiomeIDs
|
||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||
@@ -42,5 +49,9 @@ public class ExtendedConstants {
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//EntityIDs
|
||||
public static final int entityIDCount = 1 << bitsPerEntity;
|
||||
public static final int entityIDMask = entityIDCount - 1;
|
||||
public static final int maxEntityID = entityIDMask;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public class VanillaConstants {
|
||||
public static final int watchableBits = 5;
|
||||
public static final int bitsPerBiome = 8;
|
||||
|
||||
public static final int bitsPerEntity = 8;
|
||||
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
@@ -25,8 +27,8 @@ public class VanillaConstants {
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
||||
public static final int nibblesPerSubChunk = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerSubChunk = (nibblesPerSubChunk + 1) / 2;
|
||||
|
||||
//BiomeIDs
|
||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||
@@ -38,4 +40,8 @@ public class VanillaConstants {
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//EntityIDs
|
||||
public static final int entityIDCount = 1 << bitsPerEntity;
|
||||
public static final int maxEntityID = entityIDCount - 1;
|
||||
}
|
||||
@@ -1,17 +1,22 @@
|
||||
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.Tags;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.ChunkNBTDataManager {
|
||||
//NOTE: Also change the save logic in MapWriter mod if changing this
|
||||
public class BiomeManager implements DataManager.PacketDataManager, DataManager.ChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -29,17 +34,17 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
data.asShortBuffer().put(((IChunkMixin)chunk).getBiomeShortArray());
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
data.asShortBuffer().put(((ChunkBiomeHook)chunk).getBiomeShortArray());
|
||||
data.position(data.position() + maxPacketSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
var arr = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
var arr = ((ChunkBiomeHook)chunk).getBiomeShortArray();
|
||||
if (arr == null) {
|
||||
arr = new short[16 * 16];
|
||||
((IChunkMixin)chunk).setBiomeShortArray(arr);
|
||||
((ChunkBiomeHook)chunk).setBiomeShortArray(arr);
|
||||
}
|
||||
buffer.asShortBuffer().get(arr);
|
||||
buffer.position(buffer.position() + maxPacketSize());
|
||||
@@ -52,16 +57,16 @@ public class BiomeManager implements ChunkDataManager, ChunkDataManager.PacketDa
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt) {
|
||||
var data = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
var data = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
if (data == null) {
|
||||
data = new short[16 * 16];
|
||||
((IChunkMixin)chunk).setBiomeShortArray(data);
|
||||
((ChunkBiomeHook)chunk).setBiomeShortArray(data);
|
||||
}
|
||||
if (nbt.hasKey("Biomes16v2", 7)) {
|
||||
Hooks.byteToShortArray(nbt.getByteArray("Biomes16v2"), 0, data, 0, data.length * 2);
|
||||
@@ -72,4 +77,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;
|
||||
|
||||
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.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||
import com.falsepattern.endlessids.util.DataUtil;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -13,7 +17,11 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
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.*;
|
||||
|
||||
//NOTE: Also change the save logic in MapWriter mod if changing this
|
||||
public class BlockIDManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -31,35 +39,35 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
int storageFlags = 0;
|
||||
val start = data.position() + 4;
|
||||
data.position(start);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
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);
|
||||
|
||||
val b2Low = ebs.getB2Low();
|
||||
val b2Low = subChunk.getB2Low();
|
||||
if (b2Low == null) {
|
||||
continue;
|
||||
}
|
||||
data.put(b2Low.data);
|
||||
|
||||
val b2High = ebs.getB2High();
|
||||
val b2High = subChunk.getB2High();
|
||||
if (b2High == null) {
|
||||
continue;
|
||||
}
|
||||
data.put(b2High.data);
|
||||
|
||||
val b3 = ebs.getB3();
|
||||
val b3 = subChunk.getB3();
|
||||
if (b3 != null) {
|
||||
data.put(b3);
|
||||
}
|
||||
@@ -68,119 +76,143 @@ public class BlockIDManager implements ChunkDataManager, ChunkDataManager.Packet
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
val storageFlags = buffer.getInt();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
continue;
|
||||
}
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
||||
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
||||
val b1 = ebs.getB1();
|
||||
val b1 = subChunk.getB1();
|
||||
buffer.get(b1);
|
||||
if (storageFlag == 0b00) {
|
||||
ebs.clearB2Low();
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
subChunk.setB2Low(null);
|
||||
subChunk.setB2High(null);
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2Low = ebs.getB2Low();
|
||||
var b2Low = subChunk.getB2Low();
|
||||
if (b2Low == null) {
|
||||
b2Low = ebs.createB2Low();
|
||||
b2Low = subChunk.createB2Low();
|
||||
}
|
||||
buffer.get(b2Low.data);
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearB2High();
|
||||
ebs.clearB3();
|
||||
subChunk.setB2High(null);
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b2High = ebs.getB2High();
|
||||
var b2High = subChunk.getB2High();
|
||||
if (b2High == null) {
|
||||
b2High = ebs.createB2High();
|
||||
b2High = subChunk.createB2High();
|
||||
}
|
||||
buffer.get(b2High.data);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearB3();
|
||||
subChunk.setB3(null);
|
||||
continue;
|
||||
}
|
||||
var b3 = ebs.getB3();
|
||||
var b3 = subChunk.getB3();
|
||||
if (b3 == null) {
|
||||
b3 = ebs.createB3();
|
||||
b3 = subChunk.createB3();
|
||||
}
|
||||
buffer.get(b3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
val b1 = ebs.getB1();
|
||||
val b2Low = ebs.getB2Low();
|
||||
val b2High = ebs.getB2High();
|
||||
val b3 = ebs.getB3();
|
||||
section.setByteArray("Blocks", b1);
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
val b1 = subChunk.getB1();
|
||||
val b2Low = subChunk.getB2Low();
|
||||
val b2High = subChunk.getB2High();
|
||||
val b3 = subChunk.getB3();
|
||||
nbt.setByteArray("Blocks", b1);
|
||||
if (b2Low != null) {
|
||||
section.setByteArray("Add", b2Low.data);
|
||||
nbt.setByteArray("Add", b2Low.data);
|
||||
}
|
||||
if (b2High != null) {
|
||||
section.setByteArray("BlocksB2Hi", b2High.data);
|
||||
nbt.setByteArray("BlocksB2Hi", b2High.data);
|
||||
}
|
||||
if (b3 != null) {
|
||||
section.setByteArray("BlocksB3", b3);
|
||||
nbt.setByteArray("BlocksB3", b3);
|
||||
}
|
||||
}
|
||||
|
||||
//NotEnoughIDs world compatibility
|
||||
public static void readSectionFromNBTNotEnoughIDsDFU(IExtendedBlockStorageMixin ebs, NBTTagCompound section) {
|
||||
val data = section.getByteArray("Blocks16");
|
||||
public static void readSubChunkFromNBTNotEnoughIDsDFU(SubChunkBlockHook subChunk, NBTTagCompound nbt) {
|
||||
val data = nbt.getByteArray("Blocks16");
|
||||
val dataShort = new short[data.length >>> 1];
|
||||
ByteBuffer.wrap(data).asShortBuffer().get(dataShort);
|
||||
val b1 = new byte[dataShort.length];
|
||||
val b2L = new byte[dataShort.length >>> 1];
|
||||
val b2H = new byte[dataShort.length >>> 1];
|
||||
val b1 = new byte[blocksPerSubChunk];
|
||||
val b2L = new byte[blocksPerSubChunk >>> 1];
|
||||
val b2H = new byte[blocksPerSubChunk >>> 1];
|
||||
for (int i = 0; i < dataShort.length; i++) {
|
||||
val s = dataShort[i];
|
||||
val nI = i >>> 1;
|
||||
val mI = (i & 1) * 4;
|
||||
b1[i] = (byte) (s & 0x00FF);
|
||||
b2L[nI] |= ((s & 0x0F00) >>> 8) << mI;
|
||||
b2H[nI] |= ((s & 0xF000) >>> 12) << mI;
|
||||
b2L[nI] |= (byte) (((s & 0x0F00) >>> 8) << mI);
|
||||
b2H[nI] |= (byte) (((s & 0xF000) >>> 12) << mI);
|
||||
}
|
||||
ebs.setB1(b1);
|
||||
ebs.setB2Low(new NibbleArray(b2L, 4));
|
||||
ebs.setB2High(new NibbleArray(b2H, 4));
|
||||
subChunk.setB1(b1);
|
||||
subChunk.setB2Low(new NibbleArray(b2L, 4));
|
||||
subChunk.setB2High(new NibbleArray(b2H, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
if (section.hasKey("Blocks16")) {
|
||||
readSectionFromNBTNotEnoughIDsDFU(ebs, section);
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
if (nbt.hasKey("Blocks16")) {
|
||||
readSubChunkFromNBTNotEnoughIDsDFU(subChunk, nbt);
|
||||
return;
|
||||
}
|
||||
assert section.hasKey("Blocks");
|
||||
val b1 = section.getByteArray("Blocks");
|
||||
final byte[] b2Low = section.hasKey("Add") ? section.getByteArray("Add") : null;
|
||||
final byte[] b2High = section.hasKey("BlocksB2Hi") ? section.getByteArray("BlocksB2Hi") : null;
|
||||
final byte[] b3 = section.hasKey("BlocksB3") ? section.getByteArray("BlocksB3") : null;
|
||||
assert nbt.hasKey("Blocks");
|
||||
val b1 = nbt.getByteArray("Blocks");
|
||||
final byte[] b2Low = nbt.hasKey("Add") ? nbt.getByteArray("Add") : null;
|
||||
final byte[] b2High = nbt.hasKey("BlocksB2Hi") ? nbt.getByteArray("BlocksB2Hi") : null;
|
||||
final byte[] b3 = nbt.hasKey("BlocksB3") ? nbt.getByteArray("BlocksB3") : null;
|
||||
|
||||
ebs.setB1(b1);
|
||||
if (b2Low == null) {
|
||||
ebs.clearB2Low();
|
||||
} else {
|
||||
ebs.setB2Low(new NibbleArray(b2Low, 4));
|
||||
}
|
||||
if (b2High == null) {
|
||||
ebs.clearB2High();
|
||||
} else {
|
||||
ebs.setB2High(new NibbleArray(b2High, 4));
|
||||
}
|
||||
ebs.setB3(b3);
|
||||
subChunk.setB1(ensureSubChunkByteArray(b1));
|
||||
subChunk.setB2Low(ensureSubChunkNibbleArray(b2Low));
|
||||
subChunk.setB2High(ensureSubChunkNibbleArray(b2High));
|
||||
subChunk.setB3(ensureSubChunkByteArray(b3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage fromVanilla, ExtendedBlockStorage toVanilla) {
|
||||
val from = (SubChunkBlockHook) fromVanilla;
|
||||
val to = (SubChunkBlockHook) toVanilla;
|
||||
|
||||
to.setB1(ArrayUtil.copyArray(from.getB1(), to.getB1()));
|
||||
to.setB2Low(ArrayUtil.copyArray(from.getB2Low(), to.getB2Low()));
|
||||
to.setB2High(ArrayUtil.copyArray(from.getB2High(), to.getB2High()));
|
||||
to.setB3(ArrayUtil.copyArray(from.getB3(), to.getB3()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String version() {
|
||||
return Tags.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String newInstallDescription() {
|
||||
return "EndlessIDs extended block IDs. Vanilla worlds can be converted to EndlessIDs worlds safely.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String uninstallMessage() {
|
||||
return "EndlessIDs extended block IDs removed. Any blocks with IDs above 4095 will get corrupted.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String versionChangeMessage(String priorVersion) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
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.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.SubChunkBlockHook;
|
||||
import com.falsepattern.endlessids.util.DataUtil;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -13,7 +17,10 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.PacketDataManager, ChunkDataManager.SectionNBTDataManager {
|
||||
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||
|
||||
//NOTE: Also change the save logic in MapWriter mod if changing this
|
||||
public class BlockMetaManager implements DataManager.PacketDataManager, DataManager.SubChunkDataManager {
|
||||
|
||||
@Override
|
||||
public String domain() {
|
||||
@@ -31,29 +38,29 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer data) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
int storageFlags = 0;
|
||||
val start = data.position() + 4;
|
||||
data.position(start);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
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);
|
||||
|
||||
val m1High = ebs.getM1High();
|
||||
val m1High = subChunk.getM1High();
|
||||
if (m1High == null) {
|
||||
continue;
|
||||
}
|
||||
data.put(m1High.data);
|
||||
|
||||
val m2 = ebs.getM2();
|
||||
val m2 = subChunk.getM2();
|
||||
if (m2 != null) {
|
||||
data.put(m2);
|
||||
}
|
||||
@@ -62,73 +69,124 @@ public class BlockMetaManager implements ChunkDataManager, ChunkDataManager.Pack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromBuffer(Chunk chunk, int ebsMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val ebsList = chunk.getBlockStorageArray();
|
||||
public void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer) {
|
||||
val subChunkList = chunk.getBlockStorageArray();
|
||||
val storageFlags = buffer.getInt();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((ebsMask & (1 << i)) == 0 || ebsList[i] == null) {
|
||||
if ((subChunkMask & (1 << i)) == 0 || subChunkList[i] == null) {
|
||||
continue;
|
||||
}
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsList[i];
|
||||
val subChunk = (SubChunkBlockHook) subChunkList[i];
|
||||
val storageFlag = (storageFlags >>> (i * 2)) & 3;
|
||||
val m1Low = ebs.getM1Low();
|
||||
val m1Low = subChunk.getM1Low();
|
||||
buffer.get(m1Low.data);
|
||||
if (storageFlag == 0b01) {
|
||||
ebs.clearM1High();
|
||||
ebs.clearM2();
|
||||
subChunk.setM1High(null);
|
||||
subChunk.setM2(null);
|
||||
continue;
|
||||
}
|
||||
var m1High = ebs.getM1High();
|
||||
var m1High = subChunk.getM1High();
|
||||
if (m1High == null) {
|
||||
m1High = ebs.createM1High();
|
||||
m1High = subChunk.createM1High();
|
||||
}
|
||||
buffer.get(m1High.data);
|
||||
if (storageFlag == 0b10) {
|
||||
ebs.clearM2();
|
||||
subChunk.setM2(null);
|
||||
continue;
|
||||
}
|
||||
var m2 = ebs.getM2();
|
||||
var m2 = subChunk.getM2();
|
||||
if (m2 == null) {
|
||||
m2 = ebs.createM2();
|
||||
m2 = subChunk.createM2();
|
||||
}
|
||||
buffer.get(m2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sectionPrivilegedAccess() {
|
||||
public boolean subChunkPrivilegedAccess() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
val m1Low = ebs.getM1Low();
|
||||
val m1High = ebs.getM1High();
|
||||
val m2 = ebs.getM2();
|
||||
section.setByteArray("Data", m1Low.data);
|
||||
public void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
val m1Low = subChunk.getM1Low();
|
||||
val m1High = subChunk.getM1High();
|
||||
val m2 = subChunk.getM2();
|
||||
nbt.setByteArray("Data", m1Low.data);
|
||||
if (m1High != null) {
|
||||
section.setByteArray("Data1High", m1High.data);
|
||||
nbt.setByteArray("Data1High", m1High.data);
|
||||
}
|
||||
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
|
||||
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebsVanilla, NBTTagCompound section) {
|
||||
val ebs = (IExtendedBlockStorageMixin) ebsVanilla;
|
||||
assert section.hasKey("Data");
|
||||
val m1Low = section.getByteArray("Data");
|
||||
final byte[] m1High = section.hasKey("Data1High") ? section.getByteArray("Data1High") : null;
|
||||
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));
|
||||
public void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunkVanilla, NBTTagCompound nbt) {
|
||||
val subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
if (nbt.hasKey("Data16")) {
|
||||
readSubChunkFromNBTNotEnoughIDsDFU(subChunk, nbt);
|
||||
return;
|
||||
}
|
||||
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 static byte[] getBiomeArrayTweaked(Chunk chunk, IntFunction<BiomeGenBase> biomesForGeneration) {
|
||||
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
|
||||
for (int i = 0; i < chunkBiomes.length; ++i) {
|
||||
chunkBiomes[i] = (short) biomesForGeneration.apply(i).biomeID;
|
||||
@@ -20,7 +20,7 @@ public class BiomePatchHelper {
|
||||
}
|
||||
|
||||
public static byte[] getBiomeArrayTweaked(Chunk chunk, BiomeGenBase[] biomesForGeneration) {
|
||||
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
|
||||
for (int i = 0; i < chunkBiomes.length; ++i) {
|
||||
chunkBiomes[i] = (short) biomesForGeneration[i].biomeID;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
public interface IChunkMixin {
|
||||
public interface ChunkBiomeHook {
|
||||
short[] getBiomeShortArray();
|
||||
|
||||
void setBiomeShortArray(short[] data);
|
||||
+3
-13
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
|
||||
public interface IExtendedBlockStorageMixin {
|
||||
public interface SubChunkBlockHook {
|
||||
byte[] getB1();
|
||||
|
||||
void setB1(byte[] data);
|
||||
@@ -11,29 +11,23 @@ public interface IExtendedBlockStorageMixin {
|
||||
|
||||
void setB2Low(NibbleArray data);
|
||||
|
||||
void clearB2Low();
|
||||
|
||||
NibbleArray createB2Low();
|
||||
|
||||
NibbleArray getB2High();
|
||||
|
||||
void setB2High(NibbleArray data);
|
||||
|
||||
void clearB2High();
|
||||
|
||||
NibbleArray createB2High();
|
||||
|
||||
byte[] getB3();
|
||||
|
||||
void setB3(byte[] data);
|
||||
|
||||
void clearB3();
|
||||
|
||||
byte[] createB3();
|
||||
|
||||
int getEBSMask();
|
||||
int getMetadataMask();
|
||||
|
||||
int getEBSMSBMask();
|
||||
int getBlockMask();
|
||||
|
||||
int getID(int x, int y, int z);
|
||||
|
||||
@@ -45,15 +39,11 @@ public interface IExtendedBlockStorageMixin {
|
||||
|
||||
void setM1High(NibbleArray m1High);
|
||||
|
||||
void clearM1High();
|
||||
|
||||
NibbleArray createM1High();
|
||||
|
||||
byte[] getM2();
|
||||
|
||||
void setM2(byte[] m2);
|
||||
|
||||
void clearM2();
|
||||
|
||||
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.VanillaConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ShortUtil;
|
||||
import hunternif.mc.atlas.core.BiomeDetectorBase;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -41,7 +41,7 @@ public abstract class BiomeDetectorBaseMixin {
|
||||
require = 1)
|
||||
private int[] biomeIDs(byte[] i) {
|
||||
try {
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
||||
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
|
||||
} finally {
|
||||
chunk = null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.antiqueatlas;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ShortUtil;
|
||||
import hunternif.mc.atlas.core.BiomeDetectorNether;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -30,7 +30,7 @@ public abstract class BiomeDetectorNetherMixin {
|
||||
require = 1)
|
||||
private int[] biomeIDs(byte[] i) {
|
||||
try {
|
||||
return ShortUtil.unsignedShortToIntArray(((IChunkMixin) chunk).getBiomeShortArray());
|
||||
return ShortUtil.unsignedShortToIntArray(((ChunkBiomeHook) chunk).getBiomeShortArray());
|
||||
} finally {
|
||||
chunk = null;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.biomewand;
|
||||
|
||||
import com.falsepattern.endlessids.PlaceholderBiome;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.spacechase0.minecraft.biomewand.BiomeWandMod;
|
||||
import com.spacechase0.minecraft.biomewand.item.BiomeWandItem;
|
||||
import com.spacechase0.minecraft.spacecore.util.TranslateUtils;
|
||||
@@ -42,7 +42,7 @@ public abstract class BiomeWandItemMixin {
|
||||
int relBlockX = blockX & 15;
|
||||
int relBlockZ = blockZ & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
short biome = ((IChunkMixin) chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
|
||||
short biome = ((ChunkBiomeHook) chunk).getBiomeShortArray()[relBlockZ * 16 + relBlockX];
|
||||
tag.setShort("sampledBiomeS", biome);
|
||||
} else {
|
||||
short biome = tag.getShort("sampledBiomeS");
|
||||
@@ -52,7 +52,7 @@ public abstract class BiomeWandItemMixin {
|
||||
int relBlockX = ix & 15;
|
||||
int relBlockZ = iz & 15;
|
||||
Chunk chunk = world.getChunkFromBlockCoords(blockX, blockZ);
|
||||
((IChunkMixin) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||
((ChunkBiomeHook) chunk).getBiomeShortArray()[relBlockZ << 4 | relBlockX] = biome;
|
||||
chunk.isModified = true;
|
||||
BiomeWandMod.proxy.updateRendererAt(ix, iz);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public abstract class BiomeWandItemMixin {
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@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();
|
||||
String str = TranslateUtils.translate("biomewand.tooltip.biome") + ": ";
|
||||
if (tag == null || !tag.hasKey("sampledBiomeS")) {
|
||||
@@ -95,7 +95,7 @@ public abstract class BiomeWandItemMixin {
|
||||
* @reason Biome ID extension
|
||||
*/
|
||||
@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));
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (biome != null && !(biome instanceof PlaceholderBiome)) {
|
||||
|
||||
+11
-7
@@ -1,14 +1,16 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.compactmachines;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.stubpackage.org.dave.CompactMachines.tileentity.TileEntityMachine;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lombok.val;
|
||||
import org.dave.CompactMachines.handler.ConfigurationHandler;
|
||||
import org.dave.CompactMachines.machines.tools.CubeTools;
|
||||
import org.dave.CompactMachines.tileentity.TileEntityMachine;
|
||||
import org.dave.CompactMachines.utility.WorldUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -27,7 +29,7 @@ public abstract class CubeToolsMixin {
|
||||
WorldServer machineWorld = MinecraftServer.getServer().worldServerForDimension(ConfigurationHandler.dimensionId);
|
||||
Chunk chunk = machineWorld.getChunkFromBlockCoords(coords * ConfigurationHandler.cubeDistance, 0);
|
||||
if (chunk != null && chunk.isChunkLoaded) {
|
||||
short[] biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
short[] biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
for (int x = 0; x < 15; ++x) {
|
||||
for (int z = 0; z < 15; ++z) {
|
||||
biomeArray[z << 4 | x] = (short) biome.biomeID;
|
||||
@@ -43,10 +45,12 @@ public abstract class CubeToolsMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public static BiomeGenBase getMachineBiome(TileEntityMachine machine) {
|
||||
short[] biomeArray = ((IChunkMixin) machine.getWorldObj()
|
||||
.getChunkFromBlockCoords(machine.xCoord,
|
||||
machine.zCoord)).getBiomeShortArray();
|
||||
int biomeId = biomeArray[(machine.zCoord & 15) << 4 | machine.xCoord & 15];
|
||||
val TE = (TileEntity)machine;
|
||||
val x = TE.xCoord;
|
||||
val z = TE.zCoord;
|
||||
short[] biomeArray = ((ChunkBiomeHook) TE.getWorldObj()
|
||||
.getChunkFromBlockCoords(x, z)).getBiomeShortArray();
|
||||
int biomeId = biomeArray[(z & 15) << 4 | x & 15];
|
||||
return biomeId > 0 && biomeId < BiomeGenBase.getBiomeGenArray().length &&
|
||||
BiomeDictionary.isBiomeRegistered(biomeId) ? BiomeGenBase.getBiome(biomeId) : WorldUtils.getBiomeByName(
|
||||
ConfigurationHandler.defaultBiome);
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
|
||||
|
||||
import Reika.DragonAPI.Libraries.World.ReikaChunkHelper;
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -20,7 +20,7 @@ public abstract class ReikaChunkHelperMixin {
|
||||
remap = true),
|
||||
require = 1)
|
||||
private static void customSet(Chunk chunk, byte[] p_76616_1_) {
|
||||
((IChunkMixin) chunk).setBiomeShortArray(biomeArray);
|
||||
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeArray);
|
||||
biomeArray = null;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class ReikaChunkHelperMixin {
|
||||
remap = true),
|
||||
require = 1)
|
||||
private static byte[] customGet(Chunk chunk) {
|
||||
biomeArray = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
biomeArray = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
return EndlessIDs.ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -2,7 +2,7 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.dragonapi;
|
||||
|
||||
import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -45,7 +45,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
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) {
|
||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
((ChunkBiomeHook) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
}
|
||||
|
||||
@Inject(method = "setBiomeAndBlocksForXZ",
|
||||
@@ -55,7 +55,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||
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) {
|
||||
fromBiomeID = ((IChunkMixin) ch).getBiomeShortArray()[index];
|
||||
fromBiomeID = ((ChunkBiomeHook) ch).getBiomeShortArray()[index];
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "setBiomeAndBlocksForXZ",
|
||||
@@ -72,6 +72,6 @@ public abstract class ReikaWorldHelperMixin {
|
||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||
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) {
|
||||
((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",
|
||||
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,
|
||||
require = 1)
|
||||
private void noLog(Logger instance, String s) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.enderlicious;
|
||||
|
||||
import DelirusCrux.Enderlicious.Dimension.EndChunkProvider;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -39,7 +39,7 @@ public abstract class EndChunkProviderMixin {
|
||||
remap = true,
|
||||
require = 1)
|
||||
private byte[] setBiomesTweaked(Chunk chunk) {
|
||||
val chunkBiomes = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
val chunkBiomes = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
for (int k = 0; k < chunkBiomes.length; ++k) {
|
||||
if (Math.abs(xx) < 160 && Math.abs(zz) < 160) {
|
||||
chunkBiomes[k] = 9;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.extrautilities;
|
||||
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -45,7 +45,7 @@ public abstract class ChunkProviderEndOfTimeMixin {
|
||||
require = 1)
|
||||
private void setBiomesTweaked3(byte[] bytes, byte b) {
|
||||
try {
|
||||
Arrays.fill(((IChunkMixin) chunk).getBiomeShortArray(), (short) id);
|
||||
Arrays.fill(((ChunkBiomeHook) chunk).getBiomeShortArray(), (short) id);
|
||||
} finally {
|
||||
chunk = null;
|
||||
id = -1;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
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.blocks.BlockCore;
|
||||
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) {
|
||||
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.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
@Mixin(value = LOTRChunkProvider.class,
|
||||
remap = false)
|
||||
public abstract class LOTRChunkProviderMixin {
|
||||
@Shadow
|
||||
@Mixin(value = LOTRChunkProvider.class)
|
||||
public abstract class LOTRChunkProviderMixin implements IChunkProvider {
|
||||
@Shadow(remap = false)
|
||||
private LOTRBiomeVariant[] variantsForGeneration;
|
||||
|
||||
@Redirect(method = "provideChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V"),
|
||||
remap = true,
|
||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V",
|
||||
remap = false),
|
||||
require = 1)
|
||||
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
||||
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.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
@Mixin(value = LOTRChunkProviderUtumno.class,
|
||||
remap = false)
|
||||
public abstract class LOTRChunkProviderUtumnoMixin {
|
||||
@Shadow
|
||||
@Mixin(value = LOTRChunkProviderUtumno.class)
|
||||
public abstract class LOTRChunkProviderUtumnoMixin implements IChunkProvider {
|
||||
@Shadow(remap = false)
|
||||
private LOTRBiomeVariant[] variantsForGeneration;
|
||||
|
||||
@Redirect(method = "provideChunk",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V"),
|
||||
remap = true,
|
||||
target = "Llotr/common/world/biome/variant/LOTRBiomeVariantStorage;setChunkBiomeVariants(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;[B)V",
|
||||
remap = false),
|
||||
require = 1)
|
||||
private void storeShorts(World world, Chunk chunk, byte[] variantsB) {
|
||||
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 cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
@Mixin(value = LOTRPacketBiomeVariantsWatch.Handler.class,
|
||||
remap = false)
|
||||
public abstract class LOTRPacketBiomeVariantsWatchHandler {
|
||||
public abstract class LOTRPacketBiomeVariantsWatchHandlerMixin implements IMessageHandler<LOTRPacketBiomeVariantsWatch, IMessage> {
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
+6
-6
@@ -8,23 +8,23 @@ import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.WorldChunkManager;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
@Mixin(value = LOTRWorldChunkManager.class,
|
||||
remap = false)
|
||||
public abstract class LOTRWorldChunkManagerMixin {
|
||||
@Shadow
|
||||
@Mixin(value = LOTRWorldChunkManager.class)
|
||||
public abstract class LOTRWorldChunkManagerMixin extends WorldChunkManager {
|
||||
@Shadow(remap = false)
|
||||
private World worldObj;
|
||||
|
||||
@Shadow
|
||||
@Shadow(remap = false)
|
||||
public abstract LOTRBiomeVariant[] getBiomeVariants(LOTRBiomeVariant[] variants, int i, int k, int xSize, int zSize);
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason fix stuff
|
||||
*/
|
||||
@Overwrite
|
||||
@Overwrite(remap = false)
|
||||
public LOTRBiomeVariant getBiomeVariantAt(int i, int k) {
|
||||
short[] variants;
|
||||
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;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.yurtmod.dimension.TentChunkProvider;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -23,6 +23,6 @@ public abstract class TentChunkProviderMixin {
|
||||
private void setBiomesTweaked(Chunk chunk, byte[] p_76616_1_) {
|
||||
short[] biomeMap = new short[256];
|
||||
Arrays.fill(biomeMap, (short) BiomeGenBase.ocean.biomeID);
|
||||
((IChunkMixin) chunk).setBiomeShortArray(biomeMap);
|
||||
((ChunkBiomeHook) chunk).setBiomeShortArray(biomeMap);
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.owg;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import owg.generator.ChunkGeneratorBeta;
|
||||
import owg.map.MapGenOLD;
|
||||
import owg.world.ManagerOWG;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.structure.MapGenMineshaft;
|
||||
import net.minecraft.world.gen.structure.MapGenStronghold;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ChunkGeneratorBeta.class)
|
||||
public abstract class ChunkGeneratorBetaMixin implements IChunkProvider {
|
||||
@Shadow private Random rand;
|
||||
|
||||
@Shadow private BiomeGenBase[] biomesForGeneration;
|
||||
|
||||
@Shadow private World worldObj;
|
||||
|
||||
@Shadow public abstract void generateTerrain(int i, int j, Block[] blocks, BiomeGenBase[] abiomegenbase, double[] ad);
|
||||
|
||||
@Shadow public abstract void replaceBlocksForBiome(int i, int j, Block[] blocks, byte[] metadata, BiomeGenBase[] abiomegenbase);
|
||||
|
||||
@Shadow private MapGenOLD field_902_u;
|
||||
|
||||
@Shadow @Final private boolean mapFeaturesEnabled;
|
||||
|
||||
@Shadow private MapGenStronghold strongholdGenerator;
|
||||
|
||||
@Shadow private MapGenMineshaft mineshaftGenerator;
|
||||
|
||||
@Shadow private int biomeSettings;
|
||||
|
||||
public Chunk provideChunk(int i, int j) {
|
||||
this.rand.setSeed((long)i * 341873128712L + (long)j * 132897987541L);
|
||||
Block[] blocks = new Block[128 * 16 * 16];
|
||||
byte[] metadata = new byte[128 * 16 * 16];
|
||||
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, i * 16, j * 16, 16, 16);
|
||||
double[] ad = ManagerOWG.temperature;
|
||||
this.generateTerrain(i, j, blocks, this.biomesForGeneration, ad);
|
||||
this.replaceBlocksForBiome(i, j, blocks, metadata, this.biomesForGeneration);
|
||||
this.field_902_u.generate(this, this.worldObj, i, j, blocks);
|
||||
if (this.mapFeaturesEnabled) {
|
||||
this.strongholdGenerator.func_151539_a(this, this.worldObj, i, j, blocks);
|
||||
this.mineshaftGenerator.func_151539_a(this, this.worldObj, i, j, blocks);
|
||||
}
|
||||
|
||||
Chunk chunk = new Chunk(this.worldObj, blocks, metadata, i, j);
|
||||
short[] abyte1 = ((ChunkBiomeHook)chunk).getBiomeShortArray();
|
||||
int k;
|
||||
if (this.biomeSettings == 0) {
|
||||
for(k = 0; k < abyte1.length; ++k) {
|
||||
abyte1[k] = (short)this.biomesForGeneration[k].biomeID;
|
||||
}
|
||||
} else {
|
||||
for(k = 0; k < abyte1.length; ++k) {
|
||||
abyte1[k] = (short)this.biomesForGeneration[(k * 16 & 255) + k / 16].biomeID;
|
||||
}
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lumien.randomthings.Items.ItemBiomeCapsule;
|
||||
import lumien.randomthings.Items.ItemBiomePainter;
|
||||
import lumien.randomthings.Items.ModItems;
|
||||
@@ -40,10 +40,10 @@ public abstract class ItemBiomePainterMixin {
|
||||
if (charges > 0 || par2EntityPlayer.capabilities.isCreativeMode) {
|
||||
Chunk c = par3World.getChunkFromBlockCoords(par4, par6);
|
||||
int biomeID = is.getItemDamage() - 1;
|
||||
short[] biomeArray = ((IChunkMixin) c).getBiomeShortArray(); //changed
|
||||
short[] biomeArray = ((ChunkBiomeHook) c).getBiomeShortArray(); //changed
|
||||
if ((biomeArray[(par6 & 15) << 4 | par4 & 15] & 255) != biomeID) {
|
||||
biomeArray[(par6 & 15) << 4 | par4 & 15] = (short) (biomeID & 0xFFFF); //changed
|
||||
((IChunkMixin) c).setBiomeShortArray(biomeArray); //changed
|
||||
((ChunkBiomeHook) c).setBiomeShortArray(biomeArray); //changed
|
||||
if (!par2EntityPlayer.capabilities.isCreativeMode) {
|
||||
nbt.setInteger("charges", charges - 1);
|
||||
par2EntityPlayer.inventoryContainer.detectAndSendChanges();
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.randomthings;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lumien.randomthings.Items.ItemBiomeCapsule;
|
||||
import lumien.randomthings.Network.Messages.MessagePaintBiome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -49,9 +49,9 @@ public abstract class MessagePaintBiomeMixin {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null && player.worldObj.provider.dimensionId == this.dimensionID) {
|
||||
Chunk c = player.worldObj.getChunkFromBlockCoords(this.posX, this.posZ);
|
||||
short[] biomeArray = ((IChunkMixin) c).getBiomeShortArray(); //changed
|
||||
short[] biomeArray = ((ChunkBiomeHook) c).getBiomeShortArray(); //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,
|
||||
player.worldObj.getActualHeight());
|
||||
BiomeGenBase biome = BiomeGenBase.getBiome(this.biomeID);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
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.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -21,7 +21,7 @@ public abstract class BiomeHelperMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
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 highIndex = BiomeGenBase.plains.biomeID;
|
||||
int highCount = -1;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.thaumcraft;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import thaumcraft.common.lib.network.PacketHandler;
|
||||
@@ -24,7 +24,7 @@ public abstract class UtilsMixin {
|
||||
public static void setBiomeAt(World world, int x, int z, BiomeGenBase biome) {
|
||||
if (biome != null) {
|
||||
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
||||
short[] array = ((IChunkMixin) chunk).getBiomeShortArray();
|
||||
short[] array = ((ChunkBiomeHook) chunk).getBiomeShortArray();
|
||||
array[(z & 15) << 4 | x & 15] = (short) (biome.biomeID);
|
||||
if (!world.isRemote) {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketBiomeChange(x, z, (short) biome.biomeID),
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.biome.thut;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import thut.api.maths.Vector3;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
@Mixin(value = Vector3.class,
|
||||
remap = false)
|
||||
public abstract class Vector3Mixin {
|
||||
|
||||
@Shadow public abstract int intX();
|
||||
|
||||
@Shadow public abstract int intZ();
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason ID Extension
|
||||
*/
|
||||
@Overwrite
|
||||
public void setBiome(BiomeGenBase biome, World worldObj) {
|
||||
int x = this.intX();
|
||||
int z = this.intZ();
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||
val chunkHook = (ChunkBiomeHook) chunk;
|
||||
short[] biomes = chunkHook.getBiomeShortArray();
|
||||
short newBiome = (short)biome.biomeID;
|
||||
int chunkX = Math.abs(x & 15);
|
||||
int chunkZ = Math.abs(z & 15);
|
||||
int point = chunkX + 16 * chunkZ;
|
||||
if (biomes[point] != newBiome) {
|
||||
biomes[point] = newBiome;
|
||||
chunkHook.setBiomeShortArray(biomes);
|
||||
chunk.setChunkModified();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+15
-12
@@ -3,12 +3,13 @@ package com.falsepattern.endlessids.mixin.mixins.common.biome.vanilla;
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -23,7 +24,7 @@ import java.util.Arrays;
|
||||
|
||||
@Mixin(value = Chunk.class,
|
||||
priority = 900)
|
||||
public abstract class ChunkMixin implements IChunkMixin {
|
||||
public abstract class ChunkMixin implements ChunkBiomeHook {
|
||||
@Shadow
|
||||
@Final
|
||||
public int xPosition;
|
||||
@@ -34,18 +35,20 @@ public abstract class ChunkMixin implements IChunkMixin {
|
||||
public World worldObj;
|
||||
@Shadow
|
||||
private byte[] blockBiomeArray;
|
||||
private short[] blockBiomeShortArray;
|
||||
@Unique
|
||||
private short[] eid$blockBiomeShortArray;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;II)V",
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private void initShortArray(World p_i1995_1_, int p_i1995_2_, int p_i1995_3_, CallbackInfo ci) {
|
||||
blockBiomeArray = null;
|
||||
blockBiomeShortArray = new short[16 * 16];
|
||||
Arrays.fill(blockBiomeShortArray, (short) -1);
|
||||
eid$blockBiomeShortArray = new short[16 * 16];
|
||||
Arrays.fill(eid$blockBiomeShortArray, (short) -1);
|
||||
}
|
||||
|
||||
private void emergencyCrash() {
|
||||
@Unique
|
||||
private void eid$emergencyCrash() {
|
||||
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the biome array of a" +
|
||||
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
|
||||
"Please report this issue on https://github.com/FalsePattern/EndlessIDs ASAP!";
|
||||
@@ -57,14 +60,14 @@ public abstract class ChunkMixin implements IChunkMixin {
|
||||
at = @At(value = "HEAD"),
|
||||
require = 1)
|
||||
private void crashSetBiomeArray(byte[] p_76616_1_, CallbackInfo ci) {
|
||||
emergencyCrash();
|
||||
eid$emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "getBiomeArray",
|
||||
at = @At(value = "HEAD"),
|
||||
require = 1)
|
||||
private void crashGetBiomeArray(CallbackInfoReturnable<byte[]> cir) {
|
||||
emergencyCrash();
|
||||
eid$emergencyCrash();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +76,7 @@ public abstract class ChunkMixin implements IChunkMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public BiomeGenBase getBiomeGenForWorldCoords(int x, int z, WorldChunkManager manager) {
|
||||
int id = this.blockBiomeShortArray[z << 4 | x] & ExtendedConstants.biomeIDMask;
|
||||
int id = this.eid$blockBiomeShortArray[z << 4 | x] & ExtendedConstants.biomeIDMask;
|
||||
if (id == ExtendedConstants.biomeIDNull) {
|
||||
//Source: https://github.com/embeddedt/ArchaicFix/blob/3d1392f4db5a7221534a6f9b00c0c36a49d9be59/src/main/java/org/embeddedt/archaicfix/mixins/common/core/MixinChunk.java#L52
|
||||
if (this.worldObj.isRemote) {
|
||||
@@ -81,7 +84,7 @@ public abstract class ChunkMixin implements IChunkMixin {
|
||||
}
|
||||
BiomeGenBase gen = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
|
||||
id = gen.biomeID;
|
||||
this.blockBiomeShortArray[z << 4 | x] = (short) (id & ExtendedConstants.biomeIDMask);
|
||||
this.eid$blockBiomeShortArray[z << 4 | x] = (short) (id & ExtendedConstants.biomeIDMask);
|
||||
}
|
||||
|
||||
return BiomeGenBase.getBiome(id) == null ? BiomeGenBase.plains : BiomeGenBase.getBiome(id);
|
||||
@@ -89,11 +92,11 @@ public abstract class ChunkMixin implements IChunkMixin {
|
||||
|
||||
@Override
|
||||
public short[] getBiomeShortArray() {
|
||||
return blockBiomeShortArray;
|
||||
return eid$blockBiomeShortArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomeShortArray(short[] data) {
|
||||
blockBiomeShortArray = data;
|
||||
eid$blockBiomeShortArray = data;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
|
||||
|
||||
import com.falsepattern.endlessids.util.DataUtil;
|
||||
import matteroverdrive.data.Inventory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@Mixin(Inventory.class)
|
||||
public abstract class InventoryMixin {
|
||||
@Redirect(method = "readFromNBT",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z"),
|
||||
require = 1)
|
||||
private boolean fixHasKey(NBTTagCompound instance, String p_150297_1_, int p_150297_2_) {
|
||||
return DataUtil.nbtHasID(instance);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.matteroverdrive;
|
||||
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import matteroverdrive.data.ItemPattern;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
@Mixin(value = ItemPattern.class,
|
||||
remap = false)
|
||||
public abstract class ItemPatternMixin {
|
||||
@Shadow private int itemID;
|
||||
|
||||
@Shadow private int progress;
|
||||
|
||||
@Shadow private int damage;
|
||||
|
||||
@Shadow private int count;
|
||||
|
||||
@Inject(method = "writeToNBT",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void writeToNBT$writeInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
|
||||
int id = this.itemID;
|
||||
if (id > VanillaConstants.maxItemID) {
|
||||
nbtTagCompound.setShort("id", (short) 0);
|
||||
}
|
||||
nbtTagCompound.setInteger("idExt", id);
|
||||
}
|
||||
|
||||
@Inject(method = "readFromNBT",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void readFromNBT$readInt(NBTTagCompound nbtTagCompound, CallbackInfo ci) {
|
||||
if (nbtTagCompound.hasKey("idExt", Constants.NBT.TAG_INT))
|
||||
this.itemID = nbtTagCompound.getInteger("idExt");
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Extend IDs
|
||||
*/
|
||||
@Overwrite
|
||||
public void writeToBuffer(ByteBuf byteBuf) {
|
||||
byteBuf.writeInt(this.itemID);
|
||||
byteBuf.writeByte(this.progress);
|
||||
byteBuf.writeShort(this.damage);
|
||||
byteBuf.writeByte(this.count);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Extend IDs
|
||||
*/
|
||||
@Overwrite
|
||||
public void readFromBuffer(ByteBuf byteBuf) {
|
||||
this.itemID = byteBuf.readInt();
|
||||
this.progress = byteBuf.readByte();
|
||||
this.damage = byteBuf.readShort();
|
||||
this.count = byteBuf.readByte();
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
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 lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -16,7 +16,7 @@ import java.util.logging.Logger;
|
||||
remap = false)
|
||||
public abstract class BiomeUndergroundDecoratorMixin {
|
||||
private static NibbleArray fakeArray;
|
||||
private IExtendedBlockStorageMixin ebs;
|
||||
private SubChunkBlockHook subChunk;
|
||||
|
||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)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",
|
||||
remap = true),
|
||||
require = 2)
|
||||
private byte[] returnLSB(ExtendedBlockStorage instance) {
|
||||
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
|
||||
ebs = iebs;
|
||||
return iebs.getB1();
|
||||
private byte[] returnLSB(ExtendedBlockStorage subChunkVanilla) {
|
||||
SubChunkBlockHook subChunk = (SubChunkBlockHook) subChunkVanilla;
|
||||
this.subChunk = subChunk;
|
||||
return subChunk.getB1();
|
||||
}
|
||||
|
||||
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V",
|
||||
@@ -47,8 +47,8 @@ public abstract class BiomeUndergroundDecoratorMixin {
|
||||
remap = true),
|
||||
require = 2)
|
||||
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
|
||||
val id = ebs.getID(x, y, z) >>> 8;
|
||||
ebs = null;
|
||||
val id = subChunk.getID(x, y, z) >>> 8;
|
||||
subChunk = null;
|
||||
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.Tags;
|
||||
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.var;
|
||||
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.storage.ExtendedBlockStorage;
|
||||
|
||||
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||
|
||||
@Mixin(ExtendedBlockStorage.class)
|
||||
public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorageMixin {
|
||||
public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
|
||||
@Shadow
|
||||
private int blockRefCount;
|
||||
@Shadow
|
||||
@@ -196,14 +198,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
blockMSBArray = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2Low() {
|
||||
blockMSBArray = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2Low() {
|
||||
return (blockMSBArray = new NibbleArray(blockLSBArray.length, 4));
|
||||
return (blockMSBArray = new NibbleArray(blocksPerSubChunk, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,14 +213,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
b2High = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB2High() {
|
||||
b2High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createB2High() {
|
||||
return (b2High = new NibbleArray(blockLSBArray.length, 4));
|
||||
return (b2High = new NibbleArray(blocksPerSubChunk, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,14 +228,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
b3 = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearB3() {
|
||||
b3 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createB3() {
|
||||
return b3 = new byte[blockLSBArray.length];
|
||||
return b3 = new byte[blocksPerSubChunk];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,14 +253,9 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
this.m1High = m1High;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM1High() {
|
||||
m1High = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NibbleArray createM1High() {
|
||||
return (m1High = new NibbleArray(blockLSBArray.length, 4));
|
||||
return (m1High = new NibbleArray(blocksPerSubChunk, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -286,18 +268,13 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
this.m2 = m2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearM2() {
|
||||
m2 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createM2() {
|
||||
return (m2 = new byte[blockLSBArray.length]);
|
||||
return (m2 = new byte[blocksPerSubChunk]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEBSMSBMask() {
|
||||
public int getBlockMask() {
|
||||
if (blockMSBArray == null) {
|
||||
return 0b00;
|
||||
}
|
||||
@@ -311,7 +288,7 @@ public abstract class ExtendedBlockStorageMixin implements IExtendedBlockStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEBSMask() {
|
||||
public int getMetadataMask() {
|
||||
if (m1High == null) {
|
||||
return 0b01;
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import com.falsepattern.endlessids.util.DataUtil;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -29,7 +31,7 @@ public abstract class ItemStackMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("id", Item.getIdFromItem(this.field_151002_e));
|
||||
DataUtil.writeIDToNBT(nbt, Item.getIdFromItem(this.field_151002_e));
|
||||
nbt.setByte("Count", (byte) this.stackSize);
|
||||
nbt.setShort("Damage", (short) this.itemDamage);
|
||||
|
||||
@@ -46,7 +48,7 @@ public abstract class ItemStackMixin {
|
||||
*/
|
||||
@Overwrite
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
func_150996_a(Item.getItemById(nbt.getInteger("id")));
|
||||
func_150996_a(Item.getItemById(DataUtil.readIDFromNBT(nbt)));
|
||||
this.stackSize = nbt.getByte("Count");
|
||||
this.itemDamage = nbt.getShort("Damage");
|
||||
|
||||
|
||||
+97
-44
@@ -1,98 +1,89 @@
|
||||
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.VanillaConstants;
|
||||
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.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(DataWatcher.class)
|
||||
@Mixin(value = DataWatcher.class,
|
||||
priority = 1001)
|
||||
public abstract class DataWatcherMixin {
|
||||
@ModifyConstant(method = {"addObject", "writeWatchedListToPacketBuffer", "func_151509_a",
|
||||
"writeWatchableObjectToPacketBuffer"},
|
||||
@ModifyConstant(method = {"addObject", "func_151509_a"},
|
||||
constant = @Constant(intValue = VanillaConstants.maxWatchableID),
|
||||
require = 3)
|
||||
private static int extend1(int constant) {
|
||||
require = 2)
|
||||
private int extend1d(int constant) {
|
||||
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
|
||||
* @reason Direct port from dumped code
|
||||
* @reason Extend IDs
|
||||
*/
|
||||
@Overwrite
|
||||
public static List<DataWatcher.WatchableObject> readWatchedListFromPacketBuffer(PacketBuffer packet)
|
||||
throws IOException {
|
||||
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) {
|
||||
watchables = new ArrayList<>();
|
||||
}
|
||||
|
||||
int flag = (id >> ExtendedConstants.watchableBits) & 0x7;
|
||||
int watchableID = id & ExtendedConstants.maxWatchableID;
|
||||
boolean shortID = (type & 0x80) != 0;
|
||||
type &= 0x7F;
|
||||
int id = shortID
|
||||
? packet.readShort() & 0xFFFF
|
||||
: packet.readByte() & 0xFF;
|
||||
DataWatcher.WatchableObject watchable = null;
|
||||
switch (flag) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readByte());
|
||||
watchable = new DataWatcher.WatchableObject(type, id, packet.readByte());
|
||||
break;
|
||||
case 1:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readShort());
|
||||
watchable = new DataWatcher.WatchableObject(type, id, packet.readShort());
|
||||
break;
|
||||
case 2:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readInt());
|
||||
watchable = new DataWatcher.WatchableObject(type, id, packet.readInt());
|
||||
break;
|
||||
case 3:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readFloat());
|
||||
watchable = new DataWatcher.WatchableObject(type, id, packet.readFloat());
|
||||
break;
|
||||
case 4:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readStringFromBuffer(32767));
|
||||
boolean present = packet.readBoolean();
|
||||
watchable = new DataWatcher.WatchableObject(type, id, present ? packet.readStringFromBuffer(32767) : null);
|
||||
break;
|
||||
case 5:
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, packet.readItemStackFromBuffer());
|
||||
watchable = new DataWatcher.WatchableObject(type, id, packet.readItemStackFromBuffer());
|
||||
break;
|
||||
case 6:
|
||||
int x = packet.readInt();
|
||||
int y = packet.readInt();
|
||||
int z = packet.readInt();
|
||||
watchable = new DataWatcher.WatchableObject(flag, watchableID, new ChunkCoordinates(x, y, z));
|
||||
ChunkCoordinates coords = null;
|
||||
if (packet.readBoolean()) {
|
||||
int x = packet.readInt();
|
||||
int y = packet.readInt();
|
||||
int z = packet.readInt();
|
||||
coords = new ChunkCoordinates(x, y, z);
|
||||
}
|
||||
watchable = new DataWatcher.WatchableObject(type, id, coords);
|
||||
}
|
||||
|
||||
watchables.add(watchable);
|
||||
@@ -100,4 +91,66 @@ public abstract class DataWatcherMixin {
|
||||
|
||||
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:
|
||||
val obj = (String) watcher.getObject();
|
||||
if (obj == null) {
|
||||
buf.writeBoolean(false);
|
||||
} else {
|
||||
buf.writeBoolean(true);
|
||||
buf.writeStringToBuffer(obj);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
ItemStack itemstack = (ItemStack) watcher.getObject();
|
||||
buf.writeItemStackToBuffer(itemstack);
|
||||
break;
|
||||
case 6:
|
||||
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) watcher.getObject();
|
||||
if (chunkcoordinates == null) {
|
||||
buf.writeBoolean(false);
|
||||
} else {
|
||||
buf.writeBoolean(true);
|
||||
buf.writeInt(chunkcoordinates.posX);
|
||||
buf.writeInt(chunkcoordinates.posY);
|
||||
buf.writeInt(chunkcoordinates.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
|
||||
|
||||
@Mixin(EntityList.class)
|
||||
public abstract class EntityListMixin {
|
||||
|
||||
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
|
||||
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
||||
require = 1)
|
||||
private static int extendRange(int constant) {
|
||||
return ExtendedConstants.maxEntityID;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
@Mixin(value = EntityRegistry.class,
|
||||
remap = false)
|
||||
public abstract class EntityRegistryMixin {
|
||||
@Shadow private BitSet availableIndicies;
|
||||
|
||||
@ModifyConstant(method = "<init>",
|
||||
constant = @Constant(intValue = VanillaConstants.entityIDCount),
|
||||
require = 1)
|
||||
private int extendIDs1(int constant) {
|
||||
return ExtendedConstants.entityIDCount;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "<init>",
|
||||
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
||||
require = 1)
|
||||
private int extendIDs2(int constant) {
|
||||
return ExtendedConstants.maxEntityID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Extended IDs
|
||||
*/
|
||||
@Overwrite
|
||||
private int validateAndClaimId(int id) {
|
||||
//Keeping the legacy sub-0 id workaround here...
|
||||
|
||||
// workaround for broken ML
|
||||
int realId = id;
|
||||
if (id < Byte.MIN_VALUE) {
|
||||
realId += 3000;
|
||||
FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId);
|
||||
}
|
||||
|
||||
if (realId < 0) {
|
||||
realId += Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
if ((realId & ~ExtendedConstants.entityIDMask) != 0) {
|
||||
FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not in the range 1-" + ExtendedConstants.entityIDMask + " and may not work", id, Loader.instance().activeModContainer().getModId());
|
||||
}
|
||||
|
||||
if (!availableIndicies.get(realId)) {
|
||||
FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id);
|
||||
}
|
||||
availableIndicies.clear(realId);
|
||||
return realId;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S0FPacketSpawnMob;
|
||||
|
||||
@Mixin(S0FPacketSpawnMob.class)
|
||||
public abstract class S0FPacketSpawnMobMixin {
|
||||
@Shadow private int field_149040_b;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/entity/EntityLivingBase;)V",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void unClampType(EntityLivingBase entity, CallbackInfo ci) {
|
||||
field_149040_b = EntityList.getEntityID(entity);
|
||||
}
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private byte noReadByte(PacketBuffer data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private void readType(PacketBuffer data, CallbackInfo ci) {
|
||||
field_149040_b = data.readShort() & ExtendedConstants.entityIDMask;
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private ByteBuf noWriteByte(PacketBuffer data, int theByte) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private void writeType(PacketBuffer data, CallbackInfo ci) {
|
||||
data.writeShort(field_149040_b & ExtendedConstants.entityIDMask);
|
||||
}
|
||||
}
|
||||
@@ -123,8 +123,10 @@ public enum Mixin implements IMixin {
|
||||
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"),
|
||||
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"),
|
||||
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
|
||||
//region NaturesCompass
|
||||
NaturesCompassBiomeUtilsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.NATURESCOMPASS)), "biome.naturescompass.BiomeUtilsMixin"),
|
||||
@@ -135,6 +137,9 @@ public enum Mixin implements IMixin {
|
||||
//region NomadicTents
|
||||
NomadicTentsTentChunkProviderMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.NOMADICTENTS)), "biome.nomadictents.TentChunkProviderMixin"),
|
||||
//endregion NomadicTents
|
||||
//region OWG
|
||||
OWGChunkGeneratorBetaMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.OWG)), "biome.owg.ChunkGeneratorBetaMixin"),
|
||||
//endregion OWG
|
||||
//region RandomThings
|
||||
ItemBiomePainterMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.ItemBiomePainterMixin"),
|
||||
MessagePaintBiomeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.RANDOMTHINGS)), "biome.randomthings.MessagePaintBiomeMixin"),
|
||||
@@ -154,6 +159,9 @@ public enum Mixin implements IMixin {
|
||||
//region Thaumcraft
|
||||
ThaumcraftUtilsMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.THAUMCRAFT)), "biome.thaumcraft.UtilsMixin"),
|
||||
//endregion Thaumcraft
|
||||
//region ThutCore
|
||||
ThutVector3Mixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.THUTCORE)), "biome.thut.Vector3Mixin"),
|
||||
//endregion ThutCore
|
||||
//region Tropicraft
|
||||
GenLayerTropiVoronoiZoomMixin(Side.COMMON, condition(() -> GeneralConfig.extendBiome).and(require(TargetedMod.TROPICRAFT)), "biome.tropicraft.GenLayerTropiVoronoiZoomMixin"),
|
||||
//endregion Tropicraft
|
||||
@@ -167,6 +175,7 @@ public enum Mixin implements IMixin {
|
||||
//region blockitem
|
||||
//region vanilla
|
||||
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"),
|
||||
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
|
||||
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
|
||||
@@ -183,6 +192,10 @@ public enum Mixin implements IMixin {
|
||||
DragonAPIBlockPropertiesMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.BlockPropertiesMixin"),
|
||||
DragonAPIBlockItemIDTypeMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.DRAGONAPI)), "blockitem.dragonapi.IDTypeMixin"),
|
||||
//endregion DragonAPI
|
||||
//region Matter Overdrive
|
||||
MOInventoryMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.InventoryMixin"),
|
||||
MOItemPatternMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MATTEROVERDRIVE)), "blockitem.matteroverdrive.ItemPatternMixin"),
|
||||
//endregion Matter Overdrive
|
||||
//region MFQM
|
||||
MFQMMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem).and(require(TargetedMod.MFQM)), "blockitem.mfqm.MFQMMixin"),
|
||||
//endregion MFQM
|
||||
@@ -215,6 +228,13 @@ public enum Mixin implements IMixin {
|
||||
S1EPacketRemoveEntityEffectMixin(Side.COMMON, condition(() -> GeneralConfig.extendPotion), "potion.vanilla.network.S1EPacketRemoveEntityEffectMixin"),
|
||||
//endregion vanilla
|
||||
//endregion potion
|
||||
//region entity
|
||||
//region vanilla
|
||||
EntityListMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityListMixin"),
|
||||
EntityRegistryMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityRegistryMixin"),
|
||||
S0FPacketSpawnMobMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.S0FPacketSpawnMobMixin"),
|
||||
//endregion vanilla
|
||||
//endregion entity
|
||||
//endregion common
|
||||
|
||||
//region client
|
||||
|
||||
@@ -37,15 +37,18 @@ public enum TargetedMod implements ITargetedMod {
|
||||
ICG("Immersive Cavegen", false, startsWith("immersivecavegen")),
|
||||
IR3("Industrial Revolution by Redstone Rebooted", false, startsWith("industrialrevolutionbyredstonerebooted-")),
|
||||
LOTR("LOTR Mod", false, startsWith("lotrmod")),
|
||||
MATTEROVERDRIVE("Matter Overdrive", false, startsWith("matteroverdrive-")),
|
||||
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
|
||||
NATURESCOMPASS("Nature's Compass", false, startsWith("naturescompass")),
|
||||
NETHERLICIOUS("Netherlicious", false, startsWith("netherlicious-")),
|
||||
NOMADICTENTS("Nomadic Tents", false, startsWith("nomadictents")),
|
||||
OWG("Nostalgic world generation", false, startsWith("owg-").or(startsWith("nostalgiagenerator-"))),
|
||||
RANDOMTHINGS("Random Things", false, startsWith("randomthings-")),
|
||||
RESTRUCTURED("Restructured", false, startsWith("restructured-")),
|
||||
RTG("Realistic Terrain Generation", false, startsWith("rtg-")),
|
||||
RWG("Realistic World Gen", false, startsWith("rwg-")),
|
||||
THAUMCRAFT("Thaumcraft", false, startsWith("thaumcraft")),
|
||||
THUTCORE("ThutCore", false, startsWith("thutcore-").or(startsWith("thutmods-"))),
|
||||
TROPICRAFT("Tropicraft", false, startsWith("tropicraft-")),
|
||||
TWILIGHTFOREST("Twilight Forest", false, startsWith("twilightforest")),
|
||||
UBC("Underground Biomes Constructs", false, startsWith("undergroundbiomesconstructs-")),
|
||||
|
||||
-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,48 @@
|
||||
package com.falsepattern.endlessids.util;
|
||||
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.falsepattern.endlessids.constants.ExtendedConstants.blocksPerSubChunk;
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_INT;
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_SHORT;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static int readIDFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("idExt", TAG_INT))
|
||||
return nbt.getInteger("idExt");
|
||||
else if (nbt.hasKey("id", TAG_INT))
|
||||
return nbt.getInteger("id");
|
||||
else if (nbt.hasKey("id", TAG_SHORT))
|
||||
return nbt.getShort("id");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void writeIDToNBT(NBTTagCompound nbt, int id) {
|
||||
if (id > VanillaConstants.maxItemID) {
|
||||
nbt.setShort("id", (short)0);
|
||||
nbt.setInteger("idExt", id);
|
||||
} else {
|
||||
nbt.setShort("id", (short) id);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean nbtHasID(NBTTagCompound nbt) {
|
||||
return nbt.hasKey("id", TAG_INT) || nbt.hasKey("idExt", TAG_INT) || nbt.hasKey("id", TAG_SHORT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.falsepattern.endlessids.util;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Like WeakHashMap, but uses identity instead of equality when comparing keys.
|
||||
*/
|
||||
public class WeakIdentityHashMap<K,V> {
|
||||
private final HashMap<WeakReference<K>,V> mMap = new HashMap<>();
|
||||
private final ReferenceQueue<Object> mRefQueue = new ReferenceQueue<>();
|
||||
private void cleanUp() {
|
||||
Reference<?> ref;
|
||||
while ((ref = mRefQueue.poll()) != null) {
|
||||
mMap.remove(ref);
|
||||
}
|
||||
}
|
||||
public void put(K key, V value) {
|
||||
cleanUp();
|
||||
mMap.put(new CmpWeakReference<>(key, mRefQueue), value);
|
||||
}
|
||||
public V get(K key) {
|
||||
cleanUp();
|
||||
return mMap.get(new CmpWeakReference<>(key));
|
||||
}
|
||||
public Collection<V> values() {
|
||||
cleanUp();
|
||||
return mMap.values();
|
||||
}
|
||||
public Set<Map.Entry<WeakReference<K>, V>> entrySet() {
|
||||
return mMap.entrySet();
|
||||
}
|
||||
public int size() {
|
||||
cleanUp();
|
||||
return mMap.size();
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
cleanUp();
|
||||
return mMap.isEmpty();
|
||||
}
|
||||
private static class CmpWeakReference<K> extends WeakReference<K> {
|
||||
private final int mHashCode;
|
||||
public CmpWeakReference(K key) {
|
||||
super(key);
|
||||
mHashCode = System.identityHashCode(key);
|
||||
}
|
||||
public CmpWeakReference(K key, ReferenceQueue<Object> refQueue) {
|
||||
super(key, refQueue);
|
||||
mHashCode = System.identityHashCode(key);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
K k = get();
|
||||
if (k != null && o instanceof CmpWeakReference) {
|
||||
return ((CmpWeakReference) o).get() == k;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mHashCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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