Search in sources :

Example 31 with RfToolsDimensionManager

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

the class DimensionMonitorItem method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
        int id = player.worldObj.provider.dimensionId;
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
        DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
        if (dimensionInformation == null) {
            Logging.message(player, "Not an RFTools dimension!");
        } else {
            String name = dimensionInformation.getName();
            DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
            int power = storage != null ? storage.getEnergyLevel(id) : 0;
            Logging.message(player, EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + EnumChatFormatting.YELLOW + "    Power: " + power + " RF");
            if (player.isSneaking()) {
                Logging.message(player, EnumChatFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
                System.out.println("Description:  = " + dimensionInformation.getDescriptor().getDescriptionString());
            }
        }
        return stack;
    }
    return stack;
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 32 with RfToolsDimensionManager

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

the class FMLEventHandlers method onPlayerLoggedIn.

@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
    Logging.log("SMP: Player logged in: Sync diminfo to clients");
    EntityPlayer player = event.player;
    RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
    manager.syncDimInfoToClients(player.getEntityWorld());
    manager.checkDimletConfig(player);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 33 with RfToolsDimensionManager

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

the class DimensionBuilderTileEntity method createDimensionTick.

private int createDimensionTick(NBTTagCompound tagCompound, int ticksLeft) {
    if (DimletConfiguration.dimensionBuilderNeedsOwner) {
        if (getOwnerUUID() == null) {
            // No valid owner so we don't build the dimension.
            errorMode = ERROR_NOOWNER;
            return ticksLeft;
        }
        if (DimletConfiguration.maxDimensionsPerPlayer >= 0) {
            int tickCost = tagCompound.getInteger("tickCost");
            if (ticksLeft == tickCost || ticksLeft < 5) {
                // Check if we are allow to make the dimension.
                RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(worldObj);
                int cnt = manager.countOwnedDimensions(getOwnerUUID());
                if (cnt >= DimletConfiguration.maxDimensionsPerPlayer) {
                    errorMode = ERROR_TOOMANYDIMENSIONS;
                    return ticksLeft;
                }
            }
        }
    }
    errorMode = OK;
    int createCost = tagCompound.getInteger("rfCreateCost");
    createCost = (int) (createCost * (2.0f - getInfusedFactor()) / 2.0f);
    if (isCreative() || (getEnergyStored(ForgeDirection.DOWN) >= createCost)) {
        if (isCreative()) {
            ticksLeft = 0;
        } else {
            consumeEnergy(createCost);
            ticksLeft--;
            if (random.nextFloat() < getInfusedFactor()) {
                // Randomly reduce another tick if the device is infused.
                ticksLeft--;
                if (ticksLeft < 0) {
                    ticksLeft = 0;
                }
            }
        }
        tagCompound.setInteger("ticksLeft", ticksLeft);
        if (ticksLeft <= 0) {
            RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(worldObj);
            DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
            String name = tagCompound.getString("name");
            int id = manager.createNewDimension(worldObj, descriptor, name, getOwnerName(), getOwnerUUID());
            tagCompound.setInteger("id", id);
        }
    }
    return ticksLeft;
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 34 with RfToolsDimensionManager

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

the class CmdSaveDims method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The directory parameters is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String directory = fetchString(sender, args, 1, null);
    if (!directory.endsWith(File.separator)) {
        directory += File.separator;
    }
    if (!new File(directory).mkdirs()) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed to create directory!"));
        return;
    }
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    for (Integer dim : dimensionManager.getDimensions().keySet()) {
        DimensionInformation information = dimensionManager.getDimensionInformation(dim);
        if (information != null) {
            String filename = directory + "dimension" + 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) File(java.io.File) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 35 with RfToolsDimensionManager

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

the class CmdInfo method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    int dim = 0;
    World world = sender.getEntityWorld();
    if (args.length == 2) {
        dim = fetchInt(sender, args, 1, 0);
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    } else {
        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;
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Dimension ID " + dim));
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Description string " + information.getDescriptor().getDescriptionString()));
    String ownerName = information.getOwnerName();
    if (ownerName != null && !ownerName.isEmpty()) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Owned by: " + ownerName));
    }
    if (sender instanceof EntityPlayer) {
        information.dump((EntityPlayer) sender);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) 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