Search in sources :

Example 11 with LocalizationHelper

use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.

the class ItemTeleporterLinker method renderGameOverlay.

@SideOnly(Side.CLIENT)
public void renderGameOverlay(RenderGameOverlayEvent event) {
    if (event.getType() != ElementType.TEXT) {
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    ItemStack heldItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
    if (StackHelper.isEmpty(heldItem)) {
        heldItem = mc.player.getHeldItem(EnumHand.OFF_HAND);
    }
    if (StackHelper.isValid(heldItem) && heldItem.getItem() == this) {
        ScaledResolution res = new ScaledResolution(mc);
        FontRenderer fontRender = mc.fontRenderer;
        int width = res.getScaledWidth();
        int height = res.getScaledHeight();
        String str;
        if (isLinked(heldItem)) {
            DimensionalPosition pos = getLinkedPosition(heldItem);
            double x = pos.x - player.posX;
            double z = pos.z - player.posZ;
            int distance = (int) Math.sqrt(x * x + z * z);
            LocalizationHelper loc = SilentGems.instance.localizationHelper;
            str = loc.getItemSubText(itemName, "Distance", distance);
            int textX = width / 2 - fontRender.getStringWidth(str) / 2;
            int textY = height * 3 / 5;
            // Text colored differently depending on situation.
            // Outside free range, same dimension
            int color = 0xffff00;
            if (pos.dim != player.dimension) {
                // Different dimension
                color = 0xff6600;
                str = loc.getItemSubText(itemName, "DifferentDimension");
            } else if (distance < GemsConfig.TELEPORTER_FREE_RANGE) {
                // Inside free range
                color = 0x00aaff;
            }
            fontRender.drawStringWithShadow(str, textX, textY, color);
        }
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) DimensionalPosition(net.silentchaos512.lib.util.DimensionalPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with LocalizationHelper

use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.

the class ItemChaosOrb method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    final boolean shifted = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    list.add(loc.getMiscText("ChaosCharge", getCharge(stack), getMaxCharge(stack)));
    list.add(loc.getItemSubText(itemName, "breakChance", (int) (getType(stack).breakChance * 100)));
    boolean mode = isItemSendEnabled(stack);
    String onOrOff = loc.getMiscText("state." + (mode ? "on" : "off"));
    onOrOff = (mode ? TextFormatting.GREEN : TextFormatting.RED) + onOrOff;
    list.add(loc.getItemSubText(Names.CHAOS_ORB, "itemSend", onOrOff));
    if (shifted) {
        for (String str : loc.getItemDescriptionLines(itemName)) {
            list.add(TextFormatting.ITALIC + str);
        }
    }
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 13 with LocalizationHelper

use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.

the class ItemEnchantmentToken method clAddInformation.

// =========================
// Item and ItemSL overrides
// =========================
@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    Map<Enchantment, Integer> enchants = getEnchantments(stack);
    if (enchants.size() == 1) {
        Enchantment ench = enchants.keySet().iterator().next();
        list.add(loc.getItemSubText(itemName, "maxLevel", ench.getMaxLevel()));
        // Recipe info
        if (KeyTracker.isControlDown()) {
            list.add(loc.getItemSubText(itemName, "materials"));
            String recipeString = recipeMap.get(ench);
            if (recipeString != null && !recipeString.isEmpty()) {
                for (String str : recipeString.split(";")) {
                    list.add("  " + str);
                }
            }
        } else {
            list.add(loc.getItemSubText(itemName, "pressCtrl"));
        }
        // Debug info
        if (KeyTracker.isAltDown()) {
            list.add(TextFormatting.DARK_GRAY + ench.getRegistryName().toString());
        // list.add(TextFormatting.DARK_GRAY + "EnchID: " + ench.getEnchantmentID(ench));
        }
    }
    // Enchantment list
    for (Entry<Enchantment, Integer> entry : enchants.entrySet()) {
        Enchantment e = entry.getKey();
        String enchName = e.getTranslatedName(entry.getValue());
        String modName = Loader.instance().getIndexedModList().get(e.getRegistryName().getResourceDomain()).getName();
        list.add(loc.getItemSubText(itemName, "enchNameWithMod", enchName, modName));
        String descKey = e.getName().replaceAll(":", ".").toLowerCase() + ".desc";
        String desc = loc.getLocalizedString(descKey);
        if (!desc.equals(descKey))
            list.add(TextFormatting.ITALIC + "  " + desc);
    }
}
Also used : Enchantment(net.minecraft.enchantment.Enchantment) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 14 with LocalizationHelper

use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.

the class ItemHoldingGem method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    IBlockState state = getBlockPlaced(stack);
    if (state == null) {
        list.addAll(loc.getItemDescriptionLines(itemName));
        return;
    }
    Block block = state.getBlock();
    ItemStack placedStack = new ItemStack(Item.getItemFromBlock(block), 1, block.getMetaFromState(state));
    list.add(placedStack.getDisplayName());
    super.clAddInformation(stack, world, list, advanced);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 15 with LocalizationHelper

use of net.silentchaos512.lib.util.LocalizationHelper in project SilentGems by SilentChaos512.

the class ItemReturnHome method tryTeleportPlayer.

public void tryTeleportPlayer(ItemStack stack, EntityPlayer player) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    DimensionalPosition pos = getBoundPosition(stack);
    // Not bound?
    if (pos == null) {
        return;
    }
    // Enough charge?
    if (getCharge(stack) < getTeleportCost(stack, player)) {
        ChatHelper.sendMessage(player, loc.getItemSubText(itemName, TEXT_NOT_ENOUGH_CHARGE));
        return;
    }
    // Is the destination sane? (ie, y > 0)
    if (pos.y <= 0) {
        ChatHelper.sendMessage(player, loc.getItemSubText(itemName, TEXT_NOT_SANE));
        return;
    }
    // Is the destination safe? (ie, no solid block at head level)
    WorldServer worldServer = player.getServer().getWorld(pos.dim);
    int height = (int) Math.ceil(player.eyeHeight);
    BlockPos target = pos.toBlockPos().up(height);
    // FIXME: Obstruction checks?
    // if (worldServer.isBlockNormalCube(target, true)) {
    // PlayerHelper.addChatMessage(player, loc.getItemSubText(itemName, TEXT_NOT_SAFE));
    // PlayerHelper.addChatMessage(player, "" + target);
    // PlayerHelper.addChatMessage(player, "" + worldServer.getBlockState(target));
    // SilentGems.logHelper.warning("Return Home Charm believes destination is obstructed:\n"
    // + "Target: " + target + "\nBlockstate: " + worldServer.getBlockState(target));
    // return;
    // }
    // It should be safe to teleport.
    // Reset fall distance then teleport.
    player.fallDistance = 0.0f;
    teleportPlayer(stack, player, pos);
    // Play sounds
    float soundPitch = 0.8f + 0.3f * SilentGems.random.nextFloat();
    for (BlockPos p : new BlockPos[] { player.getPosition(), pos.toBlockPos() }) {
        player.world.playSound(null, p, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0f, soundPitch);
    }
}
Also used : DimensionalPosition(net.silentchaos512.lib.util.DimensionalPosition) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Aggregations

LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)24 ItemStack (net.minecraft.item.ItemStack)6 DimensionalPosition (net.silentchaos512.lib.util.DimensionalPosition)4 TextFormatting (net.minecraft.util.text.TextFormatting)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 UUID (java.util.UUID)2 ActionResult (net.minecraft.util.ActionResult)2 EnumActionResult (net.minecraft.util.EnumActionResult)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)2 ToolPartTip (net.silentchaos512.gems.api.tool.part.ToolPartTip)2 ChaosBuff (net.silentchaos512.gems.lib.ChaosBuff)2 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)2 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1