FallingLeavesParticle.java
net.minecraft.client.particle.FallingLeavesParticle
信息
- 全限定名:net.minecraft.client.particle.FallingLeavesParticle
- 类型:public class
- 包:net.minecraft.client.particle
- 源码路径:src/main/java/net/minecraft/client/particle/FallingLeavesParticle.java
- 起始行号:L12
- 继承:SingleQuadParticle
- 职责:
TODO
字段/常量
-
ACCELERATION_SCALE- 类型:
float - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
INITIAL_LIFETIME- 类型:
int - 修饰符:
private static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
CURVE_ENDPOINT_TIME- 类型:
int - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
rotSpeed- 类型:
float - 修饰符:
private - 源码定位:
L16 - 说明:
TODO
- 类型:
-
spinAcceleration- 类型:
float - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
windBig- 类型:
float - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
swirl- 类型:
boolean - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
flowAway- 类型:
boolean - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
xaFlowScale- 类型:
double - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
zaFlowScale- 类型:
double - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
swirlPeriod- 类型:
double - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.particle.FallingLeavesParticle.CherryProvider- 类型:
class - 修饰符:
public static - 源码定位:
L104 - 说明:
TODO
- 类型:
-
net.minecraft.client.particle.FallingLeavesParticle.PaleOakProvider- 类型:
class - 修饰符:
public static - 源码定位:
L119 - 说明:
TODO
- 类型:
-
net.minecraft.client.particle.FallingLeavesParticle.TintedLeavesProvider- 类型:
class - 修饰符:
public static - 源码定位:
L134 - 说明:
TODO
- 类型:
构造器
protected FallingLeavesParticle(ClientLevel level, double x, double y, double z, TextureAtlasSprite sprite, float fallAcceleration, float sideAcceleration, boolean swirl, boolean flowAway, float scale, float startVelocity) @ L25
- 构造器名:FallingLeavesParticle
- 源码定位:L25
- 修饰符:protected
参数:
- level: ClientLevel
- x: double
- y: double
- z: double
- sprite: TextureAtlasSprite
- fallAcceleration: float
- sideAcceleration: float
- swirl: boolean
- flowAway: boolean
- scale: float
- startVelocity: float
说明:
TODO
方法
下面的方法块按源码顺序生成。
public SingleQuadParticle.Layer getLayer() @ L55
- 方法名:getLayer
- 源码定位:L55
- 返回类型:SingleQuadParticle.Layer
- 修饰符:public
参数:
- 无
说明:
TODO
public void tick() @ L60
- 方法名:tick
- 源码定位:L60
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class FallingLeavesParticle extends SingleQuadParticle {
private static final float ACCELERATION_SCALE = 0.0025F;
private static final int INITIAL_LIFETIME = 300;
private static final int CURVE_ENDPOINT_TIME = 300;
private float rotSpeed = (float)Math.toRadians(this.random.nextBoolean() ? -30.0 : 30.0);
private final float spinAcceleration = (float)Math.toRadians(this.random.nextBoolean() ? -5.0 : 5.0);
private final float windBig;
private final boolean swirl;
private final boolean flowAway;
private final double xaFlowScale;
private final double zaFlowScale;
private final double swirlPeriod;
protected FallingLeavesParticle(
ClientLevel level,
double x,
double y,
double z,
TextureAtlasSprite sprite,
float fallAcceleration,
float sideAcceleration,
boolean swirl,
boolean flowAway,
float scale,
float startVelocity
) {
super(level, x, y, z, sprite);
this.windBig = sideAcceleration;
this.swirl = swirl;
this.flowAway = flowAway;
this.lifetime = 300;
this.gravity = fallAcceleration * 1.2F * 0.0025F;
float size = scale * (this.random.nextBoolean() ? 0.05F : 0.075F);
this.quadSize = size;
this.setSize(size, size);
this.friction = 1.0F;
this.yd = -startVelocity;
float particleRandom = this.random.nextFloat();
this.xaFlowScale = Math.cos(Math.toRadians(particleRandom * 60.0F)) * this.windBig;
this.zaFlowScale = Math.sin(Math.toRadians(particleRandom * 60.0F)) * this.windBig;
this.swirlPeriod = Math.toRadians(1000.0F + particleRandom * 3000.0F);
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.OPAQUE;
}
@Override
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.lifetime-- <= 0) {
this.remove();
}
if (!this.removed) {
float aliveTicks = 300 - this.lifetime;
float relativeAge = Math.min(aliveTicks / 300.0F, 1.0F);
double xa = 0.0;
double za = 0.0;
if (this.flowAway) {
xa += this.xaFlowScale * Math.pow(relativeAge, 1.25);
za += this.zaFlowScale * Math.pow(relativeAge, 1.25);
}
if (this.swirl) {
xa += relativeAge * Math.cos(relativeAge * this.swirlPeriod) * this.windBig;
za += relativeAge * Math.sin(relativeAge * this.swirlPeriod) * this.windBig;
}
this.xd += xa * 0.0025F;
this.zd += za * 0.0025F;
this.yd = this.yd - this.gravity;
this.rotSpeed = this.rotSpeed + this.spinAcceleration / 20.0F;
this.oRoll = this.roll;
this.roll = this.roll + this.rotSpeed / 20.0F;
this.move(this.xd, this.yd, this.zd);
if (this.onGround || this.lifetime < 299 && (this.xd == 0.0 || this.zd == 0.0)) {
this.remove();
}
if (!this.removed) {
this.xd = this.xd * this.friction;
this.yd = this.yd * this.friction;
this.zd = this.zd * this.friction;
}
}
}
@OnlyIn(Dist.CLIENT)
public static class CherryProvider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public CherryProvider(SpriteSet sprites) {
this.sprites = sprites;
}
public Particle createParticle(
SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
return new FallingLeavesParticle(level, x, y, z, this.sprites.get(random), 0.25F, 2.0F, false, true, 1.0F, 0.0F);
}
}
@OnlyIn(Dist.CLIENT)
public static class PaleOakProvider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprites;
public PaleOakProvider(SpriteSet sprites) {
this.sprites = sprites;
}
public Particle createParticle(
SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
return new FallingLeavesParticle(level, x, y, z, this.sprites.get(random), 0.07F, 10.0F, true, false, 2.0F, 0.021F);
}
}
@OnlyIn(Dist.CLIENT)
public static class TintedLeavesProvider implements ParticleProvider<ColorParticleOption> {
private final SpriteSet sprites;
public TintedLeavesProvider(SpriteSet sprites) {
this.sprites = sprites;
}
public Particle createParticle(
ColorParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
FallingLeavesParticle particle = new FallingLeavesParticle(level, x, y, z, this.sprites.get(random), 0.07F, 10.0F, true, false, 2.0F, 0.021F);
particle.setColor(options.getRed(), options.getGreen(), options.getBlue());
return particle;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置: