Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -2,25 +2,26 @@ 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.SimpleAnimatedParticle;
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 net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class FireflyParticle extends AnimatedParticle {
public class FireflyParticle extends SimpleAnimatedParticle {
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) {
protected FireflyParticle(ClientLevel world, double x, double y, double z, SpriteSet 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);
@ -28,16 +29,16 @@ public class FireflyParticle extends AnimatedParticle {
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;
@ -50,31 +51,31 @@ public class FireflyParticle extends AnimatedParticle {
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age <= 60) {
this.setColorAlpha(this.age / 60F);
}
else if (this.age > maxAge - 60) {
} 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 static class FireflyParticleFactory implements ParticleFactory<SimpleParticleType> {
private final SpriteSet sprites;
public FireflyParticleFactory(SpriteProvider sprites) {
public FireflyParticleFactory(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new FireflyParticle(world, x, y, z, sprites, 1, 1, 1);
}
}

View file

@ -3,12 +3,12 @@ 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 net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.Registry;
import ru.betterend.registry.EndParticles;
public class GlowingSphereParticleEffect implements ParticleEffect {
public class GlowingSphereParticleEffect implements ParticleOptions {
private final float red;
private final float green;
private final float blue;
@ -33,7 +33,8 @@ public class GlowingSphereParticleEffect implements ParticleEffect {
@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);
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(this.getType()), this.red,
this.green, this.blue);
}
public float getRed() {

View file

@ -6,14 +6,15 @@ 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.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
public class InfusionParticle extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
public InfusionParticle(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, float[] palette, SpriteProvider spriteProvider) {
private final SpriteSet spriteProvider;
public InfusionParticle(ClientLevel clientWorld, double x, double y, double z, double velocityX, double velocityY,
double velocityZ, float[] palette, SpriteSet spriteProvider) {
super(clientWorld, x, y, z, 0.0, 0.0, 0.0);
this.setSpriteForAge(spriteProvider);
this.spriteProvider = spriteProvider;
@ -30,7 +31,7 @@ public class InfusionParticle extends SpriteBillboardParticle {
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
this.prevPosX = this.x;
@ -49,13 +50,14 @@ public class InfusionParticle extends SpriteBillboardParticle {
@Environment(EnvType.CLIENT)
public static class InfusionFactory implements ParticleFactory<InfusionParticleType> {
private final SpriteProvider spriteProvider;
public InfusionFactory(SpriteProvider spriteProvider) {
private final SpriteSet spriteProvider;
public InfusionFactory(SpriteSet spriteProvider) {
this.spriteProvider = spriteProvider;
}
public Particle createParticle(InfusionParticleType particleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i) {
public Particle createParticle(InfusionParticleType particleType, ClientLevel clientWorld, double d, double e,
double f, double g, double h, double i) {
return new InfusionParticle(clientWorld, d, e, f, g, h, i, particleType.getPalette(), this.spriteProvider);
}
}

View file

@ -8,25 +8,27 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.command.argument.ItemStackArgument;
import net.minecraft.command.argument.ItemStringReader;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.util.registry.Registry;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.Registry;
import ru.betterend.registry.EndParticles;
import ru.betterend.util.ColorUtil;
public class InfusionParticleType extends ParticleType<InfusionParticleType> implements ParticleEffect {
public class InfusionParticleType extends ParticleType<InfusionParticleType> implements ParticleOptions {
public static final Codec<InfusionParticleType> CODEC = ItemStack.CODEC.xmap(itemStack -> {
return new InfusionParticleType(EndParticles.INFUSION, itemStack);
}, infusionParticleType -> {
return infusionParticleType.itemStack;
});
public static final ParticleEffect.Factory<InfusionParticleType> PARAMETERS_FACTORY = new ParticleEffect.Factory<InfusionParticleType>() {
public InfusionParticleType read(ParticleType<InfusionParticleType> particleType, StringReader stringReader) throws CommandSyntaxException {
public static final ParticleOptions.Factory<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Factory<InfusionParticleType>() {
public InfusionParticleType read(ParticleType<InfusionParticleType> particleType, StringReader stringReader)
throws CommandSyntaxException {
stringReader.expect(' ');
ItemStringReader itemStringReader = new ItemStringReader(stringReader, false).consume();
ItemStack itemStack = new ItemStackArgument(itemStringReader.getItem(), itemStringReader.getTag()).createStack(1, false);
ItemStack itemStack = new ItemStackArgument(itemStringReader.getItem(), itemStringReader.getTag())
.createStack(1, false);
return new InfusionParticleType(particleType, itemStack);
}
@ -34,20 +36,20 @@ public class InfusionParticleType extends ParticleType<InfusionParticleType> imp
return new InfusionParticleType(particleType, packetByteBuf.readItemStack());
}
};
private ParticleType<InfusionParticleType> type;
private ItemStack itemStack;
public InfusionParticleType(ParticleType<InfusionParticleType> particleType, ItemStack stack) {
super(true, PARAMETERS_FACTORY);
this.type = particleType;
this.itemStack = stack;
}
public InfusionParticleType(ItemStack stack) {
this(EndParticles.INFUSION, stack);
}
@Environment(EnvType.CLIENT)
public float[] getPalette() {
int color = ColorUtil.extractColor(itemStack.getItem());

View file

@ -2,43 +2,44 @@ 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.SimpleAnimatedParticle;
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 net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleBlackSpore extends AnimatedParticle {
public class ParticleBlackSpore extends SimpleAnimatedParticle {
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) {
protected ParticleBlackSpore(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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;
@ -51,41 +52,41 @@ public class ParticleBlackSpore extends AnimatedParticle {
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) {
} 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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.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> {
public static class FactoryBlackSpore implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactoryBlackSpore(SpriteProvider sprites) {
public FactoryBlackSpore(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleBlackSpore(world, x, y, z, 1, 1, 1, sprites);
}
}

View file

@ -6,19 +6,20 @@ 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.DefaultParticleType;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.BlockPos.MutableBlockPos;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleGeyser extends SpriteBillboardParticle {
private Mutable mut = new Mutable();
private MutableBlockPos mut = new MutableBlockPos();
private boolean changeDir = false;
private boolean check = true;
protected ParticleGeyser(ClientWorld world, double x, double y, double z, double vx, double vy, double vz, SpriteProvider sprites) {
protected ParticleGeyser(ClientLevel world, double x, double y, double z, double vx, double vy, double vz,
SpriteSet sprites) {
super(world, x, y, z, vx, vy, vz);
setSprite(sprites);
this.maxAge = MHelper.randRange(400, 800, random);
@ -27,28 +28,26 @@ public class ParticleGeyser extends SpriteBillboardParticle {
this.velocityZ = vz;
this.prevPosY = y - 0.125;
}
@Override
public void tick() {
if (this.prevPosY == this.y || this.age > this.maxAge) {
this.markDead();
}
else {
} else {
if (this.age >= this.maxAge - 200) {
this.setColorAlpha((this.maxAge - this.age) / 200F);
}
this.scale += 0.005F;
this.velocityY = 0.125;
if (changeDir) {
changeDir = false;
check = false;
this.velocityX += MHelper.randRange(-0.2, 0.2, random);
this.velocityZ += MHelper.randRange(-0.2, 0.2, random);
}
else if (check) {
} else if (check) {
changeDir = world.getBlockState(mut.set(x, y, z)).getFluidState().isEmpty();
this.velocityX = 0;
this.velocityZ = 0;
@ -56,23 +55,24 @@ public class ParticleGeyser extends SpriteBillboardParticle {
}
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryGeyser implements ParticleFactory<DefaultParticleType> {
public static class FactoryGeyser implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactoryGeyser(SpriteProvider sprites) {
public FactoryGeyser(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleGeyser(world, x, y, z, 0, 0.125, 0, sprites);
}
}

View file

@ -2,17 +2,17 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.AnimatedParticle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.SimpleAnimatedParticle;
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 net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleGlowingSphere extends AnimatedParticle {
public class ParticleGlowingSphere extends SimpleAnimatedParticle {
private int ticks;
private double preVX;
private double preVY;
@ -20,27 +20,28 @@ public class ParticleGlowingSphere extends AnimatedParticle {
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) {
protected ParticleGlowingSphere(ClientLevel world, double x, double y, double z, SpriteSet 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);
setSprite(sprites.get(random));
this.lifetime = MHelper.randRange(150, 300, random);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setTargetColor(15916745);
this.setSpriteForAge(spriteProvider);
this.setFadeColor(15916745);
this.setSpriteFromAge(sprites);
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 ++;
ticks++;
if (ticks > 30) {
preVX = nextVX;
preVY = nextVY;
@ -51,25 +52,26 @@ public class ParticleGlowingSphere extends AnimatedParticle {
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Environment(EnvType.CLIENT)
public static class FactoryGlowingSphere implements ParticleFactory<DefaultParticleType> {
public static class FactoryGlowingSphere implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactoryGlowingSphere(SpriteProvider sprites) {
public FactoryGlowingSphere(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleGlowingSphere(world, x, y, z, sprites, 1, 1, 1);
}
}

View file

@ -2,18 +2,19 @@ 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.SimpleAnimatedParticle;
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.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleJungleSpore extends AnimatedParticle {
protected ParticleJungleSpore(ClientWorld world, double x, double y, double z, SpriteProvider sprites, double r, double g, double b) {
public class ParticleJungleSpore extends SimpleAnimatedParticle {
protected ParticleJungleSpore(ClientLevel world, double x, double y, double z, SpriteSet 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);
@ -22,11 +23,11 @@ public class ParticleJungleSpore extends AnimatedParticle {
this.setSpriteForAge(spriteProvider);
this.setColorAlpha(0);
}
@Override
public void tick() {
super.tick();
int ticks = this.age % 30;
if (ticks == 0) {
this.velocityX = random.nextGaussian() * 0.02;
@ -34,36 +35,34 @@ public class ParticleJungleSpore extends AnimatedParticle {
this.velocityZ = random.nextGaussian() * 0.02;
ticks = 0;
}
if (this.age <= 30) {
float delta = ticks / 30F;
this.setColorAlpha(delta);
}
else if (this.age >= this.maxAge) {
} else if (this.age >= this.maxAge) {
this.setColorAlpha(0);
}
else if (this.age >= this.maxAge - 30) {
} else if (this.age >= this.maxAge - 30) {
this.setColorAlpha((this.maxAge - this.age) / 30F);
}
else {
} else {
this.setColorAlpha(1);
}
this.velocityY -= 0.001F;
this.velocityX *= 0.99F;
this.velocityZ *= 0.99F;
}
@Environment(EnvType.CLIENT)
public static class FactoryJungleSpore implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider sprites;
public static class FactoryJungleSpore implements ParticleFactory<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryJungleSpore(SpriteProvider sprites) {
public FactoryJungleSpore(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleJungleSpore(world, x, y, z, sprites, 1, 1, 1);
}
}

View file

@ -6,10 +6,10 @@ 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.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
@ -21,27 +21,28 @@ public class ParticleSnowflake extends SpriteBillboardParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleSnowflake(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) {
protected ParticleSnowflake(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet sprites) {
super(world, x, y, z, r, g, b);
setSprite(sprites);
this.maxAge = MHelper.randRange(150, 300, random);
this.scale = MHelper.randRange(0.05F, 0.2F, random);
this.setColorAlpha(0F);
preVX = random.nextGaussian() * 0.015;
preVY = random.nextGaussian() * 0.015;
preVZ = random.nextGaussian() * 0.015;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextGaussian() * 0.015;
nextVZ = random.nextGaussian() * 0.015;
}
@Override
public void tick() {
ticks ++;
ticks++;
if (ticks > 200) {
preVX = nextVX;
preVY = nextVY;
@ -55,41 +56,41 @@ public class ParticleSnowflake extends SpriteBillboardParticle {
ticks = 0;
}
double delta = (double) ticks / 200.0;
if (this.age <= 40) {
this.setColorAlpha(this.age / 40F);
}
else if (this.age >= this.maxAge - 40) {
} else if (this.age >= this.maxAge - 40) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
}
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySnowflake implements ParticleFactory<DefaultParticleType> {
public static class FactorySnowflake implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactorySnowflake(SpriteProvider sprites) {
public FactorySnowflake(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleSnowflake(world, x, y, z, 1, 1, 1, sprites);
}
}

View file

@ -6,10 +6,10 @@ 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.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
@ -21,28 +21,29 @@ public class ParticleSulphur extends SpriteBillboardParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleSulphur(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) {
protected ParticleSulphur(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet sprites) {
super(world, x, y, z, r, g, b);
setSprite(sprites);
this.maxAge = MHelper.randRange(150, 300, random);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
this.setColorAlpha(0);
preVX = random.nextGaussian() * 0.015;
preVY = random.nextGaussian() * 0.015;
preVZ = random.nextGaussian() * 0.015;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextGaussian() * 0.015;
nextVZ = random.nextGaussian() * 0.015;
}
@Override
public void tick() {
ticks ++;
ticks++;
if (ticks > 200) {
preVX = nextVX;
preVY = nextVY;
@ -56,41 +57,41 @@ public class ParticleSulphur extends SpriteBillboardParticle {
ticks = 0;
}
double delta = (double) ticks / 200.0;
if (this.age <= 40) {
this.setColorAlpha(this.age / 40F);
}
else if (this.age >= this.maxAge - 40) {
} else if (this.age >= this.maxAge - 40) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
}
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySulphur implements ParticleFactory<DefaultParticleType> {
public static class FactorySulphur implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactorySulphur(SpriteProvider sprites) {
public FactorySulphur(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleSulphur(world, x, y, z, 1, 1, 1, sprites);
}
}

View file

@ -2,52 +2,53 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.block.BlockColor;
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.DefaultParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleTenaneaPetal extends SpriteBillboardParticle {
private static BlockColorProvider provider;
private static BlockColor provider;
private double preVX;
private double preVY;
private double preVZ;
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleTenaneaPetal(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) {
protected ParticleTenaneaPetal(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet sprites) {
super(world, x, y, z, r, g, b);
setSprite(sprites);
if (provider == null) {
IColorProvider block = (IColorProvider) EndBlocks.TENANEA_FLOWERS;
provider = block.getProvider();
provider = block.getBlockProvider();
}
int color = provider.getColor(null, null, new BlockPos(x, y, z), 0);
this.colorRed = ((color >> 16) & 255) / 255F;
this.colorGreen = ((color >> 8) & 255) / 255F;
this.colorBlue = ((color) & 255) / 255F;
this.maxAge = MHelper.randRange(120, 200, random);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setColorAlpha(0);
preVX = 0;
preVY = 0;
preVZ = 0;
nextVX = random.nextGaussian() * 0.02;
nextVY = -random.nextDouble() * 0.02 - 0.02;
nextVZ = random.nextGaussian() * 0.02;
@ -57,7 +58,7 @@ public class ParticleTenaneaPetal extends SpriteBillboardParticle {
public int getColorMultiplier(float tint) {
return 15728880;
}
@Override
public void tick() {
int ticks = this.age & 63;
@ -70,41 +71,41 @@ public class ParticleTenaneaPetal extends SpriteBillboardParticle {
nextVZ = random.nextGaussian() * 0.02;
}
double delta = (double) ticks / 63.0;
if (this.age <= 40) {
this.setColorAlpha(this.age / 40F);
}
else if (this.age >= this.maxAge - 40) {
} else if (this.age >= this.maxAge - 40) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
}
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryTenaneaPetal implements ParticleFactory<DefaultParticleType> {
public static class FactoryTenaneaPetal implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactoryTenaneaPetal(SpriteProvider sprites) {
public FactoryTenaneaPetal(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new ParticleTenaneaPetal(world, x, y, z, 1, 1, 1, sprites);
}
}

View file

@ -2,16 +2,16 @@ 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.SimpleAnimatedParticle;
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 net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
public class PaticlePortalSphere extends AnimatedParticle {
public class PaticlePortalSphere extends SimpleAnimatedParticle {
private int ticks;
private double preVX;
private double preVY;
@ -19,8 +19,8 @@ public class PaticlePortalSphere extends AnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
public PaticlePortalSphere(ClientWorld world, double x, double y, double z, SpriteProvider spriteProvider) {
public PaticlePortalSphere(ClientLevel world, double x, double y, double z, SpriteSet spriteProvider) {
super(world, x, y, z, spriteProvider, 0);
setSprite(spriteProvider.getSprite(random));
this.maxAge = MHelper.randRange(20, 80, random);
@ -28,16 +28,16 @@ public class PaticlePortalSphere extends AnimatedParticle {
this.setColor(0xFEBBD5);
this.setTargetColor(0xBBFEE4);
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++;
@ -51,25 +51,26 @@ public class PaticlePortalSphere extends AnimatedParticle {
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Environment(EnvType.CLIENT)
public static class FactoryPortalSphere implements ParticleFactory<DefaultParticleType> {
public static class FactoryPortalSphere implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public FactoryPortalSphere(SpriteProvider sprites) {
public FactoryPortalSphere(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new PaticlePortalSphere(world, x, y, z, sprites);
}
}

View file

@ -2,43 +2,44 @@ 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.SimpleAnimatedParticle;
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 net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class SmaragdantParticle extends AnimatedParticle {
public class SmaragdantParticle extends SimpleAnimatedParticle {
private double preVX;
private double preVY;
private double preVZ;
private double nextVX;
private double nextVY;
private double nextVZ;
protected SmaragdantParticle(ClientWorld world, double x, double y, double z, double r, double g, double b, SpriteProvider sprites) {
protected SmaragdantParticle(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet sprites) {
super(world, x, y, z, sprites, 0);
setSprite(sprites.getSprite(random));
this.maxAge = MHelper.randRange(60, 120, random);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
this.setColorAlpha(0);
preVX = random.nextGaussian() * 0.01;
preVY = random.nextGaussian() * 0.01;
preVZ = random.nextGaussian() * 0.01;
nextVX = random.nextGaussian() * 0.01;
nextVY = random.nextGaussian() * 0.01;
nextVZ = random.nextGaussian() * 0.01;
}
@Override
public void tick() {
int ticks = this.age & 31;
@ -51,41 +52,41 @@ public class SmaragdantParticle extends AnimatedParticle {
nextVZ = random.nextGaussian() * 0.015;
}
double delta = (double) ticks / 31.0;
if (this.age <= 31) {
this.setColorAlpha(this.age / 31F);
}
else if (this.age >= this.maxAge - 31) {
} else if (this.age >= this.maxAge - 31) {
this.setColorAlpha((this.maxAge - this.age) / 31F);
}
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);
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class SmaragdantParticleFactory implements ParticleFactory<DefaultParticleType> {
public static class SmaragdantParticleFactory implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider sprites;
private final SpriteSet sprites;
public SmaragdantParticleFactory(SpriteProvider sprites) {
public SmaragdantParticleFactory(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double vX, double vY, double vZ) {
public Particle createParticle(SimpleParticleType type, ClientLevel world, double x, double y, double z,
double vX, double vY, double vZ) {
return new SmaragdantParticle(world, x, y, z, 1, 1, 1, sprites);
}
}