Search in sources :

Example 1 with MerchantRecipeList

use of net.minecraft.village.MerchantRecipeList 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 2 with MerchantRecipeList

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

the class EntityPigtificate method readEntityFromNBT.

@Override
public void readEntityFromNBT(NBTTagCompound compound) {
    super.readEntityFromNBT(compound);
    setProfession(compound.getInteger("Profession"));
    setCareer(compound.getInteger("Career"));
    setCareerLevel(compound.getInteger("CareerLevel"));
    setWillingToMate(compound.getBoolean("Willing"));
    if (compound.hasKey("Trades", 10)) {
        NBTTagCompound trades = compound.getCompoundTag("Trades");
        tradeList = new MerchantRecipeList(trades);
    }
    NBTTagList list = compound.getTagList("Inventory", 10);
    for (int i = 0; i < list.tagCount(); ++i) {
        ItemStack stack = new ItemStack(list.getCompoundTagAt(i));
        if (!stack.isEmpty()) {
            inventory.addItem(stack);
        }
    }
    setCanPickUpLoot(true);
    setAdditionalAITasks();
}
Also used : MerchantRecipeList(net.minecraft.village.MerchantRecipeList) NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 3 with MerchantRecipeList

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

the class TileTradeStation method attemptTrade.

private boolean attemptTrade(List<EntityVillager> villagers, int tradeSet) {
    ItemStack buy1 = recipeSlots.getStackInSlot(tradeSet * 3 + 0);
    ItemStack buy2 = recipeSlots.getStackInSlot(tradeSet * 3 + 1);
    ItemStack sell = recipeSlots.getStackInSlot(tradeSet * 3 + 2);
    for (EntityVillager villager : villagers) {
        MerchantRecipeList recipes = villager.getRecipes(null);
        for (MerchantRecipe recipe : recipes) {
            if (recipe.isRecipeDisabled())
                continue;
            //noinspection ConstantConditions
            if (recipe.getItemToBuy() != null && !InvTools.isItemLessThanOrEqualTo(recipe.getItemToBuy(), buy1))
                continue;
            //noinspection ConstantConditions
            if (recipe.getSecondItemToBuy() != null && !InvTools.isItemLessThanOrEqualTo(recipe.getSecondItemToBuy(), buy2))
                continue;
            if (!InvTools.isItemGreaterOrEqualThan(recipe.getItemToSell(), sell))
                continue;
            //                System.out.printf("Buying: %d %s Found: %d%n", recipe.getItemToBuy().stackSize, recipe.getItemToBuy().getDisplayName(), InvTools.countItems(invInput, recipe.getItemToBuy()));
            if (canDoTrade(recipe)) {
                //                    System.out.println("Can do trade");
                doTrade(villager, recipe);
                return true;
            }
        }
    }
    return false;
}
Also used : MerchantRecipeList(net.minecraft.village.MerchantRecipeList) MerchantRecipe(net.minecraft.village.MerchantRecipe) EntityVillager(net.minecraft.entity.passive.EntityVillager) ItemStack(net.minecraft.item.ItemStack)

Example 4 with MerchantRecipeList

use of net.minecraft.village.MerchantRecipeList 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

MerchantRecipeList (net.minecraft.village.MerchantRecipeList)4 EntityVillager (net.minecraft.entity.passive.EntityVillager)3 ItemStack (net.minecraft.item.ItemStack)3 MerchantRecipe (net.minecraft.village.MerchantRecipe)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 IPneumaticRecipeRegistry (pneumaticCraft.api.recipe.IPneumaticRecipeRegistry)1