diff --git a/dependencies.gradle b/dependencies.gradle index 445ee6fc..8c9dda99 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,4 +7,5 @@ dependencies { compileOnly('openperipheral:OpenPeripheralCore-API:3.4.1') compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.6.11-GTNH:dev') compileOnly('curse.maven:computercraft-67504:2269339') + compileOnly('com.github.GTNewHorizons:Mobs-Info:0.4.5-GTNH:dev') } diff --git a/src/main/java/openblocks/common/RadioVillagerTradeManager.java b/src/main/java/openblocks/common/RadioVillagerTradeManager.java index e757b94f..27ee2cef 100644 --- a/src/main/java/openblocks/common/RadioVillagerTradeManager.java +++ b/src/main/java/openblocks/common/RadioVillagerTradeManager.java @@ -1,7 +1,13 @@ package openblocks.common; +import static com.kuba6000.mobsinfo.api.VillagerTrade.create; +import static com.kuba6000.mobsinfo.api.VillagerTrade.createItem; + +import java.util.ArrayList; import java.util.Random; +import javax.annotation.Nonnull; + import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -11,10 +17,15 @@ import net.minecraft.village.MerchantRecipeList; import net.minecraftforge.oredict.OreDictionary; +import com.kuba6000.mobsinfo.api.IVillagerInfoProvider; +import com.kuba6000.mobsinfo.api.VillagerTrade; + +import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; import openblocks.Config; -public class RadioVillagerTradeManager implements IVillageTradeHandler { +@Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IVillagerInfoProvider", modid = "mobsinfo") +public class RadioVillagerTradeManager implements IVillageTradeHandler, IVillagerInfoProvider { private static ItemStack randomItemAmount(Random random, Item item, int min, int max) { int amount = random.nextInt(max - min) + min; @@ -39,4 +50,24 @@ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeL .addToListWithCheck(new MerchantRecipe(randomEmeralds(random, 3, 7), new ItemStack(Blocks.jukebox))); } + @Optional.Method(modid = "mobsinfo") + @Override + public void provideTrades(@Nonnull EntityVillager villager, int profession, + @Nonnull ArrayList trades) { + if (Config.radioVillagerRecords) { + for (ItemStack record : OreDictionary.getOres("record")) { + trades.add( + create(createItem(Items.emerald).withPossibleSizes(7, 15), createItem(record)) + .withChance(0.01d)); + } + } + trades.add( + create( + createItem(Items.emerald).withPossibleSizes(1, 2), + createItem(Item.getItemFromBlock(Blocks.noteblock))).withChance(0.5d)); + trades.add( + create( + createItem(Items.emerald).withPossibleSizes(3, 7), + createItem(Item.getItemFromBlock(Blocks.jukebox))).withChance(0.25d)); + } }