Search in sources :

Example 1 with DimensionInformation

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

the class DimensionEnscriberTileEntity method setName.

private void setName(String name) {
    ItemStack realizedTab = inventoryHelper.getStackInSlot(DimensionEnscriberContainer.SLOT_TAB);
    if (realizedTab != null) {
        NBTTagCompound tagCompound = realizedTab.getTagCompound();
        if (tagCompound == null) {
            tagCompound = new NBTTagCompound();
            realizedTab.setTagCompound(tagCompound);
        }
        tagCompound.setString("name", name);
        if (tagCompound.hasKey("id")) {
            Integer id = tagCompound.getInteger("id");
            RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (information != null) {
                information.setName(name);
                dimensionManager.save(worldObj);
            }
        }
        markDirty();
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 2 with DimensionInformation

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

the class ActivityProbeBlock method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    super.breakBlock(world, x, y, z, block, meta);
    if (!world.isRemote) {
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
        if (information != null) {
            information.removeProbe();
        }
        dimensionManager.save(world);
    }
}
Also used : DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 3 with DimensionInformation

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

the class TeleportDestinations method getValidDestinations.

// Server side only
public Collection<TeleportDestinationClientInfo> getValidDestinations(World worldObj, String playerName) {
    PlayerExtendedProperties properties = null;
    if (playerName != null) {
        List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
        for (Object player : list) {
            EntityPlayerMP entityplayermp = (EntityPlayerMP) player;
            if (playerName.equals(entityplayermp.getDisplayName())) {
                properties = PlayerExtendedProperties.getProperties(entityplayermp);
                break;
            }
        }
    }
    List<TeleportDestinationClientInfo> result = new ArrayList<TeleportDestinationClientInfo>();
    for (TeleportDestination destination : destinations.values()) {
        TeleportDestinationClientInfo destinationClientInfo = new TeleportDestinationClientInfo(destination);
        Coordinate c = destination.getCoordinate();
        World world = DimensionManager.getWorld(destination.getDimension());
        String dimName = null;
        if (world != null) {
            dimName = DimensionManager.getProvider(destination.getDimension()).getDimensionName();
        }
        DimensionInformation information = RfToolsDimensionManager.getDimensionManager(worldObj).getDimensionInformation(destination.getDimension());
        if (information != null) {
            dimName = information.getName();
        }
        if (dimName == null || dimName.trim().isEmpty()) {
            dimName = "Id " + destination.getDimension();
        } else {
            dimName = dimName + " (" + destination.getDimension() + ")";
        }
        destinationClientInfo.setDimensionName(dimName);
        if (world != null) {
            TileEntity te = world.getTileEntity(c.getX(), c.getY(), c.getZ());
            if (te instanceof MatterReceiverTileEntity) {
                MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) te;
                if (playerName != null && !matterReceiverTileEntity.checkAccess(playerName)) {
                    // No access.
                    continue;
                }
            }
        }
        if (properties != null) {
            destinationClientInfo.setFavorite(properties.getFavoriteDestinationsProperties().isDestinationFavorite(new GlobalCoordinate(c, destination.getDimension())));
        }
        result.add(destinationClientInfo);
    }
    Collections.sort(result);
    return result;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) PlayerExtendedProperties(mcjty.rftools.playerprops.PlayerExtendedProperties) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagList(net.minecraft.nbt.NBTTagList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) DimensionInformation(mcjty.rftools.dimension.DimensionInformation)

Example 4 with DimensionInformation

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

the class CmdDelEffect method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Several parameters are missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    String effectName = fetchString(sender, args, 1, "");
    effectName = "EFFECT_" + effectName.toUpperCase();
    EffectType type = null;
    try {
        type = EffectType.valueOf(effectName);
    } catch (IllegalArgumentException e) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bad effect name!"));
        return;
    }
    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;
    }
    if (!information.getEffectTypes().contains(type)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This effect is not active!"));
        return;
    }
    information.getEffectTypes().remove(type);
    dimensionManager.save(world);
}
Also used : EffectType(mcjty.rftools.dimension.world.types.EffectType) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 5 with DimensionInformation

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

the class CmdLoadDim 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.loadFromJson(filename);
    if (error != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
    } else {
        dimensionManager.save(world);
    }
}
Also used : World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

DimensionInformation (mcjty.rftools.dimension.DimensionInformation)35 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)29 World (net.minecraft.world.World)19 ChatComponentText (net.minecraft.util.ChatComponentText)13 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 IOException (java.io.IOException)4 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)4 ItemStack (net.minecraft.item.ItemStack)4 File (java.io.File)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 Map (java.util.Map)2 Coordinate (mcjty.lib.varia.Coordinate)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 PacketGetDimensionEnergy (mcjty.rftools.dimension.network.PacketGetDimensionEnergy)2 IMob (net.minecraft.entity.monster.IMob)2