Search in sources :

Example 11 with MerchantRecipe

use of net.minecraft.village.MerchantRecipe in project PneumaticCraft by MineMaarten.

the class CraftingRegistrator method registerAmadronOffers.

private static void registerAmadronOffers() {
    PneumaticRecipeRegistry registry = PneumaticRecipeRegistry.getInstance();
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.PCBBlueprint));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 0));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 14), new ItemStack(Itemss.assemblyProgram, 1, 2));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.oil, 5000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.diesel, 4000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lubricant, 2500), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.kerosene, 3000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.gasoline, 2000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lpg, 1000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald), new FluidStack(Fluids.oil, 1000));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 5), new FluidStack(Fluids.lubricant, 1000));
    for (int i = 0; i < 256; i++) {
        try {
            for (int j = 0; j < 10; j++) {
                EntityVillager villager = new EntityVillager(null, i);
                MerchantRecipeList list = villager.getRecipes(null);
                for (MerchantRecipe recipe : (List<MerchantRecipe>) list) {
                    if (recipe.getSecondItemToBuy() == null && recipe.getItemToBuy() != null && recipe.getItemToBuy().getItem() != null && recipe.getItemToSell() != null && recipe.getItemToSell().getItem() != null) {
                        registry.registerDefaultPeriodicAmadronOffer(recipe.getItemToBuy(), recipe.getItemToSell());
                    }
                }
            }
        } catch (Throwable e) {
        }
    }
}
Also used : MerchantRecipeList(net.minecraft.village.MerchantRecipeList) MerchantRecipe(net.minecraft.village.MerchantRecipe) IPneumaticRecipeRegistry(pneumaticCraft.api.recipe.IPneumaticRecipeRegistry) FluidStack(net.minecraftforge.fluids.FluidStack) EntityVillager(net.minecraft.entity.passive.EntityVillager) ArrayList(java.util.ArrayList) MerchantRecipeList(net.minecraft.village.MerchantRecipeList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 12 with MerchantRecipe

use of net.minecraft.village.MerchantRecipe in project ArsMagica2 by Mithion.

the class MageVillagerTrade method manipulateTradesForVillager.

@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
    recipeList.clear();
    int numChoices = random.nextInt(4) + 1;
    for (int i = 0; i < numChoices; ++i) {
        ItemStack choice = getRandomChoiceForTrade(random);
        if (choice != null) {
            MerchantRecipe itemToSell = new MerchantRecipe(new ItemStack(Items.emerald, random.nextInt(max - min) + min), choice);
            recipeList.add(itemToSell);
        }
    }
}
Also used : MerchantRecipe(net.minecraft.village.MerchantRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 13 with MerchantRecipe

use of net.minecraft.village.MerchantRecipe in project ImmersiveEngineering by BluSunrize.

the class EventHandler method onMerchantTrade.

@SubscribeEvent
public void onMerchantTrade(MerchantTradeOffersEvent event) {
    if (event.getMerchant() instanceof EntityVillager && ((EntityVillager) event.getMerchant()).getProfessionForge() == IEVillagerHandler.PROF_ENGINEER && event.getList() != null) {
        Iterator<MerchantRecipe> iterator = event.getList().iterator();
        while (iterator.hasNext()) {
            MerchantRecipe recipe = iterator.next();
            ItemStack output = recipe.getItemToSell();
            if (output.getItem() == IEContent.itemMaterial && ItemNBTHelper.hasKey(output, "generatePerks")) {
                EntityPlayer player = event.getPlayer();
                Random random = player.getRNG();
                ItemNBTHelper.remove(output, "generatePerks");
                NBTTagCompound perksTag = ItemRevolver.RevolverPerk.generatePerkSet(random, player.getLuck());
                ItemNBTHelper.setTagCompound(output, "perks", perksTag);
                int tier = Math.max(1, ItemRevolver.RevolverPerk.calculateTier(perksTag));
                recipe.getItemToBuy().setCount(5 * tier + random.nextInt(5));
            } else // Make recipe Unusable
            if (output.getItem() == IEContent.itemMaterial && ItemNBTHelper.hasKey(output, "perks") && recipe.getToolUses() >= 1 && recipe.getMaxTradeUses() > 0)
                recipe.increaseMaxTradeUses(Integer.MIN_VALUE);
        }
    }
}
Also used : MerchantRecipe(net.minecraft.village.MerchantRecipe) EntityVillager(net.minecraft.entity.passive.EntityVillager) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with MerchantRecipe

use of net.minecraft.village.MerchantRecipe in project NetherEx by LogicTechCorp.

the class EntityPigtificate method updateAITasks.

@Override
protected void updateAITasks() {
    if (randomTickDivider-- <= 0) {
        BlockPos blockpos = new BlockPos(this);
        PigtificateVillageManager.getPigtificateVillages(getWorld()).addToVillagerPositionList(blockpos);
        randomTickDivider = 70 + rand.nextInt(50);
        village = PigtificateVillageManager.getPigtificateVillages(getWorld()).getNearestVillage(blockpos, 32);
        if (village == null) {
            detachHome();
        } else {
            BlockPos blockpos1 = village.getCenter();
            setHomePosAndDistance(blockpos1, village.getVillageRadius());
            if (lookingForHome) {
                lookingForHome = false;
                village.setDefaultPlayerReputation(5);
            }
        }
    }
    if (!isTrading() && timeUntilRestock > 0) {
        --timeUntilRestock;
        if (timeUntilRestock <= 0) {
            if (needsInitialization) {
                for (MerchantRecipe merchantrecipe : tradeList) {
                    if (merchantrecipe.isRecipeDisabled()) {
                        merchantrecipe.increaseMaxTradeUses(rand.nextInt(6) + rand.nextInt(6) + 2);
                    }
                }
                populateTradeList();
                needsInitialization = false;
                if (village != null && lastCustomer != null) {
                    world.setEntityState(this, (byte) 14);
                    village.modifyPlayerReputation(lastCustomer, 1);
                }
            }
            addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200, 0));
        }
    }
    super.updateAITasks();
}
Also used : MerchantRecipe(net.minecraft.village.MerchantRecipe) PotionEffect(net.minecraft.potion.PotionEffect) BlockPos(net.minecraft.util.math.BlockPos)

