56 lines
1.8 KiB
Java
56 lines
1.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.google.common.collect.ImmutableMap
|
|
* com.mojang.datafixers.DSL
|
|
* com.mojang.datafixers.Typed
|
|
* com.mojang.datafixers.schemas.Schema
|
|
* com.mojang.datafixers.util.Pair
|
|
* com.mojang.serialization.Dynamic
|
|
*/
|
|
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.mojang.datafixers.DSL;
|
|
import com.mojang.datafixers.Typed;
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import com.mojang.datafixers.util.Pair;
|
|
import com.mojang.serialization.Dynamic;
|
|
import java.util.Map;
|
|
import net.minecraft.util.datafix.fixes.NamedEntityFix;
|
|
import net.minecraft.util.datafix.fixes.References;
|
|
|
|
public class MemoryExpiryDataFix
|
|
extends NamedEntityFix {
|
|
public MemoryExpiryDataFix(Schema schema, String entityType) {
|
|
super(schema, false, "Memory expiry data fix (" + entityType + ")", References.ENTITY, entityType);
|
|
}
|
|
|
|
@Override
|
|
protected Typed<?> fix(Typed<?> entity) {
|
|
return entity.update(DSL.remainderFinder(), this::fixTag);
|
|
}
|
|
|
|
public Dynamic<?> fixTag(Dynamic<?> input) {
|
|
return input.update("Brain", this::updateBrain);
|
|
}
|
|
|
|
private Dynamic<?> updateBrain(Dynamic<?> input) {
|
|
return input.update("memories", this::updateMemories);
|
|
}
|
|
|
|
private Dynamic<?> updateMemories(Dynamic<?> memories) {
|
|
return memories.updateMapValues(this::updateMemoryEntry);
|
|
}
|
|
|
|
private Pair<Dynamic<?>, Dynamic<?>> updateMemoryEntry(Pair<Dynamic<?>, Dynamic<?>> memoryEntry) {
|
|
return memoryEntry.mapSecond(this::wrapMemoryValue);
|
|
}
|
|
|
|
private Dynamic<?> wrapMemoryValue(Dynamic<?> dynamic) {
|
|
return dynamic.createMap((Map)ImmutableMap.of((Object)dynamic.createString("value"), dynamic));
|
|
}
|
|
}
|
|
|