Search in sources :

Example 26 with TextComponentTranslation

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())));
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) CitizenData(com.minecolonies.coremod.colony.CitizenData) BlockPos(net.minecraft.util.math.BlockPos) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 27 with TextComponentTranslation

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);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 28 with TextComponentTranslation

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);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) PotionEffect(net.minecraft.potion.PotionEffect)

Example 29 with TextComponentTranslation

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);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 30 with TextComponentTranslation

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;
}
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