Skip to content

Commit

Permalink
Added function to set clear weather
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Oct 15, 2022
1 parent c6c6076 commit 6e831f8
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/main/java/com/mlib/levels/LevelHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ public static void spawnItemEntityFlyingTowardsDirection( ItemStack itemStack, L
level.addFreshEntity( itemEntity );
}

public static void startRaining( Level level, int ticks, boolean withThunder ) {
public static void startRaining( Level level, int ticks, boolean withThunder, int transitionTicks ) {
if( !( level.getLevelData() instanceof ServerLevelData data ) ) {
return;
}

data.setClearWeatherTime( 0 );
data.setClearWeatherTime( transitionTicks );
data.setRaining( true );
data.setRainTime( ticks );
level.setRainLevel( 0.0f );
Expand All @@ -209,4 +209,26 @@ public static void startRaining( Level level, int ticks, boolean withThunder ) {
level.setThunderLevel( 0.0f );
}
}

public static void startRaining( Level level, int ticks ) {
startRaining( level, ticks, false, 0 );
}

public static void setClearWeather( Level level, int ticks, int transitionTicks ) {
if( !( level.getLevelData() instanceof ServerLevelData data ) ) {
return;
}

data.setClearWeatherTime( ticks );
data.setRaining( false );
data.setRainTime( transitionTicks );
level.setRainLevel( 1.0f );
data.setThundering( false );
data.setThunderTime( transitionTicks );
level.setThunderLevel( 1.0f );
}

public static void setClearWeather( Level level, int ticks ) {
setClearWeather( level, ticks, 0 );
}
}

0 comments on commit 6e831f8

Please sign in to comment.