Search in sources :

Example 6 with ParticleHoldPosition

use of am2.particles.ParticleHoldPosition in project ArsMagica2 by Mithion.

the class MeltArmor method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "radiant", x + 0.5, y + 0.5, z + 0.5);
    if (particle != null) {
        particle.AddParticleController(new ParticleHoldPosition(particle, 20, 1, false));
        particle.setMaxAge(20);
        particle.setParticleScale(0.3f);
        particle.setRGBColorF(0.7f, 0.4f, 0.2f);
        particle.SetParticleAlpha(0.1f);
        if (colorModifier > -1) {
            particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition)

Example 7 with ParticleHoldPosition

use of am2.particles.ParticleHoldPosition in project ArsMagica2 by Mithion.

the class TileEntityInscriptionTable method candleUpdate.

private void candleUpdate() {
    ticksToNextParticle--;
    if (isRenderingLeft()) {
        if (ticksToNextParticle == 0 || ticksToNextParticle == 15) {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & ~0x8;
            double particleX = 0;
            double particleZ = 0;
            switch(meta) {
                case 1:
                    particleX = this.xCoord + 0.15;
                    particleZ = this.zCoord + 0.22;
                    break;
                case 2:
                    particleX = this.xCoord + 0.22;
                    particleZ = this.zCoord + 0.85;
                    break;
                case 3:
                    particleX = this.xCoord + 0.83;
                    particleZ = this.zCoord + 0.78;
                    break;
                case 4:
                    particleX = this.xCoord + 0.79;
                    particleZ = this.zCoord + 0.15;
                    break;
            }
            ticksToNextParticle = 30;
            AMParticle effect = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "fire", particleX, yCoord + 1.32, particleZ);
            if (effect != null) {
                effect.setParticleScale(0.025f, 0.1f, 0.025f);
                effect.AddParticleController(new ParticleHoldPosition(effect, 29, 1, false));
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(400);
            }
            if (worldObj.rand.nextInt(100) > 80) {
                AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ);
                if (smoke != null) {
                    smoke.setParticleScale(0.025f);
                    smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false));
                    smoke.setIgnoreMaxAge(false);
                    smoke.setMaxAge(20 + worldObj.rand.nextInt(10));
                }
            }
        }
        if (ticksToNextParticle == 10 || ticksToNextParticle == 25) {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & ~0x8;
            double particleX = 0;
            double particleZ = 0;
            switch(meta) {
                case 1:
                    particleX = this.xCoord + 0.59;
                    particleZ = this.zCoord - 0.72;
                    break;
                case 2:
                    particleX = this.xCoord - 0.72;
                    particleZ = this.zCoord + 0.41;
                    break;
                case 3:
                    particleX = this.xCoord + 0.41;
                    particleZ = this.zCoord + 1.72;
                    break;
                case 4:
                    particleX = this.xCoord + 1.72;
                    particleZ = this.zCoord + 0.60;
                    break;
            }
            AMParticle effect = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "fire", particleX, yCoord + 1.26, particleZ);
            if (effect != null) {
                effect.setParticleScale(0.025f, 0.1f, 0.025f);
                effect.AddParticleController(new ParticleHoldPosition(effect, 29, 1, false));
                effect.setIgnoreMaxAge(false);
                effect.setMaxAge(400);
            }
            if (worldObj.rand.nextInt(100) > 80) {
                AMParticle smoke = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ);
                if (smoke != null) {
                    smoke.setParticleScale(0.025f);
                    smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false));
                    smoke.setIgnoreMaxAge(false);
                    smoke.setMaxAge(20 + worldObj.rand.nextInt(10));
                }
            }
        }
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 8 with ParticleHoldPosition

use of am2.particles.ParticleHoldPosition in project ArsMagica2 by Mithion.

