From 8e34ef9b758a3785415dffaf4ab2d2405d2903c1 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:29:47 -0500 Subject: [PATCH] optimize slightly --- .../impl/features/SnowBlanketFeature.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/features/SnowBlanketFeature.java b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/features/SnowBlanketFeature.java index 1f79c8470..2c1c92679 100644 --- a/src/main/java/net/frozenblock/wilderwild/worldgen/impl/features/SnowBlanketFeature.java +++ b/src/main/java/net/frozenblock/wilderwild/worldgen/impl/features/SnowBlanketFeature.java @@ -41,7 +41,12 @@ public SnowBlanketFeature(@NotNull Codec codec) { super(codec); } - private static boolean placeSnowAtPos(@NotNull WorldGenLevel level, @NotNull BlockPos.MutableBlockPos motionBlockingPos, @NotNull BlockPos.MutableBlockPos belowLeavesPos, @NotNull Holder biomeHolder) { + private static boolean placeSnowAtPos( + @NotNull WorldGenLevel level, + @NotNull BlockPos.MutableBlockPos motionBlockingPos, + @NotNull BlockPos.MutableBlockPos belowLeavesPos, + @NotNull Holder biomeHolder + ) { boolean returnValue = false; int lowestY = belowLeavesPos.getY() - 1; while (motionBlockingPos.getY() > lowestY) { @@ -53,7 +58,11 @@ private static boolean placeSnowAtPos(@NotNull WorldGenLevel level, @NotNull Blo return returnValue; } - private static boolean placeSnowAtPos(@NotNull WorldGenLevel level, @NotNull BlockPos.MutableBlockPos motionBlockingPos, @NotNull BlockPos.MutableBlockPos belowLeavesPos) { + private static boolean placeSnowAtPos( + @NotNull WorldGenLevel level, + @NotNull BlockPos.MutableBlockPos motionBlockingPos, + @NotNull BlockPos.MutableBlockPos belowLeavesPos + ) { boolean returnValue = false; int lowestY = belowLeavesPos.getY() - 1; while (motionBlockingPos.getY() > lowestY) { @@ -96,18 +105,19 @@ public boolean place(@NotNull FeaturePlaceContext cont boolean returnValue = false; int posX = pos.getX(); int posZ = pos.getZ(); - BlockState iceState = Blocks.ICE.defaultBlockState(); for (int i = 0; i < 16; i++) { int x = posX + i; for (int j = 0; j < 16; j++) { int z = posZ + j; - mutablePos.set(x, level.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z) - 1, z); - mutablePlacementPos.set(x, level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, x, z), z); - if (!mutablePos.equals(mutablePlacementPos) && mutablePos.getY() > mutablePlacementPos.getY()) { + int height = level.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z); + int belowLeavesHeight = level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, x, z); + if (height > belowLeavesHeight) { + mutablePos.set(x, height, z); + mutablePlacementPos.set(x, belowLeavesHeight, z); Holder biomeHolder = level.getBiome(mutablePos); Holder lowerBiomeHolder = level.getBiome(mutablePlacementPos); if (lowerBiomeHolder.value().shouldFreeze(level, mutablePlacementPos.move(Direction.DOWN), false)) { - level.setBlock(mutablePlacementPos, iceState, 2); + level.setBlock(mutablePlacementPos, Blocks.ICE.defaultBlockState(), Block.UPDATE_CLIENTS); } mutablePlacementPos.move(Direction.UP); if (biomeHolder.equals(lowerBiomeHolder)) {