Fireflies, small fixes
This commit is contained in:
parent
1168ec55b0
commit
31163e7658
7 changed files with 97 additions and 0 deletions
81
src/main/java/ru/betterend/particle/FireflyParticle.java
Normal file
81
src/main/java/ru/betterend/particle/FireflyParticle.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
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.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 FireflyParticle extends AnimatedParticle {
|
||||
private double preVX;
|
||||
private double preVY;
|
||||
private double preVZ;
|
||||
private double nextVX;
|
||||
private double nextVY;
|
||||
private double nextVZ;
|
||||
|
||||
protected FireflyParticle(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double r, double g, double b) {
|
||||
super(world, x, y, z, sprites, 0);
|
||||
setSprite(sprites.getSprite(random));
|
||||
this.maxAge = MHelper.randRange(150, 300, random);
|
||||
this.scale = MHelper.randRange(0.05F, 0.15F, random);
|
||||
this.setTargetColor(15916745);
|
||||
this.setSpriteForAge(spriteProvider);
|
||||
this.setColorAlpha(0);
|
||||
|
||||
preVX = random.nextGaussian() * 0.02;
|
||||
preVY = random.nextGaussian() * 0.02;
|
||||
preVZ = random.nextGaussian() * 0.02;
|
||||
|
||||
nextVX = random.nextGaussian() * 0.02;
|
||||
nextVY = random.nextGaussian() * 0.02;
|
||||
nextVZ = random.nextGaussian() * 0.02;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
int ticks = this.age & 31;
|
||||
if (ticks == 0) {
|
||||
preVX = nextVX;
|
||||
preVY = nextVY;
|
||||
preVZ = nextVZ;
|
||||
nextVX = random.nextGaussian() * 0.02;
|
||||
nextVY = random.nextGaussian() * 0.02;
|
||||
nextVZ = random.nextGaussian() * 0.02;
|
||||
}
|
||||
double delta = (double) ticks / 31.0;
|
||||
|
||||
this.velocityX = MathHelper.lerp(delta, preVX, nextVX);
|
||||
this.velocityY = MathHelper.lerp(delta, preVY, nextVY);
|
||||
this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ);
|
||||
|
||||
if (this.age <= 60) {
|
||||
this.setColorAlpha(this.age / 60F);
|
||||
}
|
||||
else if (this.age > maxAge - 60) {
|
||||
this.setColorAlpha((maxAge - this.age) / 60F);
|
||||
}
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class FireflyParticleFactory implements ParticleFactory<DefaultParticleType> {
|
||||
private final SpriteProvider sprites;
|
||||
|
||||
public FireflyParticleFactory(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 FireflyParticle(world, x, y, z, sprites, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import net.minecraft.particle.ParticleEffect;
|
|||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.particle.FireflyParticle;
|
||||
import ru.betterend.particle.InfusionParticle;
|
||||
import ru.betterend.particle.InfusionParticleType;
|
||||
import ru.betterend.particle.ParticleBlackSpore;
|
||||
|
@ -29,6 +30,7 @@ public class EndParticles {
|
|||
public static final DefaultParticleType BLACK_SPORE = register("black_spore");
|
||||
public static final DefaultParticleType TENANEA_PETAL = register("tenanea_petal");
|
||||
public static final DefaultParticleType JUNGLE_SPORE = register("jungle_spore");
|
||||
public static final DefaultParticleType FIREFLY = register("firefly");
|
||||
|
||||
public static void register() {
|
||||
ParticleFactoryRegistry.getInstance().register(GLOWING_SPHERE, ParticleGlowingSphere.FactoryGlowingSphere::new);
|
||||
|
@ -41,6 +43,7 @@ public class EndParticles {
|
|||
ParticleFactoryRegistry.getInstance().register(BLACK_SPORE, ParticleBlackSpore.FactoryBlackSpore::new);
|
||||
ParticleFactoryRegistry.getInstance().register(TENANEA_PETAL, ParticleTenaneaPetal.FactoryTenaneaPetal::new);
|
||||
ParticleFactoryRegistry.getInstance().register(JUNGLE_SPORE, ParticleJungleSpore.FactoryJungleSpore::new);
|
||||
ParticleFactoryRegistry.getInstance().register(FIREFLY, FireflyParticle.FireflyParticleFactory::new);
|
||||
}
|
||||
|
||||
private static DefaultParticleType register(String name) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.world.biome;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
|
||||
public class GlowingGrasslandsBiome extends EndBiome {
|
||||
|
@ -10,6 +11,7 @@ public class GlowingGrasslandsBiome extends EndBiome {
|
|||
super(new BiomeDefinition("glowing_grasslands")
|
||||
.setFogColor(99, 228, 247)
|
||||
.setFogDensity(1.3F)
|
||||
.setParticles(EndParticles.FIREFLY, 0.001F)
|
||||
.setMusic(EndSounds.MUSIC_OPENSPACE)
|
||||
.setSurface(EndBlocks.END_MOSS)
|
||||
.addFeature(EndFeatures.END_LAKE_RARE)
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
|||
import ru.betterend.blocks.BlockProperties.LumecornShape;
|
||||
import ru.betterend.blocks.LumecornBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
@ -19,6 +20,8 @@ import ru.betterend.world.features.DefaultFeature;
|
|||
public class Lumecorn extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
int height = MHelper.randRange(3, 6, random);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
for (int i = 1; i < height; i++) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"material": "canvas:emissive_no_diffuse"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"textures": [
|
||||
"betterend:firefly"
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
Add table
Add a link
Reference in a new issue