Search in sources :

Example 36 with DimletKey

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

the class DimletWorkbenchTileEntity method startExtracting.

private void startExtracting() {
    if (extracting > 0) {
        // Already extracting
        return;
    }
    ItemStack stack = inventoryHelper.getStackInSlot(DimletWorkbenchContainer.SLOT_INPUT);
    if (!stack.isEmpty()) {
        if (ModItems.knownDimletItem.equals(stack.getItem())) {
            DimletKey key = KnownDimletConfiguration.getDimletKey(stack);
            Settings settings = KnownDimletConfiguration.getSettings(key);
            if (settings != null && settings.isDimlet()) {
                if (!KnownDimletConfiguration.isCraftable(key)) {
                    extracting = 64;
                    idToExtract = key;
                    inventoryHelper.decrStackSize(DimletWorkbenchContainer.SLOT_INPUT, 1);
                    markDirty();
                }
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) Settings(mcjty.rftoolsdim.config.Settings)

Example 37 with DimletKey

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

the class GuiDimletWorkbench method suggestParts.

private void suggestParts() {
    int selected = itemList.getSelected();
    if (selected == -1) {
        return;
    }
    Widget widget = itemList.getChild(selected);
    Object userObject = widget.getUserObject();
    if (userObject instanceof DimletKey) {
        DimletKey key = (DimletKey) userObject;
        sendServerCommand(RFToolsDimMessages.INSTANCE, DimletWorkbenchTileEntity.CMD_SUGGESTPARTS, new Argument("type", key.getType().dimletType.getName()), new Argument("id", key.getId()));
    }
}
Also used : Argument(mcjty.lib.network.Argument) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey)

Example 38 with DimletKey

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

the class CmdCreateDimension method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (!(sender instanceof EntityPlayer)) {
        sender.sendMessage(new TextComponentString(TextFormatting.RED + "You must be a player to use this command!"));
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    if (args.length < 2) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "The name parameter is missing!"), false);
        return;
    } else if (args.length > 4) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Too many parameters!"), false);
        return;
    }
    String name = fetchString(player, args, 1, "");
    String terrainName = fetchString(player, args, 2, "Void");
    List<DimletKey> descriptors;
    if (terrainName.charAt(0) == '@') {
        descriptors = DimensionDescriptor.parseDescriptionString(terrainName);
        for (DimletKey key : descriptors) {
            if (key.getType() == null) {
                player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Invalid descriptor!"), false);
                return;
            }
        }
    } else {
        TerrainType terrainType = TerrainType.getTerrainById(terrainName);
        if (terrainType == null) {
            player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Unknown terrain type!"), false);
            return;
        }
        descriptors = new ArrayList<>(1);
        descriptors.add(new DimletKey(DimletType.DIMLET_TERRAIN, terrainType.getId()));
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
    DimensionDescriptor descriptor = new DimensionDescriptor(descriptors, fetchInt(player, args, 3, 0));
    Integer dim = dimensionManager.getDimensionID(descriptor);
    if (dim != null) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "A dimension with that descriptor already exists: " + dim), false);
        return;
    }
    dim = dimensionManager.createNewDimension(player.getEntityWorld(), descriptor, name, player.getName(), player.getPersistentID());
    player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "Created dimension: " + dim), false);
    dimensionManager.save(player.getEntityWorld());
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 39 with DimletKey

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

the class CmdCreateDimlet method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (!(sender instanceof EntityPlayer)) {
        sender.sendMessage(new TextComponentString(TextFormatting.RED + "This command only works as a player!"));
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    if (args.length != 3) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Bad parameters!"), false);
        return;
    }
    String typeString = fetchString(player, args, 1, "material");
    String name = fetchString(player, args, 2, "");
    DimletType type = DimletType.getTypeByName(typeString);
    if (type == null) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Bad type!"), false);
        return;
    }
    ItemStack dimlet = KnownDimletConfiguration.getDimletStack(new DimletKey(type, name));
    InventoryHelper.mergeItemStack(player.inventory, false, dimlet, 0, 35, null);
}
Also used : DimletType(mcjty.rftoolsdim.dimensions.dimlets.types.DimletType) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 40 with DimletKey

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

the class DimensionInformation method getMaterialAndFluidModifiers.

public static void getMaterialAndFluidModifiers(List<DimletKey> modifiers, List<IBlockState> blocks, List<Block> fluids) {
    if (modifiers != null) {
        for (DimletKey modifier : modifiers) {
            if (modifier.getType() == DimletType.DIMLET_MATERIAL) {
                IBlockState block = DimletObjectMapping.getBlock(modifier);
                blocks.add(block);
            } else if (modifier.getType() == DimletType.DIMLET_LIQUID) {
                Block fluid = DimletObjectMapping.getFluid(modifier);
                fluids.add(fluid);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) 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