use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.
the class PacketPoint method apply.
@Override
public void apply(INetHandler handler) {
if (player == null)
return;
Notice notice = null;
switch(type) {
case COORD:
notice = new Notice(new NotificationCoord(player.world, pos), new TextComponentString(message));
break;
case ENTITY:
notice = new Notice(entity, new TextComponentString(message));
break;
}
notice.withStyle(NoticeStyle.DRAWFAR, NoticeStyle.VERY_LONG, NoticeStyle.SCALE_SIZE, NoticeStyle.EXACTPOSITION);
double maxDistSq = 256 * 256;
for (EntityPlayer viewer : player.world.playerEntities) {
if (player.getDistanceSq(viewer) >= maxDistSq)
continue;
notice.sendTo(viewer);
}
}
use of net.minecraft.util.text.TextComponentString in project Nutrition by WesCook.
the class ChatCommand method commandGetNutrition.
private void commandGetNutrition(ICommandSender sender, String[] args) {
// If missing parameter, offer help
if (args.length != 2) {
sender.sendMessage(new TextComponentString("Invalid format. /nutrition get <nutrient>"));
return;
}
// Write nutrient name and percentage to chat
EntityPlayer player = (EntityPlayer) sender;
Nutrient nutrient = NutrientList.getByName(args[1]);
if (nutrient != null) {
Float nutrientValue = player.getCapability(CapProvider.NUTRITION_CAPABILITY, null).get(nutrient);
sender.sendMessage(new TextComponentString(nutrient.name + ": " + String.format("%.2f", nutrientValue) + "%"));
} else
// Write error message
sender.sendMessage(new TextComponentString("'" + args[1] + "' is not a valid nutrient."));
}
use of net.minecraft.util.text.TextComponentString in project ForestryMC by ForestryMC.
the class BlockStructure 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 (playerIn.isSneaking()) {
return false;
}
MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
if (part == null) {
return false;
}
IMultiblockController controller = part.getMultiblockLogic().getController();
ItemStack heldItem = playerIn.getHeldItem(hand);
// multiblock-debugging message if the machine is not assembled.
if (heldItem.isEmpty()) {
if (controller != null) {
if (!controller.isAssembled()) {
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = worldIn.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
playerIn.sendMessage(new TextComponentString(validationError));
previousMessageTick = tick;
}
return true;
}
}
} else {
playerIn.sendMessage(new TextComponentTranslation("for.multiblock.error.notConnected"));
return true;
}
}
// Don't open the GUI if the multiblock isn't assembled
if (controller == null || !controller.isAssembled()) {
return false;
}
if (!worldIn.isRemote) {
part.openGui(playerIn);
}
return true;
}
use of net.minecraft.util.text.TextComponentString in project ForestryMC by ForestryMC.
the class BlockGreenhouse 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 (playerIn.isSneaking()) {
return false;
}
MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
if (part == null) {
return false;
}
IMultiblockController controller = part.getMultiblockLogic().getController();
ItemStack mainHand = playerIn.getHeldItemMainhand();
if (mainHand.isEmpty()) {
if (playerIn.getHeldItemOffhand().isEmpty()) {
// multiblock-debugging message if the machine is not assembled.
if (!controller.isAssembled()) {
String validationError = controller.getLastValidationError();
if (validationError != null) {
long tick = worldIn.getTotalWorldTime();
if (tick > previousMessageTick + 20) {
playerIn.sendMessage(new TextComponentString(validationError));
previousMessageTick = tick;
}
return true;
}
}
}
}
// Don't open the GUI if the multiblock isn't assembled
if (!controller.isAssembled()) {
return false;
}
if (!worldIn.isRemote) {
part.openGui(playerIn);
}
return true;
}
use of net.minecraft.util.text.TextComponentString in project TechReborn by TechReborn.
the class ItemFrequencyTransmitter method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setInteger("x", pos.getX());
stack.getTagCompound().setInteger("y", pos.getY());
stack.getTagCompound().setInteger("z", pos.getZ());
stack.getTagCompound().setInteger("dim", world.provider.getDimension());
if (!world.isRemote) {
ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " X: " + TextFormatting.GOLD + pos.getX() + TextFormatting.GRAY + " Y: " + TextFormatting.GOLD + pos.getY() + TextFormatting.GRAY + " Z: " + TextFormatting.GOLD + pos.getZ() + TextFormatting.GRAY + " " + I18n.format("techreborn.message.in") + " " + TextFormatting.GOLD + DimensionManager.getProviderType(world.provider.getDimension()).getName() + " (" + world.provider.getDimension() + ")"));
}
return EnumActionResult.SUCCESS;
}
Aggregations