Skip to content

Commit

Permalink
Fix snow layer jump
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jan 4, 2024
1 parent 7c117d6 commit 6f57ab9
Showing 1 changed file with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ private boolean meltAndFreeze(ServerLevel level) {
BlockPos.MutableBlockPos above = new BlockPos.MutableBlockPos();
above.set(waterySurface);
above.setY(above.getY() + 1);
if (!canSeeWindIgnoreLeavesOrSnow(above)) {
if (!canSeeWindSnow(above)) {
above.setY(above.getY() + 1);
if (level.random.nextBoolean() || !canSeeWindIgnoreLeavesOrSnow(above)) {
if (level.random.nextBoolean() || !canSeeWindIgnoreLeavesOrSnow(above)) {
if (level.random.nextBoolean() || !canSeeWindSnow(above)) {
if (level.random.nextBoolean() || !canSeeWindSnow(above)) {
return false;
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ private boolean tryFreezeBlock(ServerLevel level, BlockPos toFreeze) {
if (state.getBlock() == Blocks.SNOW) {
int levels = state.getValue(SnowLayerBlock.LAYERS);
BlockState newState;
if (levels < 6) {
if (levels < 7) {
newState = state.setValue(SnowLayerBlock.LAYERS, levels + 1);
} else {
if (level.random.nextFloat() < 0.75f) {
Expand Down Expand Up @@ -445,21 +445,7 @@ private boolean tryFreezeBlock(ServerLevel level, BlockPos toFreeze) {
return level.random.nextFloat() < (level.random.nextBoolean() ? -temp : precip);
}

public boolean canSeeWindIgnoreLeaves(BlockPos pos) {
var mutablePos = new BlockPos.MutableBlockPos();
for (BlockPos check : windCheckPositions) {
mutablePos.setWithOffset(pos, check);
if (chunk.getLevel().isLoaded(mutablePos)) {
BlockState blockState = chunk.getLevel().getBlockState(mutablePos);
if (isMotionBlocking(blockState) && !(blockState.getBlock() instanceof LeavesBlock)) {
return false;
}
}
}
return true;
}

public boolean canSeeWindIgnoreLeavesOrSnow(BlockPos pos) {
public boolean canSeeWindSnow(BlockPos pos) {
var mutablePos = new BlockPos.MutableBlockPos();
for (BlockPos check : windCheckPositions) {
mutablePos.setWithOffset(pos, check);
Expand Down

0 comments on commit 6f57ab9

Please sign in to comment.