Search in sources :

Example 6 with LocalizationHelper

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

the class BlockTeleporter method clOnBlockActivated.

@Override
protected boolean clOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = player.getHeldItem(hand);
    boolean holdingLinker = StackHelper.isValid(heldItem) && heldItem.getItem() == ModItems.teleporterLinker;
    boolean holdingReturnHome = StackHelper.isValid(heldItem) && heldItem.getItem() == ModItems.returnHomeCharm;
    if (world.isRemote) {
        return holdingLinker || holdingReturnHome ? true : !isAnchor;
    }
    TileTeleporter tile = (TileTeleporter) world.getTileEntity(pos);
    if (tile == null) {
        SilentGems.logHelper.warning("Teleporter tile at " + pos + " not found!");
        return false;
    }
    // Link teleporters with linker.
    if (holdingLinker) {
        return tile.linkTeleporters(player, world, pos, heldItem, hand);
    }
    // Link return home charm.
    if (holdingReturnHome) {
        return tile.linkReturnHomeCharm(player, world, pos, heldItem, hand);
    }
    // If this is an anchor, we're done.
    if (isAnchor) {
        return false;
    }
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    // Destination set?
    if (!tile.isDestinationSet()) {
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NoDestination"));
        return true;
    }
    // Safety checks before teleporting:
    if (!tile.isDestinationSane(player)) {
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NotSane"));
        return true;
    }
    if (!tile.isDestinationSafe(player)) {
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NotSafe"));
        return true;
    }
    if (!tile.isDestinationAllowedIfDumb(player)) {
        ChatHelper.sendMessage(player, loc.getBlockSubText(Names.TELEPORTER, "NoReceiver"));
        return true;
    }
    // Check available charge, drain if there is enough.
    if (!tile.checkAndDrainChaos(player)) {
        return true;
    }
    // Teleport player
    tile.teleportEntityToDestination(player);
    // Play sounds
    float pitch = 0.7f + 0.3f * SilentGems.instance.random.nextFloat();
    for (BlockPos p : new BlockPos[] { pos, tile.getDestination().toBlockPos() }) {
        world.playSound(null, p, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0f, pitch);
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) TileTeleporter(net.silentchaos512.gems.tile.TileTeleporter) ItemStack(net.minecraft.item.ItemStack) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 7 with LocalizationHelper

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

the class ItemChaosOrb method clOnItemRightClick.

@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        toggleItemSendEnabled(stack);
        boolean mode = isItemSendEnabled(stack);
        LocalizationHelper loc = SilentGems.localizationHelper;
        String onOrOff = loc.getMiscText("state." + (mode ? "on" : "off"));
        onOrOff = (mode ? TextFormatting.GREEN : TextFormatting.RED) + onOrOff;
        String line = loc.getItemSubText(Names.CHAOS_ORB, "itemSend", onOrOff);
        ChatHelper.sendStatusMessage(player, new TextComponentString(line), true);
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 8 with LocalizationHelper

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

the class ItemChaosRune method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean advanced) {
    ChaosBuff buff = getBuff(stack);
    if (buff != null) {
        LocalizationHelper loc = SilentGems.localizationHelper;
        // Name
        TextFormatting nameColor = buff.getPotion() != null && buff.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GOLD;
        list.add(nameColor + buff.getLocalizedName(1));
        // Description (may not have one)
        String desc = "  " + buff.getDescription();
        if (!desc.isEmpty())
            list.add(TextFormatting.DARK_GRAY + desc);
        list.add("  " + loc.getItemSubText(itemName, "maxLevel", buff.getMaxLevel()));
        list.add("  " + loc.getItemSubText(itemName, "slotsUsed", buff.getSlotsUsed(1)));
        String varCost = buff.hasVariableCost() ? loc.getItemSubText(itemName, "variableCost") : "";
        list.add("  " + loc.getItemSubText(itemName, "chaosCost", buff.getChaosCost(1, null), varCost));
        // Debug
        if (KeyTracker.isAltDown()) {
            list.add(TextFormatting.DARK_GRAY + String.format("Key: %s", buff.getKey()));
            list.add(TextFormatting.DARK_GRAY + String.format("Potion: %s", buff.getPotion()));
            list.add(TextFormatting.DARK_GRAY + String.format("Color: %X", buff.getColor()));
        }
    }
}
Also used : TextFormatting(net.minecraft.util.text.TextFormatting) ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 9 with LocalizationHelper

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

the class ItemReturnHome method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List list, boolean par4) {
    // Is ctrl key down?
    boolean modifier = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    // How to use
    list.addAll(loc.getItemDescriptionLines(itemName));
    // Display coordinates if modifier key is held.
    DimensionalPosition pos = getBoundPosition(stack);
    if (pos != null) {
        if (modifier) {
            list.add(loc.getItemSubText(itemName, TEXT_BOUND_TO, pos));
        } else {
            list.add(loc.getMiscText("PressCtrl"));
        }
    } else {
        list.add(loc.getItemSubText(itemName, TEXT_NOT_BOUND));
    }
}
Also used : DimensionalPosition(net.silentchaos512.lib.util.DimensionalPosition) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 10 with LocalizationHelper

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

the class ItemSoulGem method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack stack) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    Soul soul = getSoul(stack);
    if (soul == null) {
        return getUnlocalizedName(stack);
    }
    if (StackHelper.isValid(soul.matchStack)) {
        return loc.getItemSubText(Names.SOUL_GEM, "name_proper", soul.matchStack.getDisplayName());
    } else {
        String name = "entity." + soul.id + ".name";
        name = loc.getLocalizedString(name);
        return loc.getItemSubText(Names.SOUL_GEM, "name_proper", name);
    }
}
Also used : 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