Skip to content

Commit

Permalink
Allowed Rain Collectors to slowly collect water when it's snowing
Browse files Browse the repository at this point in the history
  • Loading branch information
Forstride committed Jan 5, 2024
1 parent d605a82 commit 499af96
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions common/src/main/java/toughasnails/block/RainCollectorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,25 @@ public void setWaterLevel(Level world, BlockPos pos, BlockState state, int level
@Override
public void handlePrecipitation(BlockState state, Level level, BlockPos pos, Biome.Precipitation precipitation)
{
if (level.getBiome(pos).value().warmEnoughToRain(pos))
if (shouldHandlePrecipitation(level, precipitation) && state.getValue(LEVEL) < 3)
{
if (state.getValue(LEVEL) < 3)
{
level.setBlock(pos, state.cycle(LEVEL), 2);
}
level.setBlock(pos, state.cycle(LEVEL), 2);
}
}

protected static boolean shouldHandlePrecipitation(Level level, Biome.Precipitation precipitation)
{
if (precipitation == Biome.Precipitation.RAIN)
{
return level.getRandom().nextFloat() < 0.6F;
}
else if (precipitation == Biome.Precipitation.SNOW)
{
return level.getRandom().nextFloat() < 0.3F;
}
else
{
return false;
}
}

Expand Down

0 comments on commit 499af96

Please sign in to comment.