From 5430016be46bc3a03aa71d004298c9f1371b86e6 Mon Sep 17 00:00:00 2001 From: Adrien1106 Date: Thu, 23 May 2024 12:33:54 +0200 Subject: [PATCH] feat: added support for ReFramed block entities with axiom --- build.gradle | 3 +++ gradle.properties | 2 +- .../reframed/mixin/CompatMixinPlugin.java | 3 ++- ...AxiomClientBlockEntitySerializerMixin.java | 26 +++++++++++++++++++ src/main/resources/reframed.mixins.json | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/adrien1106/reframed/mixin/compat/AxiomClientBlockEntitySerializerMixin.java diff --git a/build.gradle b/build.gradle index 43707f3..f438f10 100755 --- a/build.gradle +++ b/build.gradle @@ -118,6 +118,9 @@ dependencies { modRuntimeOnly "com.teamresourceful.resourcefullib:resourcefullib-fabric-${project.minecraft_version}:2.4.7" modRuntimeOnly "earth.terrarium.chipped:Chipped-fabric-${project.minecraft_version}:3.1.2" + // Axiom for blueprint support + modCompileOnly "maven.modrinth:N6n5dqoA:nvx3oDkz" + // Fabric API. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" } diff --git a/gradle.properties b/gradle.properties index fbab9f1..150bdf0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ loader_version=0.15.11 # Mod Properties modrinth_id = jCpoCBpn -mod_version = 1.5.10 +mod_version = 1.5.11 maven_group = fr.adrien1106 archives_base_name = ReFramed mod_id = reframed diff --git a/src/main/java/fr/adrien1106/reframed/mixin/CompatMixinPlugin.java b/src/main/java/fr/adrien1106/reframed/mixin/CompatMixinPlugin.java index 2530838..cb8014f 100644 --- a/src/main/java/fr/adrien1106/reframed/mixin/CompatMixinPlugin.java +++ b/src/main/java/fr/adrien1106/reframed/mixin/CompatMixinPlugin.java @@ -17,7 +17,7 @@ public class CompatMixinPlugin implements IMixinConfigPlugin { private static final FabricLoader LOADER = FabricLoader.getInstance(); private static final Logger LOGGER = LoggerFactory.getLogger("ReFramed MIXIN"); - private static final List COMPAT_MOD = List.of("athena", "indium", "sodium", "special-model-loader", "continuity"); + private static final List COMPAT_MOD = List.of("athena", "indium", "sodium", "special-model-loader", "continuity", "axiom"); private static final Map> CONDITIONS = new HashMap<>(); static { CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.AthenaBakedModelMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(0))); @@ -33,6 +33,7 @@ public class CompatMixinPlugin implements IMixinConfigPlugin { CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityCTMBakedModelMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4))); CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityCTMQuadTransformMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4))); CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.ContinuityModelWrappingHandlerMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(4))); + CONDITIONS.put("fr.adrien1106.reframed.mixin.compat.AxiomClientBlockEntitySerializerMixin", () -> LOADER.isModLoaded(COMPAT_MOD.get(5))); } diff --git a/src/main/java/fr/adrien1106/reframed/mixin/compat/AxiomClientBlockEntitySerializerMixin.java b/src/main/java/fr/adrien1106/reframed/mixin/compat/AxiomClientBlockEntitySerializerMixin.java new file mode 100644 index 0000000..aae38cb --- /dev/null +++ b/src/main/java/fr/adrien1106/reframed/mixin/compat/AxiomClientBlockEntitySerializerMixin.java @@ -0,0 +1,26 @@ +package fr.adrien1106.reframed.mixin.compat; + +import com.moulberry.axiom.world_modification.ClientBlockEntitySerializer; +import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryWrapper; +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(ClientBlockEntitySerializer.class) +public class AxiomClientBlockEntitySerializerMixin { + + @Inject( + method = "serialize", + at = @At("HEAD"), + remap = false, + cancellable = true + ) + private static void serialize(BlockEntity blockEntity, RegistryWrapper.WrapperLookup provider, CallbackInfoReturnable cir) { + if (!(blockEntity instanceof ThemeableBlockEntity)) return; + cir.setReturnValue(blockEntity.createNbt()); + } +} diff --git a/src/main/resources/reframed.mixins.json b/src/main/resources/reframed.mixins.json index 5ed414c..035eb75 100644 --- a/src/main/resources/reframed.mixins.json +++ b/src/main/resources/reframed.mixins.json @@ -15,6 +15,7 @@ "compat.AthenaBakedModelMixin", "compat.AthenaConnectedBlockModelMixin", "compat.AthenaWrappedGetterMixin", + "compat.AxiomClientBlockEntitySerializerMixin", "compat.ContinuityConnectionPredicateMixin", "compat.ContinuityCTMBakedModelMixin", "compat.ContinuityCTMQuadTransformMixin",