the class ItemCandle method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!stack.hasTagCompound() || !stack.stackTagCompound.hasKey("search_block")) {
        Block block = world.getBlock(x, y, z);
        if (player.isSneaking() && block != null && block.getBlockHardness(world, x, y, z) > 0f && world.getTileEntity(x, y, z) == null) {
            if (!world.isRemote) {
                setSearchBlock(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z), stack);
                world.setBlockToAir(x, y, z);
            } else {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "radiant", x + 0.5, y + 0.5, z + 0.5);
                if (particle != null) {
                    particle.AddParticleController(new ParticleHoldPosition(particle, 20, 1, false));
                    particle.setRGBColorF(0, 0.5f, 1);
                }
            }
            return true;
        }
    }
    if (!world.isRemote) {
        if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("search_block")) {
            player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.candlecantplace")));
            return false;
        }
        switch(side) {
            case 0:
                y--;
                break;
            case 1:
                y++;
                break;
            case 2:
                z--;
                break;
            case 3:
                z++;
                break;
            case 4:
                x--;
                break;
            case 5:
                x++;
                break;
        }
        Block block = world.getBlock(x, y, z);
        if (block == null || block.isReplaceable(world, x, y, z)) {
            int newMeta = (int) Math.ceil(stack.getItemDamage() / 1200);
            world.setBlock(x, y, z, BlocksCommonProxy.candle, newMeta, 2);
            if (!player.capabilities.isCreativeMode)
                player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
        }
        return true;
    }
    return false;
}
Also used : AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) Block(net.minecraft.block.Block) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 9 with ParticleHoldPosition

use of am2.particles.ParticleHoldPosition in project ArsMagica2 by Mithion.

the class ItemFrameWatcher method spawnCompendiumCompleteParticles.

@SideOnly(Side.CLIENT)
public void spawnCompendiumCompleteParticles(EntityItemFrame frame) {
    AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(frame.worldObj, "radiant", frame.posX, frame.posY, frame.posZ);
    if (particle != null) {
        particle.setIgnoreMaxAge(false);
        particle.setMaxAge(40);
        particle.setParticleScale(0.3f);
        //particle.AddParticleController(new ParticleApproachEntity(particle, frame, 0.02f, 0.04f, 1, false).setKillParticleOnFinish(true));
        particle.AddParticleController(new ParticleHoldPosition(particle, 40, 1, false));
        particle.AddParticleController(new ParticleColorShift(particle, 1, false).SetShiftSpeed(0.2f));
    }
}
Also used : AMParticle(am2.particles.AMParticle) ParticleColorShift(am2.particles.ParticleColorShift) ParticleHoldPosition(am2.particles.ParticleHoldPosition) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 10 with ParticleHoldPosition

use of am2.particles.ParticleHoldPosition in project ArsMagica2 by Mithion.

the class EntitySpellProjectile method onUpdate.

