Search in sources :

Example 1 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class NodePacketHelper method spawnParticles.

public static void spawnParticles(World world, Vec3d from, Vec3d to, int color) {
    if (!world.isRemote) {
        // We can only spawn particles on the client, so send a packet out to the clients if we try to do this on the
        // server side!
        NetworkHandler.INSTANCE.sendToAllAround(new MessageTransferParticles(from, to, color), new TargetPoint(world.provider.getDimension(), from.x, from.y, from.z, 64));
        return;
    }
    final int stepCount = 20 - 4 * SilentGems.proxy.getParticleSettings();
    final double distance = (float) from.distanceTo(to);
    final double stepX = (to.x - from.x) / stepCount;
    final double stepY = (to.y - from.y) / stepCount;
    final double stepZ = (to.z - from.z) / stepCount;
    for (int i = 0; i <= stepCount; ++i) {
        double x = from.x + stepX * i;
        double y = from.y + stepY * i;
        double z = from.z + stepZ * i;
        double motionX = 0.0075 * SilentGems.random.nextGaussian();
        double motionY = 0.0075 * SilentGems.random.nextGaussian();
        double motionZ = 0.0075 * SilentGems.random.nextGaussian();
        for (int j = 0; j < 4 - SilentGems.proxy.getParticleSettings(); ++j) {
            SilentGems.proxy.spawnParticles(EnumModParticles.CHAOS_PACKET_TAIL, new Color(color), world, x, y, z, motionX, motionY, motionZ);
        }
    }
}
Also used : MessageTransferParticles(net.silentchaos512.gems.network.message.MessageTransferParticles) Color(net.silentchaos512.lib.util.Color) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)

Example 2 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class ItemGemArmor method clAddInformation.

@Override
public void clAddInformation(ItemStack stack, World world, List<String> list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    ToolRenderHelper helper = ToolRenderHelper.getInstance();
    boolean controlDown = KeyTracker.isControlDown();
    boolean shiftDown = KeyTracker.isShiftDown();
    boolean altDown = KeyTracker.isAltDown();
    String line;
    // UUID
    if (GemsConfig.DEBUG_MODE && controlDown && shiftDown) {
        UUID uuid = ToolHelper.hasUUID(stack) ? ToolHelper.getUUID(stack) : null;
        list.add(uuid == null ? "No UUID" : uuid.toString());
        uuid = ToolHelper.getSoulUUID(stack);
        list.add(uuid == null ? "No Soul UUID" : uuid.toString());
    }
    // Tool Soul
    ToolSoul soul = SoulManager.getSoul(stack);
    if (soul != null) {
        soul.addInformation(stack, world, list, advanced);
    }
    // Show original owner?
    if (controlDown) {
        String owner = ArmorHelper.getOriginalOwner(stack);
        if (!owner.isEmpty()) {
            list.add(loc.getMiscText("Tooltip.OriginalOwner", owner));
        } else {
            list.add(loc.getMiscText("Tooltip.OriginalOwner.Unknown"));
        }
    }
    // TODO: Remove me
    if (altDown) {
        list.add(TextFormatting.RED + "Armor models WIP.");
    }
    // Broken?
    if (ArmorHelper.isBroken(stack)) {
        list.add(loc.getMiscText("Tooltip.Broken"));
    }
    final String sep = loc.getMiscText("Tooltip.Separator");
    if (controlDown) {
        // Properties header
        list.add(loc.getMiscText("Tooltip.Properties"));
        TextFormatting color = TextFormatting.YELLOW;
        float durabilityBoost = ToolSoul.getDurabilityModifierForDisplay(soul);
        list.add(color + helper.getTooltipLine("Durability", getMaxDamage(stack), durabilityBoost));
        float protectionBoost = ToolSoul.getProtectionModifierForDisplay(soul);
        list.add(color + helper.getTooltipLine("Protection", getProtection(stack), protectionBoost));
        // Statistics Header
        list.add(sep);
        list.add(loc.getMiscText("Tooltip.Statistics"));
        list.add(helper.getTooltipLine("DamageTaken", ArmorHelper.getStatDamageTaken(stack), 0f));
        list.add(helper.getTooltipLine("Redecorated", ArmorHelper.getStatRedecorated(stack), 0f));
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("PressCtrl"));
    }
    if (altDown) {
        list.add(loc.getMiscText("Tooltip.Construction"));
        ToolPart[] parts = ArmorHelper.getConstructionParts(stack);
        EnumMaterialGrade[] grades = ArmorHelper.getConstructionGrades(stack);
        for (int i = 0; i < parts.length; ++i) {
            ToolPart part = parts[i];
            EnumMaterialGrade grade = grades[i];
            line = "  " + TextFormatting.YELLOW + part.getKey() + TextFormatting.GOLD + " (" + grade + ")";
            list.add(line);
        }
        ToolPart partFrame = ArmorHelper.getPart(stack, ArmorPartPosition.FRAME);
        if (partFrame != null)
            list.add("  " + TextFormatting.YELLOW + partFrame.getKey());
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("PressAlt"));
    }
}
Also used : ToolRenderHelper(net.silentchaos512.gems.item.ToolRenderHelper) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) TextFormatting(net.minecraft.util.text.TextFormatting) UUID(java.util.UUID)

Example 3 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class ToolPartFlint method getColor.

