Search in sources :

Example 6 with ParticleFloatUpward

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

the class Charm method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    for (int i = 0; i < 10; ++i) {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "heart", x, y, z);
        if (particle != null) {
            particle.addRandomOffset(1, 2, 1);
            particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.05f + rand.nextFloat() * 0.1f, 1, false));
            particle.setMaxAge(20);
            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) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 7 with ParticleFloatUpward

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

the class FlickerOperatorButchery method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
    HashMap<Class, Integer> entityCount = new HashMap<Class, Integer>();
    int radius = 6;
    List<EntityAnimal> creatures = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
    for (EntityAnimal creature : creatures) {
        Class clazz = creature.getClass();
        if (!SpawnBlacklists.canButcheryAffect(clazz))
            continue;
        Integer count = entityCount.get(clazz);
        if (count == null)
            count = 0;
        if (!creature.isChild())
            count++;
        entityCount.put(clazz, count);
        if (count > 2) {
            if (worldObj.isRemote) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ghost", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 0.7, ((TileEntity) habitat).zCoord + 0.5);
                if (particle != null) {
                    particle.setMaxAge(20);
                    particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.05f, 1, false));
                }
            } else {
                creature.attackEntityFrom(DamageSource.generic, 500);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) HashMap(java.util.HashMap) ParticleFloatUpward(am2.particles.ParticleFloatUpward) EntityAnimal(net.minecraft.entity.passive.EntityAnimal)

Example 8 with ParticleFloatUpward

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

the class FlickerOperatorLight method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
    if (!worldObj.isRemote) {
        int radius = 16;
        int yRadius = radius / 4;
        int checksPerOperation = 8;
        int checkX = ((TileEntity) habitat).xCoord - radius;
        int checkY = ((TileEntity) habitat).yCoord - yRadius;
        int checkZ = ((TileEntity) habitat).zCoord - radius;
        byte[] meta = habitat.getMetadata(this);
        if (meta.length != 0) {
            AMDataReader rdr = new AMDataReader(meta, false);
            checkX = rdr.getInt();
            checkY = rdr.getInt();
            checkZ = rdr.getInt();
        }
        for (int i = 0; i < checksPerOperation; ++i) {
            int light = worldObj.getBlockLightValue(checkX, checkY, checkZ);
            if (light < 10 && worldObj.isAirBlock(checkX, checkY, checkZ)) {
                worldObj.setBlock(checkX, checkY, checkZ, BlocksCommonProxy.invisibleUtility, 10, 2);
            }
            checkX++;
            if (checkX > ((TileEntity) habitat).xCoord + radius) {
                checkX = ((TileEntity) habitat).xCoord - radius;
                checkY++;
                if (checkY > ((TileEntity) habitat).yCoord + yRadius) {
                    checkY = ((TileEntity) habitat).yCoord - yRadius;
                    checkZ++;
                    if (checkZ > ((TileEntity) habitat).zCoord + radius) {
                        checkZ = ((TileEntity) habitat).zCoord - radius;
                    }
                }
            }
        }
        AMDataWriter writer = new AMDataWriter();
        writer.add(checkX).add(checkY).add(checkZ);
        habitat.setMetadata(this, writer.generate());
    } else {
        AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "sparkle", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 1, ((TileEntity) habitat).zCoord + 0.5);
        if (particle != null) {
            particle.addRandomOffset(0.5, 0.4, 0.5);
            particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.02f, 1, false));
            particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.05f));
            particle.setMaxAge(20);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) AMDataReader(am2.network.AMDataReader) ParticleFadeOut(am2.particles.ParticleFadeOut) ParticleFloatUpward(am2.particles.ParticleFloatUpward) AMDataWriter(am2.network.AMDataWriter)

Example 9 with ParticleFloatUpward

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

