-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 20241228 - Cannon Turret Implementation
Finally implemented a fully working Cannon Turret (without its projectile - Cannonball). [CHANGELOG] 🟢 Added a base particle emitter class called "CustomEmitter" which provides a base for all emitter type particles such as the Cannon Flash. 🟢 Created a copy of the Projectile Attack Goal class but with an added flexibility of knowing when the entity is shooting or not. 🟡 Renamed CannonFlash into Sparks. 🟡 Updated Cannon Turret's renderer class to prevent the entity from using the standard death rotation animation upon death. 🟡 Updated the Cannon Turret entity class to now minimize usage of other unnecessary and redundant fields, along with its particle keyframe fix and animation fix. 🟡 Moved all RawAnimation instances into a Map for easier access and for reusability (Cannon Turret Entity). 🟡 Updated the value of the "@author" in all class and interface documentation to a link to my GitHub. 🟡 Shortened the animation length of Cannon Fuse to allow the particle's position to immediately update when the Cannon Turret swung its barrel. 🟡 Renamed the particle JSON file of Cannon Flash from "cannon_flash" to "sparks". 🔴 Removed some processes in the Sparks (formerly known as Cannon Flash) and moved it somewhere else. 🔴 Removed all unneeded and redundant data in Turret Entity base entity class.
- Loading branch information
Showing
15 changed files
with
702 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/client/java/com/virus5600/defensive_measures/particle/custom/emitters/CannonFlash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.virus5600.defensive_measures.particle.custom.emitters; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleFactory; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.particle.SimpleParticleType; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
import com.virus5600.defensive_measures.particle.ModParticles; | ||
|
||
/** | ||
* Defines the particles emitted by the {@link com.virus5600.defensive_measures.entity.turrets.CannonTurretEntity Cannon Turret} | ||
* when it fires. | ||
* The particle shots out in a cone shape and fades out over time. The direction is | ||
* determined by the direction the turret is facing. | ||
*/ | ||
@Environment(EnvType.CLIENT) | ||
public class CannonFlash extends CustomEmitter { | ||
/// CONSTRUCTORS /// | ||
public CannonFlash(ClientWorld world, double x, double y, double z, double vx, double vy, double vz) { | ||
super(world, ModParticles.SPARKS, x, y, z, 9); | ||
this.velocityX = vx; | ||
this.velocityY = vy; | ||
this.velocityZ = vz; | ||
this.setCustomEmitterCode(); | ||
} | ||
|
||
public CannonFlash(ClientWorld world, Entity entity, double vx, double vy, double vz) { | ||
super(world, entity, ModParticles.SPARKS, 9); | ||
this.velocityX = vx; | ||
this.velocityY = vy; | ||
this.velocityZ = vz; | ||
this.setCustomEmitterCode(); | ||
} | ||
|
||
// CUSTOM EMITTER CODE // | ||
private void setCustomEmitterCode() { | ||
this.customEmitterCode = (particle) -> { | ||
// Flash | ||
if (this.age < 3) { | ||
double variance = 0.75; | ||
double minX = this.velocityX - variance, | ||
maxX = this.velocityX + variance, | ||
minY = this.velocityY - variance, | ||
maxY = this.velocityY + variance, | ||
minZ = this.velocityZ - variance, | ||
maxZ = this.velocityZ + variance; | ||
|
||
for (int i = 0; i < MathHelper.nextInt(this.random, 10, 25); i++) { | ||
this.world.addParticle( | ||
particle, | ||
this.getPosSource().x, | ||
this.getPosSource().y, | ||
this.getPosSource().z, | ||
MathHelper.nextDouble(this.random, minX, maxX), | ||
MathHelper.nextDouble(this.random, minY, maxY), | ||
MathHelper.nextDouble(this.random, minZ, maxZ) | ||
); | ||
} | ||
} | ||
|
||
// Smoke | ||
if (this.age >= this.maxAge) { | ||
for (int i = 0; i < MathHelper.nextInt(this.random, 1, 3); i++) { | ||
this.world.addParticle( | ||
ParticleTypes.CAMPFIRE_COSY_SMOKE, | ||
this.getPosSource().x, | ||
this.getPosSource().y, | ||
this.getPosSource().z, | ||
MathHelper.nextDouble(this.random, -0.01, 0.01), | ||
MathHelper.nextDouble(this.random, 0.01, 0.025), | ||
MathHelper.nextDouble(this.random, -0.01, 0.01) | ||
); | ||
} | ||
} | ||
|
||
return null; | ||
}; | ||
} | ||
|
||
/// FACTORY /// | ||
@Environment(EnvType.CLIENT) | ||
public static class Factory implements ParticleFactory<SimpleParticleType> { | ||
public Particle createParticle(SimpleParticleType simpleParticleType, ClientWorld world, double x, double y, double z, double vx, double vy, double vz) { | ||
return new CannonFlash(world, x, y, z, vx, vy, vz); | ||
} | ||
} | ||
} |
Oops, something went wrong.