Search in sources :

Example 6 with Color

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

the class GuiToolSouls method renderAPBarForItem.

private static void renderAPBarForItem(ItemStack stack, int xPosition, int yPosition) {
    if (!stack.isEmpty()) {
        ToolSoul soul = SoulManager.getSoul(stack);
        if (soul != null) {
            // SilentGems.logHelper.debug(soul);
            GlStateManager.disableLighting();
            GlStateManager.disableDepth();
            GlStateManager.disableTexture2D();
            GlStateManager.disableAlpha();
            GlStateManager.disableBlend();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();
            double ap = 1.0 - ((double) soul.getActionPoints() / soul.getMaxActionPoints());
            int rgbfordisplay = new Color(0f, 0.75f * (1f - (float) ap), 1f).getColor();
            int i = Math.round(13.0F - (float) ap * 13.0F);
            int j = rgbfordisplay;
            draw(bufferbuilder, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
            draw(bufferbuilder, xPosition + 2, yPosition + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
            GlStateManager.enableBlend();
            GlStateManager.enableAlpha();
            GlStateManager.enableTexture2D();
            GlStateManager.enableLighting();
            GlStateManager.enableDepth();
        }
    // EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
    // float f3 = entityplayersp == null ? 0.0F
    // : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(),
    // Minecraft.getMinecraft().getRenderPartialTicks());
    // 
    // if (f3 > 0.0F) {
    // GlStateManager.disableLighting();
    // GlStateManager.disableDepth();
    // GlStateManager.disableTexture2D();
    // Tessellator tessellator1 = Tessellator.getInstance();
    // BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
    // this.draw(bufferbuilder1, xPosition, yPosition + MathHelper.floor(16.0F * (1.0F - f3)), 16,
    // MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
    // //        GlStateManager.enableTexture2D();
    // //        GlStateManager.enableLighting();
    // //        GlStateManager.enableDepth();
    // }
    }
}
Also used : ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Color(net.silentchaos512.lib.util.Color)

Example 7 with Color

use of net.silentchaos512.utils.Color 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 8 with Color

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

the class TileChaosFlowerPot method tryPlacePhantomLight.

private boolean tryPlacePhantomLight() {
    if (world.isRemote || StackHelper.isEmpty(getFlowerItemStack())) {
        return false;
    }
    Random rand = SilentGems.random;
    // final int step = ticksExisted / TRY_LIGHT_DELAY - 1;
    // step > 7
    final boolean longRange = rand.nextFloat() < 0.5f;
    // SilentGems.instance.logHelper.debug(ticksExisted, step, longRange);
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    int dist = 8 + (longRange ? 6 : 0);
    // Select a random angle to rotate target position around center.
    final int k = longRange ? 8 : 4;
    final int angleFactor = rand.nextInt(2 * k);
    Vec3d vec = new Vec3d(dist, 0, 0);
    // vec = vec.rotateYaw(rand.nextInt(2 * k) / (float) k * (float) Math.PI);
    // final int angleFactor = step - (longRange ? 8 : 0);
    vec = vec.rotateYaw(angleFactor / (float) k * (float) Math.PI);
    x += Math.round(vec.xCoord);
    // rand.nextInt(5) - 2;
    y += 2;
    z += Math.round(vec.zCoord);
    MutableBlockPos tryPos = new MutableBlockPos(x, y, z);
    // Debug particles
    if (SilentGems.proxy.isClientPlayerHoldingDebugItem()) {
        // Debug particles: try position
        Color debugColor = new Color(0.4f, 0f, 1f);
        for (int i = 0; i < 100; ++i) {
            SilentGems.proxy.spawnParticles(EnumModParticles.CHAOS, debugColor, world, x + 0.5, y, z + 0.5, 0.005f * rand.nextGaussian(), 0.25f * rand.nextGaussian(), 0.005f * rand.nextGaussian());
        }
        // Debug particles: ring
        for (float f = 0; f < 2 * Math.PI; f += Math.PI / 32) {
            Vec3d v = new Vec3d(dist, 0, 0).rotateYaw(f);
            SilentGems.proxy.spawnParticles(EnumModParticles.CHAOS, debugColor, world, pos.getX() + 0.5 + v.xCoord, pos.getY() + 0.5, pos.getZ() + 0.5 + v.zCoord, 0, 0, 0);
        }
    }
    if (canPlacePhantomLightAt(tryPos)) {
        placePhantomLightAt(tryPos);
        return true;
    }
    for (int ty = y + 1; ty > y - 2; --ty) {
        for (int tx = x - 1; tx < x + 2; ++tx) {
            for (int tz = z - 1; tz < z + 2; ++tz) {
                tryPos.setPos(tx, ty, tz);
                if (canPlacePhantomLightAt(tryPos)) {
                    placePhantomLightAt(tryPos);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Random(java.util.Random) Color(net.silentchaos512.lib.util.Color) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with Color

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

the class ArmorHelper method recalculateStats.

public static void recalculateStats(ItemStack armor) {
    ToolPart[] parts = getConstructionParts(armor);
    EnumMaterialGrade[] grades = getConstructionGrades(armor);
    if (parts.length == 0)
        return;
    // TODO: Reset render cache? Will that even be a thing for armor?
    float sumDurability = 0f;
    float sumProtection = 0f;
    // TODO: Toughness?
    float sumEnchantability = 0f;
    Set<ToolPart> uniqueParts = Sets.newConcurrentHashSet();
    // Get sum stats for parts.
    for (int i = 0; i < parts.length; ++i) {
        ToolPart part = parts[i];
        EnumMaterialGrade grade = grades[i];
        float multi = (100 + grade.bonusPercent) / 100f;
        sumDurability += part.getDurability() * multi;
        sumProtection += part.getProtection() * multi;
        sumEnchantability += part.getEnchantability() * multi;
        uniqueParts.add(part);
    }
    // Set render colors
    ToolPart[] renderParts = getRenderParts(armor);
    for (int i = 0; i < renderParts.length; ++i) {
        if (renderParts[i] != null) {
            setTagInt(armor, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + i + "Color", renderParts[i].getColor(armor));
        }
    }
    // Variety bonus
    int variety = MathHelper.clamp(uniqueParts.size(), 1, 3);
    float bonus = 1.0f + GemsConfig.VARIETY_BONUS * (variety - 1);
    // Average stats
    float durability = bonus * sumDurability / parts.length;
    float protection = bonus * sumProtection / parts.length;
    float enchantability = bonus * sumEnchantability / parts.length;
    // Set NBT
    setTagInt(armor, NBT_ROOT_PROPERTIES, NBT_PROP_DURABILITY, (int) durability);
    setTagFloat(armor, NBT_ROOT_PROPERTIES, NBT_PROP_PROTECTION, protection);
    setTagInt(armor, NBT_ROOT_PROPERTIES, NBT_PROP_ENCHANTABILITY, (int) enchantability);
    setTagInt(armor, NBT_ROOT_PROPERTIES, NBT_ARMOR_TIER, parts[0].getTier().ordinal());
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade)

Example 10 with Color

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

the class GemsClientProxy method spawnParticles.

// Particles
@Override
public void spawnParticles(EnumModParticles type, Color color, World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
    Particle fx = null;
    float r = color.getRed();
    float g = color.getGreen();
    float b = color.getBlue();
    switch(type) {
        case CHAOS:
            // fx = new EntityFXChaos(world, x, y, z, motionX, motionY, motionZ, 2.0f, 25, r, g, b);
            fx = new FXChaos(world, x, y, z, .2f, r, g, b, 25).setSpeed(motionX, motionY, motionZ);
            break;
        case CHAOS_PROJECTILE_BODY:
            // fx = new EntityFXChaos(world, x, y, z, 0f, 0f, 0f, 3.0f, 1, r, g, b);
            fx = new FXChaos(world, x, y, z, .3f, r, g, b, 2);
            break;
        case CHAOS_PACKET_HEAD:
            // fx = new EntityFXChaos(world, x, y, z, motionX, motionY, motionZ, 2.0f, 0, r, g, b);
            fx = new FXChaos(world, x, y, z, .2f, r, g, b, 1).setSpeed(motionX, motionY, motionZ);
            break;
        case CHAOS_PACKET_TAIL:
            // fx = new EntityFXChaos(world, x, y, z, motionX, motionY, motionZ, 1.0f, 25, r, g, b);
            fx = new FXChaos(world, x, y, z, .1f, r, g, b, 15).setSpeed(motionX, motionY, motionZ);
            break;
        case CHAOS_NODE:
            // fx = new EntityFXChaos(world, x, y, z, motionX, motionY, motionZ, 3.0f, 20, r, g, b);
            fx = new FXChaos(world, x, y, z, .3f, r, g, b, 20).setSpeed(motionX, motionY, motionZ);
            break;
        case PHANTOM_LIGHT:
            // fx = new EntityFXChaos(world, x, y, z, motionX, motionY, motionZ, 1.0f, 15, r, g, b);
            fx = new FXChaos(world, x, y, z, .1f, r, g, b, 15).setSpeed(motionX, motionY, motionZ);
            break;
        case DRAWING_COMPASS:
            fx = new EntityFXCompass(world, x, y, z, motionX, motionY, motionZ, 1.0f, 10, r, g, b);
            break;
        default:
            throw new NotImplementedException("Unknown particle type: " + type);
    }
    if (fx != null) {
        Minecraft.getMinecraft().effectRenderer.addEffect(fx);
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) FXChaos(net.silentchaos512.gems.client.fx.FXChaos) NotImplementedException(org.apache.commons.lang3.NotImplementedException) EntityFXCompass(net.silentchaos512.gems.client.render.particle.EntityFXCompass)

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