Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Radio villager trades in NEI #22

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
33 changes: 32 additions & 1 deletion src/main/java/openblocks/common/RadioVillagerTradeManager.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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<VillagerTrade> 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));
}
}