@Override
public int getColor(ItemStack toolOrArmor, IPartPosition position, int animationFrame) {
    Item item = toolOrArmor.getItem();
    boolean isTextureUncolored = position == ToolPartPosition.ROD_DECO || item instanceof IArmor || item instanceof ItemGemBow || item instanceof ItemGemShield;
    return isTextureUncolored || ToolHelper.isBroken(toolOrArmor) ? COLOR : 0xFFFFFF;
}
Also used : Item(net.minecraft.item.Item) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) IArmor(net.silentchaos512.gems.api.IArmor)

Example 4 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class ToolSoul method addInformation.

public void addInformation(ItemStack stack, World world, List<String> list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    String color;
    // Level, XP, AP
    color = "" + TextFormatting.GREEN;
    list.add(color + loc.getMiscText("ToolSoul.level", level, xp, getXpToNextLevel()));
    list.add(color + loc.getMiscText("ToolSoul.actionPoints", actionPoints, getMaxActionPoints()));
    boolean skillsKeyDown = Keyboard.isKeyDown(Keyboard.KEY_S);
    if (skillsKeyDown || stack.getItem() instanceof ItemToolSoul) {
        // Display elements.
        String e1 = element1 == null ? "None" : element1.getDisplayName();
        String e2 = element2 == null ? "None" : element2.getDisplayName();
        String elements = e1 + (e2.equalsIgnoreCase("none") ? "" : ", " + e2);
        list.add(loc.getMiscText("ToolSoul.elements", elements));
    }
    if (skillsKeyDown) {
        // Display stat modifiers.
        color = "  " + TextFormatting.YELLOW;
        float durability = getDurabilityModifierForDisplay(this);
        float harvestSpeed = getHarvestSpeedModifierForDisplay(this);
        float meleeDamage = getMeleeDamageModifierForDisplay(this);
        float magicDamage = getMagicDamageModifierForDisplay(this);
        float protection = getProtectionModifierForDisplay(this);
        if (durability != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("Durability", durability, 0, true));
        if (harvestSpeed != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("HarvestSpeed", harvestSpeed, 0, true));
        if (meleeDamage != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("MeleeDamage", meleeDamage, 0, true));
        if (magicDamage != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("MagicDamage", magicDamage, 0, true));
        if (protection != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("Protection", protection, 0, true));
        // Display skills.
        for (Entry<SoulSkill, Integer> entry : skills.entrySet()) {
            SoulSkill skill = entry.getKey();
            int level = entry.getValue();
            list.add("  " + skill.getLocalizedName(stack, level));
        }
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.keyForSkills"));
    }
}
Also used : ItemToolSoul(net.silentchaos512.gems.item.ItemToolSoul) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 5 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class GuiChaosBar method onRenderGameOverlay.

@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
    if (event.getType() != ElementType.AIR) {
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    currentTime = ClientTickHandler.ticksInGame;
    if (player.capabilities.isCreativeMode || (!GemsConfig.CHAOS_BAR_SHOW_ALWAYS && currentTime > lastUpdateTime + POPUP_TIME)) {
        return;
    }
    int width = event.getResolution().getScaledWidth();
    int height = event.getResolution().getScaledHeight();
    PlayerData data = PlayerDataHandler.get(player);
    int chaos = data.getCurrentChaos();
    int maxChaos = data.getMaxChaos();
    int chaosHalves = (int) (20f * chaos / maxChaos);
    int rowHeight = 10;
    int left = width / 2 + 10;
    int top = height - GuiIngameForge.right_height;
    GuiIngameForge.right_height += rowHeight;
    final int textureX = 0;
    final int textureY = 23;
    final int textureWidth = 9;
    final int textureHeight = 9;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    mc.renderEngine.bindTexture(TEXTURE);
    for (int i = 9; i >= 0; --i) {
        int row = MathHelper.ceil((i + 1) / 10f) - 1;
        int x = left + i % 10 * 8;
        int y = top - row * rowHeight;
        GlStateManager.color(1f, 1f, 1f, 1f);
        drawTexturedModalRect(x, y, textureX + 2 * textureWidth, textureY, textureWidth, textureHeight);
        Color color = new Color();
        float hue = ((currentTime + COLOR_CHANGE_STEP * i) % COLOR_CHANGE_DELAY) / COLOR_CHANGE_DELAY;
        color.fromHSB(hue, 0.6f, 1f);
        GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1f);
        if (i * 2 + 1 < chaosHalves) {
            drawTexturedModalRect(x, y, textureX, textureY, textureWidth, textureHeight);
        } else if (i * 2 + 1 == chaosHalves) {
            drawTexturedModalRect(x, y, textureX + textureWidth, textureY, textureWidth, textureHeight);
        }
    }
    GlStateManager.color(1f, 1f, 1f, 1f);
    mc.renderEngine.bindTexture(Gui.ICONS);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
Also used : Color(org.lwjgl.util.Color) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Minecraft(net.minecraft.client.Minecraft) PlayerData(net.silentchaos512.gems.handler.PlayerDataHandler.PlayerData) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Color (net.silentchaos512.lib.util.Color)12 Color (net.silentchaos512.utils.Color)9 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)8 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)7 TextComponent (net.minecraft.network.chat.TextComponent)6 TextFormatting (net.minecraft.util.text.TextFormatting)6 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)6 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)6 MutableComponent (net.minecraft.network.chat.MutableComponent)4 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)4 Random (java.util.Random)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Item (net.minecraft.item.Item)3 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)3 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)3 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)3 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)3 UUID (java.util.UUID)2 Minecraft (net.minecraft.client.Minecraft)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2