Esempio n. 1
0
 private int calculateCostFactor(DimletKey key) {
   DimletEntry dimletEntry = KnownDimletConfiguration.getEntry(key);
   if (dimletEntry == null) {
     Logging.logError("Something went wrong for key: " + key);
     return 0;
   }
   return (int) (dimletEntry.getRfMaintainCost() * DimletConfiguration.afterCreationCostFactor);
 }
Esempio n. 2
0
 private void getRandomBuyDimlet(
     EntityVillager villager, MerchantRecipeList recipeList, Random random, int bonus) {
   DimletKey dimlet = DimletRandomizer.getRandomDimlet(random);
   if (dimlet != null) {
     DimletEntry entry = KnownDimletConfiguration.idToDimletEntry.get(dimlet);
     if (entry != null) {
       int rarity = entry.getRarity();
       ItemStack dimletStack = KnownDimletConfiguration.makeKnownDimlet(dimlet, villager.worldObj);
       recipeList.add(
           new MerchantRecipe(
               dimletStack,
               new ItemStack(Items.emerald, (bonus + random.nextInt(2)) * (rarity / 2 + 1))));
     }
   }
 }
Esempio n. 3
0
  private void addToCost(DimletKey key) {
    DimletEntry dimletEntry = KnownDimletConfiguration.getEntry(key);
    int rfMaintainCost = dimletEntry.getRfMaintainCost();

    if (rfMaintainCost < 0) {
      int nominalCost = descriptor.calculateNominalCost();
      int rfMinimum = Math.max(10, nominalCost * DimletConfiguration.minimumCostPercentage / 100);

      actualRfCost = actualRfCost - (actualRfCost * (-rfMaintainCost) / 100);
      if (actualRfCost < rfMinimum) {
        actualRfCost = rfMinimum; // Never consume less then this
      }
    } else {
      actualRfCost += rfMaintainCost;
    }
  }
Esempio n. 4
0
 private void getRandomSellDimlet(
     EntityVillager villager, MerchantRecipeList recipeList, Random random, float dimletBonus) {
   WeightedRandomSelector.Distribution<Integer> distribution =
       DimletRandomizer.randomDimlets.createDistribution(dimletBonus);
   DimletKey dimlet = DimletRandomizer.getRandomDimlet(distribution, random);
   if (dimlet != null) {
     DimletEntry entry = KnownDimletConfiguration.idToDimletEntry.get(dimlet);
     if (entry != null) {
       int rarity = entry.getRarity();
       ItemStack dimletStack = KnownDimletConfiguration.makeKnownDimlet(dimlet, villager.worldObj);
       recipeList.add(
           new MerchantRecipe(
               new ItemStack(Items.emerald, (1 + random.nextInt(2)) * (rarity / 2 + 1)),
               dimletStack));
     }
   }
 }