Search in sources :

Example 26 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project VanillaTeleporter by dyeo.

the class CommandTeleporters method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    TeleporterNetwork network = TeleporterNetwork.get(sender.getEntityWorld());
    TextComponentString chat = new TextComponentString("--- There are currently " + network.getSubnets().size() + " teleporter networks ---");
    chat.getStyle().setColor(TextFormatting.DARK_GREEN);
    sender.sendMessage(chat);
    Iterator<String> it = network.getSubnets().iterator();
    while (it.hasNext()) {
        String s = it.next();
        chat = new TextComponentString("(" + network.getSubnetSize(s) + ") " + s);
        sender.sendMessage(chat);
    }
}
Also used : TeleporterNetwork(net.dyeo.teleporter.teleport.TeleporterNetwork) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 27 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Geolosys by oitsjustjose.

the class BlockSample method registerEvent.

@SubscribeEvent
public void registerEvent(BlockEvent.HarvestDropsEvent event) {
    if (!Config.getInstance().boringSamples || event.getHarvester() == null || event.getState() == null || event.getState().getBlock() != this) {
        return;
    }
    String resource = Types.Modded.byMetadata(event.getState().getBlock().getMetaFromState(event.getState())).getResource();
    event.getHarvester().sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    event.getDrops().clear();
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 28 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Geolosys by oitsjustjose.

the class BlockSample method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (Config.getInstance().boringSamples) {
        String resource = Types.Modded.byMetadata(state.getBlock().getMetaFromState(state)).getResource();
        playerIn.sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    } else {
        this.dropBlockAsItem(worldIn, pos, state, 0);
    }
    worldIn.setBlockToAir(pos);
    playerIn.swingArm(EnumHand.MAIN_HAND);
    return true;
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 29 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Geolosys by oitsjustjose.

the class ItemProPick method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote) {
        player.swingArm(hand);
        return EnumActionResult.PASS;
    }
    int xStart;
    int xEnd;
    int yStart;
    int yEnd;
    int zStart;
    int zEnd;
    int confAmt = Config.getInstance().proPickRange;
    boolean found = false;
    switch(facing) {
        case UP:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -confAmt;
            yEnd = 0;
            zStart = -(confAmt / 2);
            zEnd = (confAmt / 2);
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case DOWN:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = 0;
            yEnd = confAmt;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case NORTH:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = 0;
            zEnd = confAmt;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case SOUTH:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -confAmt;
            zEnd = 0;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case EAST:
            xStart = -(confAmt);
            xEnd = 0;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case WEST:
            xStart = 0;
            xEnd = confAmt;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
    }
    if (!found) {
        player.sendStatusMessage(new TextComponentString("No deposits found"), true);
    }
    player.swingArm(hand);
    return EnumActionResult.SUCCESS;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockOreVanilla(com.oitsjustjose.geolosys.blocks.BlockOreVanilla) BlockOre(com.oitsjustjose.geolosys.blocks.BlockOre) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 30 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project SpongeCommon by SpongePowered.

the class MixinServerStatusResponse method setServerDescription.

/**
 * @author minecrell - January 18th, 2015
 * @reason Use our Text API
 *
 * @param motd The message of the day to set
 */
@Overwrite
public void setServerDescription(@Nullable ITextComponent motd) {
    if (motd != null) {
        this.description = motd;
        this.descriptionText = SpongeTexts.toText(motd);
    } else {
        this.description = new TextComponentString("");
        this.descriptionText = Text.of();
    }
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) Overwrite(org.spongepowered.asm.mixin.Overwrite)

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