mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32b04a0408 | ||
|
|
06350f82ac | ||
|
|
f693ca75b9 |
No files matched your search
+15
-20
@@ -1,4 +1,4 @@
|
|||||||
//version: 1702141377
|
//version: 1704751096
|
||||||
/*
|
/*
|
||||||
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,8 +31,7 @@ buildscript {
|
|||||||
maven {
|
maven {
|
||||||
// GTNH RetroFuturaGradle and ASM Fork
|
// GTNH RetroFuturaGradle and ASM Fork
|
||||||
name "GTNH Maven"
|
name "GTNH Maven"
|
||||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||||
allowInsecureProtocol = true
|
|
||||||
}
|
}
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
@@ -49,12 +48,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.4.0'
|
id 'de.undercouch.download' version '5.5.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.26'
|
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27'
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
@@ -118,7 +117,7 @@ propertyDefaultIfUnset("forceEnableMixins", false)
|
|||||||
propertyDefaultIfUnset("channel", "stable")
|
propertyDefaultIfUnset("channel", "stable")
|
||||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||||
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
propertyDefaultIfUnset("mavenPublishUrl", "https://nexus.gtnewhorizons.com/repository/releases/")
|
||||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||||
propertyDefaultIfUnset("modrinthRelations", "")
|
propertyDefaultIfUnset("modrinthRelations", "")
|
||||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||||
@@ -573,13 +572,15 @@ afterEvaluate {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name 'Overmind forge repo mirror'
|
name = "GTNH Maven"
|
||||||
url 'https://gregtech.overminddl1.com/'
|
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 = "GTNH Maven"
|
name 'Overmind forge repo mirror'
|
||||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
url 'https://gregtech.overminddl1.com/'
|
||||||
allowInsecureProtocol = true
|
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name 'sonatype'
|
name 'sonatype'
|
||||||
@@ -785,7 +786,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.3.35')
|
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.4')
|
||||||
}
|
}
|
||||||
|
|
||||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||||
@@ -960,8 +961,7 @@ 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) {
|
||||||
enabled = false
|
archiveClassifier.set('dev-preshadow')
|
||||||
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,11 +970,6 @@ 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
|
||||||
@@ -1178,7 +1173,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://") // Mostly for the GTNH maven
|
allowInsecureProtocol = mavenPublishUrl.startsWith("http://")
|
||||||
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"
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.colen.postea;
|
package com.colen.postea;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
|
import com.colen.postea.checker.PosteaProcessedChunksWorldSavedData;
|
||||||
|
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
@@ -9,7 +13,7 @@ public class Postea {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
|
MinecraftForge.EVENT_BUS.register(new PosteaProcessedChunksWorldSavedData(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ 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;
|
||||||
@@ -19,8 +20,15 @@ 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) {
|
||||||
transformTileEntities(compound, world);
|
NBTTagCompound level = compound.getCompoundTag("Level");
|
||||||
transformNormalBlocks(compound, world);
|
int x = level.getInteger("xPos");
|
||||||
|
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) {
|
||||||
@@ -82,9 +90,11 @@ public class ChunkFixerUtility {
|
|||||||
|
|
||||||
Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(level.getTagList("TileEntities", 10), world);
|
Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(level.getTagList("TileEntities", 10), world);
|
||||||
List<ConversionInfo> conversionInfoList = output.first();
|
List<ConversionInfo> conversionInfoList = output.first();
|
||||||
|
|
||||||
NBTTagList tileEntities = output.second();
|
NBTTagList tileEntities = output.second();
|
||||||
level.setTag("TileEntities", tileEntities);
|
|
||||||
|
if (tileEntities.tagCount() > 0) {
|
||||||
|
level.setTag("TileEntities", tileEntities);
|
||||||
|
}
|
||||||
|
|
||||||
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
|
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
|
||||||
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
||||||
@@ -169,6 +179,8 @@ 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,7 +1,14 @@
|
|||||||
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")
|
||||||
@@ -21,4 +28,29 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
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