From fc745da88b19064f3015f918b4f090f2c4666524 Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 26 Apr 2023 00:53:12 +0200 Subject: Make ruler not work cross plot --- .../notenoughupdates/miscfeatures/CustomItemEffects.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java index c8c7a3da..242fce4e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; +import lombok.var; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -53,6 +54,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumFacing; +import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.util.Vec3i; @@ -1585,10 +1587,21 @@ public class CustomItemEffects { Facing facing = Facing.forDirection(yaw); int xOff = facing == Facing.WEST ? -1 : facing == Facing.EAST ? 1 : 0; int zOff = facing == Facing.NORTH ? -1 : facing == Facing.SOUTH ? 1 : 0; + BlockPos posNew = candidate.add(xOff, 0, zOff); + if ( + "garden".equals(SBInfo.getInstance().getLocation()) + ) { + var plotX = MathHelper.floor_float((candidate.getX() + 48) / 96F); + var plotXNew = MathHelper.floor_float((posNew.getX() + 48) / 96F); + var plotZ = MathHelper.floor_float((candidate.getZ() + 48) / 96F); + var plotZNew = MathHelper.floor_float((posNew.getZ() + 48) / 96F); + if (plotX != plotXNew || plotZ != plotZNew) { + continue; + } + } if (!sneaking) { if (Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(xOff, 1, zOff)).getBlock() == Blocks.air) { - BlockPos posNew = candidate.add(xOff, 0, zOff); if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) { IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew.add(0, 1, 0)); if (blockNew.getBlock() == Blocks.air) { @@ -1601,7 +1614,6 @@ public class CustomItemEffects { } else { if (Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(xOff, 0, zOff)).getBlock() == Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos()).getBlock()) { - BlockPos posNew = candidate.add(xOff, 0, zOff); if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) { IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew.add(0, 0, 0)); if (blockNew.getBlock() == -- cgit