Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -2,11 +2,11 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@ -19,26 +19,25 @@ public class FireflyParticle extends SimpleAnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected FireflyParticle(ClientLevel world, double x, double y, double z, SpriteSet 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);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setTargetColor(15916745);
this.setSpriteForAge(spriteProvider);
this.setColorAlpha(0);
setSprite(sprites.get(random));
this.lifetime = MHelper.randRange(150, 300, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setFadeColor(15916745);
this.setSpriteFromAge(sprites);
this.setAlpha(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;
@ -51,22 +50,23 @@ public class FireflyParticle extends SimpleAnimatedParticle {
nextVZ = random.nextGaussian() * 0.02;
}
double delta = (double) ticks / 31.0;
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.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);
this.setAlpha(this.age / 60F);
}
else if (this.age > lifetime - 60) {
this.setAlpha((lifetime - this.age) / 60F);
}
super.tick();
}
@Environment(EnvType.CLIENT)
public static class FireflyParticleFactory implements ParticleFactory<SimpleParticleType> {
public static class FireflyParticleFactory implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FireflyParticleFactory(SpriteSet sprites) {
@ -74,8 +74,7 @@ public class FireflyParticle extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -1,11 +1,10 @@
package ru.betterend.particle;
import java.util.Locale;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
import ru.betterend.registry.EndParticles;
public class GlowingSphereParticleEffect implements ParticleOptions {
@ -25,16 +24,15 @@ public class GlowingSphereParticleEffect implements ParticleOptions {
}
@Override
public void write(PacketByteBuf buf) {
public void writeToNetwork(FriendlyByteBuf 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 String writeToString() {
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue);
}
public float getRed() {

View file

@ -2,62 +2,60 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
public class InfusionParticle extends SpriteBillboardParticle {
public class InfusionParticle extends TextureSheetParticle {
private final SpriteSet spriteProvider;
public InfusionParticle(ClientLevel clientWorld, double x, double y, double z, double velocityX, double velocityY,
double velocityZ, float[] palette, 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.setSpriteFromAge(spriteProvider);
this.spriteProvider = spriteProvider;
this.setColor(palette[0], palette[1], palette[2]);
this.setColorAlpha(palette[3]);
this.velocityX = velocityX * 0.1D;
this.velocityY = velocityY * 0.1D;
this.velocityZ = velocityZ * 0.1D;
this.maxAge = (int) (3.0F / (this.random.nextFloat() * 0.9F + 0.1F));
this.scale *= 0.9F;
this.setAlpha(palette[3]);
this.xd = velocityX * 0.1D;
this.yd = velocityY * 0.1D;
this.zd = velocityZ * 0.1D;
this.lifetime = (int) (3.0F / (this.random.nextFloat() * 0.9F + 0.1F));
this.quadSize *= 0.9F;
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge) {
this.markDead();
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.age++ >= this.lifetime) {
this.remove();
} else {
this.setSpriteForAge(spriteProvider);
double velocityX = 2.0D * this.velocityX * this.random.nextDouble();
double velocityY = 3.0D * this.velocityY * this.random.nextDouble();
double velocityZ = 2.0D * this.velocityZ * this.random.nextDouble();
this.setSpriteFromAge(spriteProvider);
double velocityX = 2.0D * this.xd * this.random.nextDouble();
double velocityY = 3.0D * this.yd * this.random.nextDouble();
double velocityZ = 2.0D * this.zd * this.random.nextDouble();
this.move(velocityX, velocityY, velocityZ);
}
}
@Environment(EnvType.CLIENT)
public static class InfusionFactory implements ParticleFactory<InfusionParticleType> {
public static class InfusionFactory implements ParticleProvider<InfusionParticleType> {
private final SpriteSet spriteProvider;
public InfusionFactory(SpriteSet spriteProvider) {
this.spriteProvider = spriteProvider;
}
public Particle createParticle(InfusionParticleType particleType, ClientLevel 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

@ -6,13 +6,13 @@ import com.mojang.serialization.Codec;
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.world.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.commands.arguments.item.ItemParser;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import ru.betterend.registry.EndParticles;
import ru.betterend.util.ColorUtil;
@ -22,34 +22,32 @@ public class InfusionParticleType extends ParticleType<InfusionParticleType> imp
}, infusionParticleType -> {
return infusionParticleType.itemStack;
});
public static final ParticleOptions.Factory<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Factory<InfusionParticleType>() {
public InfusionParticleType read(ParticleType<InfusionParticleType> particleType, StringReader stringReader)
throws CommandSyntaxException {
public static final ParticleOptions.Deserializer<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Deserializer<InfusionParticleType>() {
public InfusionParticleType fromCommand(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);
ItemParser itemStringReader = new ItemParser(stringReader, false).parse();
ItemStack itemStack = new ItemInput(itemStringReader.getItem(), itemStringReader.getNbt()).createItemStack(1, false);
return new InfusionParticleType(particleType, itemStack);
}
public InfusionParticleType read(ParticleType<InfusionParticleType> particleType, PacketByteBuf packetByteBuf) {
return new InfusionParticleType(particleType, packetByteBuf.readItemStack());
public InfusionParticleType fromNetwork(ParticleType<InfusionParticleType> particleType, FriendlyByteBuf packetByteBuf) {
return new InfusionParticleType(particleType, packetByteBuf.readItem());
}
};
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());
@ -62,17 +60,17 @@ public class InfusionParticleType extends ParticleType<InfusionParticleType> imp
}
@Override
public void write(PacketByteBuf buffer) {
buffer.writeItemStack(itemStack);
public void writeToNetwork(FriendlyByteBuf buffer) {
buffer.writeItem(itemStack);
}
@Override
public String asString() {
return Registry.PARTICLE_TYPE.getId(this).toString();
public String writeToString() {
return Registry.PARTICLE_TYPE.getKey(this).toString();
}
@Override
public Codec<InfusionParticleType> getCodec() {
public Codec<InfusionParticleType> codec() {
return CODEC;
}
}

View file

@ -2,12 +2,12 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@ -20,26 +20,25 @@ public class ParticleBlackSpore extends SimpleAnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleBlackSpore(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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);
setSprite(sprites.get(random));
this.lifetime = MHelper.randRange(30, 60, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
this.setColorAlpha(0);
this.setAlpha(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;
@ -52,31 +51,32 @@ public class ParticleBlackSpore extends SimpleAnimatedParticle {
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);
this.setAlpha(this.age / 15F);
}
if (this.age >= this.maxAge) {
this.markDead();
else if (this.age >= this.lifetime - 15) {
this.setAlpha((this.lifetime - this.age) / 15F);
}
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age >= this.lifetime) {
this.remove();
}
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryBlackSpore implements ParticleFactory<SimpleParticleType> {
public static class FactoryBlackSpore implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -85,8 +85,7 @@ public class ParticleBlackSpore extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -2,67 +2,68 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.particles.SimpleParticleType;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleGeyser extends SpriteBillboardParticle {
public class ParticleGeyser extends TextureSheetParticle {
private MutableBlockPos mut = new MutableBlockPos();
private boolean changeDir = false;
private boolean check = true;
protected ParticleGeyser(ClientLevel world, double x, double y, double z, double vx, double vy, double vz,
SpriteSet 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);
this.scale = MHelper.randRange(0.5F, 1.0F, random);
this.velocityX = vx;
this.velocityZ = vz;
this.prevPosY = y - 0.125;
pickSprite(sprites);
this.lifetime = MHelper.randRange(400, 800, random);
this.quadSize = MHelper.randRange(0.5F, 1.0F, random);
this.xd = vx;
this.zd = vz;
this.yo = y - 0.125;
}
@Override
public void tick() {
if (this.prevPosY == this.y || this.age > this.maxAge) {
this.markDead();
} else {
if (this.age >= this.maxAge - 200) {
this.setColorAlpha((this.maxAge - this.age) / 200F);
if (this.yo == this.y || this.age > this.lifetime) {
this.remove();
}
else {
if (this.age >= this.lifetime - 200) {
this.setAlpha((this.lifetime - this.age) / 200F);
}
this.scale += 0.005F;
this.velocityY = 0.125;
this.quadSize += 0.005F;
this.yd = 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) {
changeDir = world.getBlockState(mut.set(x, y, z)).getFluidState().isEmpty();
this.velocityX = 0;
this.velocityZ = 0;
this.xd += MHelper.randRange(-0.2, 0.2, random);
this.zd += MHelper.randRange(-0.2, 0.2, random);
}
else if (check) {
changeDir = level.getBlockState(mut.set(x, y, z)).getFluidState().isEmpty();
this.xd = 0;
this.zd = 0;
}
}
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryGeyser implements ParticleFactory<SimpleParticleType> {
public static class FactoryGeyser implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -71,8 +72,7 @@ public class ParticleGeyser extends SpriteBillboardParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -3,9 +3,9 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.ParticleProvider;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
@ -20,28 +20,27 @@ public class ParticleGlowingSphere extends SimpleAnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleGlowingSphere(ClientLevel world, double x, double y, double z, SpriteSet 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.get(random));
this.lifetime = MHelper.randRange(150, 300, random);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
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;
@ -52,16 +51,16 @@ public class ParticleGlowingSphere extends SimpleAnimatedParticle {
ticks = 0;
}
double delta = (double) ticks / 30.0;
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Environment(EnvType.CLIENT)
public static class FactoryGlowingSphere implements ParticleFactory<SimpleParticleType> {
public static class FactoryGlowingSphere implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -70,8 +69,7 @@ public class ParticleGlowingSphere extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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,58 +2,60 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleJungleSpore extends SimpleAnimatedParticle {
protected ParticleJungleSpore(ClientLevel world, double x, double y, double z, SpriteSet sprites, double r,
double g, double b) {
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);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
this.setTargetColor(15916745);
this.setSpriteForAge(spriteProvider);
this.setColorAlpha(0);
setSprite(sprites.get(random));
this.lifetime = MHelper.randRange(150, 300, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setFadeColor(15916745);
this.setSpriteFromAge(sprites);
this.setAlpha(0);
}
@Override
public void tick() {
super.tick();
int ticks = this.age % 30;
if (ticks == 0) {
this.velocityX = random.nextGaussian() * 0.02;
this.velocityY = random.nextFloat() * 0.02 + 0.02;
this.velocityZ = random.nextGaussian() * 0.02;
this.xd = random.nextGaussian() * 0.02;
this.yd = random.nextFloat() * 0.02 + 0.02;
this.zd = random.nextGaussian() * 0.02;
ticks = 0;
}
if (this.age <= 30) {
float delta = ticks / 30F;
this.setColorAlpha(delta);
} else if (this.age >= this.maxAge) {
this.setColorAlpha(0);
} else if (this.age >= this.maxAge - 30) {
this.setColorAlpha((this.maxAge - this.age) / 30F);
} else {
this.setColorAlpha(1);
this.setAlpha(delta);
}
this.velocityY -= 0.001F;
this.velocityX *= 0.99F;
this.velocityZ *= 0.99F;
else if (this.age >= this.lifetime) {
this.setAlpha(0);
}
else if (this.age >= this.lifetime - 30) {
this.setAlpha((this.lifetime - this.age) / 30F);
}
else {
this.setAlpha(1);
}
this.yd -= 0.001F;
this.xd *= 0.99F;
this.zd *= 0.99F;
}
@Environment(EnvType.CLIENT)
public static class FactoryJungleSpore implements ParticleFactory<SimpleParticleType> {
public static class FactoryJungleSpore implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryJungleSpore(SpriteSet sprites) {
@ -61,8 +63,7 @@ public class ParticleJungleSpore extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -2,18 +2,18 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleSnowflake extends SpriteBillboardParticle {
public class ParticleSnowflake extends TextureSheetParticle {
private int ticks;
private double preVX;
private double preVY;
@ -21,28 +21,27 @@ public class ParticleSnowflake extends SpriteBillboardParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleSnowflake(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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);
pickSprite(sprites);
this.lifetime = MHelper.randRange(150, 300, random);
this.quadSize = MHelper.randRange(0.05F, 0.2F, random);
this.setAlpha(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;
@ -56,31 +55,32 @@ 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) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
this.setAlpha(this.age / 40F);
}
if (this.age >= this.maxAge) {
this.markDead();
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age >= this.lifetime) {
this.remove();
}
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySnowflake implements ParticleFactory<SimpleParticleType> {
public static class FactorySnowflake implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -89,8 +89,7 @@ public class ParticleSnowflake extends SpriteBillboardParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -2,18 +2,18 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleSulphur extends SpriteBillboardParticle {
public class ParticleSulphur extends TextureSheetParticle {
private int ticks;
private double preVX;
private double preVY;
@ -21,29 +21,28 @@ public class ParticleSulphur extends SpriteBillboardParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleSulphur(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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);
pickSprite(sprites);
this.lifetime = MHelper.randRange(150, 300, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
this.setColorAlpha(0);
this.setAlpha(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;
@ -57,31 +56,32 @@ 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) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
this.setAlpha(this.age / 40F);
}
if (this.age >= this.maxAge) {
this.markDead();
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age >= this.lifetime) {
this.remove();
}
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySulphur implements ParticleFactory<SimpleParticleType> {
public static class FactorySulphur implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -90,8 +90,7 @@ public class ParticleSulphur extends SpriteBillboardParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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

@ -3,62 +3,61 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.SimpleParticleType;
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 {
public class ParticleTenaneaPetal extends TextureSheetParticle {
private static BlockColor provider;
private double preVX;
private double preVY;
private double preVZ;
private double nextVX;
private double nextVY;
private double nextVZ;
protected ParticleTenaneaPetal(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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);
pickSprite(sprites);
if (provider == null) {
IColorProvider block = (IColorProvider) EndBlocks.TENANEA_FLOWERS;
provider = block.getBlockProvider();
provider = block.getProvider();
}
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);
this.rCol = ((color >> 16) & 255) / 255F;
this.gCol = ((color >> 8) & 255) / 255F;
this.bCol = ((color) & 255) / 255F;
this.lifetime = MHelper.randRange(120, 200, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setAlpha(0);
preVX = 0;
preVY = 0;
preVZ = 0;
nextVX = random.nextGaussian() * 0.02;
nextVY = -random.nextDouble() * 0.02 - 0.02;
nextVZ = random.nextGaussian() * 0.02;
}
@Override
public int getColorMultiplier(float tint) {
public int getLightColor(float tint) {
return 15728880;
}
@Override
public void tick() {
int ticks = this.age & 63;
@ -71,31 +70,32 @@ 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) {
this.setColorAlpha((this.maxAge - this.age) / 40F);
this.setAlpha(this.age / 40F);
}
if (this.age >= this.maxAge) {
this.markDead();
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age >= this.lifetime) {
this.remove();
}
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryTenaneaPetal implements ParticleFactory<SimpleParticleType> {
public static class FactoryTenaneaPetal implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -104,8 +104,7 @@ public class ParticleTenaneaPetal extends SpriteBillboardParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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,11 +2,11 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@ -19,25 +19,25 @@ public class PaticlePortalSphere extends SimpleAnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
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);
this.scale = MHelper.randRange(0.05F, 0.15F, random);
setSprite(spriteProvider.get(random));
this.lifetime = MHelper.randRange(20, 80, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(0xFEBBD5);
this.setTargetColor(0xBBFEE4);
this.setSpriteForAge(spriteProvider);
this.setFadeColor(0xBBFEE4);
this.setSpriteFromAge(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,16 +51,16 @@ public class PaticlePortalSphere extends SimpleAnimatedParticle {
ticks = 0;
}
double delta = (double) ticks / 30.0;
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Environment(EnvType.CLIENT)
public static class FactoryPortalSphere implements ParticleFactory<SimpleParticleType> {
public static class FactoryPortalSphere implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -69,8 +69,7 @@ public class PaticlePortalSphere extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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,12 +2,12 @@ package ru.betterend.particle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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.SpriteSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import ru.betterend.util.MHelper;
@ -20,26 +20,25 @@ public class SmaragdantParticle extends SimpleAnimatedParticle {
private double nextVX;
private double nextVY;
private double nextVZ;
protected SmaragdantParticle(ClientLevel world, double x, double y, double z, double r, double g, double b,
SpriteSet 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);
setSprite(sprites.get(random));
this.lifetime = MHelper.randRange(60, 120, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
this.setColorAlpha(0);
this.setAlpha(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;
@ -52,31 +51,32 @@ public class SmaragdantParticle extends SimpleAnimatedParticle {
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) {
this.setColorAlpha((this.maxAge - this.age) / 31F);
this.setAlpha(this.age / 31F);
}
if (this.age >= this.maxAge) {
this.markDead();
else if (this.age >= this.lifetime - 31) {
this.setAlpha((this.lifetime - this.age) / 31F);
}
this.velocityX = Mth.lerp(delta, preVX, nextVX);
this.velocityY = Mth.lerp(delta, preVY, nextVY);
this.velocityZ = Mth.lerp(delta, preVZ, nextVZ);
if (this.age >= this.lifetime) {
this.remove();
}
this.xd = Mth.lerp(delta, preVX, nextVX);
this.yd = Mth.lerp(delta, preVY, nextVY);
this.zd = Mth.lerp(delta, preVZ, nextVZ);
super.tick();
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class SmaragdantParticleFactory implements ParticleFactory<SimpleParticleType> {
public static class SmaragdantParticleFactory implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
@ -85,8 +85,7 @@ public class SmaragdantParticle extends SimpleAnimatedParticle {
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel 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);
}
}