Search in sources :

Example 31 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class TimeAbsorberBlock method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    NBTTagCompound tagCompound = itemStack.getTagCompound();
    if (tagCompound != null) {
        if (tagCompound.hasKey("angle") && tagCompound.getFloat("angle") > -0.001f) {
            float angle = tagCompound.getFloat("angle");
            DimletKey key = TimeAbsorberTileEntity.findBestTimeDimlet(angle);
            String name = KnownDimletConfiguration.getDisplayName(key);
            if (name == null) {
                name = "<unknown>";
            }
            list.add(TextFormatting.GREEN + "Dimlet: " + name + " (" + angle + ")");
            int absorbing = tagCompound.getInteger("absorbing");
            int pct = ((DimletConstructionConfiguration.maxTimeAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxTimeAbsorbtion;
            list.add(TextFormatting.GREEN + "Absorbed: " + pct + "%");
            int timeout = tagCompound.getInteger("registerTimeout");
            list.add(TextFormatting.GREEN + "Timeout: " + timeout);
        }
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        list.add(TextFormatting.WHITE + "Place this block outside and give it a redstone");
        list.add(TextFormatting.WHITE + "signal around the time that you want to absorb.");
        list.add(TextFormatting.WHITE + "You can use the end result in the Dimlet Workbench.");
    } else {
        list.add(TextFormatting.WHITE + RFToolsDim.SHIFT_MESSAGE);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 32 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimensionEnscriberTileEntity method convertToDimensionDescriptor.

/**
     * Convert the dimlets in the inventory to a dimension descriptor.
     */
private DimensionDescriptor convertToDimensionDescriptor() {
    List<DimletKey> descriptors = new ArrayList<>();
    long forcedSeed = 0;
    for (int i = 0; i < DimensionEnscriberContainer.SIZE_DIMLETS; i++) {
        ItemStack stack = inventoryHelper.getStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS);
        if (ItemStackTools.isValid(stack)) {
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            Settings settings = KnownDimletConfiguration.getSettings(key);
            if (settings != null) {
                // Make sure the dimlet is not blacklisted.
                descriptors.add(key);
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
                    forcedSeed = tagCompound.getLong("forcedSeed");
                }
            }
        }
        inventoryHelper.setStackInSlot(i + DimensionEnscriberContainer.SLOT_DIMLETS, ItemStackTools.getEmptyStack());
    }
    return new DimensionDescriptor(descriptors, forcedSeed);
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ItemStack(net.minecraft.item.ItemStack) Settings(mcjty.rftoolsdim.config.Settings)

Example 33 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class GuiEssencePainter method extractModifiersForType.

private List<DimletKey> extractModifiersForType(List<DimletKey> modifiers, DimletType type) {
    List<DimletKey> modifiersForType = new ArrayList<>();
    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.rftoolsdim.dimensions.dimlets.DimletKey)

Example 34 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimletWorkbenchTileEntity method checkDimletCrafting.

private boolean checkDimletCrafting() {
    ItemStack stackBase = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_BASE);
    if (stackBase.isEmpty()) {
        return false;
    }
    ItemStack stackController = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_CONTROLLER);
    if (stackController.isEmpty()) {
        return false;
    }
    ItemStack stackTypeController = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_TYPE_CONTROLLER);
    if (stackTypeController.isEmpty()) {
        return false;
    }
    ItemStack stackMemory = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_MEMORY);
    if (stackMemory.isEmpty()) {
        return false;
    }
    ItemStack stackEnergy = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_ENERGY);
    if (stackEnergy.isEmpty()) {
        return false;
    }
    ItemStack stackEssence = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_ESSENCE);
    if (stackEssence.isEmpty()) {
        return false;
    }
    DimletType type = DimletType.values()[stackTypeController.getItemDamage()];
    IDimletType itype = type.dimletType;
    DimletKey key = itype.attemptDimletCrafting(stackController, stackMemory, stackEnergy, stackEssence);
    if (key != null) {
        inventoryHelper.setInventorySlotContents(1, DimletWorkbenchContainer.SLOT_OUTPUT, KnownDimletConfiguration.getDimletStack(key));
        return true;
    }
    return false;
}
Also used : IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType) DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 35 with DimletKey

use of mcjty.rftoolsdim.dimensions.dimlets.DimletKey in project RFToolsDimensions by McJty.

the class DimletWorkbenchTileEntity method readRestorableFromNBT.

@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
    super.readRestorableFromNBT(tagCompound);
    readBufferFromNBT(tagCompound, inventoryHelper);
    extracting = tagCompound.getInteger("extracting");
    extractMode = tagCompound.getBoolean("extractMode");
    idToExtract = null;
    if (tagCompound.hasKey("extKtype")) {
        DimletType type = DimletType.getTypeByOpcode(tagCompound.getString("extKtype"));
        idToExtract = new DimletKey(type, tagCompound.getString("extDkey"));
    } else {
        idToExtract = null;
    }
}
Also used : IDimletType(mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType) DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Aggregations

DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)66 ArrayList (java.util.ArrayList)21 Settings (mcjty.rftoolsdim.config.Settings)16 ItemStack (net.minecraft.item.ItemStack)16 List (java.util.List)15 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)14 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 Block (net.minecraft.block.Block)10 IBlockState (net.minecraft.block.state.IBlockState)6 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 HashMap (java.util.HashMap)3 IDimletType (mcjty.rftoolsdim.dimensions.dimlets.types.IDimletType)3 ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)3 FeatureType (mcjty.rftoolsdim.dimensions.types.FeatureType)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Pair (org.apache.commons.lang3.tuple.Pair)3 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2