Search in sources :

Example 36 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.

the class CmdListEffects method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (EffectType type : information.getEffectTypes()) {
        sender.addChatMessage(new ChatComponentText("    Effect: " + type.toString().substring(7)));
    }
}
Also used : World(net.minecraft.world.World) EffectType(mcjty.rftools.dimension.world.types.EffectType) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 37 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.

the class CmdRecover method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    World world = sender.getEntityWorld();
    ItemStack heldItem = null;
    String playerName = null;
    UUID playerUUID = null;
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        heldItem = player.getHeldItem();
        playerName = player.getDisplayName();
        playerUUID = player.getGameProfile().getId();
    }
    if (heldItem == null || heldItem.getItem() != DimletSetup.realizedDimensionTab) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You need to hold a realized dimension tab in your hand!"));
        return;
    }
    int specifiedDim = -1;
    if (args.length == 2) {
        specifiedDim = fetchInt(sender, args, 1, -1);
    }
    NBTTagCompound tagCompound = heldItem.getTagCompound();
    int dim = tagCompound.getInteger("id");
    if ((!tagCompound.hasKey("id")) || dim == 0 || dim == -1) {
        if (specifiedDim == -1) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension id is missing from the tab!"));
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You can specify a dimension id manually"));
            return;
        } else {
            dim = specifiedDim;
        }
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension information is already present!"));
        return;
    }
    if (DimensionManager.isDimensionRegistered(dim)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension is already registered!"));
        return;
    }
    DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
    String name = tagCompound.getString("name");
    dimensionManager.recoverDimension(world, dim, descriptor, name, playerName, playerUUID);
    sender.addChatMessage(new ChatComponentText("Dimension was succesfully recovered"));
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 38 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.

the class CmdReclaim method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    if (DimensionManager.isDimensionRegistered(dim)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension is still in use! You can't reclaim the id!"));
        return;
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    dimensionManager.reclaimId(dim);
    dimensionManager.save(world);
    sender.addChatMessage(new ChatComponentText("Dimension id " + dim + " reclaimed for future use."));
}
Also used : World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 39 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.

the class CmdSafeDelete method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameter is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    World w = DimensionManager.getWorld(dim);
    if (w != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Dimension is still in use!"));
        return;
    }
    if (!sender.canCommandSenderUseCommand(3, "safedel")) {
        DimensionInformation information = dimensionManager.getDimensionInformation(dim);
        if (information.getOwner() == null) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension has no owner. You cannot delete it!"));
            return;
        }
        if (!(sender instanceof EntityPlayerMP)) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command must be run as a player!"));
            return;
        }
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
        if (!information.getOwner().equals(entityPlayerMP.getGameProfile().getId())) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You are not the owner of this dimension. You cannot delete it!"));
            return;
        }
    }
    TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
    destinations.removeDestinationsInDimension(dim);
    destinations.save(world);
    dimensionManager.removeDimension(dim);
    dimensionManager.reclaimId(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    if (DimletConfiguration.dimensionFolderIsDeletedWithSafeDel) {
        File rootDirectory = DimensionManager.getCurrentSaveRootDirectory();
        try {
            FileUtils.deleteDirectory(new File(rootDirectory.getPath() + File.separator + "DIM" + dim));
            sender.addChatMessage(new ChatComponentText("Dimension deleted and dimension folder succesfully wiped!"));
        } catch (IOException e) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Dimension deleted but dimension folder could not be completely wiped!"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Dimension deleted. Please remove the dimension folder from disk!"));
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IOException(java.io.IOException) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) File(java.io.File) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 40 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.

the class SyncDimensionInfoHelper method syncDimensionManagerFromServer.

public static void syncDimensionManagerFromServer(PacketSyncDimensionInfo message) {
    World world = Minecraft.getMinecraft().theWorld;
    System.out.println("SYNC DIMENSION STUFF: world.isRemote = " + world.isRemote);
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    dimensionManager.syncFromServer(message.getDimensions(), message.getDimensionInformation());
    dimensionManager.save(world);
}
Also used : World(net.minecraft.world.World) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)43 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)29 World (net.minecraft.world.World)27 ChatComponentText (net.minecraft.util.ChatComponentText)16 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)5 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 File (java.io.File)3 Coordinate (mcjty.lib.varia.Coordinate)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 IOException (java.io.IOException)2 Map (java.util.Map)2 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 IMob (net.minecraft.entity.monster.IMob)2 IAnimals (net.minecraft.entity.passive.IAnimals)2