Search in sources :

Example 66 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class TeleportToColony method teleportPlayer.

/**
 * Method used to teleport the player.
 *
 * @param colID            the senders colony ID.
 * @param playerToTeleport the player which shall be teleported.
 */
private static void teleportPlayer(final EntityPlayer playerToTeleport, final int colID, final ICommandSender sender) {
    final Colony colony = ColonyManager.getColony(colID);
    final BuildingTownHall townHall = colony.getBuildingManager().getTownHall();
    if (townHall == null) {
        sender.sendMessage(new TextComponentString(NO_TOWNHALL));
        return;
    }
    playerToTeleport.sendMessage(new TextComponentString("We got places to go, kid..."));
    final BlockPos position = townHall.getLocation();
    final int dimension = playerToTeleport.getEntityWorld().provider.getDimension();
    final int colonyDimension = townHall.getColony().getDimension();
    if (colID < MIN_COLONY_ID) {
        playerToTeleport.sendMessage(new TextComponentString(CANT_FIND_COLONY));
        return;
    }
    final EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
    if (dimension != colonyDimension) {
        playerToTeleport.sendMessage(new TextComponentString("Buckle up buttercup, this ain't no joy ride!!!"));
        final MinecraftServer server = sender.getEntityWorld().getMinecraftServer();
        final WorldServer worldServer = server.getWorld(colonyDimension);
        // Vanilla does that as well.
        entityPlayerMP.connection.sendPacket(new SPacketEffect(SOUND_TYPE, BlockPos.ORIGIN, 0, false));
        entityPlayerMP.addExperience(0);
        entityPlayerMP.setPlayerHealthUpdated();
        playerToTeleport.sendMessage(new TextComponentString("Hold onto your pants, we're going Inter-Dimensional!"));
        worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, colonyDimension, new Teleporter(worldServer));
        if (dimension == 1) {
            worldServer.spawnEntity(playerToTeleport);
            worldServer.updateEntityWithOptionalForce(playerToTeleport, false);
        }
    }
    entityPlayerMP.connection.setPlayerLocation(position.getX(), position.getY() + 2.0, position.getZ(), entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch);
}
Also used : SPacketEffect(net.minecraft.network.play.server.SPacketEffect) Teleporter(net.minecraft.world.Teleporter) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) BuildingTownHall(com.minecolonies.coremod.colony.buildings.BuildingTownHall) TextComponentString(net.minecraft.util.text.TextComponentString) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 67 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class ShowColonyInfoCommand method execute.

@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    int colonyId = getIthArgument(args, 0, -1);
    IColony tempColony = ColonyManager.getColony(colonyId);
    if (colonyId == -1 && args.length >= 1) {
        final GameProfile playerProfile = server.getPlayerProfileCache().getGameProfileForUsername(args[0]);
        if (playerProfile != null) {
            tempColony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), playerProfile.getId());
        }
    }
    if (sender.getCommandSenderEntity() != null) {
        final UUID mayorID = sender.getCommandSenderEntity().getUniqueID();
        if (tempColony == null) {
            tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
        }
        if (tempColony != null) {
            colonyId = tempColony.getID();
        }
        final EntityPlayer player = (EntityPlayer) sender;
        if (!canPlayerUseCommand(player, SHOWCOLONYINFO, colonyId)) {
            sender.getCommandSenderEntity().sendMessage(new TextComponentString(NOT_PERMITTED));
            return;
        }
    }
    if (tempColony == null) {
        if (colonyId == -1 && args.length != 0) {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, args[0])));
        } else {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_ID_FOUND_MESSAGE, colonyId)));
        }
        return;
    }
    final Colony colony = ColonyManager.getColony(tempColony.getID());
    if (colony == null) {
        if (colonyId == -1 && args.length != 0) {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, args[0])));
        } else {
            sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_ID_FOUND_MESSAGE, colonyId)));
        }
        return;
    }
    executeShared(server, sender, colony);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) IColony(com.minecolonies.api.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.api.colony.IColony) UUID(java.util.UUID) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 68 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class ShowColonyInfoCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final Colony colony) throws CommandException {
    final BlockPos position = colony.getCenter();
    sender.sendMessage(new TextComponentString(ID_TEXT + colony.getID() + NAME_TEXT + colony.getName()));
    final String mayor = colony.getPermissions().getOwnerName();
    sender.sendMessage(new TextComponentString(MAYOR_TEXT + mayor));
    sender.sendMessage(new TextComponentString(CITIZENS + colony.getCitizenManager().getCitizens().size() + "/" + colony.getCitizenManager().getMaxCitizens()));
    sender.sendMessage(new TextComponentString(COORDINATES_TEXT + String.format(COORDINATES_XYZ, position.getX(), position.getY(), position.getZ())));
    sender.sendMessage(new TextComponentString(String.format(LAST_CONTACT_TEXT, colony.getLastContactInHours())));
    sender.sendMessage(new TextComponentString(IS_DELETABLE + !colony.canBeAutoDeleted()));
    if (!colony.isCanHaveBarbEvents()) {
        sender.sendMessage(new TextComponentString(CANNOT_BE_RAIDED));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 69 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class RSResetCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final Colony colony) throws CommandException {
    final Entity senderEntity = sender.getCommandSenderEntity();
    if (senderEntity instanceof EntityPlayer) {
        final EntityPlayer player = (EntityPlayer) sender;
        if (!canPlayerUseCommand(player, RSRESET, colony.getID())) {
            senderEntity.sendMessage(new TextComponentString(NOT_PERMITTED));
            return;
        }
    }
    colony.getRequestManager().reset();
    sender.sendMessage(new TextComponentString(String.format(SUCCESS_MESSAGE, colony.getID())));
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 70 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.

the class RandomTeleportCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, final String playerName) throws CommandException {
    if (SPAWN_NO_TP >= LOWER_BOUNDS) {
        sender.sendMessage(new TextComponentString("Please have an admin raise the maxDistanceFromWorldSpawn number in config."));
        return;
    }
    if (!canCommandSenderUseCommand(RTP) || sender.getEntityWorld().provider.getDimension() != 0) {
        sender.sendMessage(new TextComponentString("Not happenin bro!!, ask an OP to TP you."));
        return;
    }
    EntityPlayer playerToTeleport = null;
    if (sender instanceof EntityPlayer) {
        playerToTeleport = (EntityPlayer) sender;
    }
    // If the arguments aren't empty, the sender probably wants to teleport another player.
    if ((null != playerName) && isPlayerOpped(sender)) {
        final World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
        playerToTeleport = ServerUtils.getPlayerFromUUID(FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getGameProfileForUsername(playerName).getId(), world);
        sender.sendMessage(new TextComponentString("TPing Player: " + playerToTeleport.getName()));
    }
    if (playerToTeleport == null) {
        sender.sendMessage(new TextComponentString(CANT_FIND_PLAYER));
        return;
    }
    teleportPlayer(sender, playerToTeleport);
    // .fallDistance is used to cancel out fall damage  basically if you have -5 it will reduce fall damage by 2.5 hearts
    playerToTeleport.fallDistance = FALL_DISTANCE;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13