コード例 #1
0
  public static ArrayList getStructureVillageWeightedPieceList(Random par0Random, int par1) {
    ArrayList var2 = new ArrayList();
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageHouse4_GardenTFC.class,
            4,
            MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 4 + par1 * 2)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageChurchTFC.class,
            20,
            MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 1 + par1)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageHouse1TFC.class,
            20,
            MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 2 + par1)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageWoodHutTFC.class,
            3,
            MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 5 + par1 * 3)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageHallTFC.class,
            15,
            MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 2 + par1)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageFieldTFC.class,
            3,
            MathHelper.getRandomIntegerInRange(par0Random, 1 + par1, 4 + par1)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageField2TFC.class,
            3,
            MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 4 + par1 * 2)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageHouse2TFC.class,
            15,
            MathHelper.getRandomIntegerInRange(par0Random, 0, 1 + par1)));
    var2.add(
        new StructureVillagePieceWeight(
            ComponentVillageHouse3TFC.class,
            8,
            MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 3 + par1 * 2)));
    Iterator var3 = var2.iterator();

    while (var3.hasNext()) {
      if (((StructureVillagePieceWeight) var3.next()).villagePiecesLimit == 0) {
        var3.remove();
      }
    }

    return var2;
  }
コード例 #2
0
  /** Apply bonemeal to the crops. */
  public void fertilize(World par1World, int par2, int par3, int par4) {
    int var5 =
        par1World.getBlockMetadata(par2, par3, par4)
            + MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5);

    if (var5 > 7) {
      var5 = 7;
    }

    par1World.setBlockMetadataWithNotify(par2, par3, par4, var5, 2);
  }
コード例 #3
0
ファイル: BlockOre.java プロジェクト: squallblade/FastFight
  /** Drops the block items with a specified chance of dropping the specified items */
  public void dropBlockAsItemWithChance(
      World par1World, int par2, int par3, int par4, int par5, float par6, int par7) {
    super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);

    if (this.idDropped(par5, par1World.rand, par7) != this.blockID) {
      int var8 = 0;

      if (this.blockID == Block.oreCoal.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 0, 2);
      } else if (this.blockID == Block.oreDiamond.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7);
      } else if (this.blockID == Block.oreEmerald.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7);
      } else if (this.blockID == Block.oreLapis.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5);
      } else if (this.blockID == Block.oreRubis.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 3, 7);
      }

      this.dropXpOnBlockBreak(par1World, par2, par3, par4, var8);
    }
  }
コード例 #4
0
  /** Drops the block items with a specified chance of dropping the specified items */
  public void dropBlockAsItemWithChance(
      World par1World, int par2, int par3, int par4, int par5, float par6, int par7) {
    super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);

    if (this.idDropped(par5, par1World.rand, par7) != this.blockID) {
      int var8 = 0;

      if (this.blockID == mod_DesertPetrifiedWood.BlockPetrifiedWood2.blockID) {
        var8 = MathHelper.getRandomIntegerInRange(par1World.rand, 0, 2);
      }

      this.dropXpOnBlockBreak(par1World, par2, par3, par4, var8);
    }
  }