@Override
public void onUpdate() {
    //super.onUpdate();
    if (!worldObj.isRemote && (getShootingEntity() == null || getShootingEntity().isDead)) {
        setDead();
    } else {
        ticksExisted++;
        int maxTicksToLive = maxTicksToExist > -1 ? maxTicksToExist : 100;
        if (ticksExisted >= maxTicksToLive && !worldObj.isRemote) {
            setDead();
            return;
        }
    }
    //TODO Fix homing
    if (this.dataWatcher.getWatchableObjectByte(DW_HOMING) != (byte) 0 && this.ticksExisted > 10) {
        if (this.dataWatcher.getWatchableObjectInt(DW_HOMING_TARGET) == -1) {
            findHomingTarget();
        } else {
            EntityLivingBase homingTarget = getHomingEntity();
            //AMCore.log.info("%.2f, %.2f, %.2f", posX, posY, posZ);
            LogHelper.trace("Homing Target: " + getHomingEntity());
            if (homingTarget != null && new AMVector3(this).distanceSqTo(new AMVector3(homingTarget)) > 2) {
                this.moveTowards(homingTarget, 60, 60);
            }
        }
    }
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = null;
    movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1, true);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
        vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int j = 0; j < list.size(); j++) {
        Entity entity1 = (Entity) list.get(j);
        if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(getShootingEntity())) {
            continue;
        }
        float f2 = 0.3F;
        AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
        MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
        if (movingobjectposition1 == null) {
            continue;
        }
        double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
        if (d1 < d || d == 0.0D) {
            entity = entity1;
            d = d1;
        }
    }
    if (entity != null) {
        if (entity instanceof EntityDragonPart && ((EntityDragonPart) entity).entityDragonObj != null && ((EntityDragonPart) entity).entityDragonObj instanceof EntityLivingBase) {
            entity = (EntityLivingBase) ((EntityDragonPart) entity).entityDragonObj;
        }
        movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null) {
        boolean doHit = true;
        boolean pierce = this.getNumPierces() > 0;
        if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityLivingBase) {
            EntityLivingBase ent = (EntityLivingBase) movingobjectposition.entityHit;
            if (ent.isPotionActive(BuffList.spellReflect.id) && !pierce) {
                doHit = false;
                this.setShootingEntity(ent);
                this.motionX = -this.motionX;
                this.motionY = -this.motionY;
                this.motionZ = -this.motionZ;
                if (!worldObj.isRemote)
                    ent.removePotionEffect(BuffList.spellReflect.id);
                setBounces(originalBounceCount);
                if (worldObj.isRemote) {
                    for (int i = 0; i < 13; ++i) {
                        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "hr_lensflare", ent.posX + rand.nextDouble() - 0.5, ent.posY + ent.getEyeHeight() + rand.nextDouble() - 0.5, ent.posZ + rand.nextDouble() - 0.5);
                        if (effect != null) {
                            EntityPlayer player = AMCore.instance.proxy.getLocalPlayer();
                            effect.setIgnoreMaxAge(true);
                            if (player != null && ent != player) {
                                effect.setParticleScale(1.5f);
                            }
                            effect.setRGBColorF(0.5f + rand.nextFloat() * 0.5f, 0.2f, 0.5f + rand.nextFloat() * 0.5f);
                            effect.AddParticleController(new ParticleHoldPosition(effect, 100, 1, false));
                        }
                    }
                }
            }
        } else if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK && getBounces() > 0) {
            doHit = false;
            switch(movingobjectposition.sideHit) {
                case 0:
                case 1:
                    motionY = motionY * friction_coefficient * -1;
                    break;
                case 2:
                case 3:
                    motionZ = motionZ * friction_coefficient * -1;
                    break;
                case 4:
                case 5:
                    motionX = motionX * friction_coefficient * -1;
                    break;
            }
            this.setBounces(getBounces() - 1);
        }
        if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
            Block block = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
            AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
            if (bb == null && !SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, getEffectStack(), 0))
                doHit = false;
        }
        if (doHit)
            HitObject(movingobjectposition, pierce);
    }
    if (getGravity() < 0 && motionY > GRAVITY_TERMINAL_VELOCITY) {
        this.motionY += getGravity();
    } else if (getGravity() > 0 && motionY < -GRAVITY_TERMINAL_VELOCITY) {
        this.motionY -= getGravity();
    }
    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) (Math.atan2(motionX, motionZ));
    for (rotationPitch = (float) (Math.atan2(motionY, f)); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
    }
    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
    }
    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
    }
    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
    }
    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;
    if (isInWater()) {
        for (int k = 0; k < 4; k++) {
            float f3 = 0.25F;
            worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ);
        }
        f1 = 0.8F;
    }
    if (!AMCore.config.NoGFX() && worldObj.isRemote && this.getShootingEntity() instanceof EntityPlayer) {
        if (this.particleType == null || this.particleType.isEmpty())
            particleType = AMParticleIcons.instance.getSecondaryParticleForAffinity(SpellUtils.instance.mainAffinityFor(getEffectStack()));
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, particleType, this.posX, this.posY, this.posZ);
        if (particle != null) {
            particle.addRandomOffset(0.3f, 0.3f, 0.3f);
            particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 0, 1, false));
            particle.setMaxAge(10);
            particle.setParticleScale(0.05f);
        }
    }
    setPosition(posX, posY, posZ);
}
Also used : Entity(net.minecraft.entity.Entity) AMParticle(am2.particles.AMParticle) ParticleHoldPosition(am2.particles.ParticleHoldPosition) ParticleFloatUpward(am2.particles.ParticleFloatUpward) AMVector3(am2.api.math.AMVector3) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) ArrayList(java.util.ArrayList) BuffList(am2.buffs.BuffList) List(java.util.List)

Aggregations

ParticleHoldPosition (am2.particles.ParticleHoldPosition)11 AMParticle (am2.particles.AMParticle)10 ParticleColorShift (am2.particles.ParticleColorShift)2 ParticleFloatUpward (am2.particles.ParticleFloatUpward)2 List (java.util.List)2 Block (net.minecraft.block.Block)2 Entity (net.minecraft.entity.Entity)2 AMVector3 (am2.api.math.AMVector3)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 BuffList (am2.buffs.BuffList)1 ParticleChangeSize (am2.particles.ParticleChangeSize)1 ParticleFadeOut (am2.particles.ParticleFadeOut)1 ParticleOrbitPoint (am2.particles.ParticleOrbitPoint)1 Colour (am2.spell.modifiers.Colour)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ArrayList (java.util.ArrayList)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1