diff --git a/src/main/java/ru/betterend/particle/AnimatedTestParticle.java b/src/main/java/ru/betterend/particle/AnimatedTestParticle.java deleted file mode 100644 index 03f53350..00000000 --- a/src/main/java/ru/betterend/particle/AnimatedTestParticle.java +++ /dev/null @@ -1,56 +0,0 @@ -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 ru.betterend.util.MHelper; - -@Environment(EnvType.CLIENT) -public class AnimatedTestParticle extends AnimatedParticle { - private int ticks; - - protected AnimatedTestParticle(ClientWorld world, double x, double y, double z, SpriteProvider sprites) { - super(world, x, y, z, sprites, 0); - setSprite(sprites.getSprite(random)); - this.maxAge = MHelper.randRange(20, 80, random); - this.scale = MHelper.randRange(0.1F, 0.3F, random); - this.setTargetColor(15916745); - this.setSpriteForAge(spriteProvider); - this.velocityX = random.nextGaussian() * 0.1F; - this.velocityY = random.nextGaussian() * 0.1F; - this.velocityZ = random.nextGaussian() * 0.1F; - } - - @Override - public void tick() { - ticks ++; - if (ticks > 10) { - this.velocityX = random.nextGaussian() * 0.1F; - this.velocityY = random.nextGaussian() * 0.1F; - this.velocityZ = random.nextGaussian() * 0.1F; - ticks = 0; - } - super.tick(); - } - - @Environment(EnvType.CLIENT) - public static class Factory implements ParticleFactory { - - private final SpriteProvider sprites; - - public Factory(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 AnimatedTestParticle(world, x, y, z, sprites); - } - } -} \ No newline at end of file diff --git a/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java b/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java new file mode 100644 index 00000000..376316f1 --- /dev/null +++ b/src/main/java/ru/betterend/particle/GlowingSphereParticleEffect.java @@ -0,0 +1,50 @@ +package ru.betterend.particle; + +import java.util.Locale; + +import net.minecraft.network.PacketByteBuf; +import net.minecraft.particle.ParticleEffect; +import net.minecraft.particle.ParticleType; +import net.minecraft.util.registry.Registry; +import ru.betterend.registry.ParticleRegistry; + +public class GlowingSphereParticleEffect implements ParticleEffect { + private final float red; + private final float green; + private final float blue; + + public GlowingSphereParticleEffect(float red, float green, float blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + + @Override + public ParticleType getType() { + return ParticleRegistry.GLOWING_SPHERE; + } + + @Override + public void write(PacketByteBuf buf) { + buf.writeFloat(this.red); + buf.writeFloat(this.green); + buf.writeFloat(this.blue); + } + + @Override + public String asString() { + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(this.getType()), this.red, this.green, this.blue); + } + + public float getRed() { + return this.red; + } + + public float getGreen() { + return this.green; + } + + public float getBlue() { + return this.blue; + } +} diff --git a/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java b/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java new file mode 100644 index 00000000..f7ac89bb --- /dev/null +++ b/src/main/java/ru/betterend/particle/ParticleGlowingSphere.java @@ -0,0 +1,76 @@ +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 ParticleGlowingSphere extends AnimatedParticle { + private int ticks; + private double preVX; + private double preVY; + private double preVZ; + private double nextVX; + private double nextVY; + private double nextVZ; + + protected ParticleGlowingSphere(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); + + 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() { + ticks ++; + if (ticks > 30) { + preVX = nextVX; + preVY = nextVY; + preVZ = nextVZ; + nextVX = random.nextGaussian() * 0.02; + nextVY = random.nextGaussian() * 0.02; + nextVZ = random.nextGaussian() * 0.02; + ticks = 0; + } + double delta = (double) ticks / 30.0; + + this.velocityX = MathHelper.lerp(delta, preVX, nextVX); + this.velocityY = MathHelper.lerp(delta, preVY, nextVY); + this.velocityZ = MathHelper.lerp(delta, preVZ, nextVZ); + + super.tick(); + } + + @Environment(EnvType.CLIENT) + public static class FactoryGlowingSphere implements ParticleFactory { + + private final SpriteProvider sprites; + + public FactoryGlowingSphere(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 ParticleGlowingSphere(world, x, y, z, sprites, 1, 1, 1); + } + } +} \ No newline at end of file diff --git a/src/main/java/ru/betterend/registry/ParticleRegistry.java b/src/main/java/ru/betterend/registry/ParticleRegistry.java index 2d45d681..51fe85b5 100644 --- a/src/main/java/ru/betterend/registry/ParticleRegistry.java +++ b/src/main/java/ru/betterend/registry/ParticleRegistry.java @@ -5,13 +5,13 @@ import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; import net.minecraft.particle.DefaultParticleType; import net.minecraft.util.registry.Registry; import ru.betterend.BetterEnd; -import ru.betterend.particle.AnimatedTestParticle; +import ru.betterend.particle.ParticleGlowingSphere; public class ParticleRegistry { - public static final DefaultParticleType TEST = register("test"); + public static final DefaultParticleType GLOWING_SPHERE = register("glowing_sphere"); public static void register() { - ParticleFactoryRegistry.getInstance().register(TEST, AnimatedTestParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(GLOWING_SPHERE, ParticleGlowingSphere.FactoryGlowingSphere::new); } private static DefaultParticleType register(String name) { diff --git a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java index 769d8644..fefd4f98 100644 --- a/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java +++ b/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java @@ -12,7 +12,7 @@ public class BiomeFoggyMushroomland extends EndBiome { .setWaterColor(119, 227, 250) .setWaterFogColor(119, 227, 250) .setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM) - .setParticles(ParticleRegistry.TEST, 0.001F) + .setParticles(ParticleRegistry.GLOWING_SPHERE, 0.001F) .addFeature(FeatureRegistry.ENDER_ORE) .addFeature(FeatureRegistry.END_LAKE) .addFeature(FeatureRegistry.MOSSY_GLOWSHROOM) diff --git a/src/main/resources/assets/betterend/particles/glowing_sphere.json b/src/main/resources/assets/betterend/particles/glowing_sphere.json new file mode 100644 index 00000000..9ede22c3 --- /dev/null +++ b/src/main/resources/assets/betterend/particles/glowing_sphere.json @@ -0,0 +1,38 @@ +{ + "textures": [ + "betterend:glowing_sphere_0", + "betterend:glowing_sphere_1", + "betterend:glowing_sphere_2", + "betterend:glowing_sphere_3", + "betterend:glowing_sphere_4", + + "betterend:glowing_sphere_5", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_7", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_5", + + "betterend:glowing_sphere_4", + + "betterend:glowing_sphere_5", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_7", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_5", + + "betterend:glowing_sphere_4", + + "betterend:glowing_sphere_5", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_7", + "betterend:glowing_sphere_6", + "betterend:glowing_sphere_5", + + "betterend:glowing_sphere_4", + + "betterend:glowing_sphere_3", + "betterend:glowing_sphere_2", + "betterend:glowing_sphere_1", + "betterend:glowing_sphere_0" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/particles/test.json b/src/main/resources/assets/betterend/particles/test.json deleted file mode 100644 index c531c014..00000000 --- a/src/main/resources/assets/betterend/particles/test.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "textures": [ - "minecraft:spell_0", - "minecraft:spell_1", - "minecraft:spell_2", - "minecraft:spell_3", - "minecraft:spell_4", - "minecraft:spell_5", - "minecraft:spell_6", - "minecraft:spell_7", - "minecraft:spell_6", - "minecraft:spell_5", - "minecraft:spell_4", - "minecraft:spell_3", - "minecraft:spell_2", - "minecraft:spell_1", - "minecraft:spell_0" - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_0.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_0.png new file mode 100644 index 00000000..1d310c5e Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_0.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_1.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_1.png new file mode 100644 index 00000000..bf13989c Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_1.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_2.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_2.png new file mode 100644 index 00000000..c6ee887b Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_2.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_3.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_3.png new file mode 100644 index 00000000..ecf5b04e Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_3.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_4.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_4.png new file mode 100644 index 00000000..0774c57c Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_4.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_5.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_5.png new file mode 100644 index 00000000..3ab7a8d8 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_5.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_6.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_6.png new file mode 100644 index 00000000..0399186b Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_6.png differ diff --git a/src/main/resources/assets/betterend/textures/particle/glowing_sphere_7.png b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_7.png new file mode 100644 index 00000000..9731544b Binary files /dev/null and b/src/main/resources/assets/betterend/textures/particle/glowing_sphere_7.png differ