Search in sources :

Example 71 with TextComponentString

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

the class WhoAmICommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender) throws CommandException {
    if (!(sender instanceof EntityPlayer)) {
        Log.getLogger().info("Very funny, you're a console!");
        return;
    }
    final IColony colony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), ((EntityPlayer) sender).getUniqueID());
    final BlockPos pos = colony.getCenter();
    final String colonyName = colony.getName();
    final String playerName = sender.getDisplayName().getFormattedText();
    final String posString = "x: " + pos.getX() + " y: " + pos.getY() + " z: " + pos.getZ();
    sender.sendMessage(new TextComponentString(String.format(TELL_HIM, playerName, colonyName, posString)));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) IColony(com.minecolonies.api.colony.IColony) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 72 with TextComponentString

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

the class AbstractKillCommand method executeShared.

private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender) throws CommandException {
    if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
        sender.sendMessage(new TextComponentString("Must be OP to use command"));
        return;
    }
    int entitiesKilled = 0;
    for (final Entity entity : server.getEntityWorld().getEntities(getEntityClass(), entity -> true)) {
        entity.setDead();
        entitiesKilled++;
    }
    sender.sendMessage(new TextComponentString(entitiesKilled + " entities killed"));
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 73 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Minestuck by mraof.

the class ServerEditHandler method newServerEditor.

public static void newServerEditor(EntityPlayerMP player, PlayerIdentifier computerOwner, PlayerIdentifier computerTarget) {
    if (player.isRiding())
        // Don't want to bother making the decoy able to ride anything right now.
        return;
    SburbConnection c = SkaianetHandler.getClientConnection(computerTarget);
    if (c != null && c.getServerIdentifier().equals(computerOwner) && getData(c) == null && getData(player) == null) {
        Debug.info("Activating edit mode on player \"" + player.getName() + "\", target player: \"" + computerTarget + "\".");
        EntityDecoy decoy = new EntityDecoy((WorldServer) player.world, player);
        EditData data = new EditData(decoy, player, c);
        if (!c.enteredGame()) {
            c.centerX = c.getClientData().getX();
            c.centerZ = c.getClientData().getZ();
        }
        if (!setPlayerStats(player, c)) {
            player.sendMessage(new TextComponentString(TextFormatting.RED + "Failed to activate edit mode."));
            return;
        }
        if (c.inventory != null)
            player.inventory.readFromNBT(c.inventory);
        decoy.world.spawnEntity(decoy);
        list.add(data);
        MinestuckPacket packet = MinestuckPacket.makePacket(Type.SERVER_EDIT, computerTarget, c.centerX, c.centerZ, c.givenItems());
        MinestuckChannelHandler.sendToPlayer(packet, player);
        MinestuckPlayerTracker.updateGristCache(c.getClientIdentifier());
    }
}
Also used : EntityDecoy(com.mraof.minestuck.entity.EntityDecoy) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket) SburbConnection(com.mraof.minestuck.network.skaianet.SburbConnection) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 74 with TextComponentString

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

the class BuildToolPasteMessage method messageOnServerThread.

@Override
public void messageOnServerThread(final BuildToolPasteMessage message, final EntityPlayerMP player) {
    final StructureName sn = new StructureName(message.structureName);
    if (!Structures.hasMD5(sn)) {
        player.sendMessage(new TextComponentString("Can not build " + message.workOrderName + ": schematic missing!"));
        return;
    }
    if (player.capabilities.isCreativeMode) {
        if (message.isHut) {
            handleHut(CompatibilityUtils.getWorld(player), player, sn, message.rotation, message.pos, message.mirror);
        }
        StructureWrapper.loadAndPlaceStructureWithRotation(player.world, message.structureName, message.pos, message.rotation, message.mirror ? Mirror.FRONT_BACK : Mirror.NONE, message.complete);
        if (message.isHut) {
            @Nullable final AbstractBuilding building = ColonyManager.getBuilding(CompatibilityUtils.getWorld(player), message.pos);
            if (building != null) {
                final WorkOrderBuild workOrder = new WorkOrderBuild(building, 1);
                ConstructionTapeHelper.removeConstructionTape(workOrder, CompatibilityUtils.getWorld(player));
            }
        }
    } else if (message.freeMode != null) {
        if (player.getStatFile().readStat(StatList.getObjectUseStats(ModItems.supplyChest)) > 0) {
            LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.error.supplyChestAlreadyPlaced");
            return;
        }
        final List<ItemStack> stacks = new ArrayList<>();
        final int chestHeight;
        if (message.freeMode == WindowBuildTool.FreeMode.SUPPLYSHIP) {
            stacks.add(new ItemStack(ModItems.supplyChest));
            chestHeight = SUPPLY_SHIP_CHEST_HEIGHT;
        } else if (message.freeMode == WindowBuildTool.FreeMode.SUPPLYCAMP) {
            stacks.add(new ItemStack(ModItems.supplyCamp));
            chestHeight = 1;
        } else {
            chestHeight = 0;
        }
        player.addStat(StatList.getObjectUseStats(ModItems.supplyChest));
        if (InventoryUtils.removeStacksFromItemHandler(new InvWrapper(player.inventory), stacks)) {
            StructureWrapper.loadAndPlaceStructureWithRotation(player.world, message.structureName, message.pos, message.rotation, message.mirror ? Mirror.FRONT_BACK : Mirror.NONE, message.complete);
            player.getServerWorld().setBlockState(message.pos.up(chestHeight), Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, player.getHorizontalFacing()));
            fillChest((TileEntityChest) player.getServerWorld().getTileEntity(message.pos.up(chestHeight)));
        } else {
            LanguageHandler.sendPlayerMessage(player, "item.supplyChestDeployer.missing");
        }
    }
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) TileEntityChest(net.minecraft.tileentity.TileEntityChest) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) StructureName(com.minecolonies.coremod.colony.StructureName) ArrayList(java.util.ArrayList) StatList(net.minecraft.stats.StatList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable) TextComponentString(net.minecraft.util.text.TextComponentString) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding)

Example 75 with TextComponentString

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

the class SchematicSaveMessage method messageOnServerThread.

@Override
public void messageOnServerThread(final SchematicSaveMessage message, final EntityPlayerMP player) {
    if (!MineColonies.isClient() && !Configurations.gameplay.allowPlayerSchematics) {
        Log.getLogger().info("SchematicSaveMessage: custom schematic is not allowed on this server.");
        player.sendMessage(new TextComponentString("The server does not allow custom schematic!"));
        return;
    }
    if (message.pieces > MAX_AMOUNT_OF_PIECES) {
        Log.getLogger().error("Schematic has more than 10 pieces, discarding.");
        player.sendMessage(new TextComponentString("Schematic has more than 10 pieces, that's too big!"));
        return;
    }
    final boolean schematicSent;
    if (message.data == null) {
        Log.getLogger().error("Received empty schematic file");
        schematicSent = false;
    } else {
        schematicSent = Structures.handleSaveSchematicMessage(message.data, message.id, message.pieces, message.piece);
    }
    if (schematicSent) {
        player.sendMessage(new TextComponentString("Schematic successfully sent!"));
    } else {
        player.sendMessage(new TextComponentString("Failed to send the Schematic!"));
    }
}
Also used : 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