Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update 1.21 masa's mod dependency, fix crashing due to tweakeroo changes #69

Merged
merged 3 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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() &&
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;
}
}