Search in sources :

Example 11 with Color

use of net.silentchaos512.lib.util.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 12 with Color

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

the class ItemDrawingCompass method spawnParticles.

public boolean spawnParticles(ItemStack stack, EntityPlayer player, World world) {
    BlockPos pos1 = getBlock1(stack);
    BlockPos pos2 = getBlock2(stack);
    if (pos1.getY() <= 0 || pos2.getY() <= 0 || pos1.equals(pos2)) {
        return false;
    }
    Color color = getColor(stack);
    // Spawn circle.
    BlockPos center = new BlockPos(pos1.getX(), pos2.getY(), pos1.getZ());
    float radius = (float) Math.sqrt(center.distanceSq(pos2));
    int count = (int) (5 * radius);
    float increment = (float) (2 * Math.PI / count);
    float start = increment * (world.getTotalWorldTime() % 30) / 30f;
    Vec3d vec;
    for (float angle = start; angle < 2 * Math.PI + start; angle += increment) {
        vec = new Vec3d(radius, 0, 0).rotateYaw(angle);
        particle(player, world, color, center.getX() + 0.5 + vec.x, center.getY() + 0.5 + vec.y, center.getZ() + 0.5 + vec.z);
    }
    // Spawn line.
    double distance = Math.sqrt(pos1.distanceSq(pos2));
    count = (int) (2 * distance);
    double dx = (double) (pos2.getX() - pos1.getX()) / count;
    double dy = (double) (pos2.getY() - pos1.getY()) / count;
    double dz = (double) (pos2.getZ() - pos1.getZ()) / count;
    for (int i = 0; i < count; ++i) {
        vec = new Vec3d(pos1.getX() + 0.5 + i * dx, pos1.getY() + 0.5 + i * dy, pos1.getZ() + 0.5 + i * dz);
        particle(player, world, color, vec.x, vec.y, vec.z);
    }
    return true;
}
Also used : Color(net.silentchaos512.lib.util.Color) EnumDyeColor(net.minecraft.item.EnumDyeColor) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with Color

use of net.silentchaos512.lib.util.Color 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 14 with Color

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

the class PotionFreezing method performEffect.

@Override
public void performEffect(EntityLivingBase entityLiving, int amplifier) {
    if (CONTINUOUS_DAMAGE_ENABLED) {
        // Continuous freeze damage.
        PotionEffect effect = entityLiving.getActivePotionEffect(this);
        if (effect == null)
            return;
        int damageDelay = CONTINUOUS_DAMAGE_DELAY;
        // Extra damage for mobs immune to fire (like blazes)
        if (entityLiving.isImmuneToFire())
            damageDelay /= 4;
        if (effect.getDuration() % damageDelay == 0) {
            int damageAmount = CONTINUOUS_DAMAGE_AMOUNT;
            entityLiving.attackEntityFrom(ModDamageSource.FREEZING, damageAmount);
        }
    }
    // Spawn freeze effect particles.
    Random rand = SilentGems.random;
    for (int i = 0; i < 2; ++i) {
        double posX = entityLiving.posX + 1.2f * (rand.nextFloat() - 0.5f) * entityLiving.width;
        double posY = entityLiving.posY + 1.1f * rand.nextFloat() * entityLiving.height;
        double posZ = entityLiving.posZ + 1.2f * (rand.nextFloat() - 0.5f) * entityLiving.width;
        double motionX = 0.005 * rand.nextGaussian();
        double motionY = 0.005 * rand.nextGaussian();
        double motionZ = 0.005 * rand.nextGaussian();
        SilentGems.proxy.spawnParticles(EnumModParticles.FREEZING, new Color(0x76e3f2), entityLiving.world, posX, posY, posZ, motionX, motionY, motionZ);
    }
}
Also used : Random(java.util.Random) PotionEffect(net.minecraft.potion.PotionEffect) Color(net.silentchaos512.lib.util.Color)

Example 15 with Color

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

the class PotionShocking method performEffect.

@Override
public void performEffect(EntityLivingBase entityLiving, int amplifier) {
    PotionEffect effect = entityLiving.getActivePotionEffect(this);
    if (effect == null)
        return;
    int shockTimer = effect.getDuration();
    if (!entityLiving.world.isRemote && CHAINING_ENABLED) {
        int halfTime = shockTimer / 2;
        // Chain to nearby mobs. Half this mob's time and effect level 1.
        if (shockTimer % CHAIN_DELAY == 0 && halfTime > 0) {
            for (EntityLivingBase nearby : entityLiving.world.getEntities(EntityLivingBase.class, e -> e.getDistanceSqToEntity(entityLiving) < CHAIN_RADIUS_SQUARED && !(e instanceof EntityPlayer))) {
                PotionEffect effectNearby = nearby.getActivePotionEffect(this);
                if (effectNearby == null) {
                    nearby.addPotionEffect(new PotionEffect(this, halfTime, 0, true, false));
                }
            }
        }
    }
    if (!entityLiving.world.isRemote && CONTINUOUS_DAMAGE_ENABLED) {
        // Continuous shock damage.
        int damageDelay = CONTINUOUS_DAMAGE_DELAY;
        // Add entity ID for a bit of "randomness"
        if ((shockTimer + entityLiving.getEntityId()) % damageDelay == 0) {
            int damageAmount = CONTINUOUS_DAMAGE_AMOUNT;
            entityLiving.attackEntityFrom(ModDamageSource.SHOCKING, damageAmount);
        }
    }
    // Spawn shock effect particles.
    Random rand = SilentGems.random;
    for (int i = 0; i < 3 - SilentGems.proxy.getParticleSettings(); ++i) {
        double posX = entityLiving.posX + 1.2f * (rand.nextFloat() - 0.5f) * entityLiving.width;
        double posY = entityLiving.posY + 1.1f * rand.nextFloat() * entityLiving.height;
        double posZ = entityLiving.posZ + 1.2f * (rand.nextFloat() - 0.5f) * entityLiving.width;
        double motionX = 0.02 * rand.nextGaussian();
        double motionY = 0.05 + Math.abs(0.1 * rand.nextGaussian());
        double motionZ = 0.02 * rand.nextGaussian();
        SilentGems.proxy.spawnParticles(EnumModParticles.SHOCKING, new Color(0xffef63), entityLiving.world, posX, posY, posZ, motionX, motionY, motionZ);
    }
}
Also used : Random(java.util.Random) PotionEffect(net.minecraft.potion.PotionEffect) Color(net.silentchaos512.lib.util.Color) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

Color (net.silentchaos512.lib.util.Color)9 TextFormatting (net.minecraft.util.text.TextFormatting)5 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)5 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)4 Random (java.util.Random)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Item (net.minecraft.item.Item)3 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)3 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)3 UUID (java.util.UUID)2 Minecraft (net.minecraft.client.Minecraft)2 ItemStack (net.minecraft.item.ItemStack)2 PotionEffect (net.minecraft.potion.PotionEffect)2 Vec3d (net.minecraft.util.math.Vec3d)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)2 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)2 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)2 IBlockState (net.minecraft.block.state.IBlockState)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1