mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf0743435e |
No files matched your search
+21
-18
@@ -1,4 +1,4 @@
|
|||||||
//version: 1704751096
|
//version: 1701530445
|
||||||
/*
|
/*
|
||||||
DO NOT CHANGE THIS FILE!
|
DO NOT CHANGE THIS FILE!
|
||||||
Also, you may replace this file at any time if there is an update available.
|
Also, you may replace this file at any time if there is an update available.
|
||||||
@@ -31,7 +31,8 @@ buildscript {
|
|||||||
maven {
|
maven {
|
||||||
// GTNH RetroFuturaGradle and ASM Fork
|
// GTNH RetroFuturaGradle and ASM Fork
|
||||||
name "GTNH Maven"
|
name "GTNH Maven"
|
||||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||||
|
allowInsecureProtocol = true
|
||||||
}
|
}
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
@@ -48,12 +49,12 @@ plugins {
|
|||||||
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
|
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||||
id 'com.palantir.git-version' version '3.0.0' apply false
|
id 'com.palantir.git-version' version '3.0.0' apply false
|
||||||
id 'de.undercouch.download' version '5.5.0'
|
id 'de.undercouch.download' version '5.4.0'
|
||||||
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
|
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
|
||||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27'
|
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
|
||||||
}
|
}
|
||||||
|
|
||||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||||
@@ -117,7 +118,7 @@ propertyDefaultIfUnset("forceEnableMixins", false)
|
|||||||
propertyDefaultIfUnset("channel", "stable")
|
propertyDefaultIfUnset("channel", "stable")
|
||||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||||
propertyDefaultIfUnset("mavenPublishUrl", "https://nexus.gtnewhorizons.com/repository/releases/")
|
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
||||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||||
propertyDefaultIfUnset("modrinthRelations", "")
|
propertyDefaultIfUnset("modrinthRelations", "")
|
||||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||||
@@ -571,17 +572,15 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
|
||||||
name = "GTNH Maven"
|
|
||||||
url = "https://nexus.gtnewhorizons.com/repository/public/"
|
|
||||||
// Links for convenience:
|
|
||||||
// Simple HTML browsing: https://nexus.gtnewhorizons.com/service/rest/repository/browse/releases/
|
|
||||||
// Rich web UI browsing: https://nexus.gtnewhorizons.com/#browse/browse:releases
|
|
||||||
}
|
|
||||||
maven {
|
maven {
|
||||||
name 'Overmind forge repo mirror'
|
name 'Overmind forge repo mirror'
|
||||||
url 'https://gregtech.overminddl1.com/'
|
url 'https://gregtech.overminddl1.com/'
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = "GTNH Maven"
|
||||||
|
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
name 'sonatype'
|
name 'sonatype'
|
||||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||||
@@ -614,7 +613,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "ic2"
|
name = "ic2"
|
||||||
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
|
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
|
||||||
content {
|
content {
|
||||||
includeGroup "net.industrial-craft"
|
includeGroup "net.industrial-craft"
|
||||||
}
|
}
|
||||||
@@ -673,8 +672,6 @@ configurations.all {
|
|||||||
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||||
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||||
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
||||||
|
|
||||||
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,7 +783,7 @@ dependencies {
|
|||||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||||
}
|
}
|
||||||
if (modId != 'hodgepodge') {
|
if (modId != 'hodgepodge') {
|
||||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.4')
|
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
|
||||||
}
|
}
|
||||||
|
|
||||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||||
@@ -961,7 +958,8 @@ if (usesShadowedDependencies.toBoolean()) {
|
|||||||
configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||||
configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||||
tasks.named("jar", Jar) {
|
tasks.named("jar", Jar) {
|
||||||
archiveClassifier.set('dev-preshadow')
|
enabled = false
|
||||||
|
finalizedBy(tasks.shadowJar)
|
||||||
}
|
}
|
||||||
tasks.named("reobfJar", ReobfuscatedJar) {
|
tasks.named("reobfJar", ReobfuscatedJar) {
|
||||||
inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile}))
|
inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile}))
|
||||||
@@ -970,6 +968,11 @@ if (usesShadowedDependencies.toBoolean()) {
|
|||||||
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
|
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
|
||||||
skip()
|
skip()
|
||||||
}
|
}
|
||||||
|
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
|
||||||
|
tasks.named(runTask).configure {
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar
|
ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar
|
||||||
ext.publishableObfJar = tasks.reobfJar
|
ext.publishableObfJar = tasks.reobfJar
|
||||||
@@ -1173,7 +1176,7 @@ publishing {
|
|||||||
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
||||||
maven {
|
maven {
|
||||||
url = mavenPublishUrl
|
url = mavenPublishUrl
|
||||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://")
|
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
|
||||||
credentials {
|
credentials {
|
||||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||||
|
|||||||
+38
-2
@@ -1,4 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Add your dependencies here. Supported configurations:
|
||||||
|
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
|
||||||
|
* Available at runtime and compiletime for mods depending on this mod
|
||||||
|
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
|
||||||
|
* Available at runtime but not compiletime for mods depending on this mod
|
||||||
|
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
|
||||||
|
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
|
||||||
|
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
|
||||||
|
* Available at compiletime but not runtime for mods depending on this mod
|
||||||
|
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
|
||||||
|
* Not available at all for mods depending on this mod, only visible at runtime for this mod
|
||||||
|
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
|
||||||
|
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
|
||||||
|
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
|
||||||
|
* Available at runtime for mods depending on this mod
|
||||||
|
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
|
||||||
|
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
|
||||||
|
*
|
||||||
|
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
|
||||||
|
* Requires you to enable usesShadowedDependencies in gradle.properties
|
||||||
|
*
|
||||||
|
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
|
||||||
|
*
|
||||||
|
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
|
||||||
|
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
|
||||||
|
*
|
||||||
|
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
|
||||||
|
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
|
||||||
|
*
|
||||||
|
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
|
||||||
|
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
|
||||||
|
*
|
||||||
|
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
|
||||||
|
*/
|
||||||
dependencies {
|
dependencies {
|
||||||
api('com.github.GTNewHorizons:NotEnoughIds:1.5.4-pre:dev')
|
// api("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||||
|
// api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.104:dev')
|
||||||
|
api('com.github.GTNewHorizons:NotEnoughIds:1.5.3:dev')
|
||||||
}
|
}
|
||||||
+1
@@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// Add any additional repositories for your dependencies here
|
// Add any additional repositories for your dependencies here
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
|
||||||
}
|
}
|
||||||
@@ -2,31 +2,30 @@ package com.colen.postea.API;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import com.colen.postea.Utility.BlockConversionInfo;
|
import com.colen.postea.Utility.BlockConversionInfo;
|
||||||
|
|
||||||
public class BlockReplacementManager {
|
public class BlockReplacementManager {
|
||||||
|
|
||||||
private static final Map<String, BiFunction<BlockConversionInfo, World, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
|
private static final Map<String, Function<BlockConversionInfo, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static void addBlockReplacement(String blockNameIn,
|
public static void addBlockReplacement(String blockNameIn,
|
||||||
BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer) {
|
Function<BlockConversionInfo, BlockConversionInfo> transformer) {
|
||||||
blockReplacementMap.put(blockNameIn, transformer);
|
blockReplacementMap.put(blockNameIn, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo, World world) {
|
@SuppressWarnings("unused")
|
||||||
|
public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo) {
|
||||||
|
|
||||||
BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer = blockReplacementMap
|
Function<BlockConversionInfo, BlockConversionInfo> transformer = blockReplacementMap
|
||||||
.getOrDefault(blockConversionInfo.blockName, null);
|
.getOrDefault(blockConversionInfo.blocKName, null);
|
||||||
|
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return transformer.apply(blockConversionInfo, world);
|
return transformer.apply(blockConversionInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
package com.colen.postea;
|
package com.colen.postea;
|
||||||
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.colen.postea.checker.PosteaProcessedChunksWorldSavedData;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
|
import com.colen.postea.API.BlockReplacementManager;
|
||||||
|
import com.colen.postea.Utility.BlockConversionInfo;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]")
|
@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]")
|
||||||
@@ -13,7 +19,50 @@ public class Postea {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
MinecraftForge.EVENT_BUS.register(new PosteaProcessedChunksWorldSavedData(""));
|
|
||||||
|
ModContainer activeMod = Loader.instance()
|
||||||
|
.activeModContainer();
|
||||||
|
String modID = activeMod.getModId();
|
||||||
|
String v = activeMod.getVersion();
|
||||||
|
|
||||||
|
Function<BlockConversionInfo, BlockConversionInfo> blockTransformer = (blockConversionInfoOld) -> {
|
||||||
|
|
||||||
|
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
|
||||||
|
|
||||||
|
if ((blockConversionInfoOld.x == -1) && (blockConversionInfoOld.y == 3)
|
||||||
|
&& (blockConversionInfoOld.z == -1)) {
|
||||||
|
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
|
||||||
|
blockConversionInfoNew.metadata = 1;
|
||||||
|
return blockConversionInfoNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((blockConversionInfoOld.x == -1) && (blockConversionInfoOld.y == 3)
|
||||||
|
&& (blockConversionInfoOld.z == 1)) {
|
||||||
|
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
|
||||||
|
blockConversionInfoNew.metadata = 1;
|
||||||
|
return blockConversionInfoNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((blockConversionInfoOld.x == 1) && (blockConversionInfoOld.y == 3) && (blockConversionInfoOld.z == 1)) {
|
||||||
|
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
|
||||||
|
blockConversionInfoNew.metadata = 1;
|
||||||
|
return blockConversionInfoNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((blockConversionInfoOld.x == 1) && (blockConversionInfoOld.y == 3)
|
||||||
|
&& (blockConversionInfoOld.z == -1)) {
|
||||||
|
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
|
||||||
|
blockConversionInfoNew.metadata = 1;
|
||||||
|
return blockConversionInfoNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockConversionInfoNew.blockID = blockConversionInfoOld.blockID;
|
||||||
|
blockConversionInfoNew.metadata = blockConversionInfoOld.metadata;
|
||||||
|
|
||||||
|
return blockConversionInfoNew;
|
||||||
|
};
|
||||||
|
|
||||||
|
BlockReplacementManager.addBlockReplacement("minecraft:grass", blockTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,5 +15,5 @@ public final class BlockConversionInfo {
|
|||||||
public World world;
|
public World world;
|
||||||
public NBTTagCompound tileEntityNBT;
|
public NBTTagCompound tileEntityNBT;
|
||||||
|
|
||||||
public String blockName;
|
public String blocKName;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,6 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import com.colen.postea.API.BlockReplacementManager;
|
import com.colen.postea.API.BlockReplacementManager;
|
||||||
import com.colen.postea.API.TileEntityReplacementManager;
|
import com.colen.postea.API.TileEntityReplacementManager;
|
||||||
import com.colen.postea.checker.PosteaProcessedChunksWorldSavedData;
|
|
||||||
|
|
||||||
import akka.japi.Pair;
|
import akka.japi.Pair;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
@@ -20,57 +19,47 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||||||
public class ChunkFixerUtility {
|
public class ChunkFixerUtility {
|
||||||
|
|
||||||
public static void processChunkNBT(NBTTagCompound compound, World world) {
|
public static void processChunkNBT(NBTTagCompound compound, World world) {
|
||||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
transformTileEntities(compound, world);
|
||||||
int x = level.getInteger("xPos");
|
transformNormalBlocks(compound, world);
|
||||||
int z = level.getInteger("zPos");
|
|
||||||
|
|
||||||
if (PosteaProcessedChunksWorldSavedData.addChunk(x, z)) {
|
|
||||||
transformTileEntities(compound, world);
|
|
||||||
transformNormalBlocks(compound, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void transformNormalBlocks(NBTTagCompound compound, World world) {
|
private static void transformNormalBlocks(NBTTagCompound compound, World world) {
|
||||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
NBTTagCompound level = compound.getCompoundTag("Level");
|
||||||
NBTTagList sections = level.getTagList("Sections", 10);
|
NBTTagList sections = level.getTagList("Sections", 10);
|
||||||
|
|
||||||
int chunkXPos = level.getInteger("xPos") * 16;
|
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
|
||||||
int chunkZPos = level.getInteger("zPos") * 16;
|
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
||||||
|
|
||||||
for (int i = 0; i < sections.tagCount(); i++) {
|
for (int i = 0; i < sections.tagCount(); i++) {
|
||||||
NBTTagCompound section = sections.getCompoundTagAt(i);
|
NBTTagCompound section = sections.getCompoundTagAt(i);
|
||||||
|
|
||||||
// Blocks16 and Data16 exist only because of NEID.
|
|
||||||
byte[] blockArray = section.getByteArray("Blocks16");
|
byte[] blockArray = section.getByteArray("Blocks16");
|
||||||
byte[] metadataArray = section.getByteArray("Data16");
|
byte[] metadataArray = section.getByteArray("Data");
|
||||||
|
|
||||||
byte sectionY = section.getByte("Y");
|
byte sectionY = section.getByte("Y");
|
||||||
|
|
||||||
for (int index = 0; index < blockArray.length / 2; index++) {
|
for (int index = 0; index < blockArray.length / 2; index++) {
|
||||||
int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF);
|
int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF);
|
||||||
int metadata = ((metadataArray[index * 2] & 0xFF) << 8) | (metadataArray[index * 2 + 1] & 0xFF);
|
byte metadata = (byte) ((index & 1) == 0 ? (metadataArray[index / 2] & 0x0F)
|
||||||
|
: ((metadataArray[index / 2] & 0xF0) >> 4));
|
||||||
|
|
||||||
Block block = Block.getBlockById(blockId);
|
Block block = Block.getBlockById(blockId);
|
||||||
String blockName = GameRegistry.findUniqueIdentifierFor(block)
|
String blockName = GameRegistry.findUniqueIdentifierFor(block)
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
|
BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
|
||||||
blockConversionInfo.blockName = blockName;
|
blockConversionInfo.blocKName = blockName;
|
||||||
blockConversionInfo.blockID = blockId;
|
blockConversionInfo.blockID = blockId;
|
||||||
blockConversionInfo.metadata = (byte) metadata; // Updated
|
blockConversionInfo.metadata = metadata;
|
||||||
blockConversionInfo.world = world;
|
blockConversionInfo.world = world;
|
||||||
|
|
||||||
int x = index % 16;
|
int x = index % 16;
|
||||||
int y = (index / 256) + (sectionY * 16);
|
int y = (index / 256) + (sectionY * 16); // Add the offset of the current section in Y direction
|
||||||
int z = (index / 16) % 16;
|
int z = (index / 16) % 16;
|
||||||
|
|
||||||
blockConversionInfo.x = x + chunkXPos + 1;
|
blockConversionInfo.x = x + chunkXPos + 1;
|
||||||
blockConversionInfo.y = y;
|
blockConversionInfo.y = y; // Y remains unchanged as it's already global
|
||||||
blockConversionInfo.z = z + chunkZPos + 1;
|
blockConversionInfo.z = z + chunkZPos + 1;
|
||||||
|
|
||||||
BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo, world);
|
BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo);
|
||||||
|
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
int newBlockId = output.blockID;
|
int newBlockId = output.blockID;
|
||||||
int newMetadata = output.metadata;
|
int newMetadata = output.metadata;
|
||||||
@@ -78,8 +67,13 @@ public class ChunkFixerUtility {
|
|||||||
blockArray[index * 2] = (byte) ((newBlockId >> 8) & 0xFF);
|
blockArray[index * 2] = (byte) ((newBlockId >> 8) & 0xFF);
|
||||||
blockArray[index * 2 + 1] = (byte) (newBlockId & 0xFF);
|
blockArray[index * 2 + 1] = (byte) (newBlockId & 0xFF);
|
||||||
|
|
||||||
metadataArray[index * 2] = (byte) ((newMetadata >> 8) & 0xFF);
|
if ((index & 1) == 0) { // Even
|
||||||
metadataArray[index * 2 + 1] = (byte) (newMetadata & 0xFF);
|
metadataArray[index / 2] &= 0xF0;
|
||||||
|
metadataArray[index / 2] |= (newMetadata & 0x0F);
|
||||||
|
} else { // Odd
|
||||||
|
metadataArray[index / 2] &= 0x0F;
|
||||||
|
metadataArray[index / 2] |= ((newMetadata << 4) & 0xF0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,7 +103,7 @@ public class ChunkFixerUtility {
|
|||||||
private static void processSection(NBTTagCompound section, List<ConversionInfo> conversionInfoList, int chunkXPos,
|
private static void processSection(NBTTagCompound section, List<ConversionInfo> conversionInfoList, int chunkXPos,
|
||||||
int chunkZPos) {
|
int chunkZPos) {
|
||||||
byte[] blockArray = section.getByteArray("Blocks16");
|
byte[] blockArray = section.getByteArray("Blocks16");
|
||||||
byte[] metadataArray = section.getByteArray("Data16"); // Updated to use Data16
|
byte[] metadataArray = section.getByteArray("Data");
|
||||||
byte y = section.getByte("Y");
|
byte y = section.getByte("Y");
|
||||||
|
|
||||||
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
||||||
@@ -118,7 +112,7 @@ public class ChunkFixerUtility {
|
|||||||
int[] localCoords = convertToChunkLocalCoordinates(info, y, chunkXPos, chunkZPos);
|
int[] localCoords = convertToChunkLocalCoordinates(info, y, chunkXPos, chunkZPos);
|
||||||
int index = computeBlockIndex(localCoords);
|
int index = computeBlockIndex(localCoords);
|
||||||
setBlockInfo(info.blockInfo.block, index, blockArray);
|
setBlockInfo(info.blockInfo.block, index, blockArray);
|
||||||
setMetadata(info.blockInfo.metadata, index, metadataArray); // This uses the updated setMetadata
|
setMetadata(info.blockInfo.metadata, index, metadataArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +140,18 @@ public class ChunkFixerUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setMetadata(int metadata, int index, byte[] metadataArray) {
|
private static void setMetadata(int metadata, int index, byte[] metadataArray) {
|
||||||
// Since each metadata is now two bytes, multiply the index by 2 to get the correct position.
|
int metadataIndex = index / 2;
|
||||||
int metadataStartIndex = index * 2;
|
byte currentMetadataByte = metadataArray[metadataIndex];
|
||||||
|
|
||||||
// Split the 16-bit metadata into two bytes and store them in the array.
|
if ((index & 1) == 0) { // Even
|
||||||
metadataArray[metadataStartIndex] = (byte) ((metadata >> 8) & 0xFF); // Higher 8 bits
|
currentMetadataByte &= 0xF0;
|
||||||
metadataArray[metadataStartIndex + 1] = (byte) (metadata & 0xFF); // Lower 8 bits
|
currentMetadataByte |= (metadata & 0x0F);
|
||||||
|
} else { // Odd
|
||||||
|
currentMetadataByte &= 0x0F;
|
||||||
|
currentMetadataByte |= ((metadata << 4) & 0xF0);
|
||||||
|
}
|
||||||
|
|
||||||
|
metadataArray[metadataIndex] = currentMetadataByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pair<List<ConversionInfo>, NBTTagList> adjustTileEntities(NBTTagList tileEntities, World world) {
|
private static Pair<List<ConversionInfo>, NBTTagList> adjustTileEntities(NBTTagList tileEntities, World world) {
|
||||||
@@ -179,8 +179,6 @@ public class ChunkFixerUtility {
|
|||||||
} // Otherwise they are removed, therefore not appended.
|
} // Otherwise they are removed, therefore not appended.
|
||||||
|
|
||||||
conversionInfo.add(new ConversionInfo(x, y, z, blockInfo));
|
conversionInfo.add(new ConversionInfo(x, y, z, blockInfo));
|
||||||
} else {
|
|
||||||
tileEntitiesCopy.appendTag(tileEntity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
package com.colen.postea.Utility;
|
package com.colen.postea.Utility;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import cpw.mods.fml.common.ModContainer;
|
|
||||||
|
|
||||||
public abstract class PosteaUtilities {
|
public abstract class PosteaUtilities {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -28,29 +21,4 @@ public abstract class PosteaUtilities {
|
|||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getModListHash() {
|
|
||||||
|
|
||||||
// We iterate over every mod, get its version and put it into a giant list.
|
|
||||||
// This is done so we can see if our mods have actually changed, if so, we
|
|
||||||
// will recheck every chunk for Postea adjustments.
|
|
||||||
|
|
||||||
ArrayList<String> modList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ModContainer mod : Loader.instance()
|
|
||||||
.getActiveModList()) {
|
|
||||||
modList.add(mod.getModId() + ":" + mod.getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort this first.
|
|
||||||
Collections.sort(modList);
|
|
||||||
|
|
||||||
// Step 2: Append all elements into one string
|
|
||||||
StringBuilder combinedModStringSorted = new StringBuilder();
|
|
||||||
for (String element : modList) {
|
|
||||||
combinedModStringSorted.append(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Objects.hash(combinedModStringSorted);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package com.colen.postea.checker;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldSavedData;
|
|
||||||
import net.minecraft.world.storage.MapStorage;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
|
||||||
|
|
||||||
import akka.japi.Pair;
|
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
|
|
||||||
public class PosteaProcessedChunksWorldSavedData extends WorldSavedData {
|
|
||||||
|
|
||||||
private static final String DATA_NAME = "GregTech_GlobalIntValue";
|
|
||||||
public static HashSet<Pair<Integer, Integer>> chunkCoordinates = new HashSet<>();
|
|
||||||
public static PosteaProcessedChunksWorldSavedData INSTANCE;
|
|
||||||
|
|
||||||
// True if chunk has not been processed, else false.
|
|
||||||
public static boolean addChunk(int x, int z) {
|
|
||||||
boolean updateChunk = chunkCoordinates.add(new Pair<>(x, z));
|
|
||||||
|
|
||||||
if (updateChunk) {
|
|
||||||
// Only mark the world NBT as dirty if we actually process a new chunk, since we will need to save that
|
|
||||||
// info.
|
|
||||||
INSTANCE.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateChunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PosteaProcessedChunksWorldSavedData() {
|
|
||||||
super(DATA_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PosteaProcessedChunksWorldSavedData(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
|
||||||
try {
|
|
||||||
byte[] ba = nbtTagCompound.getByteArray(DATA_NAME);
|
|
||||||
InputStream byteArrayInputStream = new ByteArrayInputStream(ba);
|
|
||||||
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
|
|
||||||
Object data = objectInputStream.readObject();
|
|
||||||
chunkCoordinates = (HashSet<Pair<Integer, Integer>>) data;
|
|
||||||
} catch (IOException | ClassNotFoundException exception) {
|
|
||||||
System.out.println(DATA_NAME + " FAILED");
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
|
||||||
// Write the integer value to NBT
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
||||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
|
||||||
objectOutputStream.writeObject(chunkCoordinates);
|
|
||||||
objectOutputStream.flush();
|
|
||||||
byte[] data = byteArrayOutputStream.toByteArray();
|
|
||||||
nbtTagCompound.setByteArray(DATA_NAME, data);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
System.out.println(DATA_NAME + " SAVE FAILED");
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void get(World world) {
|
|
||||||
|
|
||||||
chunkCoordinates.clear();
|
|
||||||
|
|
||||||
MapStorage storage = world.mapStorage;
|
|
||||||
INSTANCE = (PosteaProcessedChunksWorldSavedData) storage
|
|
||||||
.loadData(PosteaProcessedChunksWorldSavedData.class, DATA_NAME);
|
|
||||||
|
|
||||||
if (INSTANCE == null) {
|
|
||||||
INSTANCE = new PosteaProcessedChunksWorldSavedData();
|
|
||||||
storage.setData(DATA_NAME, INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register event in a static block to ensure it's done as early as possible
|
|
||||||
static {
|
|
||||||
MinecraftForge.EVENT_BUS.register(new PosteaProcessedChunksWorldSavedData());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
|
||||||
public void onWorldLoad(WorldEvent.Load event) {
|
|
||||||
if (!event.world.isRemote && event.world.provider.dimensionId == 0) {
|
|
||||||
get(event.world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user