From c957b90908b7649f8f25c098026cb991fba87167 Mon Sep 17 00:00:00 2001 From: etianl <115842502+etianl@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:22:25 -0700 Subject: [PATCH] 1.1.5 BaseHunting/ChunkTracing Performance improved muchly ***Base Hunting Performance Muchly Improved!!!*** **BaseFinder** - Switched to reading the block positions from chunk sections so we can easily skip sections that are empty or null. - Switching to reading chunk sections like this has also massively improved performance with BaseFinder. - Made Saving and Loading base chunks to disk not enabled by default because it's really not necessary. - Fixed the slider range for Sky Build Finder, it's minimum and slider range were too high meaning it couldn't be configured for all situations properly. - Set the default for "Render-Distance(Chunks)" to 128 from 512. - Added a function to both **BaseFinder** and **NewerNewChunks** which removes chunks from RAM if they are outside of the "Render-Distance(Chunks)" setting. This only will occur if the SaveData and LoadData settings are off (other wise it'd mess up the saved data). - The function above may massively improve performance. I did leave SaveData and LoadData enabled by default for **NewerNewChunks** so you don't lose chunk data but you can disable those options to gain the benefit from this function if you want to (Or just press the Delete Chunk Data button once in a while in the options for it). **NewerNewChunks** - The Palette checks for BlockStates now only happen on sections that are not empty to improve performance and reduce some false positives. - NewerNewChunks now only checks the unique blockstates against palettes that are a BiMap Palette because those are the only kind used for new structure generation. Previously I was just checking it against every palette because my previous method reading bytes couldn't see what kind of palette it was. - Made biome palette checking only occur in the End dimension where it's needed. - Made the taskexecutor code gooder for loading chunk datas in both **NewerNewChunks** and **BaseFinder**. Chunk tracing using **NewerNewChunks** with **BaseFinder** is now super smooth and lag free :D --- README.md | 2 +- gradle.properties | 2 +- .../trouserstreak/modules/BaseFinder.java | 238 ++++++++++-------- .../trouserstreak/modules/NewerNewChunks.java | 150 ++++++----- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 220 insertions(+), 174 deletions(-) diff --git a/README.md b/README.md index e0fe38fc..78d14137 100644 --- a/README.md +++ b/README.md @@ -177,4 +177,4 @@ In no particular order - Please try [ViaFabricPlus](https://github.com/FlorianMichael/ViaFabricPlus), which will let you connect to almost any version from a new version client. - Don't forget to try updating any other mods you are using if your game is crashing. -plz give me star on githoob kthx +plz give me star on githoob kthx \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7022a4bc..b043748e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings=1.21+build.9 loader_version=0.15.11 # Mod Properties -mod_version=1.1.4-1.21 +mod_version=1.1.5-1.21 maven_group=pwn.noobs archives_base_name=1trouser-streak diff --git a/src/main/java/pwn/noobs/trouserstreak/modules/BaseFinder.java b/src/main/java/pwn/noobs/trouserstreak/modules/BaseFinder.java index 8ff7559c..4ff506f2 100644 --- a/src/main/java/pwn/noobs/trouserstreak/modules/BaseFinder.java +++ b/src/main/java/pwn/noobs/trouserstreak/modules/BaseFinder.java @@ -32,6 +32,7 @@ import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.WorldChunk; import pwn.noobs.trouserstreak.Trouser; @@ -44,6 +45,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -85,8 +88,8 @@ public class BaseFinder extends Module { private final Setting skybuildint = sgDetectors.add(new IntSetting.Builder() .name("Sky Build Y Threshold") .description("If Blocks higher than this Y value, flag chunk as possible build.") - .min(258) - .sliderRange(258,319) + .min(-64) + .sliderRange(-64, 319) .defaultValue(260) .visible(() -> skybuildfind.get()) .build()); @@ -262,13 +265,13 @@ public class BaseFinder extends Module { private final Setting save = sgCdata.add(new BoolSetting.Builder() .name("SaveBaseData") .description("Saves the cached bases to a file.") - .defaultValue(true) + .defaultValue(false) .build() ); private final Setting load = sgCdata.add(new BoolSetting.Builder() .name("LoadBaseData") .description("Loads the saved bases from the file.") - .defaultValue(true) + .defaultValue(false) .build() ); private final Setting autoreload = sgCdata.add(new BoolSetting.Builder() @@ -385,7 +388,7 @@ public WWidget getWidget(GuiTheme theme) { public final Setting renderDistance = sgRender.add(new IntSetting.Builder() .name("Render-Distance(Chunks)") .description("How many chunks from the character to render the detected chunks with bases.") - .defaultValue(512) + .defaultValue(128) .min(6) .sliderRange(6,1024) .build() @@ -635,6 +638,7 @@ else if (basefoundspamTicks>= bsefndtickdelay.get()){ } loadData(); } + if (!save.get() && !load.get())removeChunksOutsideRenderDistance(); } @EventHandler private void onRender(Render3DEvent event) { @@ -682,132 +686,145 @@ private void onReadPacket(PacketEvent.Receive event) { if (mc.world.getChunkManager().getChunk(packet.getChunkX(), packet.getChunkZ()) == null) { WorldChunk chunk = new WorldChunk(mc.world, basepos); try { - taskExecutor.execute(() -> chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ()))); - } catch (ArrayIndexOutOfBoundsException e) { - return; - } + CompletableFuture future = CompletableFuture.runAsync(() -> { + chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), + packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ())); + }, taskExecutor); + future.join(); + } catch (CompletionException e) {} if (Blawcks1.get().size()>0 || Blawcks2.get().size()>0 || Blawcks3.get().size()>0 || Blawcks4.get().size()>0 || Blawcks5.get().size()>0 || Blawcks6.get().size()>0 || Blawcks7.get().size()>0){ int Ymin = mc.world.getBottomY()+minY.get(); int Ymax = mc.world.getTopY()-maxY.get(); try { - for (int x = 0; x < 16; x++) { - for (int y = Ymin; y < Ymax; y++) { - for (int z = 0; z < 16; z++) { - BlockState blerks = chunk.getBlockState(new BlockPos(x, y, z)); - blockposi=new BlockPos(x, y, z); - if (blerks.getBlock()!=Blocks.AIR){ - if (skybuildfind.get() && y>skybuildint.get()) { - if (!baseChunks.contains(basepos)){ - baseChunks.add(basepos); - if (save.get()) { - saveBaseChunkData(); - } - if (basefoundspamTicks==0){ - ChatUtils.sendMsg(Text.of("(Skybuild)Possible build located near X"+basepos.getCenterX()+", Y"+y+", Z"+basepos.getCenterZ())); - LastBaseFound= new ChunkPos(basepos.x, basepos.z); - basefound=true; + ChunkSection[] sections = chunk.getSectionArray(); + int Y = mc.world.getBottomY(); + for (ChunkSection section: sections){ + if (section == null || section.isEmpty()) { + Y+=16; + continue; + } + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + int currentY = Y + y; + if (currentY < Ymin || currentY > Ymax) continue; + blockposi=new BlockPos(x, currentY, z); + BlockState blerks = section.getBlockState(x,y,z); + if (blerks.getBlock()!=Blocks.AIR){ + if (skybuildfind.get() && currentY>skybuildint.get()) { + if (!baseChunks.contains(basepos)){ + baseChunks.add(basepos); + if (save.get()) { + saveBaseChunkData(); + } + if (basefoundspamTicks==0){ + ChatUtils.sendMsg(Text.of("(Skybuild)Possible build located near X"+basepos.getCenterX()+", Y"+currentY+", Z"+basepos.getCenterZ())); + LastBaseFound= new ChunkPos(basepos.x, basepos.z); + basefound=true; + } } } - } - if (bedrockfind.get() && blerks.getBlock()==Blocks.BEDROCK && ((y>mc.world.getBottomY()+bedrockint.get() && mc.world.getRegistryKey() == World.OVERWORLD) || (y>mc.world.getBottomY()+bedrockint.get() && (y < 123 || y > 127) && mc.world.getRegistryKey() == World.NETHER))) { - if (!baseChunks.contains(basepos)){ - baseChunks.add(basepos); - if (save.get()) { - saveBaseChunkData(); - } - if (basefoundspamTicks==0){ - ChatUtils.sendMsg(Text.of("(Unnatural Bedrock)Possible build located near X"+basepos.getCenterX()+", Y"+y+", Z"+basepos.getCenterZ())); - LastBaseFound= new ChunkPos(basepos.x, basepos.z); - basefound=true; + if (bedrockfind.get() && blerks.getBlock()==Blocks.BEDROCK && ((currentY>mc.world.getBottomY()+bedrockint.get() && mc.world.getRegistryKey() == World.OVERWORLD) || (currentY>mc.world.getBottomY()+bedrockint.get() && (currentY < 123 || currentY > 127) && mc.world.getRegistryKey() == World.NETHER))) { + if (!baseChunks.contains(basepos)){ + baseChunks.add(basepos); + if (save.get()) { + saveBaseChunkData(); + } + if (basefoundspamTicks==0){ + ChatUtils.sendMsg(Text.of("(Unnatural Bedrock)Possible build located near X"+basepos.getCenterX()+", Y"+currentY+", Z"+basepos.getCenterZ())); + LastBaseFound= new ChunkPos(basepos.x, basepos.z); + basefound=true; + } } } - } - if (roofDetector.get() && blerks.getBlock()!=Blocks.AIR && blerks.getBlock()!=Blocks.RED_MUSHROOM && blerks.getBlock()!=Blocks.BROWN_MUSHROOM && y>=128 && mc.world.getRegistryKey() == World.NETHER){ - if (!baseChunks.contains(basepos)){ - baseChunks.add(basepos); - if (save.get()) { - saveBaseChunkData(); - } - if (basefoundspamTicks==0){ - ChatUtils.sendMsg(Text.of("(Nether Roof)Possible build located near X"+basepos.getCenterX()+", Y"+y+", Z"+basepos.getCenterZ())); - LastBaseFound= new ChunkPos(basepos.x, basepos.z); - basefound=true; + if (roofDetector.get() && blerks.getBlock()!=Blocks.AIR && blerks.getBlock()!=Blocks.RED_MUSHROOM && blerks.getBlock()!=Blocks.BROWN_MUSHROOM && currentY>=128 && mc.world.getRegistryKey() == World.NETHER){ + if (!baseChunks.contains(basepos)){ + baseChunks.add(basepos); + if (save.get()) { + saveBaseChunkData(); + } + if (basefoundspamTicks==0){ + ChatUtils.sendMsg(Text.of("(Nether Roof)Possible build located near X"+basepos.getCenterX()+", Y"+currentY+", Z"+basepos.getCenterZ())); + LastBaseFound= new ChunkPos(basepos.x, basepos.z); + basefound=true; + } } } - } - if (!(blerks.getBlock()==Blocks.STONE)){ - if (!(blerks.getBlock()==Blocks.DEEPSLATE) && !(blerks.getBlock()==Blocks.DIRT) && !(blerks.getBlock()==Blocks.GRASS_BLOCK) && !(blerks.getBlock()==Blocks.WATER) && !(blerks.getBlock()==Blocks.SAND) && !(blerks.getBlock()==Blocks.GRAVEL) && !(blerks.getBlock()==Blocks.BEDROCK)&& !(blerks.getBlock()==Blocks.NETHERRACK) && !(blerks.getBlock()==Blocks.LAVA)){ - if (spawner.get()){ - if (blerks.getBlock()==Blocks.SPAWNER){ - spawnerY=y; - spawnerfound=true; + if (!(blerks.getBlock()==Blocks.STONE)){ + if (!(blerks.getBlock()==Blocks.DEEPSLATE) && !(blerks.getBlock()==Blocks.DIRT) && !(blerks.getBlock()==Blocks.GRASS_BLOCK) && !(blerks.getBlock()==Blocks.WATER) && !(blerks.getBlock()==Blocks.SAND) && !(blerks.getBlock()==Blocks.GRAVEL) && !(blerks.getBlock()==Blocks.BEDROCK)&& !(blerks.getBlock()==Blocks.NETHERRACK) && !(blerks.getBlock()==Blocks.LAVA)){ + if (spawner.get()){ + if (blerks.getBlock()==Blocks.SPAWNER){ + spawnerY=currentY; + spawnerfound=true; + } + //dungeon MOSSY_COBBLESTONE, mineshaft COBWEB, fortress NETHER_BRICK_FENCE, stronghold STONE_BRICK_STAIRS, bastion CHAIN + if (mc.world.getRegistryKey() == World.OVERWORLD && (blerks.getBlock()==Blocks.MOSSY_COBBLESTONE || blerks.getBlock()==Blocks.COBWEB || blerks.getBlock()==Blocks.STONE_BRICK_STAIRS || blerks.getBlock()==Blocks.BUDDING_AMETHYST))spawnernaturalblocks=true; + else if (mc.world.getRegistryKey() == World.NETHER && (blerks.getBlock()==Blocks.NETHER_BRICK_FENCE || blerks.getBlock()==Blocks.CHAIN))spawnernaturalblocks=true; } - //dungeon MOSSY_COBBLESTONE, mineshaft COBWEB, fortress NETHER_BRICK_FENCE, stronghold STONE_BRICK_STAIRS, bastion CHAIN - if (mc.world.getRegistryKey() == World.OVERWORLD && (blerks.getBlock()==Blocks.MOSSY_COBBLESTONE || blerks.getBlock()==Blocks.COBWEB || blerks.getBlock()==Blocks.STONE_BRICK_STAIRS || blerks.getBlock()==Blocks.BUDDING_AMETHYST))spawnernaturalblocks=true; - else if (mc.world.getRegistryKey() == World.NETHER && (blerks.getBlock()==Blocks.NETHER_BRICK_FENCE || blerks.getBlock()==Blocks.CHAIN))spawnernaturalblocks=true; - } - if (Blawcks1.get().size()>0){ - if (Blawcks1.get().contains(blerks.getBlock())) { - blockpositions1.add(blockposi); - found1= blockpositions1.size(); - lastblockfound1=blerks.getBlock().toString(); + if (Blawcks1.get().size()>0){ + if (Blawcks1.get().contains(blerks.getBlock())) { + blockpositions1.add(blockposi); + found1= blockpositions1.size(); + lastblockfound1=blerks.getBlock().toString(); + } } - } - if (Blawcks2.get().size()>0){ - if (Blawcks2.get().contains(blerks.getBlock())) { - blockpositions2.add(blockposi); - found2= blockpositions2.size(); - lastblockfound2=blerks.getBlock().toString(); + if (Blawcks2.get().size()>0){ + if (Blawcks2.get().contains(blerks.getBlock())) { + blockpositions2.add(blockposi); + found2= blockpositions2.size(); + lastblockfound2=blerks.getBlock().toString(); + } } - } - if (Blawcks3.get().size()>0){ - if (Blawcks3.get().contains(blerks.getBlock())) { - blockpositions3.add(blockposi); - found3= blockpositions3.size(); - lastblockfound3=blerks.getBlock().toString(); + if (Blawcks3.get().size()>0){ + if (Blawcks3.get().contains(blerks.getBlock())) { + blockpositions3.add(blockposi); + found3= blockpositions3.size(); + lastblockfound3=blerks.getBlock().toString(); + } } - } - if (Blawcks4.get().size()>0){ - if (Blawcks4.get().contains(blerks.getBlock())) { - blockpositions4.add(blockposi); - found4= blockpositions4.size(); - lastblockfound4=blerks.getBlock().toString(); + if (Blawcks4.get().size()>0){ + if (Blawcks4.get().contains(blerks.getBlock())) { + blockpositions4.add(blockposi); + found4= blockpositions4.size(); + lastblockfound4=blerks.getBlock().toString(); + } } - } - if (Blawcks5.get().size()>0){ - if (Blawcks5.get().contains(blerks.getBlock())) { - blockpositions5.add(blockposi); - found5= blockpositions5.size(); - lastblockfound5=blerks.getBlock().toString(); + if (Blawcks5.get().size()>0){ + if (Blawcks5.get().contains(blerks.getBlock())) { + blockpositions5.add(blockposi); + found5= blockpositions5.size(); + lastblockfound5=blerks.getBlock().toString(); + } } - } - if (Blawcks6.get().size()>0){ - if (Blawcks6.get().contains(blerks.getBlock())) { - blockpositions6.add(blockposi); - found6= blockpositions6.size(); - lastblockfound6=blerks.getBlock().toString(); + if (Blawcks6.get().size()>0){ + if (Blawcks6.get().contains(blerks.getBlock())) { + blockpositions6.add(blockposi); + found6= blockpositions6.size(); + lastblockfound6=blerks.getBlock().toString(); + } } - } - if (Blawcks7.get().size()>0){ - if (Blawcks7.get().contains(blerks.getBlock())) { - blockpositions7.add(blockposi); - found7= blockpositions7.size(); - lastblockfound7=blerks.getBlock().toString(); + if (Blawcks7.get().size()>0){ + if (Blawcks7.get().contains(blerks.getBlock())) { + blockpositions7.add(blockposi); + found7= blockpositions7.size(); + lastblockfound7=blerks.getBlock().toString(); + } } } } } + if (Blawcks1.get().size()>0)checkingchunk1=true; + if (Blawcks2.get().size()>0)checkingchunk2=true; + if (Blawcks3.get().size()>0)checkingchunk3=true; + if (Blawcks4.get().size()>0)checkingchunk4=true; + if (Blawcks5.get().size()>0)checkingchunk5=true; + if (Blawcks6.get().size()>0)checkingchunk6=true; + if (Blawcks7.get().size()>0)checkingchunk7=true; } - if (Blawcks1.get().size()>0)checkingchunk1=true; - if (Blawcks2.get().size()>0)checkingchunk2=true; - if (Blawcks3.get().size()>0)checkingchunk3=true; - if (Blawcks4.get().size()>0)checkingchunk4=true; - if (Blawcks5.get().size()>0)checkingchunk5=true; - if (Blawcks6.get().size()>0)checkingchunk6=true; - if (Blawcks7.get().size()>0)checkingchunk7=true; } } + Y+=16; } //CheckList 1 if (Blawcks1.get().size()>0){ @@ -1045,4 +1062,13 @@ private boolean isNaturalLagCausingBlock(Block block) { !(block ==Blocks.NETHERRACK) && !(block ==Blocks.LAVA); } + private void removeChunksOutsideRenderDistance() { + BlockPos cameraPos = mc.getCameraEntity().getBlockPos(); + double renderDistanceBlocks = renderDistance.get() * 16; + + removeChunksOutsideRenderDistance(baseChunks, cameraPos, renderDistanceBlocks); + } + private void removeChunksOutsideRenderDistance(Set chunkSet, BlockPos cameraPos, double renderDistanceBlocks) { + chunkSet.removeIf(chunkPos -> !cameraPos.isWithinDistance(chunkPos.getStartPos(), renderDistanceBlocks)); + } } \ No newline at end of file diff --git a/src/main/java/pwn/noobs/trouserstreak/modules/NewerNewChunks.java b/src/main/java/pwn/noobs/trouserstreak/modules/NewerNewChunks.java index 405ed243..c7c0c01c 100644 --- a/src/main/java/pwn/noobs/trouserstreak/modules/NewerNewChunks.java +++ b/src/main/java/pwn/noobs/trouserstreak/modules/NewerNewChunks.java @@ -31,10 +31,7 @@ import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; -import net.minecraft.world.chunk.ChunkSection; -import net.minecraft.world.chunk.Palette; -import net.minecraft.world.chunk.PalettedContainer; -import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.chunk.*; import pwn.noobs.trouserstreak.Trouser; import java.io.File; @@ -585,6 +582,7 @@ private void onPreTick(TickEvent.Pre event) { } loadData(); } + if (!save.get() && !load.get())removeChunksOutsideRenderDistance(); } @EventHandler private void onRender(Render3DEvent event) { @@ -649,8 +647,8 @@ private void render(Box box, Color sides, Color lines, ShapeMode shapeMode, Rend @EventHandler private void onReadPacket(PacketEvent.Receive event) { - if (event.packet instanceof AcknowledgeChunksC2SPacket)return; - if (event.packet instanceof ChunkDeltaUpdateS2CPacket && liquidexploit.get()) { + if (event.packet instanceof AcknowledgeChunksC2SPacket)return; //for some reason this packet keeps getting cast to other packets + if (!(event.packet instanceof AcknowledgeChunksC2SPacket) && event.packet instanceof ChunkDeltaUpdateS2CPacket && liquidexploit.get()) { ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.packet; packet.visitUpdates((pos, state) -> { @@ -701,25 +699,19 @@ else if (!(event.packet instanceof AcknowledgeChunksC2SPacket) && event.packet i } } } - else if (!(event.packet instanceof PlayerMoveC2SPacket) && event.packet instanceof ChunkDataS2CPacket && mc.world != null) { + else if (!(event.packet instanceof AcknowledgeChunksC2SPacket) && !(event.packet instanceof PlayerMoveC2SPacket) && event.packet instanceof ChunkDataS2CPacket && mc.world != null) { ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.packet; ChunkPos oldpos = new ChunkPos(packet.getChunkX(), packet.getChunkZ()); if (mc.world.getChunkManager().getChunk(packet.getChunkX(), packet.getChunkZ()) == null) { WorldChunk chunk = new WorldChunk(mc.world, oldpos); - try { - Future future = taskExecutor.submit(() -> { - chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ())); - }); - try { - future.get(); // This will block until the task is complete - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - } + CompletableFuture future = CompletableFuture.runAsync(() -> { + chunk.loadFromPacket(packet.getChunkData().getSectionsDataBuf(), new NbtCompound(), + packet.getChunkData().getBlockEntities(packet.getChunkX(), packet.getChunkZ())); + }, taskExecutor); + future.join(); + } catch (CompletionException e) {} boolean isNewChunk = false; boolean isOldGeneration = false; @@ -785,79 +777,94 @@ else if (!(event.packet instanceof PlayerMoveC2SPacket) && event.packet instance if (section != null) { //System.out.println("Processing Chunk Section: " + i); - var blockStatesContainer = section.getBlockStateContainer(); - Set bstates = new HashSet<>(); - for (int x = 0; x < 16; x++){ - for (int y = 0; y < 16; y++){ - for (int z = 0; z < 16; z++){ - bstates.add(blockStatesContainer.get(x, y, z)); + int isNewSection = 0; + int isBeingUpdatedSection = 0; + + if (!section.isEmpty()) { + var blockStatesContainer = section.getBlockStateContainer(); + Palette blockStatePalette = blockStatesContainer.data.palette(); + int blockPaletteLength = blockStatePalette.getSize(); + + //System.out.println("Block Palette Length for Section " + i + ": " + blockPaletteLength); + if (blockStatePalette instanceof BiMapPalette){ + Set bstates = new HashSet<>(); + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + bstates.add(blockStatesContainer.get(x, y, z)); + } + } + } + //System.out.println("Unique BlockStates in Section " + i + ": " + bstates.size()); + int bstatesSize = bstates.size(); + if (bstatesSize <= 1) bstatesSize = blockPaletteLength; + if (bstatesSize < blockPaletteLength) { + isNewSection = 2; + //System.out.println("Section: " + loops + " | smaller bstates size!!!!!!!"); + newChunkQuantifier++; //double the weight of this } } - } - //System.out.println("Unique BlockStates in Section " + i + ": " + bstates.size()); - Palette blockStatePalette = blockStatesContainer.data.palette(); - int blockPaletteLength = blockStatePalette.getSize(); - //System.out.println("Block Palette Length for Section " + i + ": " + blockPaletteLength); - - int isNewSection = 0; - int isBeingUpdatedSection = 0; - int bstatesSize = bstates.size(); - if (bstatesSize<=1) bstatesSize = blockPaletteLength; - if (bstatesSize= 2) oldChunkQuantifier++; + if (isNewSection >= 2) newChunkQuantifier++; + //System.out.println("Section " + i + " - isNewSection: " + isNewSection + ", isBeingUpdatedSection: " + isBeingUpdatedSection); } - if (isBeingUpdatedSection>=2) oldChunkQuantifier++; - if (isNewSection >= 2) newChunkQuantifier++; - - //System.out.println("Section " + i + " - isNewSection: " + isNewSection + ", isBeingUpdatedSection: " + isBeingUpdatedSection); - - var biomesContainer = section.getBiomeContainer(); - if (biomesContainer instanceof PalettedContainer> biomesPaletteContainer) { - Palette> biomePalette = biomesPaletteContainer.data.palette(); - //System.out.println("Biome Palette Size for Section " + i + ": " + biomePalette.getSize()); - for (int i3 = 0; i3 < biomePalette.getSize(); i3++) { - //System.out.println("Section: " + i + " Biome Palette entry :" + i3 + " Biome: " + biomePalette.get(i3).getKey().get()); - if (i3 == 0 && biomePalette.get(i3).getKey().get() == BiomeKeys.PLAINS && mc.world.getRegistryKey() == World.END) isNewChunk = true; - if (!isNewChunk && i3 == 0 && biomePalette.get(i3).getKey().get() != BiomeKeys.THE_END && mc.world.getRegistryKey() == World.END) isNewChunk = false; + if (mc.world.getRegistryKey() == World.END) { + var biomesContainer = section.getBiomeContainer(); + if (biomesContainer instanceof PalettedContainer> biomesPaletteContainer) { + Palette> biomePalette = biomesPaletteContainer.data.palette(); + //System.out.println("Biome Palette Size for Section " + i + ": " + biomePalette.getSize()); + for (int i3 = 0; i3 < biomePalette.getSize(); i3++) { + //System.out.println("Section: " + i + " Biome Palette entry :" + i3 + " Biome: " + biomePalette.get(i3).getKey().get()); + if (i3 == 0 && biomePalette.get(i3).getKey().get() == BiomeKeys.PLAINS) isNewChunk = true; + if (!isNewChunk && i3 == 0 && biomePalette.get(i3).getKey().get() != BiomeKeys.THE_END) isNewChunk = false; + } } } + loops++; } - loops++; } if (loops > 0) { if (beingUpdatedDetector.get() && (mc.world.getRegistryKey() == World.NETHER || mc.world.getRegistryKey() == World.END)){ double oldpercentage = ((double) oldChunkQuantifier / loops) * 100; + //System.out.println("Being updated Percentage: " + oldpercentage); if (oldpercentage >= 25) chunkIsBeingUpdated = true; } else if (mc.world.getRegistryKey() != World.NETHER && mc.world.getRegistryKey() != World.END){ double percentage = ((double) newChunkQuantifier / loops) * 100; + //System.out.println("Percentage: " + percentage); if (percentage >= 65) isNewChunk = true; } } } catch (Exception e) { if (beingUpdatedDetector.get() && (mc.world.getRegistryKey() == World.NETHER || mc.world.getRegistryKey() == World.END)){ double oldpercentage = ((double) oldChunkQuantifier / loops) * 100; + //System.out.println("Being updated Percentage: " + oldpercentage); if (oldpercentage >= 25) chunkIsBeingUpdated = true; } else if (mc.world.getRegistryKey() != World.NETHER && mc.world.getRegistryKey() != World.END){ double percentage = ((double) newChunkQuantifier / loops) * 100; + //System.out.println("Percentage: " + percentage); if (percentage >= 65) isNewChunk = true; } } @@ -971,4 +978,17 @@ private void saveData(String savedDataLocation, ChunkPos chunkpos) { } catch (IOException e) { } } + private void removeChunksOutsideRenderDistance() { + BlockPos cameraPos = mc.getCameraEntity().getBlockPos(); + double renderDistanceBlocks = renderDistance.get() * 16; + + removeChunksOutsideRenderDistance(newChunks, cameraPos, renderDistanceBlocks); + removeChunksOutsideRenderDistance(oldChunks, cameraPos, renderDistanceBlocks); + removeChunksOutsideRenderDistance(beingUpdatedOldChunks, cameraPos, renderDistanceBlocks); + removeChunksOutsideRenderDistance(OldGenerationOldChunks, cameraPos, renderDistanceBlocks); + removeChunksOutsideRenderDistance(tickexploitChunks, cameraPos, renderDistanceBlocks); + } + private void removeChunksOutsideRenderDistance(Set chunkSet, BlockPos cameraPos, double renderDistanceBlocks) { + chunkSet.removeIf(chunkPos -> !cameraPos.isWithinDistance(chunkPos.getStartPos(), renderDistanceBlocks)); + } } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 41a9e632..1906da3d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "streak-addon", - "version": "1.1.4", + "version": "1.1.5", "name": "TrouserStreak", "description": "Trouser-Streak is a compilation of modules, updated to the latest version and optimized for maximum grief. I did not make all of these.", "authors": [