use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class CitizenInfoCommand method executeSpecializedCode.
@Override
void executeSpecializedCode(@NotNull final MinecraftServer server, final ICommandSender sender, final Colony colony, final int citizenId) {
final CitizenData citizenData = colony.getCitizen(citizenId);
final EntityCitizen entityCitizen = citizenData.getCitizenEntity();
sender.sendMessage(new TextComponentString(String.format(CITIZEN_DESCRIPTION, citizenData.getId(), citizenData.getName())));
if (entityCitizen == null) {
sender.sendMessage(new TextComponentTranslation(CITIZEN_NOT_LOADED));
return;
}
final BlockPos citizenPosition = entityCitizen.getPosition();
sender.sendMessage(new TextComponentString(String.format(CITIZEN_POSITION, citizenPosition.getX(), citizenPosition.getY(), citizenPosition.getZ())));
final BlockPos homePosition = entityCitizen.getHomePosition();
sender.sendMessage(new TextComponentString(String.format(CITIZEN_HOME_POSITION, homePosition.getX(), homePosition.getY(), homePosition.getZ())));
if (entityCitizen.getWorkBuilding() == null) {
sender.sendMessage(new TextComponentString(String.format(CITIZEN_WORK_POSITION_NULL)));
} else {
final BlockPos workingPosition = entityCitizen.getWorkBuilding().getLocation();
sender.sendMessage(new TextComponentString(String.format(CITIZEN_WORK_POSITION, workingPosition.getX(), workingPosition.getY(), workingPosition.getZ())));
}
sender.sendMessage(new TextComponentString(String.format(CITIZEN_HEALTH, entityCitizen.getHealth(), entityCitizen.getMaxHealth())));
sender.sendMessage(new TextComponentString(String.format(CITIZEN_LEVEL_AND_AGE, entityCitizen.getLevel(), entityCitizen.getAge(), entityCitizen.getExperienceLevel())));
sender.sendMessage(new TextComponentString(String.format(CITIZEN_SKILLS, entityCitizen.getCharisma(), entityCitizen.getDexterity(), entityCitizen.getEndurance(), entityCitizen.getIntelligence(), entityCitizen.getStrength())));
if (entityCitizen.getColonyJob() == null) {
sender.sendMessage(new TextComponentString(String.format(CITIZEN_JOB_NULL)));
sender.sendMessage(new TextComponentString(String.format(CITIZEN_NO_ACTIVITY)));
} else if (entityCitizen.getWorkBuilding() != null) {
sender.sendMessage(new TextComponentString(String.format(CITIZEN_JOB, entityCitizen.getWorkBuilding().getJobName())));
sender.sendMessage(new TextComponentString(String.format(CITIZEN_DESIRED_ACTIVITY, entityCitizen.getDesiredActivity(), entityCitizen.getColonyJob().getNameTagDescription())));
}
}
use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.
the class EntityCitizen method sendChat.
/**
* Sends a chat string close to the citizen.
*
* @param msg the message string.
*/
private void sendChat(final String key, @Nullable final Object... msg) {
if (msg == null || statusMessages.containsKey(key)) {
return;
}
final TextComponentTranslation requiredItem;
if (msg.length == 0) {
requiredItem = new TextComponentTranslation(key);
} else {
statusMessages.put(key + msg[0], ticksExisted);
requiredItem = new TextComponentTranslation(key, msg);
}
final TextComponentString citizenDescription = new TextComponentString(" ");
citizenDescription.appendText(this.getCustomNameTag()).appendText(": ");
final TextComponentString colonyDescription = new TextComponentString(" at " + this.getColony().getName() + ":");
final List<EntityPlayer> players = new ArrayList<>(colony.getMessageEntityPlayers());
final EntityPlayer owner = ServerUtils.getPlayerFromUUID(world, this.getColony().getPermissions().getOwner());
if (owner != null) {
players.remove(owner);
LanguageHandler.sendPlayerMessage(owner, this.getColonyJob() == null ? "" : this.getColonyJob().getName(), citizenDescription, requiredItem);
}
LanguageHandler.sendPlayersMessage(players, this.getColonyJob() == null ? "" : this.getColonyJob().getName(), colonyDescription, citizenDescription, requiredItem);
}
use of net.minecraft.util.text.TextComponentTranslation in project Pearcel-Mod by MiningMark48.
the class ItemPearcelStaff method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
if (player.isSneaking()) {
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 5000, 1));
item.damageItem(50, player);
return new ActionResult(EnumActionResult.PASS, item);
} else {
if (player.posY <= ConfigurationHandler.maxStaffFlyHeight || player.capabilities.isCreativeMode) {
player.addVelocity(0, 0.5, 0);
} else {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.DARK_RED + Translate.toLocal("chat.pearcel_staff.weaken")));
item.damageItem(10, player);
}
}
item.damageItem(1, player);
return new ActionResult(EnumActionResult.PASS, item);
}
}
use of net.minecraft.util.text.TextComponentTranslation in project Pearcel-Mod by MiningMark48.
the class ItemTPPearcel method onItemRightClick.
@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setDouble("tpX", player.posX);
stack.getTagCompound().setDouble("tpY", player.posY);
stack.getTagCompound().setDouble("tpZ", player.posZ);
stack.getTagCompound().setInteger("dim", player.dimension);
stack.getTagCompound().setFloat("yaw", player.rotationYaw);
stack.getTagCompound().setFloat("pitch", player.rotationPitch);
stack.getTagCompound().setBoolean("set", true);
}
if (player.isSneaking()) {
stack.getTagCompound().setDouble("tpX", player.posX);
stack.getTagCompound().setDouble("tpY", player.posY);
stack.getTagCompound().setDouble("tpZ", player.posZ);
stack.getTagCompound().setInteger("dim", player.dimension);
stack.getTagCompound().setFloat("yaw", player.rotationYaw);
stack.getTagCompound().setFloat("pitch", player.rotationPitch);
stack.getTagCompound().setBoolean("set", true);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.DARK_GREEN + (Translate.toLocal("chat.tpPearcel.location.set"))));
}
} else {
tpX = stack.getTagCompound().getDouble("tpX");
tpY = stack.getTagCompound().getDouble("tpY");
tpZ = stack.getTagCompound().getDouble("tpZ");
dim = stack.getTagCompound().getInteger("dim");
yaw = stack.getTagCompound().getFloat("yaw");
pitch = stack.getTagCompound().getFloat("pitch");
if (!stack.getTagCompound().getBoolean("set")) {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.RED + (Translate.toLocal("chat.tpPearcel.location.notSet"))));
}
} else {
if (player.dimension == dim) {
//player.setPositionAndUpdate(tpX, tpY, tpZ);
player.setLocationAndAngles(tpX, tpY, tpZ, yaw, pitch);
player.addStat(Achievements.achievement_use_tp_pearcel);
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.tpPearcel.tp"))));
}
if (!player.capabilities.isCreativeMode) {
if (player.inventory.hasItemStack(new ItemStack(ModItems.pearcel_item))) {
player.inventory.deleteStack(new ItemStack(ModItems.pearcel_item, 1));
} else {
stack.damageItem(1, player);
}
}
} else {
if (!world.isRemote) {
player.sendMessage(new TextComponentTranslation(TextFormatting.RED + (Translate.toLocal("chat.tpPearcel.wrongDim"))));
}
}
}
}
return new ActionResult(EnumActionResult.PASS, stack);
}
use of net.minecraft.util.text.TextComponentTranslation in project ImmersiveEngineering by BluSunrize.
the class TileEntityEnergyMeter method interact.
@Override
public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) {
int transfer = getAveragePower();
int packets = lastPackets.size();
if (dummy) {
TileEntity above = worldObj.getTileEntity(getPos().add(0, 1, 0));
if (above instanceof TileEntityEnergyMeter)
packets = ((TileEntityEnergyMeter) above).lastPackets.size();
}
String transferred = "0";
if (transfer > 0)
transferred = Utils.formatDouble(transfer, "0.###");
ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "energyTransfered", packets, transferred));
return true;
}
Aggregations