Reorganized Imports/Packages

This commit is contained in:
Frank 2022-05-18 23:56:18 +02:00
parent a8beba9196
commit 770a5b4046
854 changed files with 42775 additions and 41811 deletions

View file

@ -0,0 +1,96 @@
package org.betterx.betterend.particle;
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 net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
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(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.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;
if (ticks == 0) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.02;
nextVY = random.nextGaussian() * 0.02;
nextVZ = random.nextGaussian() * 0.02;
}
double delta = (double) ticks / 31.0;
this.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

@ -0,0 +1,74 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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);
this.spriteProvider = spriteProvider;
this.setColor(palette[0], palette[1], palette[2]);
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 ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}
@Override
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.age++ >= this.lifetime) {
this.remove();
} else {
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 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

@ -0,0 +1,83 @@
package org.betterx.betterend.particle;
import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.commands.arguments.item.ItemParser;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.serialization.Codec;
import org.betterx.bclib.util.ColorUtil;
import org.betterx.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);
@SuppressWarnings("deprecation")
public static final ParticleOptions.Deserializer<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Deserializer<InfusionParticleType>() {
public InfusionParticleType fromCommand(ParticleType<InfusionParticleType> particleType,
StringReader stringReader) throws CommandSyntaxException {
stringReader.expect(' ');
ItemParser.ItemResult itemResult = ItemParser.parseForItem(HolderLookup.forRegistry(Registry.ITEM),
stringReader);
ItemStack itemStack = new ItemInput(itemResult.item(), itemResult.nbt()).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

@ -0,0 +1,103 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
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(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;
if (ticks == 0) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextFloat() * 0.02 + 0.01;
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

@ -0,0 +1,89 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.particles.SimpleParticleType;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleGeyser extends TextureSheetParticle {
private final 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);
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.yo == this.y || this.age > this.lifetime) {
this.remove();
} else {
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;
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 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

@ -0,0 +1,92 @@
package org.betterx.betterend.particle;
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 net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleGlowingSphere extends SimpleAnimatedParticle {
private int ticks;
private double preVX;
private double preVY;
private double preVZ;
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));
this.lifetime = MHelper.randRange(150, 300, 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++;
if (ticks > 30) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.02;
nextVY = random.nextGaussian() * 0.02;
nextVZ = random.nextGaussian() * 0.02;
ticks = 0;
}
double delta = (double) ticks / 30.0;
this.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

@ -0,0 +1,83 @@
package org.betterx.betterend.particle;
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.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.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));
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.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.setAlpha(delta);
} 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 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

@ -0,0 +1,107 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleSnowflake extends TextureSheetParticle {
private int ticks;
private double preVX;
private double preVY;
private double preVZ;
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++;
if (ticks > 200) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextGaussian() * 0.015;
nextVZ = random.nextGaussian() * 0.015;
if (random.nextInt(4) == 0) {
nextVY = Math.abs(nextVY);
}
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

@ -0,0 +1,108 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
public class ParticleSulphur extends TextureSheetParticle {
private int ticks;
private double preVX;
private double preVY;
private double preVZ;
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++;
if (ticks > 200) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextGaussian() * 0.015;
nextVZ = random.nextGaussian() * 0.015;
if (random.nextInt(4) == 0) {
nextVY = Math.abs(nextVY);
}
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

@ -0,0 +1,122 @@
package org.betterx.betterend.particle;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.interfaces.CustomColorProvider;
import org.betterx.bclib.util.MHelper;
import org.betterx.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) {
CustomColorProvider block = (CustomColorProvider) EndBlocks.TENANEA_FLOWERS;
provider = block.getProvider();
}
int color = provider.getColor(null, null, new BlockPos(x, y, z), 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 getLightColor(float tint) {
return 15728880;
}
@Override
public void tick() {
int ticks = this.age & 63;
if (ticks == 0) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.02;
nextVY = -random.nextDouble() * 0.02 - 0.02;
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

@ -0,0 +1,85 @@
package org.betterx.betterend.particle;
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 net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
public class PaticlePortalSphere extends SimpleAnimatedParticle {
private int ticks;
private double preVX;
private double preVY;
private double preVZ;
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));
this.lifetime = MHelper.randRange(20, 80, random);
this.quadSize = MHelper.randRange(0.05F, 0.15F, random);
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++;
if (ticks > 30) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.02;
nextVY = random.nextGaussian() * 0.02;
nextVZ = random.nextGaussian() * 0.02;
ticks = 0;
}
double delta = (double) ticks / 30.0;
this.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

@ -0,0 +1,103 @@
package org.betterx.betterend.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.util.MHelper;
@Environment(EnvType.CLIENT)
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(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;
if (ticks == 0) {
preVX = nextVX;
preVY = nextVY;
preVZ = nextVZ;
nextVX = random.nextGaussian() * 0.015;
nextVY = random.nextFloat() * 0.02 + 0.01;
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);
}
}
}