-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
220 additions
and
35 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
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
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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
package com.goby56.wakes.particle; | ||
|
||
import com.goby56.wakes.WakesClient; | ||
import com.goby56.wakes.particle.custom.SplashCloudParticle; | ||
import com.goby56.wakes.particle.custom.SplashPlaneParticle; | ||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; | ||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; | ||
import net.minecraft.particle.DefaultParticleType; | ||
import net.minecraft.particle.ParticleType; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class ModParticles { | ||
public static SplashPlaneParticleType SPLASH_PLANE; | ||
public static WithOwnerParticleType SPLASH_PLANE; | ||
public static DefaultParticleType SPLASH_CLOUD = FabricParticleTypes.simple(); | ||
|
||
public static void registerParticles() { | ||
SPLASH_PLANE = Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "splash_plane"), new SplashPlaneParticleType(true)); | ||
SPLASH_PLANE = Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "splash_plane"), new WithOwnerParticleType(true)); | ||
ParticleFactoryRegistry.getInstance().register(SPLASH_PLANE, SplashPlaneParticle.Factory::new); | ||
|
||
Registry.register(Registries.PARTICLE_TYPE, new Identifier(WakesClient.MOD_ID, "splash_cloud"), SPLASH_CLOUD); | ||
ParticleFactoryRegistry.getInstance().register(SPLASH_CLOUD, SplashCloudParticle.Factory::new); | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
src/main/java/com/goby56/wakes/particle/custom/SplashCloudParticle.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,76 @@ | ||
package com.goby56.wakes.particle.custom; | ||
|
||
import com.goby56.wakes.particle.WithOwnerParticleType; | ||
import com.goby56.wakes.utils.WakesUtils; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.client.particle.*; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.particle.DefaultParticleType; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class SplashCloudParticle extends SpriteBillboardParticle { | ||
|
||
public SplashCloudParticle(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double velocityX, double velocityY, double velocityZ) { | ||
super(world, x, y, z, velocityX, velocityY, velocityZ); | ||
|
||
this.velocityX += 0.001f * (world.random.nextGaussian() - 0.5f); | ||
this.velocityY += 0.01f * Math.abs(world.random.nextGaussian() - 0.5f); | ||
this.velocityZ += 0.001f * (world.random.nextGaussian() - 0.5f); | ||
|
||
this.prevPosX = x; | ||
this.prevPosY = y; | ||
this.prevPosZ = z; | ||
|
||
this.maxAge = 15; | ||
this.scale *= 2; | ||
this.setSprite(sprites.getSprite(world.random)); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
this.prevPosX = this.x; | ||
this.prevPosY = this.y; | ||
this.prevPosZ = this.z; | ||
if (this.age++ >= this.maxAge) { | ||
this.markDead(); | ||
return; | ||
} | ||
this.alpha = 1f - (float) this.age / this.maxAge; | ||
|
||
Vec3d pos = new Vec3d(this.x, this.y, this.z); | ||
BlockState currBlock = this.world.getBlockState(WakesUtils.vecToBlockPos(pos)); | ||
|
||
if (currBlock.isAir()) { | ||
this.velocityY -= 0.02f; | ||
} else if (currBlock.isOf(Blocks.WATER)) { | ||
this.velocityY += 0.01f; | ||
} | ||
this.velocityX *= 0.99f; | ||
this.velocityY *= 0.5f; | ||
this.velocityZ *= 0.99f; | ||
this.move(velocityX, velocityY, velocityZ); | ||
} | ||
|
||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; | ||
} | ||
|
||
public static class Factory implements ParticleFactory<DefaultParticleType> { | ||
private final SpriteProvider sprites; | ||
|
||
public Factory(SpriteProvider spriteSet) { | ||
this.sprites = spriteSet; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { | ||
return new SplashCloudParticle(world, x, y, z, this.sprites, velocityX, velocityY, velocityZ); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.