调整粒子颜色
This commit is contained in:
parent
521fc8d080
commit
f1eff29ae3
2 changed files with 20 additions and 11 deletions
|
@ -9,8 +9,9 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BulletDecalOption implements ParticleOptions {
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class BulletDecalOption implements ParticleOptions {
|
|||
private final float blue;
|
||||
|
||||
public BulletDecalOption(int dir, long pos) {
|
||||
this(Direction.values()[dir], BlockPos.of(pos), 0f, 0f, 0f);
|
||||
this(Direction.values()[dir], BlockPos.of(pos), 0.9f, 0f, 0f);
|
||||
}
|
||||
|
||||
public BulletDecalOption(int dir, long pos, float r, float g, float b) {
|
||||
|
@ -61,7 +62,7 @@ public class BulletDecalOption implements ParticleOptions {
|
|||
}
|
||||
|
||||
public BulletDecalOption(Direction dir, BlockPos pos) {
|
||||
this(dir, pos, 0f, 0f, 0f);
|
||||
this(dir, pos, 0.9f, 0f, 0f);
|
||||
}
|
||||
|
||||
public BulletDecalOption(Direction dir, BlockPos pos, float r, float g, float b) {
|
||||
|
@ -93,7 +94,7 @@ public class BulletDecalOption implements ParticleOptions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
public @NotNull ParticleType<?> getType() {
|
||||
return ModParticleTypes.BULLET_DECAL.get();
|
||||
}
|
||||
|
||||
|
@ -108,6 +109,6 @@ public class BulletDecalOption implements ParticleOptions {
|
|||
|
||||
@Override
|
||||
public String writeToString() {
|
||||
return ForgeRegistries.PARTICLE_TYPES.getKey(this.getType()) + " " + this.direction.getName();
|
||||
return BuiltInRegistries.PARTICLE_TYPE.getKey(this.getType()) + " " + this.direction.getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,10 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
|||
|| input.getBlock() instanceof TrapDoorBlock
|
||||
|| input.getBlock() instanceof BarbedWireBlock);
|
||||
|
||||
public static final float DEFAULT_R = 1.0f;
|
||||
public static final float DEFAULT_G = 222 / 255f;
|
||||
public static final float DEFAULT_B = 39 / 255f;
|
||||
|
||||
@Nullable
|
||||
protected LivingEntity shooter;
|
||||
protected int shooterId;
|
||||
|
@ -264,10 +268,9 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
|||
|
||||
@Override
|
||||
protected void defineSynchedData(SynchedEntityData.@NotNull Builder builder) {
|
||||
builder.define(COLOR_R, 1.0f)
|
||||
.define(COLOR_G, 222 / 255f)
|
||||
.define(COLOR_B, 39 / 255f);
|
||||
|
||||
builder.define(COLOR_R, DEFAULT_R)
|
||||
.define(COLOR_G, DEFAULT_G)
|
||||
.define(COLOR_B, DEFAULT_B);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -510,8 +513,13 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
|||
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);
|
||||
} else {
|
||||
BulletDecalOption bulletDecalOption = new BulletDecalOption(result.getDirection(), result.getBlockPos(),
|
||||
this.entityData.get(COLOR_R), this.entityData.get(COLOR_G), this.entityData.get(COLOR_B));
|
||||
BulletDecalOption bulletDecalOption;
|
||||
if (this.entityData.get(COLOR_R) == DEFAULT_R && this.entityData.get(COLOR_G) == DEFAULT_G && this.entityData.get(COLOR_B) == DEFAULT_B) {
|
||||
bulletDecalOption = new BulletDecalOption(result.getDirection(), result.getBlockPos());
|
||||
} else {
|
||||
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);
|
||||
|
||||
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