Black spore particle
This commit is contained in:
parent
99f5a20d0b
commit
ae172a1517
11 changed files with 107 additions and 4 deletions
|
@ -6,9 +6,9 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class BlockShadowGrass extends BlockTerrain {
|
||||
public BlockShadowGrass() {
|
||||
|
@ -19,7 +19,7 @@ public class BlockShadowGrass extends BlockTerrain {
|
|||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
super.randomDisplayTick(state, world, pos, random);
|
||||
if (random.nextInt(32) == 0) {
|
||||
world.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
|
||||
world.addParticle(EndParticles.BLACK_SPORE, (double) pos.getX() + random.nextDouble(), (double) pos.getY() + 1.1D, (double) pos.getZ() + random.nextDouble(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
92
src/main/java/ru/betterend/particle/ParticleBlackSpore.java
Normal file
92
src/main/java/ru/betterend/particle/ParticleBlackSpore.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
package ru.betterend.particle;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.particle.AnimatedParticle;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleFactory;
|
||||
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||
import net.minecraft.client.particle.SpriteProvider;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ParticleBlackSpore extends AnimatedParticle {
|
||||
private double preVX;
|
||||
private double preVY;
|
||||
private double preVZ;
|
||||
private double nextVX;
|
||||
private double nextVY;
|
||||
private double nextVZ;
|
||||
|
||||
protected ParticleBlackSpore(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) {
|
||||
super(world, x, y, z, sprites, 0);
|
||||
setSprite(sprites.getSprite(random));
|
||||
|
||||
this.maxAge = MHelper.randRange(30, 60, random);
|
||||
this.scale = MHelper.randRange(0.05F, 0.15F, random);
|
||||
this.setColor(1, 1, 1);
|
||||
this.setColorAlpha(0);
|
||||
|
||||
preVX = random.nextGaussian() * 0.015;
|
||||
preVY = 0;
|
||||
preVZ = random.nextGaussian() * 0.015;
|
||||
|
||||
nextVX = random.nextGaussian() * 0.015;
|
||||
nextVY = random.nextFloat() * 0.02 + 0.01;
|
||||
nextVZ = random.nextGaussian() * 0.015;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
int ticks = this.age & 15;
|
||||
if (ticks == 0) {
|
||||
preVX = nextVX;
|
||||
preVY = nextVY;
|
||||
preVZ = nextVZ;
|
||||
nextVX = random.nextGaussian() * 0.015;
|
||||
nextVY = random.nextFloat() * 0.02 + 0.01;
|
||||
nextVZ = random.nextGaussian() * 0.015;
|
||||
}
|
||||
double delta = (double) ticks / 15.0;
|
||||
|
||||
if (this.age <= 15) {
|
||||
this.setColorAlpha(this.age / 15F);
|
||||
}
|
||||
else if (this.age >= this.maxAge - 15) {
|
||||
this.setColorAlpha((this.maxAge - this.age) / 15F);
|
||||
}
|
||||
|
||||
if (this.age >= this.maxAge) {
|
||||
this.markDead();
|
||||
}
|
||||
|
||||
this.velocityX = MathHelper.lerp(delta, preVX, nextVX);
|
||||
this.velocityY = MathHelper.lerp(delta, preVY, nextVY);
|
||||
this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ);
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleTextureSheet getType() {
|
||||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class FactoryBlackSpore implements ParticleFactory<DefaultParticleType> {
|
||||
|
||||
private final SpriteProvider sprites;
|
||||
|
||||
public FactoryBlackSpore(SpriteProvider sprites) {
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
|
||||
return new ParticleBlackSpore(world, x, y, z, 1, 1, 1, sprites);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import net.minecraft.util.registry.Registry;
|
|||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.particle.InfusionParticle;
|
||||
import ru.betterend.particle.InfusionParticleType;
|
||||
import ru.betterend.particle.ParticleBlackSpore;
|
||||
import ru.betterend.particle.ParticleGeyser;
|
||||
import ru.betterend.particle.ParticleGlowingSphere;
|
||||
import ru.betterend.particle.ParticleSnowflake;
|
||||
|
@ -23,6 +24,7 @@ public class EndParticles {
|
|||
public static final DefaultParticleType GEYSER_PARTICLE = registerFar("geyser_particle");
|
||||
public static final DefaultParticleType SNOWFLAKE = register("snowflake");
|
||||
public static final DefaultParticleType AMBER_SPHERE = register("amber_sphere");
|
||||
public static final DefaultParticleType BLACK_SPORE = register("black_spore");
|
||||
|
||||
public static void register() {
|
||||
ParticleFactoryRegistry.getInstance().register(GLOWING_SPHERE, ParticleGlowingSphere.FactoryGlowingSphere::new);
|
||||
|
@ -32,6 +34,7 @@ public class EndParticles {
|
|||
ParticleFactoryRegistry.getInstance().register(GEYSER_PARTICLE, ParticleGeyser.FactoryGeyser::new);
|
||||
ParticleFactoryRegistry.getInstance().register(SNOWFLAKE, ParticleSnowflake.FactorySnowflake::new);
|
||||
ParticleFactoryRegistry.getInstance().register(AMBER_SPHERE, ParticleGlowingSphere.FactoryGlowingSphere::new);
|
||||
ParticleFactoryRegistry.getInstance().register(BLACK_SPORE, ParticleBlackSpore.FactoryBlackSpore::new);
|
||||
}
|
||||
|
||||
private static DefaultParticleType register(String name) {
|
||||
|
|
|
@ -61,8 +61,6 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
return false;
|
||||
}
|
||||
|
||||
System.out.println(center);
|
||||
|
||||
Structure structure = getStructure(world, center, random);
|
||||
BlockRotation rotation = getRotation(world, center, random);
|
||||
BlockMirror mirror = getMirror(world, center, random);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue