Search in sources :

Example 26 with DimletKey

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

the class TimeDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    Float celestialAngle = null;
    Float timeSpeed = null;
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_TIME, dimlets);
    if (dimlets.isEmpty()) {
        if (random.nextFloat() < DimletConfiguration.randomSpecialTimeChance) {
            // Default
            celestialAngle = null;
            timeSpeed = null;
        } else {
            List<DimletKey> keys = new ArrayList<DimletKey>(DimletObjectMapping.idToCelestialAngle.keySet());
            DimletKey key = keys.get(random.nextInt(keys.size()));
            celestialAngle = DimletObjectMapping.idToCelestialAngle.get(key);
            timeSpeed = DimletObjectMapping.idToSpeed.get(key);
        }
    } else {
        DimletKey key = dimlets.get(random.nextInt(dimlets.size())).getKey();
        celestialAngle = DimletObjectMapping.idToCelestialAngle.get(key);
        timeSpeed = DimletObjectMapping.idToSpeed.get(key);
    }
    dimensionInformation.setCelestialAngle(celestialAngle);
    dimensionInformation.setTimeSpeed(timeSpeed);
}
Also used : ArrayList(java.util.ArrayList) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 27 with DimletKey

use of mcjty.rftools.items.dimlets.DimletKey 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)

Example 28 with DimletKey

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

the class DimletScramblerTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    if (scrambling > 0) {
        scrambling--;
        if (scrambling == 0) {
            DimletKey key = DimletRandomizer.getRandomDimlet(bonus, worldObj.rand);
            InventoryHelper.mergeItemStack(this, false, KnownDimletConfiguration.makeKnownDimlet(key, worldObj), 3, 4, null);
        }
        markDirty();
    } else {
        ItemStack input1 = inventoryHelper.getStackInSlot(0);
        ItemStack input2 = inventoryHelper.getStackInSlot(1);
        ItemStack input3 = inventoryHelper.getStackInSlot(2);
        ItemStack outputStack = inventoryHelper.getStackInSlot(3);
        if (isValidInput(input1, input2, input3) && outputStack == null) {
            startScrambling();
        }
    }
}
Also used : DimletKey(mcjty.rftools.items.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack)

Example 29 with DimletKey

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

the class GuiDimensionEnscriber method extractModifiersForType.

private List<DimletKey> extractModifiersForType(List<DimletKey> modifiers, DimletType type) {
    List<DimletKey> modifiersForType = new ArrayList<DimletKey>();
    int i = 0;
    while (i < modifiers.size()) {
        DimletKey modifier = modifiers.get(i);
        if (type.dimletType.isModifiedBy(modifier.getType())) {
            modifiersForType.add(modifier);
            modifiers.remove(i);
        } else {
            i++;
        }
    }
    return modifiersForType;
}
Also used : ArrayList(java.util.ArrayList) DimletKey(mcjty.rftools.items.dimlets.DimletKey)

Example 30 with DimletKey

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

the class DimletResearcherTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    if (researching > 0) {
        researching--;
        if (researching == 0) {
            DimletKey key = DimletRandomizer.getRandomDimlet(worldObj.rand);
            InventoryHelper.mergeItemStack(this, false, KnownDimletConfiguration.makeKnownDimlet(key, worldObj), 1, 2, null);
        }
        markDirty();
    } else {
        ItemStack inputStack = inventoryHelper.getStackInSlot(0);
        ItemStack outputStack = inventoryHelper.getStackInSlot(1);
        if (inputStack != null && inputStack.getItem() == DimletSetup.unknownDimlet && outputStack == null) {
            startResearching();
        }
    }
}
Also used : DimletKey(mcjty.rftools.items.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DimletKey (mcjty.rftools.items.dimlets.DimletKey)37 ItemStack (net.minecraft.item.ItemStack)9 List (java.util.List)7 ArrayList (java.util.ArrayList)6 DimletEntry (mcjty.rftools.items.dimlets.DimletEntry)5 Block (net.minecraft.block.Block)4 BlockMeta (mcjty.lib.varia.BlockMeta)3 TerrainType (mcjty.rftools.dimension.world.types.TerrainType)3 Slot (net.minecraft.inventory.Slot)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 Map (java.util.Map)2 MobDescriptor (mcjty.rftools.dimension.description.MobDescriptor)2 ControllerType (mcjty.rftools.dimension.world.types.ControllerType)2 FeatureType (mcjty.rftools.dimension.world.types.FeatureType)2 DimletType (mcjty.rftools.items.dimlets.DimletType)2 MerchantRecipe (net.minecraft.village.MerchantRecipe)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Counter (mcjty.lib.varia.Counter)1