Removed color provider

This commit is contained in:
paulevsGitch 2021-07-10 16:25:34 +03:00
parent 2c8862a37b
commit 4040597a6d
475 changed files with 5411 additions and 7521 deletions

View file

@ -19,7 +19,7 @@ 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) {
super(world, x, y, z, sprites, 0);
setSprite(sprites.get(random));
@ -28,16 +28,16 @@ public class FireflyParticle extends SimpleAnimatedParticle {
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;
@ -50,29 +50,29 @@ public class FireflyParticle extends SimpleAnimatedParticle {
nextVZ = random.nextGaussian() * 0.02;
}
double delta = (double) ticks / 31.0;
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.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 ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FireflyParticleFactory(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -10,9 +10,9 @@ import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
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) {
super(clientWorld, x, y, z, 0.0, 0.0, 0.0);
this.setSpriteFromAge(spriteProvider);
@ -25,12 +25,12 @@ public class InfusionParticle extends TextureSheetParticle {
this.lifetime = (int) (3.0F / (this.random.nextFloat() * 0.9F + 0.1F));
this.quadSize *= 0.9F;
}
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
this.xo = this.x;
@ -47,15 +47,15 @@ public class InfusionParticle extends TextureSheetParticle {
this.move(velocityX, velocityY, velocityZ);
}
}
@Environment(EnvType.CLIENT)
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) {
return new InfusionParticle(clientWorld, d, e, f, g, h, i, particleType.getPalette(), this.spriteProvider);
}

View file

@ -16,10 +16,8 @@ import ru.bclib.util.ColorUtil;
import ru.betterend.registry.EndParticles;
public class InfusionParticleType extends ParticleType<InfusionParticleType> implements ParticleOptions {
public static final Codec<InfusionParticleType> CODEC = ItemStack.CODEC.xmap(
itemStack -> new InfusionParticleType(EndParticles.INFUSION, itemStack),
infusionParticleType -> infusionParticleType.itemStack);
public static final Codec<InfusionParticleType> CODEC = ItemStack.CODEC.xmap(itemStack -> new InfusionParticleType(EndParticles.INFUSION, itemStack), infusionParticleType -> infusionParticleType.itemStack);
public static final ParticleOptions.Deserializer<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Deserializer<InfusionParticleType>() {
public InfusionParticleType fromCommand(ParticleType<InfusionParticleType> particleType, StringReader stringReader) throws CommandSyntaxException {
stringReader.expect(' ');
@ -27,46 +25,46 @@ public class InfusionParticleType extends ParticleType<InfusionParticleType> imp
ItemStack itemStack = new ItemInput(itemStringReader.getItem(), itemStringReader.getNbt()).createItemStack(1, false);
return new InfusionParticleType(particleType, itemStack);
}
public InfusionParticleType fromNetwork(ParticleType<InfusionParticleType> particleType, FriendlyByteBuf packetByteBuf) {
return new InfusionParticleType(particleType, packetByteBuf.readItem());
}
};
private final ParticleType<InfusionParticleType> type;
private final 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());
return ColorUtil.toFloatArray(color);
}
@Override
public ParticleType<?> getType() {
return this.type;
}
@Override
public void writeToNetwork(FriendlyByteBuf buffer) {
buffer.writeItem(itemStack);
}
@Override
public String writeToString() {
return Registry.PARTICLE_TYPE.getKey(this).toString();
}
@Override
public Codec<InfusionParticleType> codec() {
return CODEC;

View file

@ -20,25 +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) {
super(world, x, y, z, sprites, 0);
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.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;
@ -51,39 +51,39 @@ public class ParticleBlackSpore extends SimpleAnimatedParticle {
nextVZ = random.nextGaussian() * 0.015;
}
double delta = (double) ticks / 15.0;
if (this.age <= 15) {
this.setAlpha(this.age / 15F);
}
else if (this.age >= this.lifetime - 15) {
this.setAlpha((this.lifetime - this.age) / 15F);
}
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryBlackSpore implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryBlackSpore(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -17,7 +17,7 @@ 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) {
super(world, x, y, z, vx, vy, vz);
pickSprite(sprites);
@ -27,10 +27,10 @@ public class ParticleGeyser extends TextureSheetParticle {
this.zd = vz;
this.yo = y - 0.125;
}
@Override
public void tick() {
if (this.yo == this.y || this.age > this.lifetime) {
this.remove();
}
@ -38,10 +38,10 @@ public class ParticleGeyser extends TextureSheetParticle {
if (this.age >= this.lifetime - 200) {
this.setAlpha((this.lifetime - this.age) / 200F);
}
this.quadSize += 0.005F;
this.yd = 0.125;
if (changeDir) {
changeDir = false;
check = false;
@ -56,21 +56,21 @@ public class ParticleGeyser extends TextureSheetParticle {
}
super.tick();
}
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryGeyser implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryGeyser(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -20,7 +20,7 @@ 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) {
super(world, x, y, z, sprites, 0);
setSprite(sprites.get(random));
@ -28,16 +28,16 @@ public class ParticleGlowingSphere extends SimpleAnimatedParticle {
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++;
@ -51,23 +51,23 @@ public class ParticleGlowingSphere extends SimpleAnimatedParticle {
ticks = 0;
}
double delta = (double) ticks / 30.0;
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 ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryGlowingSphere(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -12,7 +12,7 @@ import ru.bclib.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) {
super(world, x, y, z, sprites, 0);
setSprite(sprites.get(random));
@ -22,11 +22,11 @@ public class ParticleJungleSpore extends SimpleAnimatedParticle {
this.setSpriteFromAge(sprites);
this.setAlpha(0);
}
@Override
public void tick() {
super.tick();
int ticks = this.age % 30;
if (ticks == 0) {
this.xd = random.nextGaussian() * 0.02;
@ -34,7 +34,7 @@ public class ParticleJungleSpore extends SimpleAnimatedParticle {
this.zd = random.nextGaussian() * 0.02;
ticks = 0;
}
if (this.age <= 30) {
float delta = ticks / 30F;
this.setAlpha(delta);
@ -48,20 +48,20 @@ public class ParticleJungleSpore extends SimpleAnimatedParticle {
else {
this.setAlpha(1);
}
this.yd -= 0.001F;
this.xd *= 0.99F;
this.zd *= 0.99F;
}
@Environment(EnvType.CLIENT)
public static class FactoryJungleSpore implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryJungleSpore(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -21,24 +21,24 @@ public class ParticleSnowflake extends TextureSheetParticle {
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) {
super(world, x, y, z, r, g, b);
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++;
@ -55,39 +55,39 @@ public class ParticleSnowflake extends TextureSheetParticle {
ticks = 0;
}
double delta = (double) ticks / 200.0;
if (this.age <= 40) {
this.setAlpha(this.age / 40F);
}
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySnowflake implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactorySnowflake(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -21,25 +21,25 @@ public class ParticleSulphur extends TextureSheetParticle {
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) {
super(world, x, y, z, r, g, b);
pickSprite(sprites);
this.lifetime = MHelper.randRange(150, 300, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
this.setColor(1, 1, 1);
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++;
@ -56,39 +56,39 @@ public class ParticleSulphur extends TextureSheetParticle {
ticks = 0;
}
double delta = (double) ticks / 200.0;
if (this.age <= 40) {
this.setAlpha(this.age / 40F);
}
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactorySulphur implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactorySulphur(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -19,18 +19,18 @@ import ru.betterend.registry.EndBlocks;
@Environment(EnvType.CLIENT)
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) {
super(world, x, y, z, r, g, b);
pickSprite(sprites);
if (provider == null) {
IColorProvider block = (IColorProvider) EndBlocks.TENANEA_FLOWERS;
provider = block.getProvider();
@ -39,25 +39,25 @@ public class ParticleTenaneaPetal extends TextureSheetParticle {
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 getLightColor(float tint) {
return 15728880;
}
@Override
public void tick() {
int ticks = this.age & 63;
@ -70,39 +70,39 @@ public class ParticleTenaneaPetal extends TextureSheetParticle {
nextVZ = random.nextGaussian() * 0.02;
}
double delta = (double) ticks / 63.0;
if (this.age <= 40) {
this.setAlpha(this.age / 40F);
}
else if (this.age >= this.lifetime - 40) {
this.setAlpha((this.lifetime - this.age) / 40F);
}
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class FactoryTenaneaPetal implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryTenaneaPetal(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -19,7 +19,7 @@ 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.get(random));
@ -28,16 +28,16 @@ public class PaticlePortalSphere extends SimpleAnimatedParticle {
this.setColor(0xFEBBD5);
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,23 +51,23 @@ public class PaticlePortalSphere extends SimpleAnimatedParticle {
ticks = 0;
}
double delta = (double) ticks / 30.0;
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 ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public FactoryPortalSphere(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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

@ -20,25 +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) {
super(world, x, y, z, sprites, 0);
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.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;
@ -51,39 +51,39 @@ public class SmaragdantParticle extends SimpleAnimatedParticle {
nextVZ = random.nextGaussian() * 0.015;
}
double delta = (double) ticks / 31.0;
if (this.age <= 31) {
this.setAlpha(this.age / 31F);
}
else if (this.age >= this.lifetime - 31) {
this.setAlpha((this.lifetime - this.age) / 31F);
}
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Environment(EnvType.CLIENT)
public static class SmaragdantParticleFactory implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public SmaragdantParticleFactory(SpriteSet sprites) {
this.sprites = sprites;
}
@Override
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);