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) {
}
}
}
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);
}
}
}
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);
}
}
}
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();
}
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());
}
Aggregations