Search in sources :

Example 6 with DimletEntry

use of mcjty.rftools.items.dimlets.DimletEntry in project RFTools by McJty.

the class DimletScramblerTileEntity method startScrambling.

private void startScrambling() {
    int rf = DimletConfiguration.rfScrambleOperation;
    rf = (int) (rf * (2.0f - getInfusedFactor()) / 2.0f);
    if (getEnergyStored(ForgeDirection.DOWN) < rf) {
        // Not enough energy.
        return;
    }
    ItemStack input0 = inventoryHelper.getStackInSlot(0);
    ItemStack input1 = inventoryHelper.getStackInSlot(1);
    ItemStack input2 = inventoryHelper.getStackInSlot(2);
    DimletKey key1 = KnownDimletConfiguration.getDimletKey(input0, worldObj);
    DimletKey key2 = KnownDimletConfiguration.getDimletKey(input1, worldObj);
    DimletKey key3 = KnownDimletConfiguration.getDimletKey(input2, worldObj);
    DimletEntry entry1 = KnownDimletConfiguration.getEntry(key1);
    if (entry1 == null) {
        // Protect against blacklisted dimlets.
        return;
    }
    DimletEntry entry2 = KnownDimletConfiguration.getEntry(key2);
    if (entry2 == null) {
        // Protect against blacklisted dimlets.
        return;
    }
    DimletEntry entry3 = KnownDimletConfiguration.getEntry(key3);
    if (entry3 == null) {
        // Protect against blacklisted dimlets.
        return;
    }
    consumeEnergy(rf);
    input0.splitStack(1);
    if (input0.stackSize == 0) {
        inventoryHelper.setStackInSlot(0, null);
    }
    input1.splitStack(1);
    if (input1.stackSize == 0) {
        inventoryHelper.setStackInSlot(1, null);
    }
    input2.splitStack(1);
    if (input2.stackSize == 0) {
        inventoryHelper.setStackInSlot(2, null);
    }
    int rarity1 = entry1.getRarity();
    int rarity2 = entry2.getRarity();
    int rarity3 = entry3.getRarity();
    float b = (rarity1 + rarity2 + rarity3) / 3.0f;
    // An average of rarity 5 will give the best bonus which is 0.1
    bonus = (b / 50.0f) * (getInfusedFactor() / 3.0f + 1.0f);
    scrambling = 64;
    markDirty();
}
Also used : DimletEntry(mcjty.rftools.items.dimlets.DimletEntry) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

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