diff --git a/build.gradle b/build.gradle index c9ec86b4..67bbe40a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'net.minecraftforge.gradle' version '5.1.+' } -version = '1.4.3' +version = '1.4.4-SNAPSHOT' group = 'com.github.Pandarix.beautify' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'beautify' diff --git a/src/main/java/com/github/Pandarix/beautify/event/ModEvents.java b/src/main/java/com/github/Pandarix/beautify/event/ModEvents.java index 178644a2..d6122309 100644 --- a/src/main/java/com/github/Pandarix/beautify/event/ModEvents.java +++ b/src/main/java/com/github/Pandarix/beautify/event/ModEvents.java @@ -7,6 +7,7 @@ import com.github.Pandarix.beautify.core.init.ModVillagers; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -14,195 +15,241 @@ import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -@Mod.EventBusSubscriber(modid = Beautify.MODID) +@Mod.EventBusSubscriber(modid = Beautify.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEvents { @SubscribeEvent - public static void addCustomTrades(VillagerTradesEvent event) { - // BOTANIST - // lvl1 - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.HANGING_POT_ITEM.get(), 1); - int villagerLevel = 1; + public static void onFMLCommonSetup(FMLCommonSetupEvent event){ + Int2ObjectMap trades = new Int2ObjectOpenHashMap<>(); + + List level1 = List.of( + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.HANGING_POT_ITEM.get()),2,1,16,6,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.FLOWER_POT),3,2,12,5,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.VINE),2,3,16,4,0.02f) + ); + List level2 = List.of( + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.OAK_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.SPRUCE_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.BIRCH_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.JUNGLE_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.ACACIA_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.DARK_OAK_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.CRIMSON_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(ItemInit.WARPED_TRELLIS_ITEM.get()),1,2,16,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.BIG_DRIPLEAF),4,3,6,9,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.SMALL_DRIPLEAF),3,4,6,8,0.02f) + ); + List level3 = List.of( + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.LILY_PAD),1,4,8,5,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.SPORE_BLOSSOM),3,1,12,10,0.02f) + ); + + List level4 = List.of( + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.MOSS_BLOCK),1,2,48,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.FLOWERING_AZALEA),2,1,16,7,0.02f) + ); + List level5 = List.of( + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.ROOTED_DIRT),1,4,24,3,0.02f), + new VillagerTrades.ItemsForEmeralds(new ItemStack(Items.HANGING_ROOTS),1,3,10,7,0.02f) + ); + + + trades.put(1, level1.toArray(new VillagerTrades.ItemListing[3])); + trades.put(2, level2.toArray(new VillagerTrades.ItemListing[10])); + trades.put(3, level3.toArray(new VillagerTrades.ItemListing[2])); + trades.put(4, level4.toArray(new VillagerTrades.ItemListing[2])); + trades.put(5, level5.toArray(new VillagerTrades.ItemListing[2])); + VillagerTrades.TRADES.put(ModVillagers.BOTANIST.get(),trades); - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 6, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.FLOWER_POT, 2); - int villagerLevel = 1; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 12, 5, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.VINE, 3); - int villagerLevel = 1; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 4, 0.02F)); - } - - // lvl2 - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.OAK_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.SPRUCE_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.BIRCH_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.JUNGLE_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.ACACIA_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.DARK_OAK_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.MANGROVE_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.CRIMSON_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(ItemInit.WARPED_TRELLIS_ITEM.get(), 2); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.BIG_DRIPLEAF, 3); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 4), stack, 6, 9, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.SMALL_DRIPLEAF, 4); - int villagerLevel = 2; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 6, 8, 0.02F)); - } - - // lvl3 - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.LILY_PAD, 4); - int villagerLevel = 3; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 8, 5, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.SPORE_BLOSSOM, 1); - int villagerLevel = 3; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 12, 10, 0.02F)); - } - - // lvl 4 - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.MOSS_BLOCK, 2); - int villagerLevel = 4; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 48, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.FLOWERING_AZALEA, 1); - int villagerLevel = 4; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 7, 0.02F)); - } - - // lvl 5 - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.ROOTED_DIRT, 4); - int villagerLevel = 5; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 24, 3, 0.02F)); - } - - if (event.getType() == ModVillagers.BOTANIST.get()) { - Int2ObjectMap> trades = event.getTrades(); - ItemStack stack = new ItemStack(Items.HANGING_ROOTS, 3); - int villagerLevel = 5; - - trades.get(villagerLevel) - .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 10, 7, 0.02F)); - } } + +// @SubscribeEvent +// public static void addCustomTrades(VillagerTradesEvent event) { +// // BOTANIST +// // lvl1 +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.HANGING_POT_ITEM.get(), 1); +// int villagerLevel = 1; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 6, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.FLOWER_POT, 2); +// int villagerLevel = 1; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 12, 5, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.VINE, 3); +// int villagerLevel = 1; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 4, 0.02F)); +// } +// +// // lvl2 +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.OAK_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.SPRUCE_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.BIRCH_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.JUNGLE_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.ACACIA_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.DARK_OAK_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.MANGROVE_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.CRIMSON_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(ItemInit.WARPED_TRELLIS_ITEM.get(), 2); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 16, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.BIG_DRIPLEAF, 3); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 4), stack, 6, 9, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.SMALL_DRIPLEAF, 4); +// int villagerLevel = 2; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 6, 8, 0.02F)); +// } +// +// // lvl3 +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.LILY_PAD, 4); +// int villagerLevel = 3; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 8, 5, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.SPORE_BLOSSOM, 1); +// int villagerLevel = 3; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 3), stack, 12, 10, 0.02F)); +// } +// +// // lvl 4 +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.MOSS_BLOCK, 2); +// int villagerLevel = 4; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 48, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.FLOWERING_AZALEA, 1); +// int villagerLevel = 4; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 2), stack, 16, 7, 0.02F)); +// } +// +// // lvl 5 +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.ROOTED_DIRT, 4); +// int villagerLevel = 5; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 24, 3, 0.02F)); +// } +// +// if (event.getType() == ModVillagers.BOTANIST.get()) { +// Int2ObjectMap> trades = event.getTrades(); +// ItemStack stack = new ItemStack(Items.HANGING_ROOTS, 3); +// int villagerLevel = 5; +// +// trades.get(villagerLevel) +// .add((trader, rand) -> new MerchantOffer(new ItemStack(Items.EMERALD, 1), stack, 10, 7, 0.02F)); +// } +// } } \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index bf715a12..7bdbf0c5 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,2 +1,4 @@ public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210559_ # rawTemplates -public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210560_ # templates \ No newline at end of file +public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210560_ # templates +public net.minecraft.world.entity.npc.VillagerTrades$ItemsForEmeralds +