SwingAnimationComponentSplitFix .java

net.minecraft.util.datafix.fixes.SwingAnimationComponentSplitFix (class): members: makeRule. strings: "minecraft:interact_animation". imports: DataFix.

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

API Surface (1)

TypeRewriteRule makeRule()

String literals (3)

"minecraft:swing_animation"
"minecraft:attack_animation"
"minecraft:interact_animation"

Full Source

SwingAnimationComponentSplitFix.java30 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
import java.util.Optional;
9
10
public class SwingAnimationComponentSplitFix extends DataFix {
11
	public SwingAnimationComponentSplitFix(final Schema outputSchema) {
12
		super(outputSchema, false);
13
	}
14
15
	@Override
16
	protected TypeRewriteRule makeRule() {
17
		return this.fixTypeEverywhereTyped(
18
			"SwingAnimationComponentSplitFix", this.getInputSchema().getType(References.DATA_COMPONENTS), input -> input.update(DSL.remainderFinder(), tag -> {
19
				Optional<? extends Dynamic<?>> swingAnimationOpt = tag.get("minecraft:swing_animation").result();
20
				if (swingAnimationOpt.isPresent()) {
21
					Dynamic<?> swingAnimation = (Dynamic<?>)swingAnimationOpt.get();
22
					return tag.remove("minecraft:swing_animation").set("minecraft:attack_animation", swingAnimation).set("minecraft:interact_animation", swingAnimation);
23
				} else {
24
					return tag;
25
				}
26
			})
27
		);
28
	}
29
}
30

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