From f1eff29ae3e63bff91148fe3b880df44914574cd Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 29 Jun 2025 18:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=B2=92=E5=AD=90=E9=A2=9C?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/particle/BulletDecalOption.java | 11 +++++----- .../entity/projectile/ProjectileEntity.java | 20 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/particle/BulletDecalOption.java b/src/main/java/com/atsuishio/superbwarfare/client/particle/BulletDecalOption.java index 0486fea59..8fa5b4c66 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/particle/BulletDecalOption.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/particle/BulletDecalOption.java @@ -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(); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java index a4a0fd6e3..ad408a351 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java @@ -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);