mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7259ad0a54 | ||
|
|
1f2314a8a5 | ||
|
|
a79bb55395 | ||
|
|
0fda010523 | ||
|
|
1f6f4605b1 | ||
|
|
99c887e67e | ||
|
|
374cad1e5c | ||
|
|
4d247eb701 | ||
|
|
7b885b8eda | ||
|
|
318af9da8c | ||
|
|
152b8d4dc5 | ||
|
|
b2d44c9654 | ||
|
|
b5be252e9e | ||
|
|
0bb9b56e6d | ||
|
|
ad46bc37da | ||
|
|
e15b0f35ff | ||
|
|
a67d392b49 |
No files matched your search
@@ -4,7 +4,7 @@ This API provides a suite of tools for transforming blocks and items in the game
|
||||
|
||||
## Features
|
||||
|
||||
1. **Tile Entity Transformation**: Replace or modify Tile Entities in the game.
|
||||
1. **Tile Entity Transformation**: Replace or modify tile entities.
|
||||
2. **Block Replacement**: Replace normal blocks with another normal block.
|
||||
3. **ItemStack Replacement**: Modify or replace items.
|
||||
|
||||
@@ -12,7 +12,7 @@ This API provides a suite of tools for transforming blocks and items in the game
|
||||
|
||||
### 1. Tile Entity Transformation
|
||||
|
||||
#### a. We provide the registered TE ID "GT_TileEntity_Ores" and a lambda function that takes in the NBTTagCompound for any matching tile entity in world and a World and returns a BlockInfo. This will replace all TE's with the ID "GT_TileEntity_Ores" with the block specified in the BlockInfo. The secondary parameter determines the damage value of the block.
|
||||
#### a. We provide the registered TE ID "GT_TileEntity_Ores" and a lambda function that takes in the NBTTagCompound for any matching tile entity in world and a World and returns a BlockInfo. This will replace all TE's with the ID "GT_TileEntity_Ores" with the block specified in the BlockInfo. The secondary parameter determines the damage value of the block. Returning null instead of a BlockInfo will leave the existing tile and block totally unchanged.
|
||||
|
||||
```java
|
||||
TileEntityReplacementManager.tileEntityTransformer("GT_TileEntity_Ores", (tag, world) -> {
|
||||
@@ -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.
|
||||
|
||||
```java
|
||||
TileEntityReplacementManager.tileEntityTransformer("Furnace", (tag, world) -> {
|
||||
TileEntityReplacementManager.tileEntityTransformer("Chest", (tag, world) -> {
|
||||
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.
|
||||
|
||||
```java
|
||||
Function<BlockConversionInfo, BlockConversionInfo> blockTransformer = (blockConversionInfoOld) -> {
|
||||
BiFunction<BlockConversionInfo, World, BlockConversionInfo> blockTransformer = (blockConversionInfoOld, world) -> {
|
||||
|
||||
BlockConversionInfo blockConversionInfoNew = new BlockConversionInfo();
|
||||
|
||||
|
||||
+2
-1602
File diff suppressed because it is too large.
Load diff
+86
-47
@@ -1,77 +1,101 @@
|
||||
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
|
||||
# LOCAL to test local config updates.
|
||||
gtnh.settings.blowdryerTag = 0.2.2
|
||||
|
||||
# Human-readable mod name, available for mcmod.info population.
|
||||
modName = Postea
|
||||
|
||||
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
||||
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
|
||||
# Conventionally lowercase.
|
||||
modId = postea
|
||||
|
||||
modGroup = com.colen.postea
|
||||
# Root package of the mod, used to find various classes in other properties,
|
||||
# mcmod.info substitution, enabling assertions in run tasks, etc.
|
||||
modGroup = com.gtnewhorizons.postea
|
||||
|
||||
# WHY is there no version field?
|
||||
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
||||
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Will update your build.gradle automatically whenever an update is available
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
autoUpdateBuildScript = false
|
||||
|
||||
# Version of Minecraft to target
|
||||
minecraftVersion = 1.7.10
|
||||
|
||||
# Version of Minecraft Forge to target
|
||||
forgeVersion = 10.13.4.1614
|
||||
|
||||
# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task.
|
||||
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
|
||||
channel = stable
|
||||
|
||||
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
|
||||
mappingsVersion = 12
|
||||
|
||||
# Define other MCP mappings for dependency deobfuscation
|
||||
# Defines other MCP mappings for dependency deobfuscation.
|
||||
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||
|
||||
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
|
||||
# restart Minecraft in development. Choose this dependent on your mod:
|
||||
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
||||
# Select a default username for testing your mod. You can always override this per-run by running
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience
|
||||
# Turns most publicly visible List, Map, etc. into proper List<Type>, Map<K, V> types
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
enableGenericInjection = false
|
||||
|
||||
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
|
||||
generateGradleTokenClass = com.colen.postea.Tags
|
||||
gradleTokenModId = MODID
|
||||
gradleTokenModName = MODNAME
|
||||
# Generate a class with a String field for the mod version named as defined below.
|
||||
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
|
||||
generateGradleTokenClass = com.gtnewhorizons.postea.Tags
|
||||
|
||||
# Name of the token containing the project's current version to generate/replace.
|
||||
gradleTokenVersion = VERSION
|
||||
gradleTokenGroupName = GROUPNAME
|
||||
|
||||
# [DEPRECATED] Mod ID replacement token.
|
||||
gradleTokenModId = MODID
|
||||
|
||||
# [DEPRECATED] Mod name replacement token.
|
||||
gradleTokenModName = MODNAME
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...])
|
||||
# Leave these properties empty to skip individual token replacements
|
||||
# version in @Mod([...], version = VERSION, [...]).
|
||||
# Leave these properties empty to skip individual token replacements.
|
||||
replaceGradleTokenInFile =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
||||
apiPackage =
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a comma-separated list.
|
||||
# Example value: mymodid_at.cfg,nei_at.cfg
|
||||
# There can be multiple files in a space-separated list.
|
||||
# Example value: mymodid_at.cfg nei_at.cfg
|
||||
accessTransformersFile =
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = true
|
||||
# Adds some debug arguments like verbose output and export
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = true
|
||||
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage = mixins
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass = mixins.PosteaLoadingPlugin
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
containsMixinsAndOrCoreModOnly = false
|
||||
@@ -79,28 +103,32 @@ containsMixinsAndOrCoreModOnly = false
|
||||
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
||||
forceEnableMixins = true
|
||||
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
||||
# responsibility check the licence and request permission for distribution, if required.
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
|
||||
# responsibility to check the license and request permission for distribution if required.
|
||||
usesShadowedDependencies = false
|
||||
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
|
||||
|
||||
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
|
||||
# their own classes, making the minimization unreliable.
|
||||
minimizeShadowedDependencies = true
|
||||
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories
|
||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
# Authenticate with the MAVEN_USERNAME and MAVEN_PASSWORD environment variables.
|
||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||
usesMavenPublishing = true
|
||||
# mavenPublishUrl = http://jenkins.usrv.eu:8081/nexus/content/repositories/releases
|
||||
|
||||
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
|
||||
# Maven repository to publish the mod to.
|
||||
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
|
||||
|
||||
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
||||
#
|
||||
# The project's ID on Modrinth. Can be either the slug or the ID.
|
||||
# Leave this empty if you don't want to publish on Modrinth.
|
||||
# Leave this empty if you don't want to publish to Modrinth.
|
||||
modrinthProjectId =
|
||||
|
||||
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
||||
@@ -112,9 +140,8 @@ modrinthProjectId =
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
modrinthRelations =
|
||||
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
|
||||
#
|
||||
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
||||
# Leave this empty if you don't want to publish on CurseForge.
|
||||
curseForgeProjectId =
|
||||
@@ -124,29 +151,41 @@ curseForgeProjectId =
|
||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||
# and the name is the CurseForge project slug of the other mod.
|
||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
curseForgeRelations =
|
||||
|
||||
|
||||
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
||||
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to prevent the source code from being published
|
||||
# noPublishedSources =
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
|
||||
# versionPattern =
|
||||
|
||||
# Uncomment this to disable spotless checks
|
||||
# Uncomment to prevent the source code from being published.
|
||||
# noPublishedSources = true
|
||||
|
||||
# Uncomment this to disable Spotless checks.
|
||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
||||
# disableSpotless = true
|
||||
|
||||
# Uncomment this to disable checkstyle checks (currently wildcard import check).
|
||||
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
|
||||
# disableCheckstyle = true
|
||||
|
||||
# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# (force use delegated build).
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build.
|
||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
|
||||
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
||||
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
||||
# ideaOverrideBuildType = idea
|
||||
|
||||
# Whether IDEA should run spotless checks when pressing the Build button.
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
gradleTokenGroupName = GROUPNAME
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,7 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -201,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
Vendored
+10
-10
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
+5
-10
@@ -4,10 +4,10 @@ pluginManagement {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons.retrofuturagradle")
|
||||
includeGroup("com.gtnewhorizons")
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
@@ -17,12 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.diffplug.blowdryerSetup' version '1.6.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
|
||||
}
|
||||
|
||||
blowdryerSetup {
|
||||
repoSubfolder 'gtnhShared'
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.2')
|
||||
//devLocal '.' // Use this when testing config updates locally
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
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.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]")
|
||||
@SuppressWarnings("unused")
|
||||
public class Postea {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new PosteaProcessedChunksWorldSavedData(""));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.colen.postea.mixins.early;
|
||||
|
||||
import static com.colen.postea.Utility.ChunkFixerUtility.processChunkNBT;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(AnvilChunkLoader.class)
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class MixinAnvilChunkLoader {
|
||||
|
||||
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("HEAD"), remap = false)
|
||||
private void onCheckedReadChunkFromNBT__Async(World world, int x, int z, NBTTagCompound compound,
|
||||
CallbackInfoReturnable<Object[]> cir) {
|
||||
processChunkNBT(compound, world);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.gtnewhorizons.postea;
|
||||
|
||||
import static com.gtnewhorizons.postea.api.BlockReplacementManager.blockReplacementMap;
|
||||
import static com.gtnewhorizons.postea.api.BlockReplacementManager.posteaMarkedIDs;
|
||||
|
||||
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]")
|
||||
@SuppressWarnings("unused")
|
||||
public class Postea {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onServerStarting(FMLServerAboutToStartEvent event) {
|
||||
for (String name : blockReplacementMap.keySet()) {
|
||||
Block block = Block.getBlockFromName(name);
|
||||
if (block != null) {
|
||||
int id = Block.getIdFromBlock(block);
|
||||
posteaMarkedIDs.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onServerStopping(FMLServerStoppingEvent event) {
|
||||
posteaMarkedIDs.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+10
-3
@@ -1,16 +1,18 @@
|
||||
package com.colen.postea.API;
|
||||
package com.gtnewhorizons.postea.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.colen.postea.Utility.BlockConversionInfo;
|
||||
import com.gtnewhorizons.postea.utility.BlockConversionInfo;
|
||||
|
||||
public class BlockReplacementManager {
|
||||
|
||||
private static final Map<String, BiFunction<BlockConversionInfo, World, 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")
|
||||
public static void addBlockReplacement(String blockNameIn,
|
||||
@@ -30,4 +32,9 @@ public class BlockReplacementManager {
|
||||
}
|
||||
}
|
||||
|
||||
// We need this to save reprocessing blocks.
|
||||
public static boolean blockNotConvertible(int blockID) {
|
||||
return !posteaMarkedIDs.contains(blockID);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.colen.postea.API;
|
||||
package com.gtnewhorizons.postea.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.colen.postea.API;
|
||||
package com.gtnewhorizons.postea.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.BiFunction;
|
||||
@@ -6,7 +6,7 @@ import java.util.function.BiFunction;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.colen.postea.Utility.BlockInfo;
|
||||
import com.gtnewhorizons.postea.utility.BlockInfo;
|
||||
|
||||
public class TileEntityReplacementManager {
|
||||
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package com.colen.postea.mixins;
|
||||
package com.gtnewhorizons.postea.mixins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -44,6 +44,7 @@ public final class PosteaLoadingPlugin implements IEarlyMixinLoader, IFMLLoading
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
final List<String> mixins = new ArrayList<>();
|
||||
mixins.add("MixinItemStack");
|
||||
mixins.add("MixinChunk");
|
||||
mixins.add("MixinAnvilChunkLoader");
|
||||
return mixins;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gtnewhorizons.postea.mixins.early;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.gtnewhorizons.postea.mixins.interfaces.IChunkMixin;
|
||||
import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
|
||||
|
||||
@Mixin(AnvilChunkLoader.class)
|
||||
public abstract class MixinAnvilChunkLoader {
|
||||
|
||||
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("HEAD"), remap = false)
|
||||
private void onCheckedReadChunkFromNBT__Async(World world, int x, int z, NBTTagCompound compound,
|
||||
CallbackInfoReturnable<Object[]> cir) {
|
||||
ChunkFixerUtility.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 != ChunkFixerUtility.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.gtnewhorizons.postea.mixins.early;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import com.gtnewhorizons.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;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.colen.postea.mixins.early;
|
||||
package com.gtnewhorizons.postea.mixins.early;
|
||||
|
||||
import static com.colen.postea.Utility.ItemFixerUtility.fixItemStack;
|
||||
import static com.gtnewhorizons.postea.utility.ItemFixerUtility.fixItemStack;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gtnewhorizons.postea.mixins.interfaces;
|
||||
|
||||
public interface IChunkMixin {
|
||||
|
||||
long Postea$getPosteaCode();
|
||||
|
||||
void Postea$setPosteaCode(long posteaID);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.colen.postea.Utility;
|
||||
package com.gtnewhorizons.postea.utility;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.colen.postea.Utility;
|
||||
package com.gtnewhorizons.postea.utility;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
+58
-26
@@ -1,6 +1,10 @@
|
||||
package com.colen.postea.Utility;
|
||||
package com.gtnewhorizons.postea.utility;
|
||||
|
||||
import static com.gtnewhorizons.postea.api.BlockReplacementManager.blockNotConvertible;
|
||||
import static com.gtnewhorizons.postea.utility.PosteaUtilities.getModListHash;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -10,9 +14,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.colen.postea.API.BlockReplacementManager;
|
||||
import com.colen.postea.API.TileEntityReplacementManager;
|
||||
import com.colen.postea.checker.PosteaProcessedChunksWorldSavedData;
|
||||
import com.gtnewhorizons.postea.api.BlockReplacementManager;
|
||||
import com.gtnewhorizons.postea.api.TileEntityReplacementManager;
|
||||
|
||||
import akka.japi.Pair;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -20,23 +23,36 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
public class ChunkFixerUtility {
|
||||
|
||||
public static void processChunkNBT(NBTTagCompound compound, World world) {
|
||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
||||
int x = level.getInteger("xPos");
|
||||
int z = level.getInteger("zPos");
|
||||
NBTTagCompound levelCompoundTag = compound.getCompoundTag("Level");
|
||||
|
||||
if (PosteaProcessedChunksWorldSavedData.addChunk(x, z)) {
|
||||
transformTileEntities(compound, world);
|
||||
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) {
|
||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
||||
NBTTagList sections = level.getTagList("Sections", 10);
|
||||
// This will not change between runs, unless a mod is updated or added.
|
||||
public static final int POSTEA_UPDATE_CODE = getModListHash();
|
||||
|
||||
int chunkXPos = level.getInteger("xPos") * 16;
|
||||
int chunkZPos = level.getInteger("zPos") * 16;
|
||||
// If a chunk has the same postea code, then do not update it. Return false.
|
||||
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++) {
|
||||
NBTTagCompound section = sections.getCompoundTagAt(i);
|
||||
@@ -48,12 +64,21 @@ public class ChunkFixerUtility {
|
||||
byte sectionY = section.getByte("Y");
|
||||
|
||||
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 metadata = ((metadataArray[index * 2] & 0xFF) << 8) | (metadataArray[index * 2 + 1] & 0xFF);
|
||||
|
||||
// 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);
|
||||
String blockName = GameRegistry.findUniqueIdentifierFor(block)
|
||||
.toString();
|
||||
String blockName = loadedBlocks.computeIfAbsent(
|
||||
block,
|
||||
b -> GameRegistry.findUniqueIdentifierFor(b)
|
||||
.toString());
|
||||
|
||||
BlockConversionInfo blockConversionInfo = new BlockConversionInfo();
|
||||
blockConversionInfo.blockName = blockName;
|
||||
@@ -85,21 +110,22 @@ public class ChunkFixerUtility {
|
||||
}
|
||||
}
|
||||
|
||||
public static void transformTileEntities(NBTTagCompound chunkNBT, World world) {
|
||||
NBTTagCompound level = chunkNBT.getCompoundTag("Level");
|
||||
private static void transformTileEntities(NBTTagCompound levelCompoundTag, World world) {
|
||||
|
||||
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();
|
||||
NBTTagList tileEntities = output.second();
|
||||
|
||||
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 chunkZPos = level.getInteger("zPos") * 16; // Assuming each chunk is 16 blocks along z-axis
|
||||
int chunkXPos = levelCompoundTag.getInteger("xPos") * 16; // Assuming each chunk is 16 blocks along x-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++) {
|
||||
NBTTagCompound section = sections.getCompoundTagAt(i);
|
||||
processSection(section, conversionInfoList, chunkXPos, chunkZPos);
|
||||
@@ -173,6 +199,11 @@ public class ChunkFixerUtility {
|
||||
int z = tileEntity.getInteger("z");
|
||||
|
||||
BlockInfo blockInfo = transformationFunction.apply(tileEntity, world);
|
||||
if (blockInfo == null) {
|
||||
// Do nothing.
|
||||
tileEntitiesCopy.appendTag(tileEntity);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blockInfo.tileTransformer != null) {
|
||||
tileEntitiesCopy.appendTag(blockInfo.tileTransformer.apply(tileEntity));
|
||||
@@ -180,6 +211,7 @@ public class ChunkFixerUtility {
|
||||
|
||||
conversionInfo.add(new ConversionInfo(x, y, z, blockInfo));
|
||||
} else {
|
||||
// Do nothing.
|
||||
tileEntitiesCopy.appendTag(tileEntity);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +219,7 @@ public class ChunkFixerUtility {
|
||||
return new Pair<>(conversionInfo, tileEntitiesCopy);
|
||||
}
|
||||
|
||||
public static class ConversionInfo {
|
||||
private static class ConversionInfo {
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
+3
-2
@@ -1,11 +1,11 @@
|
||||
package com.colen.postea.Utility;
|
||||
package com.gtnewhorizons.postea.utility;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.colen.postea.API.ItemStackReplacementManager;
|
||||
import com.gtnewhorizons.postea.api.ItemStackReplacementManager;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -18,6 +18,7 @@ public abstract class ItemFixerUtility {
|
||||
if (tag.hasKey("id")) {
|
||||
short id = tag.getShort("id");
|
||||
Item item = Item.getItemById(id);
|
||||
if (item == null) return;
|
||||
String itemNameInternal = GameRegistry.findUniqueIdentifierFor(item).modId + ":"
|
||||
+ GameRegistry.findUniqueIdentifierFor(item).name;
|
||||
|
||||
+17
-5
@@ -1,10 +1,11 @@
|
||||
package com.colen.postea.Utility;
|
||||
package com.gtnewhorizons.postea.utility;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
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;
|
||||
@@ -45,12 +46,23 @@ public abstract class PosteaUtilities {
|
||||
Collections.sort(modList);
|
||||
|
||||
// Step 2: Append all elements into one string
|
||||
StringBuilder combinedModStringSorted = new StringBuilder();
|
||||
StringBuilder combinedModStringSortedBuilder = new StringBuilder();
|
||||
for (String element : modList) {
|
||||
combinedModStringSorted.append(element);
|
||||
combinedModStringSortedBuilder.append(element);
|
||||
}
|
||||
|
||||
return Objects.hash(combinedModStringSorted);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5-GTNH",
|
||||
"package": "com.colen.postea.mixins.early",
|
||||
"package": "com.gtnewhorizons.postea.mixins.early",
|
||||
"refmap": "mixins.postea.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinAnvilChunkLoader",
|
||||
"MixinChunk",
|
||||
"MixinItemStack"
|
||||
],
|
||||
"client": [],
|
||||
|
||||
Reference in new issue
Block a user