use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.
the class CharsetTransportCarts method onNothingInteract.
@SubscribeEvent
public void onNothingInteract(PlayerInteractEvent.RightClickEmpty event) {
if (!event.getEntityPlayer().getEntityWorld().isRemote && event.getItemStack().getItem() == itemLinker) {
if (linkMap.containsKey(event.getEntityPlayer())) {
linkMap.remove(event.getEntityPlayer());
event.getEntityPlayer().sendMessage(new TextComponentString("dev_unlinked"));
event.setCanceled(true);
}
}
}
use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.
the class TileShelf method onActivated.
protected boolean onActivated(float hitX, float hitY, float hitZ, ItemStack stack, EntityPlayer player) {
int slotId = getSlotId(hitX, hitY, hitZ);
if (slotId < 0)
return false;
if (stack.isEmpty()) {
if (handler.getStackInSlot(slotId).isEmpty()) {
slotId = toNonBookSlotId(slotId);
}
if (!handler.getStackInSlot(slotId).isEmpty()) {
final int sentSlotId = slotId;
new Notice(new Vec3d(pos).addVector(hitX, hitY, hitZ), msg -> msg.withItem(handler.getStackInSlot(sentSlotId)).setMessage(new TextComponentString("{ITEM_NAME}{ITEM_INFOS_NEWLINE}"))).sendTo(player);
return true;
} else {
return false;
}
} else {
if (!isBook(stack))
slotId = toNonBookSlotId(slotId);
if (isSlotTaken(slotId))
return false;
stack = stack.splitStack(1);
handler.setStackInSlot(slotId, stack);
markBlockForUpdate();
return true;
}
}
use of net.minecraft.util.text.TextComponentString in project DefiledLands by Lykrast.
the class ItemBookWyrmAnalyzer method itemInteractionForEntity.
/**
* Returns true if the item can be used on the given entity, e.g. shears on sheep.
*/
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
if (entity.world.isRemote) {
return false;
}
if (entity instanceof EntityBookWyrm) {
EntityBookWyrm target = (EntityBookWyrm) entity;
String base = "ui.defiledlands.book_wyrm_analyze.";
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "health")) + (int) target.getHealth() + "/" + (int) target.getMaxHealth()));
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digest_time")) + target.getDigestTime()));
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "max_level")) + target.getMaxLevel()));
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digested")) + target.digested));
if (target.digesting > 0)
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digesting")) + target.digesting + I18n.translateToLocal(String.format("%s%s", base, "levels"))));
if (target.isChild()) {
int minutes = (int) Math.ceil((-target.getGrowingAge()) / 1200.0D);
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "maturing")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
} else if (target.getGrowingAge() > 0) {
int minutes = (int) Math.ceil(target.getGrowingAge() / 1200.0D);
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "reproduce")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
} else
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "ready"))));
if (target.isGolden())
player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "golden"))));
return true;
}
return false;
}
use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.
the class CommandMutter method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof TileEntity || sender instanceof Entity)) {
return;
}
EnumSet theStyle = EnumSet.noneOf(NoticeStyle.class);
ItemStack heldItem = ItemStack.EMPTY;
if (sender instanceof EntityLivingBase) {
heldItem = ((EntityLivingBase) sender).getHeldItem(EnumHand.MAIN_HAND);
}
ItemStack sendItem = ItemStack.EMPTY;
for (int i = 0; i < args.length; i++) {
String s = args[i];
if (s.equalsIgnoreCase("--long")) {
theStyle.add(NoticeStyle.LONG);
} else if (s.equalsIgnoreCase("--show-item") && !heldItem.isEmpty()) {
theStyle.add(NoticeStyle.DRAWITEM);
sendItem = heldItem;
} else {
break;
}
args[i] = null;
}
String msg = Joiner.on(" ").skipNulls().join(args);
msg = msg.replace("\\n", "\n");
new Notice(sender, new TextComponentString(msg)).withStyle(theStyle).withItem(sendItem).sendToAll();
}
use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.
the class Notice method clear.
/**
* Erases all Notifications a player has.
*/
public static void clear(EntityPlayer player) {
NotificationCoord at = new NotificationCoord(player.world, new BlockPos(player));
NotifyImplementation.instance.doSend(player, at, player.world, EnumSet.of(NoticeStyle.CLEAR), null, new TextComponentString(""));
}
Aggregations