use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.
the class DimletRarityItemSorter method getRarity.
private int getRarity(Pair<ItemStack, Integer> object) {
int rarity = -1;
if (object.getKey().getItem() == DimletSetup.knownDimlet) {
DimletKey key = KnownDimletConfiguration.getDimletKey(object.getKey(), null);
DimletEntry entry = KnownDimletConfiguration.getEntry(key);
if (entry != null) {
rarity = entry.getRarity();
}
}
return rarity;
}
use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.
the class RFToolsTradeHandler method getRandomSellDimlet.
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));
}
}
}
use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.
the class RFToolsTradeHandler method getRandomBuyDimlet.
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))));
}
}
}
use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.
the class DimletFilterTileEntity method canExtractItem.
@Override
public boolean canExtractItem(int index, ItemStack stack, int side) {
if (!isOutputMode(side)) {
return false;
}
if (stack == null) {
return false;
}
DimletKey key = KnownDimletConfiguration.getDimletKey(stack, worldObj);
if (key == null) {
return false;
}
if (types[side] != null && !types[side].equals(key.getType())) {
return false;
}
DimletEntry entry = KnownDimletConfiguration.getEntry(key);
if (entry == null) {
return false;
}
int rarity = entry.getRarity();
if (rarity < minRarity[side] || rarity > maxRarity[side]) {
return false;
}
if (craftable[side] != 0) {
int cr = KnownDimletConfiguration.craftableDimlets.contains(key) ? CRAFTABLE_YES : CRAFTABLE_NO;
if (cr != craftable[side]) {
return false;
}
}
// Is this the best match?
return findMostSpecificExtractionSide(entry) == side;
}
use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.
the class DimletCraftingTools method matchDimletRecipe.
public static boolean matchDimletRecipe(DimletKey key, ItemStack stackController, ItemStack stackMemory, ItemStack stackEnergy) {
DimletEntry dimletEntry = KnownDimletConfiguration.getEntry(key);
int rarity = dimletEntry.getRarity();
if (stackController.getItemDamage() != rarity) {
return false;
}
int level = calculateItemLevelFromRarity(rarity);
if (stackMemory.getItemDamage() != level) {
return false;
}
if (stackEnergy.getItemDamage() != level) {
return false;
}
return true;
}
Aggregations