Search in sources :

Example 31 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class DimensionEnscriberTileEntity method convertToDimensionDescriptor.

/**
 * Convert the dimlets in the inventory to a dimension descriptor.
 */
private DimensionDescriptor convertToDimensionDescriptor(EntityPlayer player) {
    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 (!stack.isEmpty()) {
            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, ItemStack.EMPTY);
            } else {
                Logging.warn(player, "Dimlet " + key.getType().dimletType.getName() + "." + key.getId() + " was not included in the tab because it is blacklisted");
            }
        }
    }
    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 32 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class KnownDimlet method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag showExtended) {
    super.addInformation(itemStack, player, list, showExtended);
    DimletKey key = KnownDimletConfiguration.getDimletKey(itemStack);
    Settings settings = KnownDimletConfiguration.getSettings(key);
    if (showExtended.isAdvanced()) {
        list.add(TextFormatting.GOLD + "Key: " + key.getId());
    }
    if (settings == null) {
        list.add(TextFormatting.WHITE + "Dimlet " + key.getType().dimletType.getName() + "." + key.getId());
        list.add(TextFormatting.RED + "This dimlet is blacklisted!");
        return;
    }
    list.add(TextFormatting.BLUE + "Rarity: " + settings.getRarity() + (KnownDimletConfiguration.isCraftable(key) ? " (craftable)" : ""));
    list.add(TextFormatting.YELLOW + "Create cost: " + settings.getCreateCost() + " RF/tick");
    int maintainCost = settings.getMaintainCost();
    if (maintainCost < 0) {
        list.add(TextFormatting.YELLOW + "Maintain cost: " + maintainCost + "% RF/tick");
    } else {
        list.add(TextFormatting.YELLOW + "Maintain cost: " + maintainCost + " RF/tick");
    }
    list.add(TextFormatting.YELLOW + "Tick cost: " + settings.getTickCost() + " ticks");
    if (KnownDimletConfiguration.isSeedDimlet(key)) {
        NBTTagCompound tagCompound = itemStack.getTagCompound();
        if (tagCompound != null && tagCompound.getLong("forcedSeed") != 0) {
            long forcedSeed = tagCompound.getLong("forcedSeed");
            boolean locked = tagCompound.getBoolean("locked");
            list.add(TextFormatting.BLUE + "Forced seed: " + forcedSeed + (locked ? " [LOCKED]" : ""));
        } else {
            list.add(TextFormatting.BLUE + "Right click to copy seed from dimension.");
            list.add(TextFormatting.BLUE + "Shift-Right click to lock copied seed.");
        }
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        for (String info : key.getType().dimletType.getInformation()) {
            list.add(TextFormatting.WHITE + info);
        }
    // @todo
    // List<String> extra = KnownDimletConfiguration.idToExtraInformation.get(entry.getKey());
    // if (extra != null) {
    // for (String info : extra) {
    // list.add(TextFormatting.YELLOW + info);
    // }
    // }
    } else {
        list.add(TextFormatting.WHITE + RFToolsDim.SHIFT_MESSAGE);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 33 with Settings

use of mcjty.rftoolsdim.config.Settings in project RFToolsDimensions by McJty.

the class PacketSyncRules method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    rules = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        Filter filter = new Filter(buf);
        Settings settings = new Settings(buf);
        rules.add(Pair.of(filter, settings));
    }
}
Also used : Filter(mcjty.rftoolsdim.config.Filter) Settings(mcjty.rftoolsdim.config.Settings)

Aggregations

Settings (mcjty.rftoolsdim.config.Settings)33 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)16 ItemStack (net.minecraft.item.ItemStack)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 Filter (mcjty.rftoolsdim.config.Filter)3 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)3 IBlockState (net.minecraft.block.state.IBlockState)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 BlockLiquid (net.minecraft.block.BlockLiquid)2 IProperty (net.minecraft.block.properties.IProperty)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 IFilterBuilder (mcjty.rftoolsdim.api.dimlet.IFilterBuilder)1 ISettingsBuilder (mcjty.rftoolsdim.api.dimlet.ISettingsBuilder)1