コード例 #5
0
ファイル: EntityVillager.java プロジェクト: WhyMeMan/Scarlet
  /**
   * based on the villagers profession add items, equipment, and recipies adds par1 random items to
   * the list of things that the villager wants to buy. (at most 1 of each wanted type is added)
   */
  private void addDefaultEquipmentAndRecipies(int par1) {
    if (this.buyingList != null) {
      this.field_82191_bN = MathHelper.sqrt_float((float) this.buyingList.size()) * 0.2F;
    } else {
      this.field_82191_bN = 0.0F;
    }

    MerchantRecipeList var2;
    var2 = new MerchantRecipeList();
    int var6;
    label50:
    switch (this.getProfession()) {
      case 0:
        addMerchantItem(var2, Item.wheat.itemID, this.rand, this.func_82188_j(0.9F));
        addMerchantItem(var2, Block.cloth.blockID, this.rand, this.func_82188_j(0.5F));
        addMerchantItem(var2, Item.chickenRaw.itemID, this.rand, this.func_82188_j(0.5F));
        addMerchantItem(var2, Item.fishCooked.itemID, this.rand, this.func_82188_j(0.4F));
        addBlacksmithItem(var2, Item.bread.itemID, this.rand, this.func_82188_j(0.9F));
        addBlacksmithItem(var2, Item.melon.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.appleRed.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.cookie.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.shears.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.flintAndSteel.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.chickenCooked.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.arrow.itemID, this.rand, this.func_82188_j(0.5F));

        if (this.rand.nextFloat() < this.func_82188_j(0.5F)) {
          var2.add(
              new MerchantRecipe(
                  new ItemStack(Block.gravel, 10),
                  new ItemStack(Item.emerald),
                  new ItemStack(Item.flint.itemID, 4 + this.rand.nextInt(2), 0)));
        }

        break;

      case 1:
        addMerchantItem(var2, Item.paper.itemID, this.rand, this.func_82188_j(0.8F));
        addMerchantItem(var2, Item.book.itemID, this.rand, this.func_82188_j(0.8F));
        addMerchantItem(var2, Item.writtenBook.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Block.bookShelf.blockID, this.rand, this.func_82188_j(0.8F));
        addBlacksmithItem(var2, Block.glass.blockID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.compass.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.pocketSundial.itemID, this.rand, this.func_82188_j(0.2F));

        if (this.rand.nextFloat() < this.func_82188_j(0.07F)) {
          Enchantment var8 =
              Enchantment.field_92090_c[this.rand.nextInt(Enchantment.field_92090_c.length)];
          int var10 =
              MathHelper.getRandomIntegerInRange(this.rand, var8.getMinLevel(), var8.getMaxLevel());
          ItemStack var11 = Item.enchantedBook.func_92111_a(new EnchantmentData(var8, var10));
          var6 = 2 + this.rand.nextInt(5 + var10 * 10) + 3 * var10;
          var2.add(
              new MerchantRecipe(
                  new ItemStack(Item.book), new ItemStack(Item.emerald, var6), var11));
        }

        break;

      case 2:
        addBlacksmithItem(var2, Item.eyeOfEnder.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.expBottle.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.redstone.itemID, this.rand, this.func_82188_j(0.4F));
        addBlacksmithItem(var2, Block.glowStone.blockID, this.rand, this.func_82188_j(0.3F));
        int[] var3 =
            new int[] {
              Item.swordIron.itemID,
              Item.swordDiamond.itemID,
              Item.plateIron.itemID,
              Item.plateDiamond.itemID,
              Item.axeIron.itemID,
              Item.axeDiamond.itemID,
              Item.pickaxeIron.itemID,
              Item.pickaxeDiamond.itemID
            };
        int[] var4 = var3;
        int var5 = var3.length;
        var6 = 0;

        while (true) {
          if (var6 >= var5) {
            break label50;
          }

          int var7 = var4[var6];

          if (this.rand.nextFloat() < this.func_82188_j(0.05F)) {
            var2.add(
                new MerchantRecipe(
                    new ItemStack(var7, 1, 0),
                    new ItemStack(Item.emerald, 2 + this.rand.nextInt(3), 0),
                    EnchantmentHelper.addRandomEnchantment(
                        this.rand, new ItemStack(var7, 1, 0), 5 + this.rand.nextInt(15))));
          }

          ++var6;
        }

      case 3:
        addMerchantItem(var2, Item.coal.itemID, this.rand, this.func_82188_j(0.7F));
        addMerchantItem(var2, Item.ingotIron.itemID, this.rand, this.func_82188_j(0.5F));
        addMerchantItem(var2, Item.ingotGold.itemID, this.rand, this.func_82188_j(0.5F));
        addMerchantItem(var2, Item.diamond.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.swordIron.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.swordDiamond.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.axeIron.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.axeDiamond.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.pickaxeIron.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.pickaxeDiamond.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.shovelIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.shovelDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.hoeIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.hoeDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.bootsIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.bootsDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.helmetIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.helmetDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.plateIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.plateDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.legsIron.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.legsDiamond.itemID, this.rand, this.func_82188_j(0.2F));
        addBlacksmithItem(var2, Item.bootsChain.itemID, this.rand, this.func_82188_j(0.1F));
        addBlacksmithItem(var2, Item.helmetChain.itemID, this.rand, this.func_82188_j(0.1F));
        addBlacksmithItem(var2, Item.plateChain.itemID, this.rand, this.func_82188_j(0.1F));
        addBlacksmithItem(var2, Item.legsChain.itemID, this.rand, this.func_82188_j(0.1F));
        break;

      case 4:
        addMerchantItem(var2, Item.coal.itemID, this.rand, this.func_82188_j(0.7F));
        addMerchantItem(var2, Item.porkRaw.itemID, this.rand, this.func_82188_j(0.5F));
        addMerchantItem(var2, Item.beefRaw.itemID, this.rand, this.func_82188_j(0.5F));
        addBlacksmithItem(var2, Item.saddle.itemID, this.rand, this.func_82188_j(0.1F));
        addBlacksmithItem(var2, Item.plateLeather.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.bootsLeather.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.helmetLeather.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.legsLeather.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.porkCooked.itemID, this.rand, this.func_82188_j(0.3F));
        addBlacksmithItem(var2, Item.beefCooked.itemID, this.rand, this.func_82188_j(0.3F));
    }

    if (var2.isEmpty()) {
      addMerchantItem(var2, Item.ingotGold.itemID, this.rand, 1.0F);
    }

    Collections.shuffle(var2);

    if (this.buyingList == null) {
      this.buyingList = new MerchantRecipeList();
    }

    for (int var9 = 0; var9 < par1 && var9 < var2.size(); ++var9) {
      this.buyingList.addToListWithCheck((MerchantRecipe) var2.get(var9));
    }
  }