46 lines
2.1 KiB
Java
46 lines
2.1 KiB
Java
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.mojang.datafixers.Typed;
|
|
import java.util.Optional;
|
|
import com.mojang.datafixers.OpticFinder;
|
|
import com.mojang.datafixers.types.Type;
|
|
import com.mojang.datafixers.Dynamic;
|
|
import com.mojang.datafixers.util.Pair;
|
|
import com.mojang.datafixers.DSL;
|
|
import com.mojang.datafixers.TypeRewriteRule;
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import com.mojang.datafixers.DataFix;
|
|
|
|
public class ItemWaterPotionFix extends DataFix {
|
|
public ItemWaterPotionFix(final Schema schema, final boolean boolean2) {
|
|
super(schema, boolean2);
|
|
}
|
|
|
|
public TypeRewriteRule makeRule() {
|
|
final Type<?> type2 = this.getInputSchema().getType(References.ITEM_STACK);
|
|
final OpticFinder<Pair<String, String>> opticFinder3 = (OpticFinder<Pair<String, String>>)DSL.fieldFinder("id", DSL.named(References.ITEM_NAME.typeName(), DSL.namespacedString()));
|
|
final OpticFinder<?> opticFinder4 = type2.findField("tag");
|
|
final OpticFinder opticFinder5;
|
|
final Optional<Pair<String, String>> optional4;
|
|
String string5;
|
|
final OpticFinder opticFinder6;
|
|
Typed<?> typed2;
|
|
Dynamic<?> dynamic7;
|
|
return this.fixTypeEverywhereTyped("ItemWaterPotionFix", (Type)type2, typed -> {
|
|
optional4 = (Optional<Pair<String, String>>)typed.getOptional(opticFinder5);
|
|
if (optional4.isPresent()) {
|
|
string5 = (String)optional4.get().getSecond();
|
|
if ("minecraft:potion".equals(string5) || "minecraft:splash_potion".equals(string5) || "minecraft:lingering_potion".equals(string5) || "minecraft:tipped_arrow".equals(string5)) {
|
|
typed2 = typed.getOrCreateTyped(opticFinder6);
|
|
dynamic7 = typed2.get(DSL.remainderFinder());
|
|
if (!dynamic7.get("Potion").asString().isPresent()) {
|
|
dynamic7 = dynamic7.set("Potion", dynamic7.createString("minecraft:water"));
|
|
}
|
|
return typed.set(opticFinder6, typed2.set(DSL.remainderFinder(), dynamic7));
|
|
}
|
|
}
|
|
return typed;
|
|
});
|
|
}
|
|
}
|