Search in sources :

Example 16 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project OpenModularTurrets by OpenModularTurretsTeam.

the class BlockExpander method clOnBlockActivated.

@Override
protected boolean clOnBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (hand.equals(EnumHand.OFF_HAND))
        return true;
    Expander expander = (Expander) worldIn.getTileEntity(pos);
    if (expander == null) {
        return true;
    }
    TurretBase base = expander.getBase();
    if (base == null) {
        worldIn.destroyBlock(pos, true);
        return true;
    }
    TrustedPlayer trustedPlayer = PlayerUtil.getTrustedPlayer(playerIn, base);
    if (trustedPlayer != null) {
        if (base.getTrustedPlayer(playerIn.getUniqueID()).canOpenGUI && state.getValue(META) < 5) {
            playerIn.openGui(OpenModularTurrets.instance, 7, worldIn, pos.getX(), pos.getY(), pos.getZ());
            return true;
        }
    }
    if (PlayerUtil.isPlayerOwner(playerIn, base)) {
        if (playerIn.isSneaking() && playerIn.getHeldItemMainhand() == null) {
            worldIn.destroyBlock(pos, true);
        } else if (state.getValue(META) < 5) {
            playerIn.openGui(OpenModularTurrets.instance, 7, worldIn, pos.getX(), pos.getY(), pos.getZ());
        } else {
            return true;
        }
    } else {
        addChatMessage(playerIn, new TextComponentString(safeLocalize("status.ownership")));
    }
    return true;
}
Also used : TrustedPlayer(omtteam.omlib.util.TrustedPlayer) ItemBlockExpander(omtteam.openmodularturrets.items.blocks.ItemBlockExpander) Expander(omtteam.openmodularturrets.tileentity.Expander) TurretBase(omtteam.openmodularturrets.tileentity.TurretBase) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 17 with TextComponentString

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

the class AbstractCitizensCommands method execute.

@NotNull
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
    if (args.length == 0) {
        sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    boolean firstArgumentColonyId = true;
    int colonyId = -1;
    if (args.length >= 2) {
        colonyId = getIthArgument(args, 0, -1);
        if (colonyId == -1) {
            firstArgumentColonyId = false;
        }
    }
    final Colony colony;
    if (sender instanceof EntityPlayer && colonyId == -1) {
        final IColony tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), (EntityPlayer) sender);
        if (tempColony != null) {
            colonyId = tempColony.getID();
            firstArgumentColonyId = false;
        }
    }
    colony = ColonyManager.getColony(colonyId);
    if (colony == null) {
        sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    if (sender instanceof EntityPlayer) {
        final EntityPlayer player = (EntityPlayer) sender;
        if (!canPlayerUseCommand(player, getCommand(), colonyId)) {
            sender.getCommandSenderEntity().sendMessage(new TextComponentString(NOT_PERMITTED));
            return;
        }
    }
    final int citizenId = getValidCitizenId(colony, firstArgumentColonyId, args);
    if (citizenId == -1 || colony.getCitizen(citizenId) == null) {
        sender.getCommandSenderEntity().sendMessage(new TextComponentString(NO_ARGUMENTS));
        return;
    }
    executeSpecializedCode(server, sender, colony, citizenId);
}
Also used : Colony(com.minecolonies.coremod.colony.Colony) IColony(com.minecolonies.coremod.colony.IColony) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.coremod.colony.IColony) TextComponentString(net.minecraft.util.text.TextComponentString) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with TextComponentString

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

the class SchematicSaveMessage method onMessage.

@Nullable
@Override
public IMessage onMessage(@NotNull final SchematicSaveMessage message, final MessageContext ctx) {
    if (!MineColonies.isClient() && !Configurations.allowPlayerSchematics) {
        Log.getLogger().info("SchematicSaveMessage: custom schematic is not allowed on this server.");
        if (ctx.side.isServer()) {
            ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("The server does not allow custom schematic!"));
        }
        return null;
    }
    final boolean schematicSent;
    if (message.data == null) {
        Log.getLogger().error("Received empty schematic file");
        schematicSent = false;
    } else {
        schematicSent = Structures.handleSaveSchematicMessage(message.data);
    }
    if (ctx.side.isServer()) {
        if (schematicSent) {
            ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("Schematic successfully sent!"));
        } else {
            ctx.getServerHandler().playerEntity.sendMessage(new TextComponentString("Failed to send the Schematic!"));
        }
    }
    return null;
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project VoodooCraft by Mod-DevCafeTeam.

the class HexSpawnPoint method activeUse.

@Override
public ItemStack activeUse(ItemStack stackIn, World world, EntityPlayer player, EnumHand hand, int strength, @Nullable EntityLivingBase target) {
    if (!world.isRemote) {
        BlockPos pos = player.getPosition();
        player.setSpawnPoint(new BlockPos(pos.getX(), pos.getY(), pos.getZ()), true);
        player.sendStatusMessage(new TextComponentString("Spawn point set to {x: " + pos.getX() + ", y: " + pos.getY() + ", z: " + pos.getZ() + "} for " + player.getName()));
    }
    return super.activeUse(stackIn, world, player, hand, strength, target);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 20 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project ImmersiveEngineering by BluSunrize.

the class CommandHelp method perform.

@Override
public void perform(CommandHandler handler, MinecraftServer server, ICommandSender sender, String[] args) {
    if (args.length > 1) {
        String sub = "";
        for (int i = 2; i < args.length; i++) sub += "." + args[i];
        for (IESubCommand com : handler.commands) {
            if (com.getIdent().equalsIgnoreCase(args[1])) {
                String h = I18n.translateToLocal(com.getHelp(sub));
                for (String s : h.split("<br>")) sender.addChatMessage(new TextComponentString(s));
            }
        }
    } else {
        String h = I18n.translateToLocal(getHelp(""));
        for (String s : h.split("<br>")) sender.addChatMessage(new TextComponentString(s));
        String sub = "";
        int i = 0;
        for (IESubCommand com : handler.commands) sub += ((i++) > 0 ? ", " : "") + com.getIdent();
        sender.addChatMessage(new TextComponentTranslation(Lib.CHAT_COMMAND + "available", sub));
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IESubCommand(blusunrize.immersiveengineering.common.util.commands.CommandHandler.IESubCommand) TextComponentString(net.minecraft.util.text.TextComponentString) 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