Skip to content

Commit

Permalink
tweakeroo 1.21+ ACCURATE_PLACEMENT_PROTOCOL field name compact
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyHPi committed Jul 18, 2024
1 parent fea1e8a commit d960b3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,7 +133,7 @@ private static boolean isFacingValidFor(Direction facing, ItemStack stack)
// Carpet-Extra mod accurate block placement protocol support
if (flexible && rotation && accurate == false &&
//#if MC >= 12100
//$$ Configs.Generic.ACCURATE_PLACEMENT_PROTOCOL.getBooleanValue() &&
//$$ TweakerooAccess.getAccuratePlacementProtocolValue() &&
//#elseif MC >= 11700
//$$ Configs.Generic.CARPET_ACCURATE_PLACEMENT_PROTOCOL.getBooleanValue() &&
//#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ConfigBoolean> newAccField = ReflectionUtil.getStaticField(genericClass, "ACCURATE_PLACEMENT_PROTOCOL");
if (newAccField.isPresent())
{
return newAccField.get().getBooleanValue();
}
ReflectionUtil.ValueWrapper<ConfigBoolean> oldAccField = ReflectionUtil.getStaticField(genericClass, "CARPET_ACCURATE_PLACEMENT_PROTOCOL");
if (oldAccField.isPresent())
{
return oldAccField.get().getBooleanValue();
}

return false;
}
}

0 comments on commit d960b3a

Please sign in to comment.