-
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 20240715 - Re-Implemented Cannon Turret
Re-implemented the Cannon Turret, allowing it to now exist in-game without crashing. However, the entity isn't animated yet and isn't shooting its designated projectile yet. TODO: Fix animations. [CHANGELOG] 🟢 Re-added the Client entry point for all the client side codes needed. 🟢 Re-added the Cannon Flash particle. (Not yet working). 🟢 Re-added the Cannon Fuse particle. (Not yet working). 🟢 Re-Added ModParticles class for registering and initializing particles from the mod. 🟢 Re-Added ModEntityRenderer class for registering and initializing mod entity renderers. 🟢 Re-Added ModCriterion class for registering and initializing mod criterions. 🟢 Re-Added the Turret Item Retrieved Criterion, which is used by the Turret Remover equipment. 🟢 Re-Added the overridden tick() method in the Cannon Turret class. 🟢 Re-Added the overridden interactMob() method in the Cannon Turret class to let the entity be disassembled and picked up as an item. 🟢 Temporarily added SPAWN_TURRET packet after re-adding the ModPackets class. 🟢 Re-Added all mod sound events via ModSoundEvents class. 🟡 Updated editor configuration file to let .yml and .yaml to use space instead of tabs for its indentation. 🟡 Updated the Yarn mappings for Minecraft source to 1.21+build.9. 🟡 Changed the allocated memory for Gradle back to 2GB max. 🟡 Moved Cannon Turret's model and renderer classes to the client side package. 🟡 Refactored all registry classes to now log something. 🟡 Updated the dimensions of Cannon Turrets to match their model size. 🟡 Updated Cannon Turret's shoot and heal sounds to now match the pre 1.21 rework. 🟡 Fully implemented the entire Itemable interface. 🟡 Refactored some codes from the pre 1.21 rework which crashes the game. 🟡 Updated some lines of codes to conform to the modern and good practice uses like in the iniDataTracker() method of TurretEntity. 🟡 Added a message shown to players when spawning a Turret via the item. Can be seen in TurretItem. ONLY FOR DEVELOPMENT. 🟡 Separated the client side code and server side code for creating, registering, and initializing particles. 🟡 Updated the animation file for Cannon Turret to conform to GeckoLib 4.5's format and syntax. 🟡 Updated the "barrel" locator for the Cannon Turret model. 🟡 Refactored custom tags to remove all blocks and entities that aren't re-added yet to prevent warnings from spamming the logs. 🔴 Temporarily removed all unneeded and unused animation assets. 🔴 Temporarily removed all unneeded and unused model assets.
- Loading branch information
Showing
43 changed files
with
926 additions
and
2,143 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
30 changes: 30 additions & 0 deletions
30
src/client/java/com/virus5600/defensive_measures/DefensiveMeasuresClient.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,30 @@ | ||
package com.virus5600.defensive_measures; | ||
|
||
import com.virus5600.defensive_measures.particle.ModParticles; | ||
import com.virus5600.defensive_measures.renderer.ModEntityRenderer; | ||
import net.fabricmc.api.ClientModInitializer; | ||
|
||
/** | ||
* The second main entry point of the mod. | ||
* | ||
* This class holds the client-specific initialization processes | ||
* along with the needed C2S packet registrations. | ||
*/ | ||
public class DefensiveMeasuresClient implements ClientModInitializer { | ||
|
||
/** | ||
* Client side initialization. | ||
*/ | ||
@Override | ||
public void onInitializeClient() { | ||
DefensiveMeasures.LOGGER.info("INITIALIZING CLIENT ENTRY POINT FOR {}...", DefensiveMeasures.MOD_NAME); | ||
|
||
// Renderers | ||
ModEntityRenderer.registerEntityRenderers(); | ||
ModParticles.registerParticles(); | ||
|
||
// Networking | ||
|
||
DefensiveMeasures.LOGGER.info("{} CLIENT ENTRY POINT INITIALIZED.", DefensiveMeasures.MOD_NAME); | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/client/java/com/virus5600/defensive_measures/particle/ModParticles.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,36 @@ | ||
package com.virus5600.defensive_measures.particle; | ||
|
||
import com.virus5600.defensive_measures.DefensiveMeasures; | ||
|
||
import com.virus5600.defensive_measures.particle.custom.*; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; | ||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; | ||
import net.minecraft.particle.SimpleParticleType; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class ModParticles { | ||
public static final SimpleParticleType CANNON_FUSE = register("cannon_fuse", true); | ||
public static final SimpleParticleType CANNON_FLASH = register("cannon_flash", false); | ||
|
||
private static SimpleParticleType register(String identifier, boolean shouldAlwaysSpawn) { | ||
return Registry.register( | ||
Registries.PARTICLE_TYPE, | ||
identifier, | ||
FabricParticleTypes.simple(shouldAlwaysSpawn) | ||
); | ||
} | ||
|
||
public static void registerParticles() { | ||
DefensiveMeasures.LOGGER.info("REGISTERING PARTICLES FOR {}...", DefensiveMeasures.MOD_NAME); | ||
|
||
ParticleFactoryRegistry registry = ParticleFactoryRegistry.getInstance(); | ||
|
||
registry.register(ModParticles.CANNON_FUSE, CannonFuse.Factory::new); | ||
registry.register(ModParticles.CANNON_FLASH, CannonFlash.Factory::new); | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
src/client/java/com/virus5600/defensive_measures/particle/custom/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,121 @@ | ||
package com.virus5600.defensive_measures.particle.custom; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.particle.*; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.particle.SimpleParticleType; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
/** | ||
* 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 SpriteBillboardParticle { | ||
private final Vec3d source; | ||
|
||
/// CONSTRUCTORS /// | ||
protected CannonFlash(ClientWorld level, double x, double y, double z, SpriteProvider spriteSet, double xd, double yd, double zd) { | ||
super(level, x, y, z, xd, yd, zd); | ||
|
||
this.velocityMultiplier = 1f; | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.scale *= 0.5f; | ||
this.maxAge = 20; | ||
this.gravityStrength = 1f; | ||
this.collidesWithWorld = true; | ||
this.setSpriteForAge(spriteSet); | ||
this.setVelocity(xd, yd, zd); | ||
this.source = new Vec3d(x, y, z); | ||
|
||
this.red = 1f; | ||
this.green= 1f; | ||
this.blue = 1f; | ||
} | ||
|
||
/// METHODS /// | ||
// PRIVATE | ||
private void fadeOut() { | ||
// Turns the particle black (Simulates tar color) | ||
if (this.age < 20 && this.red > 0.1 && this.green > 0.1 && this.blue > 0.1) { | ||
this.red -= 0.05f; | ||
this.green -= 0.05f; | ||
this.blue -= 0.05f; | ||
} | ||
|
||
// Fades the particle out and make it small overtime | ||
if (this.red <= 0.1 && this.green <= 0.1 && this.blue <= 0.1 && this.alpha > 0.05) { | ||
this.alpha -= 0.05F; | ||
|
||
if (this.scale > 0) | ||
this.scale = Math.min(this.scale - 0.5f, 0); | ||
} | ||
} | ||
|
||
// PUBLIC | ||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; | ||
} | ||
|
||
@Override | ||
public int getBrightness(float tint) { | ||
int i = super.getBrightness(tint); | ||
@SuppressWarnings("unused") int j = 240; | ||
int k = i >> 16 & 0xFF; | ||
|
||
return 0xF0 | k << 16; | ||
} | ||
|
||
@Override | ||
public float getSize(float tickDelta) { | ||
float f = ((float)this.age + tickDelta) / (float)this.maxAge; | ||
|
||
return this.scale * (1.0f - f * f); | ||
} | ||
|
||
public void setVelocity(double vx, double vy, double vz) { | ||
super.setVelocity(vx, vy, vz); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.tick(); | ||
this.fadeOut(); | ||
|
||
if (this.dead) { | ||
for (int i = 0; i < MathHelper.nextInt(this.random, 1, 3); i++) { | ||
this.world.addParticle( | ||
ParticleTypes.CAMPFIRE_COSY_SMOKE, | ||
this.source.x, | ||
this.source.y, | ||
this.source.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) | ||
); | ||
} | ||
} | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static class Factory implements ParticleFactory<SimpleParticleType> { | ||
private final SpriteProvider sprites; | ||
|
||
public Factory(SpriteProvider sprites) { | ||
this.sprites = sprites; | ||
} | ||
|
||
public Particle createParticle(SimpleParticleType type, ClientWorld level, double x, double y, double z, double xd, double yd, double zd) { | ||
return new CannonFlash(level, x, y, z, this.sprites, xd, yd, zd); | ||
} | ||
|
||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
src/client/java/com/virus5600/defensive_measures/particle/custom/CannonFuse.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,109 @@ | ||
package com.virus5600.defensive_measures.particle.custom; | ||
|
||
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.particle.ParticleTextureSheet; | ||
import net.minecraft.client.particle.SpriteBillboardParticle; | ||
import net.minecraft.client.particle.SpriteProvider; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.particle.SimpleParticleType; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
/** | ||
* Defines the particles emitted by the {@link com.virus5600.defensive_measures.entity.turrets.CannonTurretEntity Cannon Turret} | ||
* when charging up to fire. | ||
* The particle is a small flame that fades out over time, emitting from the back | ||
* of the cannon. | ||
*/ | ||
@Environment(EnvType.CLIENT) | ||
public class CannonFuse extends SpriteBillboardParticle { | ||
private final Vec3d source; | ||
|
||
/// CONSTRUCTORS /// | ||
protected CannonFuse(ClientWorld level, double x, double y, double z, SpriteProvider spriteSet, double xd, double yd, double zd) { | ||
super(level, x, y, z, xd, yd, zd); | ||
|
||
this.velocityMultiplier = 0.75f; | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.scale *= 0.5f; | ||
this.maxAge = 25; | ||
this.gravityStrength = 1f; | ||
this.collidesWithWorld = true; | ||
this.setSpriteForAge(spriteSet); | ||
this.source = new Vec3d(x, y, z); | ||
|
||
this.red = 1f; | ||
this.green= 1f; | ||
this.blue = 1f; | ||
} | ||
|
||
/// METHODS /// | ||
// PRIVATE | ||
private void fadeOut() { | ||
// Turns the particle black (Simulates tar color) | ||
if (this.age < 10 && this.red > 0.1 && this.green > 0.1 && this.blue > 0.1) { | ||
this.red -= 0.05f; | ||
this.green -= 0.05f; | ||
this.blue -= 0.05f; | ||
} | ||
|
||
// Fades the particle out | ||
if (this.red <= 0.1 && this.green <= 0.1 && this.blue <= 0.1 && this.alpha > 0.05) { | ||
this.alpha -= 0.05F; | ||
} | ||
} | ||
|
||
// PUBLIC | ||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; | ||
} | ||
|
||
@Override | ||
public int getBrightness(float tint) { | ||
int i = super.getBrightness(tint); | ||
@SuppressWarnings("unused") int j = 240; | ||
int k = i >> 16 & 0xFF; | ||
|
||
return 0xF0 | k << 16; | ||
} | ||
|
||
@Override | ||
public float getSize(float tickDelta) { | ||
float f = ((float)this.age + tickDelta) / (float)this.maxAge; | ||
|
||
return this.scale * (1.0f - f * f); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.tick(); | ||
this.fadeOut(); | ||
|
||
if (this.age < 10) { | ||
if (MathHelper.nextInt(this.random, 0, 100) > 90) { | ||
this.world.addParticle(ParticleTypes.SMOKE, this.source.x, this.source.y, this.source.z, MathHelper.nextDouble(this.random, -0.01, 0.01), MathHelper.clamp(Math.abs(this.velocityY), 0.0625, 0.125), MathHelper.nextDouble(this.random, -0.01, 0.01)); | ||
} | ||
} | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static class Factory implements ParticleFactory<SimpleParticleType> { | ||
private final SpriteProvider sprites; | ||
|
||
public Factory(SpriteProvider sprites) { | ||
this.sprites = sprites; | ||
} | ||
|
||
public Particle createParticle(SimpleParticleType type, ClientWorld level, double x, double y, double z, double xd, double yd, double zd) { | ||
return new CannonFuse(level, x, y, z, this.sprites, xd, yd, zd); | ||
} | ||
|
||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/client/java/com/virus5600/defensive_measures/renderer/ModEntityRenderer.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,19 @@ | ||
package com.virus5600.defensive_measures.renderer; | ||
|
||
import com.virus5600.defensive_measures.DefensiveMeasures; | ||
import com.virus5600.defensive_measures.entity.ModEntities; | ||
import com.virus5600.defensive_measures.renderer.entity.CannonTurretRenderer; | ||
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; | ||
|
||
public class ModEntityRenderer { | ||
public static void registerEntityRenderers() { | ||
DefensiveMeasures.LOGGER.info("REGISTERING ENTITY RENDERERS FOR {}...", DefensiveMeasures.MOD_NAME); | ||
|
||
///////////// | ||
// TURRETS // | ||
///////////// | ||
|
||
// v1.0.0 | ||
EntityRendererRegistry.register(ModEntities.CANNON_TURRET, CannonTurretRenderer::new); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/client/java/com/virus5600/defensive_measures/renderer/entity/CannonTurretRenderer.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,14 @@ | ||
package com.virus5600.defensive_measures.renderer.entity; | ||
|
||
import com.virus5600.defensive_measures.model.entity.CannonTurretModel; | ||
import net.minecraft.client.render.entity.EntityRendererFactory.Context; | ||
|
||
import com.virus5600.defensive_measures.entity.turrets.CannonTurretEntity; | ||
|
||
import software.bernie.geckolib.renderer.GeoEntityRenderer; | ||
|
||
public class CannonTurretRenderer extends GeoEntityRenderer<CannonTurretEntity> { | ||
public CannonTurretRenderer(Context ctx) { | ||
super(ctx, new CannonTurretModel()); | ||
} | ||
} |
Oops, something went wrong.