The great particle refactoring part 2: Splitting and Streamlining!

- Splits all particle textures into individual files intead of sprite sheets
- Replaces arc and lightning pulse entities with particles
- Pulls particle code up to the general ParticleWizardry so behaviours such as spin can be applied to all particle types
- Renames a few ParticleBuilder methods for conciseness.
- Adds a few new particle effects to various spells and entities, with a slight tweak to EntityMagicArrow#onBlockHit to facilitate impact effects
This commit is contained in:
Electroblob77
2019-01-01 21:40:04 +00:00
parent ad363c64af
commit b374f71533
201 changed files with 1682 additions and 1551 deletions
@@ -53,24 +53,13 @@ public class EntityBlizzard extends EntityMagicConstruct {
if(!MagicDamage.isEntityImmune(DamageType.FROST, target))
target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 20, 0));
}
}else{
for(int i=1; i<6; i++){
float brightness = 0.5f + (rand.nextFloat() / 2);
ParticleBuilder.create(Type.BLIZZARD)
.pos(this.posX, this.posY + rand.nextDouble() * 3, this.posZ)
.lifetime(100)
.colour(brightness, brightness + 0.1f, 1.0f)
.radius(rand.nextDouble() * 2.5d + 0.5d)
.spawn(world);
ParticleBuilder.create(Type.BLIZZARD)
.pos(this.posX, this.posY + rand.nextDouble() * 3, this.posZ)
.lifetime(100)
.colour(1, 1, 1)
.radius(rand.nextDouble() * 2.5d + 0.5d)
.spawn(world);
for(int i=1; i<12; i++){
double speed = (rand.nextBoolean() ? 1 : -1) * 0.1 + 0.05 * rand.nextDouble();
ParticleBuilder.create(Type.SNOW).pos(this.posX, this.posY + rand.nextDouble() * 3, this.posZ).vel(0, 0, 0)
.time(100).scale(2).spin(rand.nextDouble() * 2.5 + 0.5, speed).spawn(world);
}
}
}
@@ -53,7 +53,7 @@ public class EntityDecay extends EntityMagicConstruct {
ParticleBuilder.create(Type.DARK_MAGIC)
.pos(this.posX + radius * Math.cos(angle), this.posY, this.posZ + radius * Math.sin(angle))
.colour(brightness, 0, brightness + 0.1f)
.clr(brightness, 0, brightness + 0.1f)
.spawn(world);
}
}
@@ -66,8 +66,8 @@ public class EntityForcefield extends EntityMagicConstruct {
ParticleBuilder.create(Type.DUST)
.pos(this.posX + radius * Math.cos(yaw) * Math.cos(pitch), this.posY + 3 + radius * Math.sin(pitch),
this.posZ + radius * Math.sin(yaw) * Math.cos(pitch))
.lifetime(48 + this.rand.nextInt(12))
.colour(brightness, brightness, 1.0f).spawn(world);
.time(48 + this.rand.nextInt(12))
.clr(brightness, brightness, 1.0f).spawn(world);
}
}
}
@@ -3,7 +3,6 @@ package electroblob.wizardry.entity.construct;
import java.util.List;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.entity.EntityArc;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.MagicDamage.DamageType;
@@ -98,24 +97,12 @@ public class EntityHammer extends EntityMagicConstruct {
if(this.isValidTarget(target)){
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(this.posX, this.posY + this.height - 0.1, this.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
world.spawnEntity(arc);
}else{
// TODO: Move all the arc particle (and sound?) stuff into a method in WizardryUtilities
for(int j=0; j<8; j++){
ParticleBuilder.create(Type.SPARK)
.pos(target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5)
.spawn(world);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat(),
target.getEntityBoundingBox().minY + target.height / 2 + rand.nextFloat(),
target.posZ + rand.nextFloat(), 0, 0, 0);
}
if(world.isRemote){
ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world);
ParticleBuilder.spawnShockParticles(world, target.posX,
target.getEntityBoundingBox().minY + target.height, target.posZ);
}
target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, rand.nextFloat() * 0.4F + 1.5F);
@@ -69,8 +69,8 @@ public class EntityHealAura extends EntityMagicConstruct {
ParticleBuilder.create(Type.SPARKLE)
.pos(this.posX + radius * Math.cos(angle), this.posY, this.posZ + radius * Math.sin(angle))
.vel(0, 0.05, 0)
.lifetime(48 + this.rand.nextInt(12))
.colour(1.0f, 1.0f, brightness)
.time(48 + this.rand.nextInt(12))
.clr(1.0f, 1.0f, brightness)
.spawn(world);
}
}
@@ -1,18 +0,0 @@
package electroblob.wizardry.entity.construct;
import net.minecraft.world.World;
@Deprecated // This needs changing into a particle
public class EntityLightningPulse extends EntityMagicConstruct {
public EntityLightningPulse(World world){
super(world);
this.setSize(6, 0.2f);
}
@Override
public boolean canRenderOnFire(){
return false;
}
}
@@ -2,7 +2,6 @@ package electroblob.wizardry.entity.construct;
import java.util.List;
import electroblob.wizardry.entity.EntityArc;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.MagicDamage.DamageType;
@@ -11,7 +10,6 @@ import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
public class EntityLightningSigil extends EntityMagicConstruct {
@@ -65,25 +63,14 @@ public class EntityLightningSigil extends EntityMagicConstruct {
if(secondaryTarget != target && this.isValidTarget(secondaryTarget)){
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(target.posX, target.posY + target.height / 2, target.posZ,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2,
if(world.isRemote){
ParticleBuilder.create(Type.LIGHTNING).entity(target)
.pos(0, target.height/2, 0).target(secondaryTarget).spawn(world);
ParticleBuilder.spawnShockParticles(world, secondaryTarget.posX,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2,
secondaryTarget.posZ);
world.spawnEntity(arc);
}else{
for(int k = 0; k < 8; k++){
ParticleBuilder.create(Type.SPARK)
.pos(secondaryTarget.posX + world.rand.nextFloat() - 0.5,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + world.rand.nextFloat() * 2 - 1,
secondaryTarget.posZ + world.rand.nextFloat() - 0.5)
.spawn(world);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE,
secondaryTarget.posX + world.rand.nextFloat() - 0.5,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
secondaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F,
@@ -140,12 +140,14 @@ public class EntityTornado extends EntityMagicConstruct {
if(block.getMaterial() == Material.SNOW || block.getMaterial() == Material.CRAFTED_SNOW)
type = Type.SNOW;
double yPos1 = rand.nextDouble() * 8;
ParticleBuilder.create(type)
.pos(this.posX + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), this.posY + yPos1,
this.posZ + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d))
.lifetime(40 + rand.nextInt(10))
.spawn(world);
if(type != null){
double yPos1 = rand.nextDouble() * 8;
ParticleBuilder.create(type)
.pos(this.posX + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), this.posY + yPos1,
this.posZ + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d))
.time(40 + rand.nextInt(10))
.spawn(world);
}
}
}
}