diff options
author | DoKM <mcazzyman@gmail.com> | 2021-07-14 14:05:15 +0200 |
---|---|---|
committer | DoKM <mcazzyman@gmail.com> | 2021-07-14 14:05:15 +0200 |
commit | af9f52a5bbb040c07d271f39a23b651316260111 (patch) | |
tree | 37bb4ab1ec78a46c033e8681f7978cad87ecf46d | |
parent | 7159455dad6ba172d64ea54218d61872463157d5 (diff) | |
download | NotEnoughUpdates-af9f52a5bbb040c07d271f39a23b651316260111.tar.gz NotEnoughUpdates-af9f52a5bbb040c07d271f39a23b651316260111.tar.bz2 NotEnoughUpdates-af9f52a5bbb040c07d271f39a23b651316260111.zip |
add check if any attached blocks are air for titanium alert
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index 6f706b5c..c6d0f008 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.overlays.MiningOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.block.BlockAir; import net.minecraft.block.BlockStone; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -27,6 +28,12 @@ public class MiningStuff { private static BlockPos overlayLoc = null; private static long titaniumNotifMillis = 0; + private static Minecraft mc; + + + public MiningStuff(){ + mc = Minecraft.getMinecraft(); + } public static void processBlockChangePacket(S23PacketBlockChange packetIn) { if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) { @@ -45,7 +52,7 @@ public class MiningStuff { IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos); if(existingBlock == null) return; if(existingBlock.getBlock() == Blocks.stone && existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) return; - + if(!checkIfAnyIsAir(getAttachedBlocks(pos))) return; BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); double distSq = pos.distanceSq(player); @@ -59,6 +66,26 @@ public class MiningStuff { } } + private static BlockPos[] getAttachedBlocks(BlockPos block){ + BlockPos[] blocks = new BlockPos[6]; + blocks[0] = new BlockPos(block.getX()-1, block.getY(), block.getZ()); + blocks[1] = new BlockPos(block.getX()+1, block.getY(), block.getZ()); + blocks[2] = new BlockPos(block.getX(), block.getY()-1, block.getZ()); + blocks[3] = new BlockPos(block.getX(), block.getY()+1, block.getZ()); + blocks[4] = new BlockPos(block.getX(), block.getY(), block.getZ()-1); + blocks[5] = new BlockPos(block.getX(), block.getY(), block.getZ()+1); + return blocks; + } + + private static boolean checkIfAnyIsAir(BlockPos[] blocks){ + for (BlockPos block : blocks) { + if(mc.theWorld.getBlockState(block).getBlock() instanceof BlockAir){ + return true; + } + } + return false; + } + @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent.Post event) { if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) { |