diff options
author | nea <nea@nea.moe> | 2023-04-26 00:53:12 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-04-26 00:53:12 +0200 |
commit | fc745da88b19064f3015f918b4f090f2c4666524 (patch) | |
tree | 501091c82d82cc47e1947d8f03609c4a2b1118a4 | |
parent | b12f18fdbc60f141657ecfbd18590724666b593d (diff) | |
download | NotEnoughUpdates-fc745da88b19064f3015f918b4f090f2c4666524.tar.gz NotEnoughUpdates-fc745da88b19064f3015f918b4f090f2c4666524.tar.bz2 NotEnoughUpdates-fc745da88b19064f3015f918b4f090f2c4666524.zip |
Make ruler not work cross plot
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java | 16 | ||||
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt | 8 |
2 files changed, 22 insertions, 2 deletions
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() == diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt index a5ff48d2..ef3c78ab 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt @@ -47,6 +47,7 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.function.Predicate import kotlin.math.floor +import kotlin.math.nextDown @NEUAutoSubscribe class DevTestCommand { @@ -107,6 +108,13 @@ class DevTestCommand { requires { canPlayerExecute(it) } + thenLiteralExecute("garden") { + val player = Minecraft.getMinecraft().thePlayer + reply("Is in Garden: ${SBInfo.getInstance().getLocation() == "garden"}") + val pp = player.position + reply("Plot X: ${floor((pp.getX() + 48) / 96F)}") + reply("Plot Z: ${floor((pp.getZ() + 48) / 96F)}") + }.withHelp("Show diagnostics information about the garden") thenLiteralExecute("profileinfo") { val currentProfile = SBInfo.getInstance().currentProfile val gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile) |