Code/net/minecraft/util/datafix/fixes/BlockEntityUUIDFix.java

34 lines
1.3 KiB
Java
Raw Normal View History

2025-07-01 06:20:03 +00:00
package net.minecraft.util.datafix.fixes;
import com.mojang.datafixers.TypeRewriteRule;
import com.mojang.datafixers.Typed;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.serialization.Dynamic;
public class BlockEntityUUIDFix extends AbstractUUIDFix {
public BlockEntityUUIDFix(Schema p_14883_) {
super(p_14883_, References.BLOCK_ENTITY);
}
@Override
protected TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped("BlockEntityUUIDFix", this.getInputSchema().getType(this.typeReference), p_14885_ -> {
p_14885_ = this.updateNamedChoice(p_14885_, "minecraft:conduit", this::updateConduit);
return this.updateNamedChoice(p_14885_, "minecraft:skull", this::updateSkull);
});
}
private Dynamic<?> updateSkull(Dynamic<?> p_14890_) {
return p_14890_.get("Owner")
.get()
.map(p_14894_ -> replaceUUIDString((Dynamic<?>)p_14894_, "Id", "Id").orElse((Dynamic<?>)p_14894_))
.<Dynamic<?>>map(p_14888_ -> p_14890_.remove("Owner").set("SkullOwner", (Dynamic<?>)p_14888_))
.result()
.orElse(p_14890_);
}
private Dynamic<?> updateConduit(Dynamic<?> p_14892_) {
return replaceUUIDMLTag(p_14892_, "target_uuid", "Target").orElse(p_14892_);
}
}