AreaEffectCloudPotionFix .java

net.minecraft.util.datafix.fixes.AreaEffectCloudPotionFix (class): members: fix. strings: "custom_effects", "custom_color", "potion_contents", "potion".

net.minecraft.util.datafix.fixesclass44 linescommonextends NamedEntityFix1.4 KB

API Surface (1)

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

String literals (8)

"minecraft:area_effect_cloud"
"Color"
"effects"
"Potion"
"custom_color"
"custom_effects"
"potion"
"potion_contents"

Code Graph: Dependencies (1)

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

Full Source

AreaEffectCloudPotionFix.java44 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
import java.util.Optional;
8
9
public class AreaEffectCloudPotionFix extends NamedEntityFix {
10
	public AreaEffectCloudPotionFix(final Schema outputSchema) {
11
		super(outputSchema, false, "AreaEffectCloudPotionFix", References.ENTITY, "minecraft:area_effect_cloud");
12
	}
13
14
	@Override
15
	protected Typed<?> fix(final Typed<?> entity) {
16
		return entity.update(DSL.remainderFinder(), this::fix);
17
	}
18
19
	private <T> Dynamic<T> fix(Dynamic<T> entity) {
20
		Optional<Dynamic<T>> color = entity.get("Color").result();
21
		Optional<Dynamic<T>> effects = entity.get("effects").result();
22
		Optional<Dynamic<T>> potion = entity.get("Potion").result();
23
		entity = entity.remove("Color").remove("effects").remove("Potion");
24
		if (color.isEmpty() && effects.isEmpty() && potion.isEmpty()) {
25
			return entity;
26
		}
27
28
		Dynamic<T> potionContents = entity.emptyMap();
29
		if (color.isPresent()) {
30
			potionContents = potionContents.set("custom_color", color.get());
31
		}
32
33
		if (effects.isPresent()) {
34
			potionContents = potionContents.set("custom_effects", effects.get());
35
		}
36
37
		if (potion.isPresent()) {
38
			potionContents = potionContents.set("potion", potion.get());
39
		}
40
41
		return entity.set("potion_contents", potionContents);
42
	}
43
}
44

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