From ee1326637804069e406d527d689f5d9333c28c92 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Wed, 18 May 2022 22:16:12 +0200 Subject: [PATCH] Hide ores with deepslate at Y=4 and below (#7792) Fixes #7771 Co-authored-by: stonar96 --- patches/server/Anti-Xray.patch | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index c187af8f24..0fbd59d3ae 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -302,10 +302,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final BlockState[] presetBlockStates; + private final BlockState[] presetBlockStatesFull; + private final BlockState[] presetBlockStatesStone; ++ private final BlockState[] presetBlockStatesDeepslate; + private final BlockState[] presetBlockStatesNetherrack; + private final BlockState[] presetBlockStatesEndStone; + private final int[] presetBlockStateBitsGlobal; + private final int[] presetBlockStateBitsStoneGlobal; ++ private final int[] presetBlockStateBitsDeepslateGlobal; + private final int[] presetBlockStateBitsNetherrackGlobal; + private final int[] presetBlockStateBitsEndStoneGlobal; + private final boolean[] solidGlobal = new boolean[Block.BLOCK_STATE_REGISTRY.size()]; @@ -327,10 +329,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + presetBlockStates = null; + presetBlockStatesFull = null; + presetBlockStatesStone = new BlockState[]{Blocks.STONE.defaultBlockState()}; ++ presetBlockStatesDeepslate = new BlockState[]{Blocks.DEEPSLATE.defaultBlockState()}; + presetBlockStatesNetherrack = new BlockState[]{Blocks.NETHERRACK.defaultBlockState()}; + presetBlockStatesEndStone = new BlockState[]{Blocks.END_STONE.defaultBlockState()}; + presetBlockStateBitsGlobal = null; + presetBlockStateBitsStoneGlobal = new int[]{GLOBAL_BLOCKSTATE_PALETTE.idFor(Blocks.STONE.defaultBlockState())}; ++ presetBlockStateBitsDeepslateGlobal = new int[]{GLOBAL_BLOCKSTATE_PALETTE.idFor(Blocks.DEEPSLATE.defaultBlockState())}; + presetBlockStateBitsNetherrackGlobal = new int[]{GLOBAL_BLOCKSTATE_PALETTE.idFor(Blocks.NETHERRACK.defaultBlockState())}; + presetBlockStateBitsEndStoneGlobal = new int[]{GLOBAL_BLOCKSTATE_PALETTE.idFor(Blocks.END_STONE.defaultBlockState())}; + } else { @@ -353,6 +357,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + presetBlockStates = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateSet.toArray(new BlockState[0]); + presetBlockStatesFull = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateList.toArray(new BlockState[0]); + presetBlockStatesStone = null; ++ presetBlockStatesDeepslate = null; + presetBlockStatesNetherrack = null; + presetBlockStatesEndStone = null; + presetBlockStateBitsGlobal = new int[presetBlockStatesFull.length]; @@ -362,6 +367,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + presetBlockStateBitsStoneGlobal = null; ++ presetBlockStateBitsDeepslateGlobal = null; + presetBlockStateBitsNetherrackGlobal = null; + presetBlockStateBitsEndStoneGlobal = null; + } @@ -407,7 +413,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return switch (level.getWorld().getEnvironment()) { + case NETHER -> presetBlockStatesNetherrack; + case THE_END -> presetBlockStatesEndStone; -+ default -> presetBlockStatesStone; ++ default -> bottomBlockY < 0 ? presetBlockStatesDeepslate : presetBlockStatesStone; + }; + } + @@ -472,7 +478,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + LevelChunkSection[] nearbyChunkSections = new LevelChunkSection[4]; + LevelChunk chunk = chunkPacketInfoAntiXray.getChunk(); + Level level = chunk.getLevel(); -+ int maxChunkSectionIndex = Math.min((maxBlockHeight >> 4) - chunk.getMinSection(), chunk.getSectionsCount() - 1); ++ int maxChunkSectionIndex = Math.min((maxBlockHeight >> 4) - chunk.getMinSection(), chunk.getSectionsCount()) - 1; + boolean[] solidTemp = null; + boolean[] obfuscateTemp = null; + bitStorageReader.setBuffer(chunkPacketInfoAntiXray.getBuffer()); @@ -506,7 +512,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + presetBlockStateBitsTemp = switch (level.getWorld().getEnvironment()) { + case NETHER -> presetBlockStateBitsNetherrackGlobal; + case THE_END -> presetBlockStateBitsEndStoneGlobal; -+ default -> presetBlockStateBitsStoneGlobal; ++ default -> chunkSectionIndex + chunk.getMinSection() < 0 ? presetBlockStateBitsDeepslateGlobal : presetBlockStateBitsStoneGlobal; + }; + } else { + presetBlockStateBitsTemp = presetBlockStateBitsGlobal;