minecraft_25w45a_unobfuscated/net/minecraft/util/datafix/fixes/EmptyItemInVillagerTradeFix.java
2025-11-24 22:52:51 +03:00

41 lines
1.4 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.DataFix
* com.mojang.datafixers.TypeRewriteRule
* com.mojang.datafixers.schemas.Schema
* com.mojang.datafixers.types.Type
* com.mojang.serialization.Dynamic
*/
package net.minecraft.util.datafix.fixes;
import com.mojang.datafixers.DataFix;
import com.mojang.datafixers.TypeRewriteRule;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.Type;
import com.mojang.serialization.Dynamic;
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.util.datafix.schemas.NamespacedSchema;
public class EmptyItemInVillagerTradeFix
extends DataFix {
public EmptyItemInVillagerTradeFix(Schema outputSchema) {
super(outputSchema, false);
}
public TypeRewriteRule makeRule() {
Type tradeType = this.getInputSchema().getType(References.VILLAGER_TRADE);
return this.writeFixAndRead("EmptyItemInVillagerTradeFix", tradeType, tradeType, input -> {
Dynamic buyB = input.get("buyB").orElseEmptyMap();
String id = NamespacedSchema.ensureNamespaced(buyB.get("id").asString("minecraft:air"));
int count = buyB.get("count").asInt(0);
if (id.equals("minecraft:air") || count == 0) {
return input.remove("buyB");
}
return input;
});
}
}