From 1f5a41f5bcbea791606ba84a92af6cdda44bf9ff Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:49:25 -0400 Subject: [PATCH] Search chunk palettes when recording taters --- .../lobby/item/tater/TaterGuidebookItem.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterGuidebookItem.java b/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterGuidebookItem.java index e0d97d5..48a35e3 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterGuidebookItem.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterGuidebookItem.java @@ -75,7 +75,6 @@ public Item getPolymerItem(ItemStack stack, ServerPlayerEntity player) { private static void recordToGuidebook(ServerPlayerEntity player, SetMultimap taterPositions, ItemStack stack) { int initialCount = taterPositions.size(); - var pos = new BlockPos.Mutable(); var chunkManager = player.getServerWorld().getChunkManager(); var chunkStorage = chunkManager.threadedAnvilChunkStorage; @@ -85,7 +84,7 @@ private static void recordToGuidebook(ServerPlayerEntity player, SetMultimap taterPositions) { - for (int z = 0; z < 16; z++) { - for (int y = chunk.getBottomY(); y < chunk.getTopY(); y++) { - for (int x = 0; x < 16; x++) { - pos.set(x, y, z); - var state = chunk.getBlockState(pos); - - if (state.getBlock() instanceof TinyPotatoBlock taterBlock) { - taterPositions.put(taterBlock.asItem(), chunk.getPos().getBlockPos(x, y, z)); - } - } - } - } + private static void recordChunk(Chunk chunk, SetMultimap taterPositions) { + chunk.forEachBlockMatchingPredicate(state -> { + return state.getBlock() instanceof TinyPotatoBlock; + }, (pos, state) -> { + taterPositions.put(state.getBlock().asItem(), pos.toImmutable()); + }); } private static void showGuidebook(ServerPlayerEntity player, SetMultimap taterPositionMap, ItemStack stack) {