Search in sources :

Example 16 with TextComponentTranslation

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

the class BlockTeleporter method neighborChanged.

@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighbourBlock, BlockPos fromPos) {
    if (!world.isRemote) {
        TileEntityTeleporter tileentity = (TileEntityTeleporter) world.getTileEntity(pos);
        if (tileentity != null) {
            boolean isNowPowered = (world.isBlockIndirectlyGettingPowered(pos) > 0);
            boolean isAlreadyPowered = tileentity.isPowered();
            tileentity.setPowered(isNowPowered);
            if (isNowPowered != isAlreadyPowered) {
                // there is no way in forge to determine who activated/deactivated the teleporter, so we simply get the closest player
                // works for _most_ cases
                EntityPlayer player = world.getClosestPlayer(fromPos.getX(), fromPos.getY(), fromPos.getZ(), 32, false);
                if (player != null) {
                    String translationKey = "message." + TeleporterMod.MODID + '_' + this.getClass().getSimpleName() + '.' + (isNowPowered ? "teleporterLocked" : "teleporterUnlocked");
                    TextComponentTranslation message = new TextComponentTranslation(translationKey);
                    player.sendMessage(message);
                }
            }
            tileentity.markDirty();
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityTeleporter(net.dyeo.teleporter.tileentity.TileEntityTeleporter)

Example 17 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project MinecraftForge by MinecraftForge.

the class ClientCommandHandler method format.

//Couple of helpers because the mcp names are stupid and long...
private TextComponentTranslation format(TextFormatting color, String str, Object... args) {
    TextComponentTranslation ret = new TextComponentTranslation(str, args);
    ret.getStyle().setColor(color);
    return ret;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 18 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project MinecraftForge by MinecraftForge.

the class ForgeCommand method doTurnOnTileEntityTracking.

private void doTurnOnTileEntityTracking(MinecraftServer server, ICommandSender sender, int duration) {
    ForgeTimeTracker.tileEntityTrackingDuration = duration;
    ForgeTimeTracker.tileEntityTracking = true;
    sender.sendMessage(new TextComponentTranslation("commands.forge.tracking.te.enabled", duration));
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 19 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project MinecraftForge by MinecraftForge.

the class ForgeCommand method displayTPS.

private void displayTPS(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    int dim = 0;
    boolean summary = true;
    if (args.length > 1) {
        dim = parseInt(args[1]);
        summary = false;
    }
    if (summary) {
        for (Integer dimId : DimensionManager.getIDs()) {
            double worldTickTime = ForgeCommand.mean(server.worldTickTimes.get(dimId)) * 1.0E-6D;
            double worldTPS = Math.min(1000.0 / worldTickTime, 20);
            sender.sendMessage(new TextComponentTranslation("commands.forge.tps.summary", String.format("Dim %d", dimId), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS)));
        }
        double meanTickTime = ForgeCommand.mean(server.tickTimeArray) * 1.0E-6D;
        double meanTPS = Math.min(1000.0 / meanTickTime, 20);
        sender.sendMessage(new TextComponentTranslation("commands.forge.tps.summary", "Overall", timeFormatter.format(meanTickTime), timeFormatter.format(meanTPS)));
    } else {
        double worldTickTime = ForgeCommand.mean(server.worldTickTimes.get(dim)) * 1.0E-6D;
        double worldTPS = Math.min(1000.0 / worldTickTime, 20);
        sender.sendMessage(new TextComponentTranslation("commands.forge.tps.summary", String.format("Dim %d", dim), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS)));
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 20 with TextComponentTranslation

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

the class TileEntityTurret method hammerUseSide.

@Override
public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) {
    if (dummy) {
        TileEntity te = worldObj.getTileEntity(getPos().offset(facing, -1));
        if (te instanceof TileEntityTurret)
            return ((TileEntityTurret) te).hammerUseSide(side, player, hitX, hitY, hitZ);
        return false;
    }
    if (player.isSneaking()) {
        redstoneControlInverted = !redstoneControlInverted;
        ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "rsControl." + (redstoneControlInverted ? "invertedOn" : "invertedOff")));
        markDirty();
        this.markContainingBlockForUpdate(null);
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)35 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 TileEntity (net.minecraft.tileentity.TileEntity)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 BlockPos (net.minecraft.util.math.BlockPos)4 TargetingInfo (blusunrize.immersiveengineering.api.TargetingInfo)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)2 ItemStack (net.minecraft.item.ItemStack)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 DimensionChunkCoords (blusunrize.immersiveengineering.api.DimensionChunkCoords)1 IMultiblock (blusunrize.immersiveengineering.api.MultiblockHandler.IMultiblock)1 IFluxProvider (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxProvider)1 IFluxReceiver (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver)1 AbstractConnection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection)1 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 WireType (blusunrize.immersiveengineering.api.energy.wires.WireType)1 MineralMix (blusunrize.immersiveengineering.api.tool.ExcavatorHandler.MineralMix)1