Example 15 with MerchantRecipe

use of net.minecraft.village.MerchantRecipe in project Railcraft by Railcraft.

the class TileTradeStation method nextTrade.

public void nextTrade(int tradeSet) {
    EntityVillager villager = new EntityVillager(worldObj);
    villager.setProfession(profession);
    MerchantRecipeList recipes = villager.getRecipes(null);
    MerchantRecipe recipe = recipes.get(MiscTools.RANDOM.nextInt(recipes.size()));
    recipeSlots.setInventorySlotContents(tradeSet * 3 + 0, recipe.getItemToBuy());
    recipeSlots.setInventorySlotContents(tradeSet * 3 + 1, recipe.getSecondItemToBuy());
    recipeSlots.setInventorySlotContents(tradeSet * 3 + 2, recipe.getItemToSell());
}
Also used : MerchantRecipeList(net.minecraft.village.MerchantRecipeList) MerchantRecipe(net.minecraft.village.MerchantRecipe) EntityVillager(net.minecraft.entity.passive.EntityVillager)

Aggregations

MerchantRecipe (net.minecraft.village.MerchantRecipe)21 ItemStack (net.minecraft.item.ItemStack)14 EntityVillager (net.minecraft.entity.passive.EntityVillager)7 MerchantRecipeList (net.minecraft.village.MerchantRecipeList)7 TradeOffer (org.spongepowered.api.item.merchant.TradeOffer)7 PotionEffect (net.minecraft.potion.PotionEffect)3 Enchantment (net.minecraft.enchantment.Enchantment)2 EnchantmentData (net.minecraft.enchantment.EnchantmentData)2 BlockPos (net.minecraft.util.math.BlockPos)2 WorldServer (net.minecraft.world.WorldServer)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IPneumaticRecipeRegistry (me.desht.pneumaticcraft.api.recipe.IPneumaticRecipeRegistry)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemEnchantedBook (net.minecraft.item.ItemEnchantedBook)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 IPneumaticRecipeRegistry (pneumaticCraft.api.recipe.IPneumaticRecipeRegistry)1