DayTimeToClockFix .java

net.minecraft.util.datafix.fixes.DayTimeToClockFix (class): members: makeRule. strings: "DayTime", "total_ticks", "paused", "world_clocks", "Time".

net.minecraft.util.datafix.fixesclass31 linescommonextends DataFix1.1 KB

API Surface (1)

TypeRewriteRule makeRule()

String literals (6)

"Time"
"DayTime"
"world_clocks"
"minecraft:overworld"
"total_ticks"
"paused"

Full Source

DayTimeToClockFix.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.DataFix;
5
import com.mojang.datafixers.TypeRewriteRule;
6
import com.mojang.datafixers.schemas.Schema;
7
import com.mojang.serialization.Dynamic;
8
9
public class DayTimeToClockFix extends DataFix {
10
	public DayTimeToClockFix(final Schema outputSchema) {
11
		super(outputSchema, false);
12
	}
13
14
	@Override
15
	protected TypeRewriteRule makeRule() {
16
		return this.fixTypeEverywhereTyped(
17
			"DayTimeToClockFix", this.getInputSchema().getType(References.LEVEL), typed -> typed.update(DSL.remainderFinder(), input -> {
18
				long gameTime = input.get("Time").asLong(0L);
19
				long dayTime = input.get("DayTime").asLong(gameTime);
20
				input = input.remove("DayTime");
21
				Dynamic<?> overworldClock = createClock(input, dayTime);
22
				return input.set("world_clocks", input.emptyMap().set("minecraft:overworld", overworldClock));
23
			})
24
		);
25
	}
26
27
	private static Dynamic<?> createClock(final Dynamic<?> input, final long totalTicks) {
28
		return input.emptyMap().set("total_ticks", input.createLong(totalTicks)).set("paused", input.createBoolean(false));
29
	}
30
}
31

Decompiled Minecraft 26.3 source of DayTimeToClockFix (net/minecraft/util/datafix/fixes/DayTimeToClockFix.java) with Mojang official mappings, stored verbatim on the site.