From 2ee6334d8a3f760539b24e48e38a44969dd314e3 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Sat, 4 Jan 2025 17:21:03 +1100 Subject: [PATCH] Fix Crash with BOP and Labs FTB Utils Fix --- dependencies.gradle | 7 ++++ gradle.properties | 3 ++ .../java/com/nomiceu/nomilabs/LabsValues.java | 1 + .../nomilabs/mixin/LabsLateMixinLoader.java | 1 + .../biomesoplenty/BlockBOPPlantMixin.java | 32 +++++++++++++++++++ .../mixins.nomilabs.biomesoplenty.json | 12 +++++++ 6 files changed, 56 insertions(+) create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/biomesoplenty/BlockBOPPlantMixin.java create mode 100644 src/main/resources/mixins.nomilabs.biomesoplenty.json diff --git a/dependencies.gradle b/dependencies.gradle index ca6278d1..f623d410 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -191,6 +191,9 @@ dependencies { // FindMyItemsAndFluids (from CurseForge) compileOnly rfg.deobf("curse.maven:findmyitemsandfluids-610085:3748963") // Version 1.0.0 + // Biomes o Plenty (from CurseForge) + compileOnly rfg.deobf("curse.maven:biomes-o-plenty-220318:2842510") // Version 7.0.1.2444 + /* -------------------------------- Soft Deps, Multiple Runtime Declaration -------------------------------- */ if (project.enable_draconic.toBoolean() || project.enable_thermal.toBoolean()) { runtimeOnly "curse.maven:redstone-flux-270789:2920436" // Version 2.1.1.1 @@ -325,4 +328,8 @@ dependencies { if (project.enable_mouse_tweaks.toBoolean()) { runtimeOnly "curse.maven:mouse-tweaks-461660:4661407" // Mouse Tweaks Unofficial, Version 3.1.4 } + + if (project.enable_biomes_o_plenty.toBoolean()) { + runtimeOnly "curse.maven:biomes-o-plenty-220318:2842510" // Version 7.0.1.2444 + } } diff --git a/gradle.properties b/gradle.properties index 262ffe82..f190adb8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -317,3 +317,6 @@ enable_thermal = false # Whether to enable Mouse Tweaks in runtime. Useful for testing interactions with various GUIs. enable_mouse_tweaks = false + +# Whether to enable Biomes o Plenty in runtime. Fixes an issue with a crash with FTB Utils, due to a Labs Mixin. +enable_biomes_o_plenty = false diff --git a/src/main/java/com/nomiceu/nomilabs/LabsValues.java b/src/main/java/com/nomiceu/nomilabs/LabsValues.java index 550b9e59..424adf76 100644 --- a/src/main/java/com/nomiceu/nomilabs/LabsValues.java +++ b/src/main/java/com/nomiceu/nomilabs/LabsValues.java @@ -48,4 +48,5 @@ public class LabsValues { public static final String BETTER_P2P_MODID = "betterp2p"; public static final String FIND_ME_MODID = "findme"; public static final String REDSTONE_FLUX_MODID = "redstoneflux"; + public static final String BIOMES_O_PLENTY_MODID = "biomesoplenty"; } diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/LabsLateMixinLoader.java b/src/main/java/com/nomiceu/nomilabs/mixin/LabsLateMixinLoader.java index e04a0f51..9b7ca806 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/LabsLateMixinLoader.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/LabsLateMixinLoader.java @@ -51,6 +51,7 @@ public class LabsLateMixinLoader implements ILateMixinLoader { .put(LabsValues.BQU_MODID, true) .put(LabsValues.BETTER_P2P_MODID, true) .put(LabsValues.STORAGE_DRAWERS_MODID, true) + .put(LabsValues.BIOMES_O_PLENTY_MODID, true) .build(); @Override diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/biomesoplenty/BlockBOPPlantMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/biomesoplenty/BlockBOPPlantMixin.java new file mode 100644 index 00000000..af8baa26 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/biomesoplenty/BlockBOPPlantMixin.java @@ -0,0 +1,32 @@ +package com.nomiceu.nomilabs.mixin.biomesoplenty; + +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import biomesoplenty.common.block.BlockBOPPlant; + +/** + * Fixes a crash with BOP and FTB Utils. + */ +@Mixin(value = BlockBOPPlant.class, remap = false) +public class BlockBOPPlantMixin { + + @Shadow + public IProperty variantProperty; + + @Inject(method = "isReplaceable", at = @At("HEAD"), cancellable = true, remap = true) + private void checkForInstance(IBlockAccess world, BlockPos pos, CallbackInfoReturnable cir) { + IBlockState state = world.getBlockState(pos); + + if (!state.getPropertyKeys().contains(variantProperty)) + cir.setReturnValue(state.getMaterial().isReplaceable()); + } +} diff --git a/src/main/resources/mixins.nomilabs.biomesoplenty.json b/src/main/resources/mixins.nomilabs.biomesoplenty.json new file mode 100644 index 00000000..00362c6e --- /dev/null +++ b/src/main/resources/mixins.nomilabs.biomesoplenty.json @@ -0,0 +1,12 @@ +{ + "package": "com.nomiceu.nomilabs.mixin.biomesoplenty", + "refmap": "mixins.nomilabs.refmap.json", + "target": "@env(DEFAULT)", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "BlockBOPPlantMixin" + ], + "client": [], + "server": [] +}