the class FlickerOperatorNaturesBounty method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered, Affinity[] flickers) {
    int radius = 6;
    int diameter = radius * 2 + 1;
    boolean updatedOnce = false;
    if (!worldObj.isRemote) {
        for (int i = 0; i < (powered ? 5 : 1); ++i) {
            int effectX = ((TileEntity) habitat).xCoord - radius + (worldObj.rand.nextInt(diameter));
            int effectZ = ((TileEntity) habitat).zCoord - radius + (worldObj.rand.nextInt(diameter));
            int effectY = ((TileEntity) habitat).yCoord;
            while (worldObj.isAirBlock(effectX, effectY, effectZ) && effectY > 0) {
                effectY--;
            }
            while (!worldObj.isAirBlock(effectX, effectY, effectZ) && effectY > 0) {
                effectY++;
            }
            effectY--;
            Block block = worldObj.getBlock(effectX, effectY, effectZ);
            if (block instanceof IPlantable || block instanceof IGrowable) {
                block.updateTick(worldObj, effectX, effectY, effectZ, worldObj.rand);
                updatedOnce = true;
            }
        }
    } else {
        int posY = ((TileEntity) habitat).yCoord;
        while (!worldObj.isAirBlock(((TileEntity) habitat).xCoord, posY, ((TileEntity) habitat).zCoord)) {
            posY++;
        }
        posY--;
        for (int i = 0; i < AMCore.config.getGFXLevel() * 2; ++i) {
            AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "plant", ((TileEntity) habitat).xCoord + 0.5, posY + 0.5f, ((TileEntity) habitat).zCoord + 0.5);
            if (particle != null) {
                particle.addRandomOffset(diameter, 0, diameter);
                particle.AddParticleController(new ParticleFloatUpward(particle, 0.01f, 0.04f, 1, false));
                particle.setMaxAge(16);
                particle.setParticleScale(0.08f);
            }
        }
    }
    if (powered) {
        for (Affinity aff : flickers) {
            if (aff == Affinity.WATER)
                FlickerOperatorRegistry.instance.getOperatorForMask(Affinity.WATER.getAffinityMask()).DoOperation(worldObj, habitat, powered);
        }
    }
    return updatedOnce;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) IGrowable(net.minecraft.block.IGrowable) IPlantable(net.minecraftforge.common.IPlantable) Block(net.minecraft.block.Block) Affinity(am2.api.spell.enums.Affinity) ParticleFloatUpward(am2.particles.ParticleFloatUpward)

Example 10 with ParticleFloatUpward

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

the class FlickerOperatorProgeny method DoOperation.

@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
    HashMap<Class, Integer> entityCount = new HashMap<Class, Integer>();
    int radius = 8;
    int diameter = radius * 2 + 1;
    List<EntityAnimal> creatures = worldObj.getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
    for (EntityAnimal creature : creatures) {
        Class clazz = creature.getClass();
        if (!SpawnBlacklists.canProgenyAffect(clazz))
            continue;
        Integer count = entityCount.get(clazz);
        if (count == null)
            count = 0;
        if (!creature.isInLove() && creature.getGrowingAge() == 0)
            count++;
        entityCount.put(clazz, count);
        if (count == 2) {
            if (worldObj.isRemote) {
                AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "heart", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 0.7, ((TileEntity) habitat).zCoord + 0.5);
                if (particle != null) {
                    particle.setMaxAge(20);
                    particle.AddParticleController(new ParticleFloatUpward(particle, 0, 0.05f, 1, false));
                }
            } else {
                creatures = worldObj.getEntitiesWithinAABB(clazz, AxisAlignedBB.getBoundingBox(((TileEntity) habitat).xCoord - radius, ((TileEntity) habitat).yCoord - radius, ((TileEntity) habitat).zCoord - radius, ((TileEntity) habitat).xCoord + radius + 1, ((TileEntity) habitat).yCoord + radius + 1, ((TileEntity) habitat).zCoord + radius + 1));
                count = 0;
                for (EntityAnimal animal : creatures) {
                    if (!animal.isChild()) {
                        animal.func_146082_f(null);
                        count++;
                        if (count == 2)
                            break;
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMParticle(am2.particles.AMParticle) HashMap(java.util.HashMap) ParticleFloatUpward(am2.particles.ParticleFloatUpward) EntityAnimal(net.minecraft.entity.passive.EntityAnimal)

Aggregations

AMParticle (am2.particles.AMParticle)39 ParticleFloatUpward (am2.particles.ParticleFloatUpward)38 ParticleFadeOut (am2.particles.ParticleFadeOut)11 ParticleOrbitEntity (am2.particles.ParticleOrbitEntity)7 AMVector3 (am2.api.math.AMVector3)4 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ParticleOrbitPoint (am2.particles.ParticleOrbitPoint)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)2 ParticleHoldPosition (am2.particles.ParticleHoldPosition)2 ParticleMoveOnHeading (am2.particles.ParticleMoveOnHeading)2 Colour (am2.spell.modifiers.Colour)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Block (net.minecraft.block.Block)2 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)2