Search in sources :

Example 26 with DimletKey

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

the class EffectDimletType method constructDimension.

@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
    Set<EffectType> effectTypes = dimensionInformation.getEffectTypes();
    dimlets = DimensionInformation.extractType(DimletType.DIMLET_EFFECT, dimlets);
    if (dimlets.isEmpty()) {
        while (random.nextFloat() < WorldgenConfiguration.randomEffectChance) {
            DimletKey key = DimletRandomizer.getRandomEffect(random);
            if (key != null) {
                EffectType effectType = DimletObjectMapping.getEffect(key);
                if (!effectTypes.contains(effectType)) {
                    dimensionInformation.updateCostFactor(key);
                    effectTypes.add(effectType);
                }
            }
        }
    } else {
        for (Pair<DimletKey, List<DimletKey>> dimletWithModifier : dimlets) {
            DimletKey key = dimletWithModifier.getLeft();
            EffectType effectType = DimletObjectMapping.getEffect(key);
            if (effectType != EffectType.EFFECT_NONE) {
                effectTypes.add(effectType);
            }
        }
    }
}
Also used : List(java.util.List) EffectType(mcjty.rftoolsdim.dimensions.types.EffectType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 27 with DimletKey

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

the class DimensionDescriptor method groupDimletsAndModifiers.

private void groupDimletsAndModifiers(List<DimletKey> descriptors, List<Pair<DimletKey, List<DimletKey>>> dimlets, List<DimletKey> currentModifiers) {
    for (DimletKey key : descriptors) {
        DimletType type = key.getType();
        if (type.dimletType.isModifier()) {
            // Keep the modifier here until we find a dimlet for which it fits.
            currentModifiers.add(key);
        } else {
            List<DimletKey> modifiers = new ArrayList<DimletKey>();
            if (!currentModifiers.isEmpty()) {
                // Check if we collected modifiers that fit with this type.
                List<DimletKey> copy = new ArrayList<DimletKey>(currentModifiers);
                // Iterate over a copy so that we can delete from original list.
                for (DimletKey modifier : copy) {
                    if (type.dimletType.isModifiedBy(modifier.getType())) {
                        modifiers.add(modifier);
                        currentModifiers.remove(modifier);
                    }
                }
            }
            dimlets.add(Pair.of(key, modifiers));
        }
    }
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) ArrayList(java.util.ArrayList) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 28 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 29 with DimletKey

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

the class TimeAbsorberBlock method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    super.addProbeInfo(mode, probeInfo, player, world, blockState, data);
    TileEntity te = world.getTileEntity(data.getPos());
    if (te instanceof TimeAbsorberTileEntity) {
        TimeAbsorberTileEntity timeAbsorberTileEntity = (TimeAbsorberTileEntity) te;
        float angle = timeAbsorberTileEntity.getAngle();
        if (angle >= -0.01f) {
            DimletKey key = TimeAbsorberTileEntity.findBestTimeDimlet(angle);
            String name = KnownDimletConfiguration.getDisplayName(key);
            if (name == null) {
                name = "<unknown>";
            }
            int absorbing = timeAbsorberTileEntity.getAbsorbing();
            int pct = ((DimletConstructionConfiguration.maxTimeAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxTimeAbsorbtion;
            probeInfo.text(TextFormatting.GREEN + "Time: " + name).progress(pct, 100, probeInfo.defaultProgressStyle().suffix("%"));
        } else {
            probeInfo.text(TextFormatting.GREEN + "Give this block a redstone signal");
            probeInfo.text(TextFormatting.GREEN + "at the right time you want to absorb");
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 30 with DimletKey

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

the class TimeAbsorberBlock method getWailaBody.

@SideOnly(Side.CLIENT)
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    super.getWailaBody(itemStack, currenttip, accessor, config);
    TileEntity te = accessor.getTileEntity();
    if (te instanceof TimeAbsorberTileEntity) {
        TimeAbsorberTileEntity timeAbsorberTileEntity = (TimeAbsorberTileEntity) te;
        float angle = timeAbsorberTileEntity.getAngle();
        if (angle >= -0.01f) {
            DimletKey key = TimeAbsorberTileEntity.findBestTimeDimlet(angle);
            String name = KnownDimletConfiguration.getDisplayName(key);
            if (name == null) {
                name = "<unknown>";
            }
            int absorbing = timeAbsorberTileEntity.getAbsorbing();
            int pct = ((DimletConstructionConfiguration.maxTimeAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxTimeAbsorbtion;
            currenttip.add(TextFormatting.GREEN + "Dimlet: " + name + " (" + angle + ", " + pct + "%)");
        } else {
            currenttip.add(TextFormatting.GREEN + "Give this block a redstone signal");
            currenttip.add(TextFormatting.GREEN + "at the right time you want to absorb");
        }
    }
    return currenttip;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)61 ArrayList (java.util.ArrayList)19 List (java.util.List)15 Settings (mcjty.rftoolsdim.config.Settings)14 ItemStack (net.minecraft.item.ItemStack)14 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)13 Block (net.minecraft.block.Block)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 IBlockState (net.minecraft.block.state.IBlockState)6 TerrainType (mcjty.rftoolsdim.dimensions.types.TerrainType)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)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 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Pair (org.apache.commons.lang3.tuple.Pair)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Argument (mcjty.lib.network.Argument)2