use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class EntityAirGuardian method onUpdate.
@SuppressWarnings("incomplete-switch")
@Override
public void onUpdate() {
if (firstTick) {
this.tasks.addTask(0, new EntityAIGuardSpawnLocation(this, 0.5F, 5, 16, new AMVector3(this)));
this.firstTick = false;
}
this.orbitRotation += 2f;
this.orbitRotation %= 360;
switch(currentAction) {
case IDLE:
break;
case SPINNING:
this.spinRotation = (this.spinRotation - 40) % 360;
if (this.worldObj.isRemote) {
for (int i = 0; i < AMCore.config.getGFXLevel(); ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "wind", posX + worldObj.rand.nextDouble() * 4 - 2, posY, posZ + worldObj.rand.nextDouble() * 4 - 2);
if (particle != null) {
if (ticksInCurrentAction < BossActions.SPINNING.getMaxActionTime() - 10) {
particle.AddParticleController(new ParticleApproachEntity(particle, this, 0.2f, 0.5f, 1, true));
particle.AddParticleController(new ParticleFloatUpward(particle, 0.01f, 0.2f, 2, true));
} else {
particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 1, 1, false));
}
particle.setMaxAge(30);
}
}
}
break;
}
if (this.motionY < 0) {
this.motionY *= 0.8999999f;
}
if (this.posY < 150) {
if (worldObj.isRemote) {
for (int i = 0; i < 25; ++i) {
AMParticle wind = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "wind", posX, posY, posZ);
if (wind != null) {
wind.setIgnoreMaxAge(false);
wind.setMaxAge(10 + rand.nextInt(10));
wind.setDontRequireControllers();
wind.addRandomOffset(1, 1, 1);
//wind.AddParticleController(new PaticleFleePoint(wind, new AMVector3(this), rand.nextInt() * 0.1f + 0.01f, 10, 1, false));
}
}
} else {
if (this.posY < 145)
this.setDead();
}
}
super.onUpdate();
}
use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class FlickerOperatorGentleRains method DoOperation.
@Override
public boolean DoOperation(World worldObj, IFlickerController habitat, boolean powered) {
int radius = 6;
int diameter = radius * 2 + 1;
if (!worldObj.isRemote) {
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 - 1;
while (worldObj.isAirBlock(effectX, effectY, effectZ) && effectY > 0) {
effectY--;
}
while (!worldObj.isAirBlock(effectX, effectY, effectZ) && worldObj.getBlock(effectX, effectY, effectZ) != Blocks.farmland && effectY > 0) {
effectY++;
}
effectY--;
Block block = worldObj.getBlock(effectX, effectY, effectZ);
if (block == Blocks.farmland && worldObj.getBlockMetadata(effectX, effectY, effectZ) < 15) {
worldObj.setBlockMetadataWithNotify(effectX, effectY, effectZ, 15, 2);
return true;
}
} else {
for (int i = 0; i < AMCore.config.getGFXLevel() * 2; ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "water_ball", ((TileEntity) habitat).xCoord + 0.5, ((TileEntity) habitat).yCoord + 3, ((TileEntity) habitat).zCoord + 0.5);
if (particle != null) {
particle.setAffectedByGravity();
particle.setMaxAge(10);
particle.setDontRequireControllers();
particle.setParticleScale(0.03f);
particle.noClip = false;
particle.addRandomOffset(diameter, 0, diameter);
}
}
}
return false;
}
use of am2.particles.AMParticle 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;
}
use of am2.particles.AMParticle 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;
}
use of am2.particles.AMParticle 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;
}
Aggregations