use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class LanguageHandler method buildChatComponent.
private static ITextComponent buildChatComponent(final String key, final Object... message) {
TextComponentTranslation translation = null;
int onlyArgsUntil = 0;
for (final Object object : message) {
if (object instanceof ITextComponent) {
if (onlyArgsUntil == 0) {
onlyArgsUntil = -1;
}
break;
}
onlyArgsUntil++;
}
if (onlyArgsUntil >= 0) {
final Object[] args = new Object[onlyArgsUntil];
System.arraycopy(message, 0, args, 0, onlyArgsUntil);
translation = new TextComponentTranslation(key, args);
}
for (final Object object : message) {
if (translation == null) {
if (object instanceof ITextComponent) {
translation = new TextComponentTranslation(key);
} else {
translation = new TextComponentTranslation(key, object);
continue;
}
}
if (object instanceof ITextComponent) {
translation.appendSibling((ITextComponent) object);
} else if (object instanceof String) {
boolean isInArgs = false;
for (final Object obj : translation.getFormatArgs()) {
if (obj.equals(object)) {
isInArgs = true;
break;
}
}
if (!isInArgs) {
translation.appendText((String) object);
}
}
}
if (translation == null) {
translation = new TextComponentTranslation(key);
}
return translation;
}
use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class AbstractEntityAIBasic method checkForWeapon.
/**
* Ensures that we have a pickaxe available.
* Will set {@code needsPickaxe} accordingly.
*
* @return true if we have a pickaxe
*/
public boolean checkForWeapon() {
//Check for a pickaxe
getOwnBuilding().setNeedsWeapon(!InventoryFunctions.matchFirstInProvider(worker, stack -> stack != null && Utils.doesItemServeAsWeapon(stack)));
delay += DELAY_RECHECK;
if (getOwnBuilding().needsWeapon()) {
if (walkToBuilding()) {
return false;
}
if (isWeaponInHut()) {
return true;
}
requestWithoutSpam(new TextComponentTranslation("com.minecolonies.coremod.job.guard.needWeapon"));
}
return getOwnBuilding().needsWeapon();
}
use of net.minecraft.util.text.TextComponentTranslation in project Pearcel-Mod by MiningMark48.
the class ItemPearcelBlockPlacer method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
if (player.isSneaking()) {
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
item.getTagCompound().setInteger("mode", 1);
} else {
if (item.getTagCompound().getInteger("mode") == 1) {
item.getTagCompound().setInteger("mode", 2);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.modeChange"))));
}
} else {
item.getTagCompound().setInteger("mode", 1);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.modeChange"))));
}
}
}
return new ActionResult(EnumActionResult.PASS, item);
} else {
return new ActionResult(EnumActionResult.PASS, item);
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Railcraft by Railcraft.
the class CommandHelpers method sendLocalizedChatMessage.
public static void sendLocalizedChatMessage(ICommandSender sender, Style chatStyle, String locTag, Object... args) {
TextComponentTranslation chat = new TextComponentTranslation(locTag, args);
chat.setStyle(chatStyle);
sender.addChatMessage(chat);
}
use of net.minecraft.util.text.TextComponentTranslation in project RecurrentComplex by Ivorforce.
the class CommandSightInfo method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
WorldStructureGenerationData generationData = WorldStructureGenerationData.get(sender.getEntityWorld());
WorldStructureGenerationData.Entry entry = generationData.getEntry(UUID.fromString(parameters.get().first().require()));
if (entry == null)
throw ServerTranslations.commandException("commands.rcsightinfo.unknown");
else {
ITextComponent area = RCTextStyle.area(RCBlockAreas.from(entry.getBoundingBox()));
ITextComponent sight = RCTextStyle.sight(entry, true);
if (entry instanceof WorldStructureGenerationData.StructureEntry) {
WorldStructureGenerationData.StructureEntry structureEntry = (WorldStructureGenerationData.StructureEntry) entry;
sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.structure", RCTextStyle.structure(structureEntry.getStructureID()), area, RCTextStyle.copy(String.valueOf(structureEntry.getSeed())), sight));
} else
sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.get", entry.description(), area, sight));
}
}
Aggregations