From ef8343546fb66db08d99f566fdae6c1c28ae348f Mon Sep 17 00:00:00 2001 From: BONNe Date: Thu, 28 Mar 2019 23:38:42 +0200 Subject: [PATCH] Improve performance for a bit... Like... some nanoseconds :) --- .../generators/populators/MaterialPopulator.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java b/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java index 5c3d0ff..88e988a 100644 --- a/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java +++ b/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java @@ -62,7 +62,9 @@ public class MaterialPopulator extends BlockPopulator @Override public void populate(World world, Random random, Chunk chunk) { - for (Map.Entry> entry : chances.get(world.getEnvironment()).materialChanceMap.entrySet()) + Chances chances = this.chances.get(world.getEnvironment()); + + for (Map.Entry> entry : chances.materialChanceMap.entrySet()) { for (int subY = 1; subY < worldHeight; subY += 16) { @@ -81,7 +83,7 @@ public class MaterialPopulator extends BlockPopulator */ Block block = chunk.getBlock(x, y, z); - if (block.getType().equals(chances.get(world.getEnvironment()).mainMaterial)) + if (block.getType().equals(chances.mainMaterial)) { int packSize = random.nextInt(entry.getValue().z); @@ -120,9 +122,8 @@ public class MaterialPopulator extends BlockPopulator block = chunk.getBlock(x, y, z); - continuePlacing = packSize > 0 && - (block.getType().equals(chances.get(world.getEnvironment()).mainMaterial) || - block.getType().equals(entry.getKey())); + continuePlacing = packSize > 0 && (block.getType().equals(chances.mainMaterial) || + block.getType().equals(entry.getKey())); } } }