TippedArrowPotionToItemFix .java

net.minecraft.util.datafix.fixes.TippedArrowPotionToItemFix (class): members: fix. strings: "CustomPotionColor", "custom_potion_effects", "Potion", "item".

net.minecraft.util.datafix.fixesclass37 linescommonextends NamedEntityWriteReadFix1.2 KB

API Surface (1)

<T> Dynamic<T> fix(final Dynamic<T> input)

String literals (6)

"minecraft:arrow"
"Potion"
"custom_potion_effects"
"Color"
"item"
"CustomPotionColor"

Code Graph: Dependencies (1)

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

Full Source

TippedArrowPotionToItemFix.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.schemas.Schema;
4
import com.mojang.serialization.Dynamic;
5
import java.util.Optional;
6
7
public class TippedArrowPotionToItemFix extends NamedEntityWriteReadFix {
8
	public TippedArrowPotionToItemFix(final Schema outputSchema) {
9
		super(outputSchema, false, "TippedArrowPotionToItemFix", References.ENTITY, "minecraft:arrow");
10
	}
11
12
	@Override
13
	protected <T> Dynamic<T> fix(final Dynamic<T> input) {
14
		Optional<Dynamic<T>> potion = input.get("Potion").result();
15
		Optional<Dynamic<T>> customPotionEffects = input.get("custom_potion_effects").result();
16
		Optional<Dynamic<T>> color = input.get("Color").result();
17
		return potion.isEmpty() && customPotionEffects.isEmpty() && color.isEmpty()
18
			? input
19
			: input.remove("Potion").remove("custom_potion_effects").remove("Color").update("item", itemStack -> {
20
				Dynamic<?> tag = itemStack.get("tag").orElseEmptyMap();
21
				if (potion.isPresent()) {
22
					tag = tag.set("Potion", potion.get());
23
				}
24
25
				if (customPotionEffects.isPresent()) {
26
					tag = tag.set("custom_potion_effects", customPotionEffects.get());
27
				}
28
29
				if (color.isPresent()) {
30
					tag = tag.set("CustomPotionColor", color.get());
31
				}
32
33
				return itemStack.set("tag", tag);
34
			});
35
	}
36
}
37

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