diff --git a/common/src/generated/resources/.cache/9dc2e1bbb6dbc88d629e62ed955e4c156b6652a3 b/common/src/generated/resources/.cache/9dc2e1bbb6dbc88d629e62ed955e4c156b6652a3 index f4909aad..2cb60aaa 100644 --- a/common/src/generated/resources/.cache/9dc2e1bbb6dbc88d629e62ed955e4c156b6652a3 +++ b/common/src/generated/resources/.cache/9dc2e1bbb6dbc88d629e62ed955e4c156b6652a3 @@ -1,4 +1,4 @@ -// 1.20.4 2024-01-04T15:02:33.4878204 Tags for minecraft:item mod id toughasnails +// 1.20.4 2024-01-04T19:53:18.3535609 Tags for minecraft:item mod id toughasnails f05342856fe99891fa5e94bbe8db82a4f75ac41e data/toughasnails/tags/items/cooling_armor.json 572f6d0748095755aeef0ca7d602f4ebba9bfd76 data/toughasnails/tags/items/cooling_consumed_items.json 7c304628a9c17ca3ba6cd13e199fcf73ad9c974f data/toughasnails/tags/items/cooling_held_items.json diff --git a/common/src/main/java/toughasnails/init/ModVillagerTrades.java b/common/src/main/java/toughasnails/init/ModVillagerTrades.java index 0ce3a77b..0e9e0f57 100644 --- a/common/src/main/java/toughasnails/init/ModVillagerTrades.java +++ b/common/src/main/java/toughasnails/init/ModVillagerTrades.java @@ -5,10 +5,71 @@ package toughasnails.init; import glitchcore.event.village.WandererTradesEvent; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.npc.VillagerTrades; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; +import toughasnails.api.item.TANItems; public class ModVillagerTrades { public static void addWanderingVillagerTrades(WandererTradesEvent event) { + //Cost, Amount, Trades Until Disabled, Villager XP + VillagerTrades.ItemListing[] WANDERING_TRADER_GENERIC = new VillagerTrades.ItemListing[]{ + new ItemsForEmeralds(TANItems.ICE_CREAM, 2, 1, 4, 1), + new ItemsForEmeralds(TANItems.CHARC_0S, 2, 1, 4, 1), + new ItemsForEmeralds(TANItems.GLOW_BERRY_JUICE, 2, 1, 4, 1), + new ItemsForEmeralds(TANItems.SWEET_BERRY_JUICE, 2, 1, 4, 1), + new ItemsForEmeralds(TANItems.PUMPKIN_JUICE, 2, 1, 3, 1), + new ItemsForEmeralds(TANItems.MELON_JUICE, 3, 1, 3, 1), + new ItemsForEmeralds(TANItems.APPLE_JUICE, 4, 1, 2, 1), + new ItemsForEmeralds(TANItems.CACTUS_JUICE, 4, 1, 2, 1)}; + + VillagerTrades.ItemListing[] WANDERING_TRADER_RARE = new VillagerTrades.ItemListing[]{ + new ItemsForEmeralds(TANItems.CHORUS_FRUIT_JUICE, 5, 1, 1, 1), + new ItemsForEmeralds(TANItems.PURIFIED_WATER_BOTTLE, 4, 1, 2, 1)}; + + for (VillagerTrades.ItemListing trade : WANDERING_TRADER_GENERIC) + { + event.addGenericTrade(trade); + } + for (VillagerTrades.ItemListing trade : WANDERING_TRADER_RARE) + { + event.addRareTrade(trade); + } + } + + static class ItemsForEmeralds implements VillagerTrades.ItemListing { + private final ItemStack itemStack; + private final int emeraldCost; + private final int numberOfItems; + private final int maxUses; + private final int villagerXp; + private final float priceMultiplier; + + public ItemsForEmeralds(Item p_35746_, int p_35747_, int p_35748_, int p_35749_, int p_35750_) { + this(new ItemStack(p_35746_), p_35747_, p_35748_, p_35749_, p_35750_); + } + + public ItemsForEmeralds(ItemStack p_35752_, int p_35753_, int p_35754_, int p_35755_, int p_35756_) { + this(p_35752_, p_35753_, p_35754_, p_35755_, p_35756_, 0.05F); + } + + public ItemsForEmeralds(ItemStack p_35758_, int p_35759_, int p_35760_, int p_35761_, int p_35762_, float p_35763_) { + this.itemStack = p_35758_; + this.emeraldCost = p_35759_; + this.numberOfItems = p_35760_; + this.maxUses = p_35761_; + this.villagerXp = p_35762_; + this.priceMultiplier = p_35763_; + } + + public MerchantOffer getOffer(Entity p_219699_, RandomSource p_219700_) { + return new MerchantOffer(new ItemStack(Items.EMERALD, this.emeraldCost), new ItemStack(this.itemStack.getItem(), this.numberOfItems), this.maxUses, this.villagerXp, this.priceMultiplier); + } } }