CopperGolemWeatherStateFix .java

net.minecraft.util.datafix.fixes.CopperGolemWeatherStateFix (class, 27 lines): members: fix. strings: "minecraft:copper_golem", "weather_state", "exposed".

net.minecraft.util.datafix.fixesclass27 linescommonextends NamedEntityFix927 B

API Surface (1)

Typed<?> fix(final Typed<?> entity)

String literals (6)

"minecraft:copper_golem"
"weather_state"
"exposed"
"weathered"
"oxidized"
"unaffected"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CopperGolemWeatherStateFix.java27 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.Typed;
5
import com.mojang.datafixers.schemas.Schema;
6
import com.mojang.serialization.Dynamic;
7
8
public class CopperGolemWeatherStateFix extends NamedEntityFix {
9
	public CopperGolemWeatherStateFix(final Schema outputSchema) {
10
		super(outputSchema, false, "CopperGolemWeatherStateFix", References.ENTITY, "minecraft:copper_golem");
11
	}
12
13
	@Override
14
	protected Typed<?> fix(final Typed<?> entity) {
15
		return entity.update(DSL.remainderFinder(), tag -> tag.update("weather_state", CopperGolemWeatherStateFix::fixWeatherState));
16
	}
17
18
	private static Dynamic<?> fixWeatherState(final Dynamic<?> value) {
19
		return switch (value.asInt(0)) {
20
			case 1 -> value.createString("exposed");
21
			case 2 -> value.createString("weathered");
22
			case 3 -> value.createString("oxidized");
23
			default -> value.createString("unaffected");
24
		};
25
	}
26
}
27

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