TerrainParticle.java
net.minecraft.client.particle.TerrainParticle
信息
- 全限定名:net.minecraft.client.particle.TerrainParticle
- 类型:public class
- 包:net.minecraft.client.particle
- 源码路径:src/main/java/net/minecraft/client/particle/TerrainParticle.java
- 起始行号:L16
- 继承:SingleQuadParticle
- 职责:
TODO
字段/常量
-
layer- 类型:
SingleQuadParticle.Layer - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
pos- 类型:
BlockPos - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
uo- 类型:
float - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
vo- 类型:
float - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.particle.TerrainParticle.CrumblingProvider- 类型:
class - 修饰符:
public static - 源码定位:
L82 - 说明:
TODO
- 类型:
-
net.minecraft.client.particle.TerrainParticle.DustPillarProvider- 类型:
class - 修饰符:
public static - 源码定位:
L97 - 说明:
TODO
- 类型:
-
net.minecraft.client.particle.TerrainParticle.Provider- 类型:
class - 修饰符:
public static - 源码定位:
L112 - 说明:
TODO
- 类型:
构造器
public TerrainParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, BlockState blockState) @ L22
- 构造器名:TerrainParticle
- 源码定位:L22
- 修饰符:public
参数:
- level: ClientLevel
- x: double
- y: double
- z: double
- xa: double
- ya: double
- za: double
- blockState: BlockState
说明:
TODO
public TerrainParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, BlockState blockState, BlockPos pos) @ L26
- 构造器名:TerrainParticle
- 源码定位:L26
- 修饰符:public
参数:
- level: ClientLevel
- x: double
- y: double
- z: double
- xa: double
- ya: double
- za: double
- blockState: BlockState
- pos: BlockPos
说明:
TODO
方法
下面的方法块按源码顺序生成。
public SingleQuadParticle.Layer getLayer() @ L47
- 方法名:getLayer
- 源码定位:L47
- 返回类型:SingleQuadParticle.Layer
- 修饰符:public
参数:
- 无
说明:
TODO
protected float getU0() @ L52
- 方法名:getU0
- 源码定位:L52
- 返回类型:float
- 修饰符:protected
参数:
- 无
说明:
TODO
protected float getU1() @ L57
- 方法名:getU1
- 源码定位:L57
- 返回类型:float
- 修饰符:protected
参数:
- 无
说明:
TODO
protected float getV0() @ L62
- 方法名:getV0
- 源码定位:L62
- 返回类型:float
- 修饰符:protected
参数:
- 无
说明:
TODO
protected float getV1() @ L67
- 方法名:getV1
- 源码定位:L67
- 返回类型:float
- 修饰符:protected
参数:
- 无
说明:
TODO
private static TerrainParticle createTerrainParticle(BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux) @ L72
- 方法名:createTerrainParticle
- 源码定位:L72
- 返回类型:TerrainParticle
- 修饰符:private static
参数:
- options: BlockParticleOption
- level: ClientLevel
- x: double
- y: double
- z: double
- xAux: double
- yAux: double
- zAux: double
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TerrainParticle extends SingleQuadParticle {
private final SingleQuadParticle.Layer layer;
private final BlockPos pos;
private final float uo;
private final float vo;
public TerrainParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, BlockState blockState) {
this(level, x, y, z, xa, ya, za, blockState, BlockPos.containing(x, y, z));
}
public TerrainParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, BlockState blockState, BlockPos pos) {
super(level, x, y, z, xa, ya, za, Minecraft.getInstance().getModelManager().getBlockStateModelSet().getParticleMaterial(blockState).sprite());
this.pos = pos;
this.gravity = 1.0F;
this.rCol = 0.6F;
this.gCol = 0.6F;
this.bCol = 0.6F;
BlockTintSource tintSource = Minecraft.getInstance().getBlockColors().getTintSource(blockState, 0);
if (tintSource != null) {
int col = tintSource.colorAsTerrainParticle(blockState, level, pos);
this.rCol *= (col >> 16 & 0xFF) / 255.0F;
this.gCol *= (col >> 8 & 0xFF) / 255.0F;
this.bCol *= (col & 0xFF) / 255.0F;
}
this.quadSize /= 2.0F;
this.uo = this.random.nextFloat() * 3.0F;
this.vo = this.random.nextFloat() * 3.0F;
this.layer = SingleQuadParticle.Layer.bySprite(this.sprite);
}
@Override
public SingleQuadParticle.Layer getLayer() {
return this.layer;
}
@Override
protected float getU0() {
return this.sprite.getU((this.uo + 1.0F) / 4.0F);
}
@Override
protected float getU1() {
return this.sprite.getU(this.uo / 4.0F);
}
@Override
protected float getV0() {
return this.sprite.getV(this.vo / 4.0F);
}
@Override
protected float getV1() {
return this.sprite.getV((this.vo + 1.0F) / 4.0F);
}
private static @Nullable TerrainParticle createTerrainParticle(
BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux
) {
BlockState state = options.getState();
return !state.isAir() && !state.is(Blocks.MOVING_PISTON) && state.shouldSpawnTerrainParticles()
? new TerrainParticle(level, x, y, z, xAux, yAux, zAux, state)
: null;
}
@OnlyIn(Dist.CLIENT)
public static class CrumblingProvider implements ParticleProvider<BlockParticleOption> {
public @Nullable Particle createParticle(
BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
Particle particle = TerrainParticle.createTerrainParticle(options, level, x, y, z, xAux, yAux, zAux);
if (particle != null) {
particle.setParticleSpeed(0.0, 0.0, 0.0);
particle.setLifetime(random.nextInt(10) + 1);
}
return particle;
}
}
@OnlyIn(Dist.CLIENT)
public static class DustPillarProvider implements ParticleProvider<BlockParticleOption> {
public @Nullable Particle createParticle(
BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
Particle particle = TerrainParticle.createTerrainParticle(options, level, x, y, z, xAux, yAux, zAux);
if (particle != null) {
particle.setParticleSpeed(random.nextGaussian() / 30.0, yAux + random.nextGaussian() / 2.0, random.nextGaussian() / 30.0);
particle.setLifetime(random.nextInt(20) + 20);
}
return particle;
}
}
@OnlyIn(Dist.CLIENT)
public static class Provider implements ParticleProvider<BlockParticleOption> {
public @Nullable Particle createParticle(
BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
) {
return TerrainParticle.createTerrainParticle(options, level, x, y, z, xAux, yAux, zAux);
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用/继承/返回值 - 关联成员:
SingleQuadParticle.Layer.bySprite()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
BlockPos.containing()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: