Fabric Seasons: Extras

Fabric Seasons: Extras

7M Downloads

[Crash] 16 is not an allowed value for PROGRESS

Nillo-Code opened this issue ยท 0 comments

commented

image

When disabling minecrafts daylight cycle it is possible for the ticks till next season to be 0. If a calendar has been placed/is placed at this time the client will crash due to an IllegalArgumentException due to how PROGRESS is calculated

java.lang.IllegalArgumentException: Cannot set property class_2758{name=progress, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]} to 16 on Block{seasonsextras:season_calendar}, it is not an allowed value
    at net.minecraft.class_2688.method_11657(class_2688.java:125)
    at io.github.lucaargolo.seasonsextras.block.SeasonCalendarBlock.method_9605(SeasonCalendarBlock.java:60)
    at net.minecraft.class_1747.method_7707(class_1747.java:119)
    at net.minecraft.class_1747.method_7712(class_1747.java:71)
    at net.minecraft.class_1747.method_7884(class_1747.java:50)
    at net.minecraft.class_1799.method_7981(class_1799.java:264)
    at net.minecraft.class_636.method_41934(class_636.java:363)
    at net.minecraft.class_636.method_41933(class_636.java:328)
    at net.minecraft.class_636.method_41931(class_636.java:278)
    at net.minecraft.class_636.method_2896(class_636.java:327)
    at net.minecraft.class_310.method_1583(class_310.java:1748)
    at net.minecraft.class_310.method_1508(class_310.java:2002)
    at net.minecraft.class_310.method_1574(class_310.java:1829)
    at net.minecraft.class_310.method_1523(class_310.java:1135)
    at net.minecraft.class_310.method_1514(class_310.java:768)
    at net.minecraft.client.main.Main.method_44604(Main.java:244)
    at net.minecraft.client.main.Main.main(Main.java:51)
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:462)
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)

public BlockState getPlacementState(ItemPlacementContext ctx) {
World world = ctx.getWorld();
long timeToNextSeason = (FabricSeasons.CONFIG.getSeasonLength() - (world.getTimeOfDay() - ((world.getTimeOfDay()/FabricSeasons.CONFIG.getSeasonLength())*FabricSeasons.CONFIG.getSeasonLength()) )) % FabricSeasons.CONFIG.getSeasonLength();
double progressLeft = timeToNextSeason / (double) FabricSeasons.CONFIG.getSeasonLength();
int currentProgress = (int) (16.0 - (progressLeft*16.0));
Season currentSeason = FabricSeasons.getCurrentSeason(world);
Direction facing = ctx.getSide().getAxis() != Direction.Axis.Y ? ctx.getSide().getOpposite() : ctx.getPlayerFacing();
return this.getDefaultState().with(SEASON, currentSeason).with(PROGRESS, currentProgress).with(FACING, facing);