Search in sources :

Example 36 with RfToolsDimensionManager

use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.

the class CmdListDimensions method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    WorldServer[] worlds = DimensionManager.getWorlds();
    for (WorldServer world : worlds) {
        int id = world.provider.getDimensionId();
        String dimName = world.provider.getDimensionName();
        sender.addChatMessage(new ChatComponentText("    Loaded: id:" + id + ", " + dimName));
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(sender.getEntityWorld());
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
        int id = me.getKey();
        DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
        String dimName = dimensionInformation.getName();
        int energy = dimensionStorage.getEnergyLevel(id);
        String ownerName = dimensionInformation.getOwnerName();
        if (ownerName != null && !ownerName.isEmpty()) {
            sender.addChatMessage(new ChatComponentText("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")"));
        } else {
            sender.addChatMessage(new ChatComponentText("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ")"));
        }
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) WorldServer(net.minecraft.world.WorldServer) ChatComponentText(net.minecraft.util.ChatComponentText) Map(java.util.Map) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 37 with RfToolsDimensionManager

use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.

the class DimensionEnscriberTileEntity method createRealizedTab.

/**
 * Create a realized dimension tab by taking a map of ids per type and storing
 * that in the NBT of the realized dimension tab.
 */
public static ItemStack createRealizedTab(DimensionDescriptor descriptor, World world) {
    ItemStack realizedTab = new ItemStack(ModItems.realizedDimensionTabItem, 1, 0);
    NBTTagCompound tagCompound = new NBTTagCompound();
    descriptor.writeToNBT(tagCompound);
    // Check if the dimension already exists and if so set the progress to 100%.
    RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
    Integer id = manager.getDimensionID(descriptor);
    if (id != null) {
        // The dimension was already created.
        tagCompound.setInteger("ticksLeft", 0);
        tagCompound.setInteger("id", id);
    }
    realizedTab.setTagCompound(tagCompound);
    return realizedTab;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 38 with RfToolsDimensionManager

use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.

the class ActivityProbeBlock method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    super.breakBlock(world, pos, state);
    if (!world.isRemote) {
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimensionId());
        if (information != null) {
            information.removeProbe();
        }
        dimensionManager.save(world);
    }
}
Also used : DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 39 with RfToolsDimensionManager

use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.

the class CmdSetPower method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int rf = fetchInt(sender, args, 1, PowerConfiguration.MAX_DIMENSION_POWER);
    World world = sender.getEntityWorld();
    int dim = world.provider.getDimensionId();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
    storage.setEnergyLevel(dim, rf);
    storage.save(world);
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 40 with RfToolsDimensionManager

use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.

the class CmdCreateDimension method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The name and terrain parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String name = fetchString(sender, args, 1, "");
    String terrainName = fetchString(sender, args, 2, "Void");
    TerrainType terrainType = TerrainType.getTerrainById(terrainName);
    if (terrainType == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Unknown terrain type!"));
        return;
    }
    if (!(sender instanceof EntityPlayer)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be a player to use this command!"));
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
    List<DimletKey> descriptors = new ArrayList<>();
    descriptors.add(new DimletKey(DimletType.DIMLET_TERRAIN, terrainType.getId()));
    DimensionDescriptor descriptor = new DimensionDescriptor(descriptors, 0);
    int dim = 0;
    try {
        dim = dimensionManager.createNewDimension(sender.getEntityWorld(), descriptor, name, player.getDisplayName().toString(), player.getPersistentID());
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Created dimension: " + dim));
    dimensionManager.save(sender.getEntityWorld());
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TerrainType(mcjty.rftoolsdim.dimensions.types.TerrainType) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Aggregations

RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)41 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)29 World (net.minecraft.world.World)13 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)11 ItemStack (net.minecraft.item.ItemStack)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 ChatComponentText (net.minecraft.util.ChatComponentText)7 IBlockState (net.minecraft.block.state.IBlockState)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)3 Block (net.minecraft.block.Block)3 BlockPos (net.minecraft.util.BlockPos)3 File (java.io.File)2 IOException (java.io.IOException)2 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)2 IMob (net.minecraft.entity.monster.IMob)2