43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.DSL
|
|
* com.mojang.datafixers.Typed
|
|
* com.mojang.datafixers.schemas.Schema
|
|
* com.mojang.serialization.Dynamic
|
|
*/
|
|
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.mojang.datafixers.DSL;
|
|
import com.mojang.datafixers.Typed;
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import com.mojang.serialization.Dynamic;
|
|
import net.minecraft.util.datafix.fixes.NamedEntityFix;
|
|
import net.minecraft.util.datafix.fixes.References;
|
|
|
|
public class VillagerFollowRangeFix
|
|
extends NamedEntityFix {
|
|
private static final double ORIGINAL_VALUE = 16.0;
|
|
private static final double NEW_BASE_VALUE = 48.0;
|
|
|
|
public VillagerFollowRangeFix(Schema outputSchema) {
|
|
super(outputSchema, false, "Villager Follow Range Fix", References.ENTITY, "minecraft:villager");
|
|
}
|
|
|
|
@Override
|
|
protected Typed<?> fix(Typed<?> entity) {
|
|
return entity.update(DSL.remainderFinder(), VillagerFollowRangeFix::fixValue);
|
|
}
|
|
|
|
private static Dynamic<?> fixValue(Dynamic<?> tag) {
|
|
return tag.update("Attributes", attributes -> tag.createList(attributes.asStream().map(attribute -> {
|
|
if (!attribute.get("Name").asString("").equals("generic.follow_range") || attribute.get("Base").asDouble(0.0) != 16.0) {
|
|
return attribute;
|
|
}
|
|
return attribute.set("Base", attribute.createDouble(48.0));
|
|
})));
|
|
}
|
|
}
|
|
|