diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java index 7f0ad20..2a156d3 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java @@ -1,6 +1,6 @@ package cc.tweaked_programs.cccbridge.common.mixin.scroller; -import cc.tweaked_programs.cccbridge.common.minecraft.block.ScrollerBlock; +import cc.tweaked_programs.cccbridge.common.create.behaviour.LuaScrollValueBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueRenderer; import com.simibubi.create.foundation.utility.AdventureUtil; @@ -9,20 +9,22 @@ import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ScrollValueRenderer.class) public abstract class MixinScrollValueRenderer { + @Unique private static boolean isPhysicalPlayer(Player player) { return player != null && !player.isSpectator(); } - @Redirect(method = "addBox", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/AdventureUtil;isAdventure(Lnet/minecraft/world/entity/player/Player;)Z"), remap = false) + @Redirect(method = "addBox", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/AdventureUtil;isAdventure(Lnet/minecraft/world/entity/player/Player;)Z")) private static boolean cccbridge$addBox$redirectIsAdventure(Player player, ClientLevel world, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, boolean highlight) { - if (world.getBlockState(pos).getBlock() instanceof ScrollerBlock) + if (behaviour instanceof LuaScrollValueBehaviour) return isPhysicalPlayer(player); - return AdventureUtil.isAdventure(player); + return !AdventureUtil.isAdventure(player); } } diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java index 13466a2..621e7ee 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java @@ -4,32 +4,27 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsInputHandler; import com.simibubi.create.foundation.utility.AdventureUtil; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; 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.Redirect; @Mixin(ValueSettingsInputHandler.class) public class MixinValueSettingsInputHandler { - private static boolean isPhysicalPlayer(Player player) { - return player != null && !player.isSpectator(); - } - - @Redirect(method = "canInteract", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/AdventureUtil;isAdventure(Lnet/minecraft/world/entity/player/Player;)Z"), remap = false) + @Redirect(method = "canInteract", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/AdventureUtil;isAdventure(Lnet/minecraft/world/entity/player/Player;)Z")) private static boolean cccbridge$canInteract$redirectIsAdventure(Player player) { - Level level = player.level(); HitResult hitResult = player.pick(5, 1, false); if (hitResult instanceof BlockHitResult blockHit) { - BlockEntity blockEntity = level.getBlockEntity(blockHit.getBlockPos()); + BlockEntity blockEntity = player.level().getBlockEntity(blockHit.getBlockPos()); if (blockEntity instanceof ScrollerBlockEntity) - return !isPhysicalPlayer(player); + return false; } - return !AdventureUtil.isAdventure(player); + return AdventureUtil.isAdventure(player); } }