Skip to content

Commit

Permalink
Fixed processing pattern component serialization for 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroksl committed Aug 17, 2024
1 parent 24dca0a commit c0a5c81
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 108 deletions.
47 changes: 21 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ base {
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

neoForge {
version = project.neo_version
version = project.neoforge_version

parchment {
mappingsVersion = project.parchment_mappings_version
Expand Down Expand Up @@ -105,46 +105,41 @@ dependencies {
implementation "curse.maven:glodium-957920:5614731"
implementation "curse.maven:applied-energistics-2-223794:5610903"
implementation "curse.maven:ex-pattern-provider-892005:5617630"
jarJar(implementation "de.mari_023:ae2wtlib_api:19.1.0-alpha.1")
compileOnly "curse.maven:emi-580555:5619579"
compileOnly "curse.maven:applied-flux-965012:5614830"
//compileOnly "curse.maven:jade-324717:5427817"
//compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:16.0.729"
compileOnly "curse.maven:jade-324717:5427817"
compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:16.0.729"
// runtime test
//runtimeOnly "curse.maven:applied-flux-965012:5614830"
//runtimeOnly "de.mari_023:ae2wtlib:19.1.0-alpha.1"
//runtimeOnly "curse.maven:mega-cells-622112:5575776"
//runtimeOnly "curse.maven:jade-324717:5427817"
runtimeOnly "curse.maven:applied-flux-965012:5614830"
runtimeOnly "de.mari_023:ae2wtlib:19.1.0-alpha.1"
runtimeOnly "curse.maven:jade-324717:5427817"
// setup Xei
switch (use_Xei) {
case "emi":
//runtimeOnly "dev.emi:emi-neoforge:1.1.10+1.21"
runtimeOnly "dev.emi:emi-neoforge:1.1.10+1.21"
break
case "rei":
//runtimeOnly "me.shedaniel:RoughlyEnoughItems-neoforge:16.0.729"
//runtimeOnly "dev.architectury:architectury-neoforge:13.0.1"
//runtimeOnly "curse.maven:cloth-config-348521:5424576"
runtimeOnly "me.shedaniel:RoughlyEnoughItems-neoforge:16.0.729"
runtimeOnly "dev.architectury:architectury-neoforge:13.0.1"
runtimeOnly "curse.maven:cloth-config-348521:5424576"
break
}
}

var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
neo_version : neoforge_version, neo_version_range: neoforge_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"

filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}

publishing {
Expand Down
15 changes: 7 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
parchment_minecraft_version=1.21
parchment_mappings_version=2024.07.28
## Environment Properties
minecraft_version=1.21
minecraft_version_range=[1.21,1.21.1)
neo_version=21.1.1
neo_version_range=[21.1.0-beta,)
minecraft_release=1.21.1
minecraft_version=1.21.1
minecraft_version_range=1.21.1
neoforge_version=21.1.1
neoforge_version_range=[21.1.1,)
loader_version_range=[4,)
## Mod Properties
mod_id=advanced_ae
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
36 changes: 14 additions & 22 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -85,9 +83,10 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -134,29 +133,26 @@ location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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=SC2039,SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,15 +197,11 @@ if "$cygwin" || "$msys" ; then
done
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, 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.
# 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.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down Expand Up @@ -249,4 +241,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
24 changes: 11 additions & 13 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

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
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.

goto fail

Expand All @@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

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
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.

goto fail

Expand Down Expand Up @@ -91,4 +89,4 @@ exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
:omega
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
package net.pedroksl.advanced_ae.common;

import appeng.api.AECapabilities;
import appeng.api.implementations.blockentities.ICraftingMachine;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IInWorldGridNodeHost;
import appeng.api.parts.PartModels;
import appeng.api.parts.RegisterPartCapabilitiesEvent;
import appeng.block.AEBaseBlockItem;
import appeng.block.AEBaseEntityBlock;
import appeng.blockentity.AEBaseBlockEntity;
import appeng.blockentity.AEBaseInvBlockEntity;
import appeng.blockentity.ClientTickingBlockEntity;
import appeng.blockentity.ServerTickingBlockEntity;
import appeng.blockentity.powersink.AEBasePoweredBlockEntity;
import appeng.items.AEBaseItem;
import appeng.items.tools.powered.powersink.PoweredItemCapabilities;
import com.glodblock.github.extendedae.api.caps.ICrankPowered;
import com.glodblock.github.extendedae.api.caps.IGenericInvHost;
import com.glodblock.github.extendedae.api.caps.IMEStorageAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.pedroksl.advanced_ae.common.entities.AdvPatternProviderEntity;
import net.pedroksl.advanced_ae.xmod.appflux.AFCommonLoad;
import com.glodblock.github.glodium.registry.RegistryHandler;
import com.glodblock.github.glodium.util.GlodUtil;
Expand All @@ -29,12 +41,25 @@
import net.pedroksl.advanced_ae.gui.patternencoder.AdvPatternEncoderContainer;
import org.apache.commons.lang3.tuple.Pair;

import java.util.Collection;

public class AAERegistryHandler extends RegistryHandler {

public static final AAERegistryHandler INSTANCE = new AAERegistryHandler();

@SuppressWarnings("UnstableApiUsage")
public AAERegistryHandler() {
super(AdvancedAE.MOD_ID);
this.cap(AEBaseInvBlockEntity.class, Capabilities.ItemHandler.BLOCK, AEBaseInvBlockEntity::getExposedItemHandler);
this.cap(AEBasePoweredBlockEntity.class, Capabilities.EnergyStorage.BLOCK, AEBasePoweredBlockEntity::getEnergyStorage);
this.cap(IInWorldGridNodeHost.class, AECapabilities.IN_WORLD_GRID_NODE_HOST, (object, context) -> object);
this.cap(IAEItemPowerStorage.class, Capabilities.EnergyStorage.ITEM, (object, context) -> new PoweredItemCapabilities(object, (IAEItemPowerStorage) object.getItem()));
this.cap(ICrankPowered.class, AECapabilities.CRANKABLE, ICrankPowered::getCrankable);
this.cap(ICraftingMachine.class, AECapabilities.CRAFTING_MACHINE, (object, context) -> object);
this.cap(IGenericInvHost.class, AECapabilities.GENERIC_INTERNAL_INV, IGenericInvHost::getGenericInv);
this.cap(IMEStorageAccess.class, AECapabilities.ME_STORAGE, IMEStorageAccess::getMEStorage);
this.cap(AdvPatternProviderEntity.class, AECapabilities.GENERIC_INTERNAL_INV,
(blockEntity, context) -> blockEntity.getLogic().getReturnInv());
}

public <T extends AEBaseBlockEntity> void block(String name, AEBaseEntityBlock<T> block, Class<T> clazz,
Expand All @@ -51,6 +76,10 @@ public void runRegister() {
this.onRegisterModels(); // Parts
}

public Collection<Block> getBlocks() {
return this.blocks.stream().map(Pair::getRight).toList();
}

@SubscribeEvent
public void onRegisterCapability(RegisterPartCapabilitiesEvent event) {
AdvPatternProviderPart.registerCapability(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import appeng.api.crafting.PatternDetailsHelper;
import appeng.items.parts.PartItem;
import com.glodblock.github.glodium.util.GlodCodecs;
import com.glodblock.github.glodium.util.GlodUtil;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.Item;
import net.pedroksl.advanced_ae.common.blocks.AdvPatternProviderBlock;
import net.pedroksl.advanced_ae.common.entities.AdvPatternProviderEntity;
Expand All @@ -15,6 +17,8 @@
public class AAESingletons {

public static DataComponentType<EncodedAdvProcessingPattern> ENCODED_ADV_PROCESSING_PATTERN;
public static DataComponentType<CompoundTag> STACK_TAG;

public static AdvPatternProviderBlock ADV_PATTERN_PROVIDER;
public static PartItem<AdvPatternProviderPart> ADV_PATTERN_PROVIDER_PART;

Expand All @@ -23,19 +27,22 @@ public class AAESingletons {
public static AdvPatternEncoderItem ADV_PATTERN_ENCODER;

public static void init(AAERegistryHandler handler) {
STACK_TAG = GlodUtil.getComponentType(CompoundTag.CODEC, GlodCodecs.NBT_STREAM_CODEC);
ENCODED_ADV_PROCESSING_PATTERN = GlodUtil.getComponentType(EncodedAdvProcessingPattern.CODEC,
EncodedAdvProcessingPattern.STREAM_CODEC);
ADV_PATTERN_PROVIDER = new AdvPatternProviderBlock();
ADV_PATTERN_PROVIDER_PART = new PartItem<>(new Item.Properties(), AdvPatternProviderPart.class,
AdvPatternProviderPart::new);

ADV_PROCESSING_PATTERN =
PatternDetailsHelper.encodedPatternItemBuilder(AdvProcessingPattern::new).invalidPatternTooltip(AdvProcessingPattern::getInvalidPatternTooltip).build();
PatternDetailsHelper.encodedPatternItemBuilder(AdvProcessingPattern::new)
.invalidPatternTooltip(AdvProcessingPattern::getInvalidPatternTooltip).build();

ADV_PATTERN_ENCODER = new AdvPatternEncoderItem();


handler.comp("encoded_adv_processing_pattern", ENCODED_ADV_PROCESSING_PATTERN);
handler.comp("generic_nbt", STACK_TAG);

handler.block("adv_pattern_provider", ADV_PATTERN_PROVIDER, AdvPatternProviderEntity.class,
AdvPatternProviderEntity::new);
Expand Down
Loading

0 comments on commit c0a5c81

Please sign in to comment.