Search in sources :

Example 16 with RfToolsDimensionManager

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

the class CmdSetOwner method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and player parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String playerName = fetchString(sender, args, 2, null);
    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;
    }
    for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) o;
        if (playerName.equals(entityPlayerMP.getDisplayName())) {
            DimensionInformation information = dimensionManager.getDimensionInformation(dim);
            information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Owner of dimension changed!"));
            dimensionManager.save(world);
            return;
        }
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not find player!"));
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 17 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools 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, DimletConfiguration.MAX_DIMENSION_POWER);
    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;
    }
    DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
    storage.setEnergyLevel(dim, rf);
    storage.save(world);
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 18 with RfToolsDimensionManager

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

the class CmdSaveDim method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and filename parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String filename = fetchString(sender, args, 2, null);
    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;
    }
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    String error = information.buildJson(filename);
    if (error != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
    }
}
Also used : World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 19 with RfToolsDimensionManager

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

the class PacketGetAllReceivers method addRfToolsDimensions.

private void addRfToolsDimensions(World world, List<TeleportDestinationClientInfo> destinationList) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
        int id = me.getKey();
        TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id);
        destination.setName("RfTools Dim: " + id);
        TeleportDestinationClientInfo teleportDestinationClientInfo = new TeleportDestinationClientInfo(destination);
        destinationList.add(teleportDestinationClientInfo);
    }
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) Coordinate(mcjty.lib.varia.Coordinate) TeleportDestinationClientInfo(mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo) Map(java.util.Map) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination)

Example 20 with RfToolsDimensionManager

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

the class ForgeEventHandlers method onAttackEntityEvent.

@SubscribeEvent
public void onAttackEntityEvent(AttackEntityEvent event) {
    World world = event.entityPlayer.getEntityWorld();
    int id = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionInformation(id) != null) {
        // RFTools dimension.
        DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
        int energy = storage.getEnergyLevel(id);
        if (energy <= 0) {
            event.setCanceled(true);
        }
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

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