diff --git a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/features/schematicProPlace/PlacementTweaksMixin.java b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/features/schematicProPlace/PlacementTweaksMixin.java index 6848b72f..1870aee8 100644 --- a/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/features/schematicProPlace/PlacementTweaksMixin.java +++ b/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/features/schematicProPlace/PlacementTweaksMixin.java @@ -30,6 +30,7 @@ import me.fallenbreath.tweakermore.impl.features.schematicProPlace.ProPlaceImpl; import me.fallenbreath.tweakermore.util.BlockUtil; import me.fallenbreath.tweakermore.util.ModIds; +import me.fallenbreath.tweakermore.util.compat.tweakermore.TweakerooAccess; import net.minecraft.block.BlockState; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; @@ -131,7 +132,9 @@ private static boolean isFacingValidFor(Direction facing, ItemStack stack) // Carpet-Extra mod accurate block placement protocol support if (flexible && rotation && accurate == false && - //#if MC >= 11700 + //#if MC >= 12100 + //$$ TweakerooAccess.getAccuratePlacementProtocolValue() && + //#elseif MC >= 11700 //$$ Configs.Generic.CARPET_ACCURATE_PLACEMENT_PROTOCOL.getBooleanValue() && //#else FeatureToggle.CARPET_ACCURATE_PLACEMENT_PROTOCOL.getBooleanValue() && diff --git a/src/main/java/me/fallenbreath/tweakermore/util/compat/tweakermore/TweakerooAccess.java b/src/main/java/me/fallenbreath/tweakermore/util/compat/tweakermore/TweakerooAccess.java index ae7c7714..e5eac15a 100644 --- a/src/main/java/me/fallenbreath/tweakermore/util/compat/tweakermore/TweakerooAccess.java +++ b/src/main/java/me/fallenbreath/tweakermore/util/compat/tweakermore/TweakerooAccess.java @@ -20,7 +20,10 @@ package me.fallenbreath.tweakermore.util.compat.tweakermore; +import fi.dy.masa.malilib.config.options.ConfigBoolean; +import fi.dy.masa.tweakeroo.config.Configs; import fi.dy.masa.tweakeroo.util.CameraEntity; +import me.fallenbreath.tweakermore.util.ReflectionUtil; import net.minecraft.client.network.ClientPlayerEntity; import org.jetbrains.annotations.Nullable; @@ -31,4 +34,23 @@ public static ClientPlayerEntity getFreecamEntity() { return CameraEntity.getCamera(); } + + // for 1.21+ tweakeroo, + // CARPET_ACCURATE_PLACEMENT_PROTOCOL changed to ACCURATE_PLACEMENT_PROTOCOL + public static boolean getAccuratePlacementProtocolValue() + { + Class genericClass = Configs.Generic.class; + ReflectionUtil.ValueWrapper newAccField = ReflectionUtil.getStaticField(genericClass, "ACCURATE_PLACEMENT_PROTOCOL"); + if (newAccField.isPresent()) + { + return newAccField.get().getBooleanValue(); + } + ReflectionUtil.ValueWrapper oldAccField = ReflectionUtil.getStaticField(genericClass, "CARPET_ACCURATE_PLACEMENT_PROTOCOL"); + if (oldAccField.isPresent()) + { + return oldAccField.get().getBooleanValue(); + } + + return false; + } }