Skip to content

Commit

Permalink
Fixed #431
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Jan 16, 2024
1 parent 9fddac5 commit b335262
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/main/java/sereneseasons/api/season/SeasonHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class SeasonHelper
* Obtains data about the state of the season cycle in the world. This works both on
* the client and the server.
*/
public static ISeasonState getSeasonState(Level world)
public static ISeasonState getSeasonState(Level level)
{
ISeasonState data;

if (!world.isClientSide())
if (!level.isClientSide())
{
data = dataProvider.getServerSeasonState(world);
data = dataProvider.getServerSeasonState(level);
}
else
{
data = dataProvider.getClientSeasonState();
data = dataProvider.getClientSeasonState(level);
}

return data;
Expand All @@ -44,8 +44,8 @@ public static boolean usesTropicalSeasons(Holder<Biome> biome)

public interface ISeasonDataProvider
{
ISeasonState getServerSeasonState(Level world);
ISeasonState getClientSeasonState();
ISeasonState getServerSeasonState(Level level);
ISeasonState getClientSeasonState(Level level);
boolean usesTropicalSeasons(Holder<Biome> key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import sereneseasons.api.season.ISeasonColorProvider;
import sereneseasons.api.season.ISeasonState;
import sereneseasons.api.season.SeasonHelper;
import sereneseasons.config.ServerConfig;
import sereneseasons.init.ModTags;
import sereneseasons.season.SeasonTime;
Expand Down Expand Up @@ -51,7 +53,7 @@ private static void registerGrassAndFoliageColorHandlers()

if (biomeHolder != null)
{
SeasonTime calendar = SeasonHandler.getClientSeasonTime();
ISeasonState calendar = SeasonHelper.getSeasonState(level);
ISeasonColorProvider colorProvider = biomeHolder.is(ModTags.Biomes.TROPICAL_BIOMES) ? calendar.getTropicalSeason() : calendar.getSubSeason();

return SeasonColorUtil.applySeasonalGrassColouring(colorProvider, biomeHolder, originalColor);
Expand All @@ -70,7 +72,7 @@ private static void registerGrassAndFoliageColorHandlers()

if (biomeHolder != null)
{
SeasonTime calendar = SeasonHandler.getClientSeasonTime();
ISeasonState calendar = SeasonHelper.getSeasonState(level);
ISeasonColorProvider colorProvider = biomeHolder.is(ModTags.Biomes.TROPICAL_BIOMES) ? calendar.getTropicalSeason() : calendar.getSubSeason();

return SeasonColorUtil.applySeasonalFoliageColouring(colorProvider, biomeHolder, originalColor);
Expand All @@ -94,7 +96,7 @@ private static void registerBirchColorHandler()

if (!biome.is(ModTags.Biomes.BLACKLISTED_BIOMES))
{
SeasonTime calendar = SeasonHandler.getClientSeasonTime();
ISeasonState calendar = SeasonHelper.getSeasonState(level);
ISeasonColorProvider colorProvider = biome.is(ModTags.Biomes.TROPICAL_BIOMES) ? calendar.getTropicalSeason() : calendar.getSubSeason();
birchColor = colorProvider.getBirchColor();

Expand Down
14 changes: 5 additions & 9 deletions src/main/java/sereneseasons/handler/season/SeasonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public static void onJoinLevel(EntityJoinLevelEvent event)

private static Season.SubSeason lastSeason = null;
public static final HashMap<ResourceKey<Level>, Integer> clientSeasonCycleTicks = new HashMap<>();
public static SeasonTime getClientSeasonTime() {
Integer i = clientSeasonCycleTicks.getOrDefault(Minecraft.getInstance().level.dimension(), 0);
return new SeasonTime(i == null ? 0 : i);
}

@SubscribeEvent
public static void onClientTick(TickEvent.ClientTickEvent event)
Expand Down Expand Up @@ -133,7 +129,7 @@ public static void onClientTick(TickEvent.ClientTickEvent event)

public static void sendSeasonUpdate(Level level)
{
if (level.isClientSide)
if (level.isClientSide())
return;

SeasonSavedData savedData = getSeasonSavedData(level);
Expand Down Expand Up @@ -194,7 +190,7 @@ public static SeasonSavedData getSeasonSavedData(Level w)

return saveDataManager.computeIfAbsent(new SavedData.Factory<>(defaultSaveDataSupplier, SeasonSavedData::load, DataFixTypes.LEVEL), SeasonSavedData.DATA_IDENTIFIER);
}

//
// Used to implement getSeasonState in the API
//
Expand All @@ -207,10 +203,10 @@ public ISeasonState getServerSeasonState(Level world)
}

@Override
public ISeasonState getClientSeasonState()
public ISeasonState getClientSeasonState(Level level)
{
Integer i = clientSeasonCycleTicks.getOrDefault(Minecraft.getInstance().level.dimension(), 0);
return new SeasonTime(i == null ? 0 : i);
int time = level != null ? clientSeasonCycleTicks.getOrDefault(level.dimension(), 0) : 0;
return new SeasonTime(time);
}

@Override
Expand Down

0 comments on commit b335262

Please sign in to comment.