mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b885b8eda | ||
|
|
318af9da8c | ||
|
|
152b8d4dc5 | ||
|
|
b2d44c9654 | ||
|
|
b5be252e9e | ||
|
|
0bb9b56e6d | ||
|
|
ad46bc37da | ||
|
|
e15b0f35ff | ||
|
|
32b04a0408 | ||
|
|
a67d392b49 | ||
|
|
06350f82ac | ||
|
|
f693ca75b9 | ||
|
|
2e8ce92f66 | ||
|
|
34ebb71357 | ||
|
|
17ab9ecd89 | ||
|
|
1ced0aa1bf | ||
|
|
a09cb976d6 | ||
|
|
3c929a7792 | ||
|
|
1b96a07a74 | ||
|
|
15a5806887 | ||
|
|
9f6ded0b1a | ||
|
|
74d4151d00 | ||
|
|
7352e2dc56 | ||
|
|
7b79649dc2 |
No files matched your search
@@ -1,39 +0,0 @@
|
|||||||
# This workflow only meant for the source mod you shouldn't bring it into your own project
|
|
||||||
|
|
||||||
name: Buildscript maintenance
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master, main ]
|
|
||||||
paths:
|
|
||||||
- build.gradle
|
|
||||||
workflow_dispatch: { }
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
buildscript-maintenance:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# Avoid running this workflow on forks
|
|
||||||
if: github.repository == 'GTNewHorizons/ExampleMod1.7.10'
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Ensure build script version is up to date
|
|
||||||
id: update-buildscript
|
|
||||||
run: |
|
|
||||||
new_version="$(date +%s)"
|
|
||||||
sed --in-place "1s!^//version:.*!//version: $new_version!g" build.gradle
|
|
||||||
echo "::set-output name=new_version::$new_version"
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
|
||||||
id: create-pull-request
|
|
||||||
uses: peter-evans/create-pull-request@v4
|
|
||||||
with:
|
|
||||||
add-paths: build.gradle
|
|
||||||
commit-message: '[ci skip] update build script version to ${{ steps.update-buildscript.outputs.new_version }}'
|
|
||||||
branch: buildscript-maintenance
|
|
||||||
title: Update build script version to ${{ steps.update-buildscript.outputs.new_version }}
|
|
||||||
body: This pull request is created by the buildscript-maintenance workflow
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
|
||||||
|
|
||||||
name: Release latest starter and migration packages
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master, main ]
|
|
||||||
tags: [ '*' ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
zip-and-release-packages:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set release version
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Prepare release folder
|
|
||||||
run: |
|
|
||||||
mkdir packages
|
|
||||||
|
|
||||||
- name: Zip starter
|
|
||||||
uses: montudor/action-zip@v1
|
|
||||||
with:
|
|
||||||
args: >
|
|
||||||
zip -r packages/starter.zip . \
|
|
||||||
\
|
|
||||||
-x "*.git/*" \
|
|
||||||
\
|
|
||||||
-x ".github/scripts/update_version" \
|
|
||||||
-x ".github/workflows/buildscript-maintenance.yml" \
|
|
||||||
-x ".github/workflows/release-packages.yml" \
|
|
||||||
\
|
|
||||||
-x "*docs/*" \
|
|
||||||
-x "README.md" \
|
|
||||||
-x "LICENSE" \
|
|
||||||
-x "gtnhShared/*" \
|
|
||||||
\
|
|
||||||
-x "packages/" \
|
|
||||||
-x "packages/starter.zip" \
|
|
||||||
-x "packages/migration.zip"
|
|
||||||
|
|
||||||
- name: Zip migration
|
|
||||||
uses: montudor/action-zip@v1
|
|
||||||
with:
|
|
||||||
args: >
|
|
||||||
zip -r packages/migration.zip . \
|
|
||||||
\
|
|
||||||
-x "*.git/*" \
|
|
||||||
\
|
|
||||||
-x ".github/scripts/update_version" \
|
|
||||||
-x ".github/workflows/buildscript-maintenance.yml" \
|
|
||||||
-x ".github/workflows/release-packages.yml" \
|
|
||||||
\
|
|
||||||
-x "*docs/*" \
|
|
||||||
-x "*src/*" \
|
|
||||||
-x "LICENSE" \
|
|
||||||
-x "README.md" \
|
|
||||||
-x "gtnhShared/*" \
|
|
||||||
\
|
|
||||||
-x "packages/" \
|
|
||||||
-x "packages/starter.zip" \
|
|
||||||
-x "packages/migration.zip"
|
|
||||||
|
|
||||||
- name: Update latest tag
|
|
||||||
uses: "marvinpinto/action-automatic-releases@latest"
|
|
||||||
if: ${{ (github.ref == 'master' || github.ref == 'main') }}
|
|
||||||
with:
|
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
automatic_release_tag: "latest-packages"
|
|
||||||
prerelease: true
|
|
||||||
title: "Latest starter and migration packages"
|
|
||||||
files: packages/*
|
|
||||||
|
|
||||||
- name: Release named version
|
|
||||||
if: ${{ !(github.ref == 'master' || github.ref == 'main') }}
|
|
||||||
uses: "marvinpinto/action-automatic-releases@latest"
|
|
||||||
with:
|
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
automatic_release_tag: "${{ env.RELEASE_VERSION }}-packages"
|
|
||||||
prerelease: false
|
|
||||||
title: "${{ env.RELEASE_VERSION }} starter and migration packages"
|
|
||||||
files: packages/*
|
|
||||||
@@ -29,7 +29,7 @@ TileEntityReplacementManager.tileEntityTransformer("GT_TileEntity_Ores", (tag, w
|
|||||||
#### b. We do the same here, but now we convert a Furnace TE to a chest TE. We also need to convert the underlying block to a chest. In addtion to this we can provide a transformer that can edit the NBTTagCompound of the TE. This is useful for converting NBT data from one format to another. Here we simply edit the NBT to place stone in the middle slot.
|
#### b. We do the same here, but now we convert a Furnace TE to a chest TE. We also need to convert the underlying block to a chest. In addtion to this we can provide a transformer that can edit the NBTTagCompound of the TE. This is useful for converting NBT data from one format to another. Here we simply edit the NBT to place stone in the middle slot.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
TileEntityReplacementManager.tileEntityTransformer("Furnace", (tag, world) -> {
|
TileEntityReplacementManager.tileEntityTransformer("Chest", (tag, world) -> {
|
||||||
return new BlockInfo(Blocks.chest, 0, Postea::chestTransformer);
|
return new BlockInfo(Blocks.chest, 0, Postea::chestTransformer);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ private static NBTTagCompound chestTransformer(NBTTagCompound oldTag) {
|
|||||||
#### a. The following example will replace all grass blocks with even x-coordinates with orange wool blocks.
|
#### a. The following example will replace all grass blocks with even x-coordinates with orange wool blocks.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Function<BlockConversionInfo, BlockConversionInfo> blockTransformer = (blockConversionInfoOld) -> {
|
BiFunction<BlockConversionInfo, World, BlockConversionInfo> blockTransformer = (blockConversionInfoOld, world) -> {
|
||||||
|
|
||||||
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
|
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
|
||||||
|
|
||||||
|
|||||||
+23
-42
@@ -1,4 +1,4 @@
|
|||||||
//version: 1697697256
|
//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.
|
||||||
@@ -28,27 +28,11 @@ import java.util.concurrent.TimeUnit
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
|
|
||||||
maven {
|
|
||||||
name 'forge'
|
|
||||||
url 'https://maven.minecraftforge.net'
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
name 'sonatype'
|
|
||||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name 'Scala CI dependencies'
|
|
||||||
url 'https://repo1.maven.org/maven2/'
|
|
||||||
}
|
|
||||||
|
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,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.24'
|
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")
|
||||||
@@ -133,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", "")
|
||||||
@@ -302,7 +286,7 @@ if (apiPackage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (accessTransformersFile) {
|
if (accessTransformersFile) {
|
||||||
for (atFile in accessTransformersFile.split(",")) {
|
for (atFile in accessTransformersFile.split(" ")) {
|
||||||
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
|
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
|
||||||
if (!getFile(targetFile).exists()) {
|
if (!getFile(targetFile).exists()) {
|
||||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||||
@@ -588,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'
|
||||||
@@ -628,7 +614,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "ic2"
|
name = "ic2"
|
||||||
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
|
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
|
||||||
content {
|
content {
|
||||||
includeGroup "net.industrial-craft"
|
includeGroup "net.industrial-craft"
|
||||||
}
|
}
|
||||||
@@ -646,7 +632,7 @@ repositories {
|
|||||||
|
|
||||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||||
def mixinProviderModule = "unimixins"
|
def mixinProviderModule = "unimixins"
|
||||||
def mixinProviderVersion = "0.1.7.1"
|
def mixinProviderVersion = "0.1.13"
|
||||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||||
ext.mixinProviderSpec = mixinProviderSpec
|
ext.mixinProviderSpec = mixinProviderSpec
|
||||||
@@ -687,6 +673,8 @@ 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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,12 +781,12 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def lwjgl3ifyVersion = '1.5.1'
|
def lwjgl3ifyVersion = '1.5.7'
|
||||||
if (modId != 'lwjgl3ify') {
|
if (modId != 'lwjgl3ify') {
|
||||||
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.17')
|
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}
|
||||||
@@ -973,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}))
|
||||||
@@ -983,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
|
||||||
@@ -1187,12 +1169,11 @@ publishing {
|
|||||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
if (usesMavenPublishing.toBoolean()) {
|
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"
|
||||||
@@ -1311,7 +1292,7 @@ def addCurseForgeRelation(String type, String name) {
|
|||||||
|
|
||||||
// Updating
|
// Updating
|
||||||
|
|
||||||
def buildscriptGradleVersion = "8.2.1"
|
def buildscriptGradleVersion = "8.5"
|
||||||
|
|
||||||
tasks.named('wrapper', Wrapper).configure {
|
tasks.named('wrapper', Wrapper).configure {
|
||||||
gradleVersion = buildscriptGradleVersion
|
gradleVersion = buildscriptGradleVersion
|
||||||
|
|||||||
+2
-38
@@ -1,40 +1,4 @@
|
|||||||
/*
|
|
||||||
* 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("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
api('com.github.GTNewHorizons:NotEnoughIds:1.5.4-pre:dev')
|
||||||
// api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.71:dev')
|
|
||||||
api('com.github.GTNewHorizons:NotEnoughIds:1.4.6:dev')
|
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-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()
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,40 @@
|
|||||||
package com.colen.postea.API;
|
package com.colen.postea.API;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
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, Function<BlockConversionInfo, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
|
public static final Map<String, BiFunction<BlockConversionInfo, World, BlockConversionInfo>> blockReplacementMap = new HashMap<>();
|
||||||
|
public static final HashSet<Integer> posteaMarkedIDs = new HashSet<>();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static void addBlockReplacement(String blockNameIn,
|
public static void addBlockReplacement(String blockNameIn,
|
||||||
Function<BlockConversionInfo, BlockConversionInfo> transformer) {
|
BiFunction<BlockConversionInfo, World, BlockConversionInfo> transformer) {
|
||||||
blockReplacementMap.put(blockNameIn, transformer);
|
blockReplacementMap.put(blockNameIn, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo, World world) {
|
||||||
public static BlockConversionInfo getBlockReplacement(BlockConversionInfo blockConversionInfo) {
|
|
||||||
|
|
||||||
Function<BlockConversionInfo, BlockConversionInfo> transformer = blockReplacementMap
|
BiFunction<BlockConversionInfo, World, 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);
|
return transformer.apply(blockConversionInfo, world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need this to save reprocessing blocks.
|
||||||
|
public static boolean blockNotConvertible(int blockID) {
|
||||||
|
return !posteaMarkedIDs.contains(blockID);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,62 +1,36 @@
|
|||||||
package com.colen.postea;
|
package com.colen.postea;
|
||||||
|
|
||||||
import com.colen.postea.API.BlockReplacementManager;
|
import static com.colen.postea.API.BlockReplacementManager.blockReplacementMap;
|
||||||
import com.colen.postea.Utility.BlockConversionInfo;
|
import static com.colen.postea.API.BlockReplacementManager.posteaMarkedIDs;
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import cpw.mods.fml.common.Mod;
|
|
||||||
import cpw.mods.fml.common.ModContainer;
|
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
import net.minecraft.block.Block;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||||
|
|
||||||
@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]")
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class Postea {
|
public class Postea {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {}
|
||||||
|
|
||||||
ModContainer activeMod = Loader.instance().activeModContainer();
|
@Mod.EventHandler
|
||||||
String modID = activeMod.getModId();
|
public void onServerStarting(FMLServerAboutToStartEvent event) {
|
||||||
String v = activeMod.getVersion();
|
for (String name : blockReplacementMap.keySet()) {
|
||||||
|
Block block = Block.getBlockFromName(name);
|
||||||
Function<BlockConversionInfo, BlockConversionInfo> blockTransformer = (blockConversionInfoOld) -> {
|
if (block != null) {
|
||||||
|
int id = Block.getIdFromBlock(block);
|
||||||
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
|
posteaMarkedIDs.add(id);
|
||||||
|
|
||||||
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)) {
|
@Mod.EventHandler
|
||||||
blockConversionInfoNew.blockID = Block.getIdFromBlock(Blocks.wool);
|
public void onServerStopping(FMLServerStoppingEvent event) {
|
||||||
blockConversionInfoNew.metadata = 1;
|
posteaMarkedIDs.clear();
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.colen.postea.Utility;
|
package com.colen.postea.Utility;
|
||||||
|
|
||||||
|
import static com.colen.postea.API.BlockReplacementManager.blockNotConvertible;
|
||||||
|
import static com.colen.postea.Utility.PosteaUtilities.getModListHash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -19,47 +23,79 @@ 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 levelCompoundTag = compound.getCompoundTag("Level");
|
||||||
transformNormalBlocks(compound, world);
|
|
||||||
|
if (processChunk(levelCompoundTag)) {
|
||||||
|
transformTileEntities(levelCompoundTag, world);
|
||||||
|
transformNormalBlocks(levelCompoundTag, world);
|
||||||
|
levelCompoundTag.setInteger("POSTEA", POSTEA_UPDATE_CODE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void transformNormalBlocks(NBTTagCompound compound, World world) {
|
// This will not change between runs, unless a mod is updated or added.
|
||||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
public static final int POSTEA_UPDATE_CODE = getModListHash();
|
||||||
NBTTagList sections = level.getTagList("Sections", 10);
|
|
||||||
|
|
||||||
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
|
// If a chunk has the same postea code, then do not update it. Return false.
|
||||||
int chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
private static boolean processChunk(NBTTagCompound compound) {
|
||||||
|
// I'm minimising the string length here since this
|
||||||
|
// will be on every single chunk in every world... Rather not duplicate too much.
|
||||||
|
if (compound.hasKey("POSTEA")) {
|
||||||
|
return compound.getInteger("POSTEA") != POSTEA_UPDATE_CODE;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int AIR_ID = 0;
|
||||||
|
private static final HashMap<Block, String> loadedBlocks = new HashMap<>();
|
||||||
|
|
||||||
|
private static void transformNormalBlocks(NBTTagCompound levelCompoundTag, World world) {
|
||||||
|
NBTTagList sections = levelCompoundTag.getTagList("Sections", 10);
|
||||||
|
|
||||||
|
int chunkXPos = levelCompoundTag.getInteger("xPos") * 16;
|
||||||
|
int chunkZPos = levelCompoundTag.getInteger("zPos") * 16;
|
||||||
|
|
||||||
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("Data");
|
byte[] metadataArray = section.getByteArray("Data16");
|
||||||
|
|
||||||
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++) {
|
||||||
|
// Horrible bit jank to recreate the actual IDs, because the array is just a byte array.
|
||||||
int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF);
|
int blockId = ((blockArray[index * 2] & 0xFF) << 8) | (blockArray[index * 2 + 1] & 0xFF);
|
||||||
byte metadata = (byte) ((index & 1) == 0 ? (metadataArray[index / 2] & 0x0F)
|
int metadata = ((metadataArray[index * 2] & 0xFF) << 8) | (metadataArray[index * 2 + 1] & 0xFF);
|
||||||
: ((metadataArray[index / 2] & 0xF0) >> 4));
|
|
||||||
|
|
||||||
|
// Skip air.
|
||||||
|
if (blockId == AIR_ID) continue;
|
||||||
|
// If this block has no registered Postea conversion, skip it.
|
||||||
|
if (blockNotConvertible(blockId)) continue;
|
||||||
|
|
||||||
|
// Cache block names to improve performance, as findUniqueIdentifierFor is expensive.
|
||||||
Block block = Block.getBlockById(blockId);
|
Block block = Block.getBlockById(blockId);
|
||||||
String blockName = GameRegistry.findUniqueIdentifierFor(block)
|
String blockName = loadedBlocks.computeIfAbsent(
|
||||||
.toString();
|
block,
|
||||||
|
b -> GameRegistry.findUniqueIdentifierFor(b)
|
||||||
|
.toString());
|
||||||
|
|
||||||
BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
|
BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
|
||||||
blockConversionInfo.blocKName = blockName;
|
blockConversionInfo.blockName = blockName;
|
||||||
blockConversionInfo.blockID = blockId;
|
blockConversionInfo.blockID = blockId;
|
||||||
blockConversionInfo.metadata = metadata;
|
blockConversionInfo.metadata = (byte) metadata; // Updated
|
||||||
blockConversionInfo.world = world;
|
blockConversionInfo.world = world;
|
||||||
|
|
||||||
int x = index % 16;
|
int x = index % 16;
|
||||||
int y = (index / 256) + (sectionY * 16); // Add the offset of the current section in Y direction
|
int y = (index / 256) + (sectionY * 16);
|
||||||
int z = (index / 16) % 16;
|
int z = (index / 16) % 16;
|
||||||
|
|
||||||
blockConversionInfo.x = x + chunkXPos + 1;
|
blockConversionInfo.x = x + chunkXPos + 1;
|
||||||
blockConversionInfo.y = y; // Y remains unchanged as it's already global
|
blockConversionInfo.y = y;
|
||||||
blockConversionInfo.z = z + chunkZPos + 1;
|
blockConversionInfo.z = z + chunkZPos + 1;
|
||||||
|
|
||||||
BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo);
|
BlockConversionInfo output = BlockReplacementManager.getBlockReplacement(blockConversionInfo, world);
|
||||||
|
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
int newBlockId = output.blockID;
|
int newBlockId = output.blockID;
|
||||||
int newMetadata = output.metadata;
|
int newMetadata = output.metadata;
|
||||||
@@ -67,33 +103,29 @@ 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);
|
||||||
|
|
||||||
if ((index & 1) == 0) { // Even
|
metadataArray[index * 2] = (byte) ((newMetadata >> 8) & 0xFF);
|
||||||
metadataArray[index / 2] &= 0xF0;
|
metadataArray[index * 2 + 1] = (byte) (newMetadata & 0xFF);
|
||||||
metadataArray[index / 2] |= (newMetadata & 0x0F);
|
|
||||||
} else { // Odd
|
|
||||||
metadataArray[index / 2] &= 0x0F;
|
|
||||||
metadataArray[index / 2] |= ((newMetadata << 4) & 0xF0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transformTileEntities(NBTTagCompound chunkNBT, World world) {
|
private static void transformTileEntities(NBTTagCompound levelCompoundTag, World world) {
|
||||||
NBTTagCompound level = chunkNBT.getCompoundTag("Level");
|
|
||||||
|
|
||||||
Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(level.getTagList("TileEntities", 10), world);
|
Pair<List<ConversionInfo>, NBTTagList> output = adjustTileEntities(
|
||||||
|
levelCompoundTag.getTagList("TileEntities", 10),
|
||||||
|
world);
|
||||||
List<ConversionInfo> conversionInfoList = output.first();
|
List<ConversionInfo> conversionInfoList = output.first();
|
||||||
NBTTagList tileEntities = output.second();
|
NBTTagList tileEntities = output.second();
|
||||||
|
|
||||||
if (tileEntities.tagCount() > 0) {
|
if (tileEntities.tagCount() > 0) {
|
||||||
level.setTag("TileEntities", tileEntities);
|
levelCompoundTag.setTag("TileEntities", tileEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
int chunkXPos = level.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-axis
|
int chunkXPos = levelCompoundTag.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 = levelCompoundTag.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
||||||
|
|
||||||
NBTTagList sections = level.getTagList("Sections", 10);
|
NBTTagList sections = levelCompoundTag.getTagList("Sections", 10);
|
||||||
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);
|
||||||
processSection(section, conversionInfoList, chunkXPos, chunkZPos);
|
processSection(section, conversionInfoList, chunkXPos, chunkZPos);
|
||||||
@@ -103,7 +135,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("Data");
|
byte[] metadataArray = section.getByteArray("Data16"); // Updated to use Data16
|
||||||
byte y = section.getByte("Y");
|
byte y = section.getByte("Y");
|
||||||
|
|
||||||
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
||||||
@@ -112,7 +144,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);
|
setMetadata(info.blockInfo.metadata, index, metadataArray); // This uses the updated setMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,18 +172,12 @@ public class ChunkFixerUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setMetadata(int metadata, int index, byte[] metadataArray) {
|
private static void setMetadata(int metadata, int index, byte[] metadataArray) {
|
||||||
int metadataIndex = index / 2;
|
// Since each metadata is now two bytes, multiply the index by 2 to get the correct position.
|
||||||
byte currentMetadataByte = metadataArray[metadataIndex];
|
int metadataStartIndex = index * 2;
|
||||||
|
|
||||||
if ((index & 1) == 0) { // Even
|
// Split the 16-bit metadata into two bytes and store them in the array.
|
||||||
currentMetadataByte &= 0xF0;
|
metadataArray[metadataStartIndex] = (byte) ((metadata >> 8) & 0xFF); // Higher 8 bits
|
||||||
currentMetadataByte |= (metadata & 0x0F);
|
metadataArray[metadataStartIndex + 1] = (byte) (metadata & 0xFF); // Lower 8 bits
|
||||||
} 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,13 +205,15 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<>(conversionInfo, tileEntitiesCopy);
|
return new Pair<>(conversionInfo, tileEntitiesCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConversionInfo {
|
private static class ConversionInfo {
|
||||||
|
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int y;
|
public final int y;
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package com.colen.postea.Utility;
|
package com.colen.postea.Utility;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
|
||||||
public abstract class PosteaUtilities {
|
public abstract class PosteaUtilities {
|
||||||
|
|
||||||
@@ -21,4 +29,40 @@ 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 combinedModStringSortedBuilder = new StringBuilder();
|
||||||
|
for (String element : modList) {
|
||||||
|
combinedModStringSortedBuilder.append(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
String combinedModStringSorted = combinedModStringSortedBuilder.toString();
|
||||||
|
|
||||||
|
return combinedModStringSorted.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void markChunkAsDirty(World world, int chunkX, int chunkZ) {
|
||||||
|
if (!world.isRemote) { // Check to make sure we're on the server side.
|
||||||
|
Chunk chunk = world.getChunkFromChunkCoords(chunkX, chunkZ);
|
||||||
|
if (chunk == null) return;
|
||||||
|
|
||||||
|
chunk.setChunkModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,7 @@ public final class PosteaLoadingPlugin implements IEarlyMixinLoader, IFMLLoading
|
|||||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||||
final List<String> mixins = new ArrayList<>();
|
final List<String> mixins = new ArrayList<>();
|
||||||
mixins.add("MixinItemStack");
|
mixins.add("MixinItemStack");
|
||||||
|
mixins.add("MixinChunk");
|
||||||
mixins.add("MixinAnvilChunkLoader");
|
mixins.add("MixinAnvilChunkLoader");
|
||||||
return mixins;
|
return mixins;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
package com.colen.postea.mixins.early;
|
package com.colen.postea.mixins.early;
|
||||||
|
|
||||||
|
import static com.colen.postea.Utility.ChunkFixerUtility.POSTEA_UPDATE_CODE;
|
||||||
import static com.colen.postea.Utility.ChunkFixerUtility.processChunkNBT;
|
import static com.colen.postea.Utility.ChunkFixerUtility.processChunkNBT;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.colen.postea.mixins.interfaces.IChunkMixin;
|
||||||
|
|
||||||
@Mixin(AnvilChunkLoader.class)
|
@Mixin(AnvilChunkLoader.class)
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public abstract class MixinAnvilChunkLoader {
|
public abstract class MixinAnvilChunkLoader {
|
||||||
|
|
||||||
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("HEAD"), remap = false)
|
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("HEAD"), remap = false)
|
||||||
@@ -21,4 +25,27 @@ public abstract class MixinAnvilChunkLoader {
|
|||||||
processChunkNBT(compound, world);
|
processChunkNBT(compound, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "readChunkFromNBT", at = @At("RETURN"))
|
||||||
|
private Chunk onReadChunkFromNBT(World world, NBTTagCompound nbtTagCompound, CallbackInfoReturnable<Chunk> cir) {
|
||||||
|
Chunk chunk = cir.getReturnValue();
|
||||||
|
if (chunk instanceof IChunkMixin iChunkMixin) {
|
||||||
|
if (nbtTagCompound.hasKey("POSTEA")) {
|
||||||
|
long posteaCode = nbtTagCompound.getLong("POSTEA");
|
||||||
|
iChunkMixin.Postea$setPosteaCode(posteaCode);
|
||||||
|
|
||||||
|
// Chunk has been updated with Postea, so we will mark it to save later.
|
||||||
|
if (posteaCode != POSTEA_UPDATE_CODE) chunk.setChunkModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "writeChunkToNBT", at = @At("HEAD"))
|
||||||
|
private void onWriteChunkToNBT(Chunk chunk, World world, NBTTagCompound nbtTagCompound, CallbackInfo ci) {
|
||||||
|
if (chunk instanceof IChunkMixin iChunkMixin) {
|
||||||
|
nbtTagCompound.setLong("POSTEA", iChunkMixin.Postea$getPosteaCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.colen.postea.mixins.early;
|
||||||
|
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
|
||||||
|
import com.colen.postea.mixins.interfaces.IChunkMixin;
|
||||||
|
|
||||||
|
@Mixin(Chunk.class)
|
||||||
|
public class MixinChunk implements IChunkMixin {
|
||||||
|
|
||||||
|
// This new field will store the hash of mod name + versions. We use this to check
|
||||||
|
// if we need to reprocess this chunk.
|
||||||
|
@Unique
|
||||||
|
private long postea_GTNH$posteaID;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
public long Postea$getPosteaCode() {
|
||||||
|
return postea_GTNH$posteaID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
public void Postea$setPosteaCode(long POSTEA_ID) {
|
||||||
|
this.postea_GTNH$posteaID = POSTEA_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.colen.postea.mixins.interfaces;
|
||||||
|
|
||||||
|
public interface IChunkMixin {
|
||||||
|
|
||||||
|
long Postea$getPosteaCode();
|
||||||
|
|
||||||
|
void Postea$setPosteaCode(long posteaID);
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinAnvilChunkLoader",
|
"MixinAnvilChunkLoader",
|
||||||
|
"MixinChunk",
|
||||||
"MixinItemStack"
|
"MixinItemStack"
|
||||||
],
|
],
|
||||||
"client": [],
|
"client": [],
|
||||||
|
|||||||
Reference in new issue
Block a user