Search in sources :

Example 1 with DimletEntry

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;
}
Also used : DimletEntry(mcjty.rftools.items.dimlets.DimletEntry) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 2 with DimletEntry

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));
        }
    }
}
Also used : MerchantRecipe(net.minecraft.village.MerchantRecipe) WeightedRandomSelector(mcjty.lib.varia.WeightedRandomSelector) DimletEntry(mcjty.rftools.items.dimlets.DimletEntry) DimletKey(mcjty.rftools.items.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack)

Example 3 with DimletEntry

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))));
        }
    }
}
Also used : MerchantRecipe(net.minecraft.village.MerchantRecipe) DimletEntry(mcjty.rftools.items.dimlets.DimletEntry) DimletKey(mcjty.rftools.items.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack)

Example 4 with DimletEntry

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;
}
Also used : DimletEntry(mcjty.rftools.items.dimlets.DimletEntry) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 5 with DimletEntry

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;
}
Also used : DimletEntry(mcjty.rftools.items.dimlets.DimletEntry)

Aggregations

DimletEntry (mcjty.rftools.items.dimlets.DimletEntry)6 DimletKey (mcjty.rftools.items.dimlets.DimletKey)5 ItemStack (net.minecraft.item.ItemStack)3 MerchantRecipe (net.minecraft.village.MerchantRecipe)2 WeightedRandomSelector (mcjty.lib.varia.WeightedRandomSelector)1