添加粒子属性
This commit is contained in:
parent
ca6e687b78
commit
b6e58c411a
3 changed files with 54 additions and 12 deletions
|
@ -17,7 +17,10 @@ public class BulletDecalOption implements ParticleOptions {
|
||||||
public static final Codec<BulletDecalOption> CODEC = RecordCodecBuilder.create(builder ->
|
public static final Codec<BulletDecalOption> CODEC = RecordCodecBuilder.create(builder ->
|
||||||
builder.group(
|
builder.group(
|
||||||
Codec.INT.fieldOf("dir").forGetter(option -> option.direction.ordinal()),
|
Codec.INT.fieldOf("dir").forGetter(option -> option.direction.ordinal()),
|
||||||
Codec.LONG.fieldOf("pos").forGetter(option -> option.pos.asLong())
|
Codec.LONG.fieldOf("pos").forGetter(option -> option.pos.asLong()),
|
||||||
|
Codec.FLOAT.fieldOf("r").forGetter(option -> option.red),
|
||||||
|
Codec.FLOAT.fieldOf("g").forGetter(option -> option.green),
|
||||||
|
Codec.FLOAT.fieldOf("b").forGetter(option -> option.blue)
|
||||||
).apply(builder, BulletDecalOption::new));
|
).apply(builder, BulletDecalOption::new));
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -28,26 +31,45 @@ public class BulletDecalOption implements ParticleOptions {
|
||||||
int dir = reader.readInt();
|
int dir = reader.readInt();
|
||||||
reader.expect(' ');
|
reader.expect(' ');
|
||||||
long pos = reader.readLong();
|
long pos = reader.readLong();
|
||||||
return new BulletDecalOption(dir, pos);
|
reader.expect(' ');
|
||||||
|
float r = reader.readFloat();
|
||||||
|
reader.expect(' ');
|
||||||
|
float g = reader.readFloat();
|
||||||
|
reader.expect(' ');
|
||||||
|
float b = reader.readFloat();
|
||||||
|
return new BulletDecalOption(dir, pos, r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulletDecalOption fromNetwork(ParticleType<BulletDecalOption> particleType, FriendlyByteBuf buffer) {
|
public BulletDecalOption fromNetwork(ParticleType<BulletDecalOption> particleType, FriendlyByteBuf buffer) {
|
||||||
return new BulletDecalOption(buffer.readVarInt(), buffer.readLong());
|
return new BulletDecalOption(buffer.readVarInt(), buffer.readLong(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Direction direction;
|
private final Direction direction;
|
||||||
private final BlockPos pos;
|
private final BlockPos pos;
|
||||||
|
private final float red;
|
||||||
|
private final float green;
|
||||||
|
private final float blue;
|
||||||
|
|
||||||
public BulletDecalOption(int dir, long pos) {
|
public BulletDecalOption(int dir, long pos) {
|
||||||
this.direction = Direction.values()[dir];
|
this(Direction.values()[dir], BlockPos.of(pos), 0f, 0f, 0f);
|
||||||
this.pos = BlockPos.of(pos);
|
}
|
||||||
|
|
||||||
|
public BulletDecalOption(int dir, long pos, float r, float g, float b) {
|
||||||
|
this(Direction.values()[dir], BlockPos.of(pos), r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BulletDecalOption(Direction dir, BlockPos pos) {
|
public BulletDecalOption(Direction dir, BlockPos pos) {
|
||||||
|
this(dir, pos, 0f, 0f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BulletDecalOption(Direction dir, BlockPos pos, float r, float g, float b) {
|
||||||
this.direction = dir;
|
this.direction = dir;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
|
this.red = r;
|
||||||
|
this.green = g;
|
||||||
|
this.blue = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Direction getDirection() {
|
public Direction getDirection() {
|
||||||
|
@ -58,6 +80,18 @@ public class BulletDecalOption implements ParticleOptions {
|
||||||
return this.pos;
|
return this.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getRed() {
|
||||||
|
return red;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getGreen() {
|
||||||
|
return green;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getBlue() {
|
||||||
|
return blue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParticleType<?> getType() {
|
public ParticleType<?> getType() {
|
||||||
return ModParticleTypes.BULLET_DECAL.get();
|
return ModParticleTypes.BULLET_DECAL.get();
|
||||||
|
@ -67,6 +101,9 @@ public class BulletDecalOption implements ParticleOptions {
|
||||||
public void writeToNetwork(FriendlyByteBuf buffer) {
|
public void writeToNetwork(FriendlyByteBuf buffer) {
|
||||||
buffer.writeEnum(this.direction);
|
buffer.writeEnum(this.direction);
|
||||||
buffer.writeBlockPos(this.pos);
|
buffer.writeBlockPos(this.pos);
|
||||||
|
buffer.writeFloat(this.red);
|
||||||
|
buffer.writeFloat(this.green);
|
||||||
|
buffer.writeFloat(this.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,8 +37,12 @@ public class BulletDecalParticle extends TextureSheetParticle {
|
||||||
private int vOffset;
|
private int vOffset;
|
||||||
private float textureDensity;
|
private float textureDensity;
|
||||||
|
|
||||||
public BulletDecalParticle(ClientLevel world, double x, double y, double z, Direction direction, BlockPos pos) {
|
public BulletDecalParticle(ClientLevel level, double x, double y, double z, Direction direction, BlockPos pos) {
|
||||||
super(world, x, y, z);
|
this(level, x, y, z, direction, pos, 0f, 0f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BulletDecalParticle(ClientLevel level, double x, double y, double z, Direction direction, BlockPos pos, float rCol, float gCol, float bCol) {
|
||||||
|
super(level, x, y, z);
|
||||||
this.setSprite(this.getSprite(pos));
|
this.setSprite(this.getSprite(pos));
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
|
@ -51,9 +55,9 @@ public class BulletDecalParticle extends TextureSheetParticle {
|
||||||
this.remove();
|
this.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rCol = 0;
|
this.rCol = rCol;
|
||||||
this.gCol = 0;
|
this.gCol = gCol;
|
||||||
this.bCol = 0;
|
this.bCol = bCol;
|
||||||
|
|
||||||
this.alpha = 0.9F;
|
this.alpha = 0.9F;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +188,7 @@ public class BulletDecalParticle extends TextureSheetParticle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulletDecalParticle createParticle(@NotNull BulletDecalOption option, @NotNull ClientLevel world, double x, double y, double z, double pXSpeed, double pYSpeed, double pZSpeed) {
|
public BulletDecalParticle createParticle(@NotNull BulletDecalOption option, @NotNull ClientLevel world, double x, double y, double z, double pXSpeed, double pYSpeed, double pZSpeed) {
|
||||||
return new BulletDecalParticle(world, x, y, z, option.getDirection(), option.getPos());
|
return new BulletDecalParticle(world, x, y, z, option.getDirection(), option.getPos(), option.getRed(), option.getGreen(), option.getBlue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -510,7 +510,8 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
||||||
if (this.beast) {
|
if (this.beast) {
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.END_ROD, location.x, location.y, location.z, 15, 0.1, 0.1, 0.1, 0.05, true);
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.END_ROD, location.x, location.y, location.z, 15, 0.1, 0.1, 0.1, 0.05, true);
|
||||||
} else {
|
} else {
|
||||||
BulletDecalOption bulletDecalOption = new BulletDecalOption(result.getDirection(), result.getBlockPos());
|
BulletDecalOption bulletDecalOption = new BulletDecalOption(result.getDirection(), result.getBlockPos(),
|
||||||
|
this.entityData.get(COLOR_R), this.entityData.get(COLOR_G), this.entityData.get(COLOR_B));
|
||||||
serverLevel.sendParticles(bulletDecalOption, location.x, location.y, location.z, 1, 0, 0, 0, 0);
|
serverLevel.sendParticles(bulletDecalOption, location.x, location.y, location.z, 1, 0, 0, 0, 0);
|
||||||
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, location.x, location.y, location.z, 3, vx, vy, vz, 0.01, true);
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, location.x, location.y, location.z, 3, vx, vy, vz, 0.01, true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue