添加在弹射物击中载具精确位置的特效
This commit is contained in:
parent
5ac84a8938
commit
9dd109c926
8 changed files with 20 additions and 54 deletions
|
@ -190,8 +190,9 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
||||||
if (obbVec != null) {
|
if (obbVec != null) {
|
||||||
hitPos = new Vec3(obbVec);
|
hitPos = new Vec3(obbVec);
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
this.level().playSound(null, BlockPos.containing(hitPos), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.2, false);
|
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.2, false);
|
||||||
sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 3, 0, 0, 0, 0.01, false);
|
sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.01, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,11 +174,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.2), random.nextFloat() * 0.1f + 1f);
|
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.2), random.nextFloat() * 0.1f + 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DamageModifier getDamageModifier() {
|
public DamageModifier getDamageModifier() {
|
||||||
return super.getDamageModifier()
|
return super.getDamageModifier()
|
||||||
|
|
|
@ -98,14 +98,8 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
return Mth.lerp(0.6f * tickDelta, pitchO, getBodyPitch());
|
return Mth.lerp(0.6f * tickDelta, pitchO, getBodyPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public DroneEntity(EntityType<? extends DroneEntity> type, Level world, float moveX, float moveY, float moveZ) {
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
super(type, world);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean playHitSoundOnHurt() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,10 +78,6 @@ public class MortarEntity extends VehicleEntity implements GeoEntity {
|
||||||
return 0.2F;
|
return 0.2F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
|
|
|
@ -100,11 +100,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.1f + 1f);
|
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.1f + 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) {
|
public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) {
|
||||||
if (player.getMainHandItem().is(Items.MELON) && !entityData.get(MELON)) {
|
if (player.getMainHandItem().is(Items.MELON) && !entityData.get(MELON)) {
|
||||||
|
|
|
@ -90,11 +90,6 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.15f + 1);
|
this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.15f + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
if (jumpCoolDown > 0 && onGround()) {
|
if (jumpCoolDown > 0 && onGround()) {
|
||||||
|
|
|
@ -72,7 +72,6 @@ import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
|
||||||
|
|
||||||
public abstract class VehicleEntity extends Entity {
|
public abstract class VehicleEntity extends Entity {
|
||||||
|
|
||||||
|
@ -430,33 +429,9 @@ public abstract class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onHurt(computedAmount, source.getEntity(), true);
|
this.onHurt(computedAmount, source.getEntity(), true);
|
||||||
|
|
||||||
// 显示火花粒子效果
|
|
||||||
if (this.sendFireStarParticleOnHurt() && this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.5 * getBbHeight(), this.getZ(), 2, 0.4, 0.4, 0.4, 0.2, false);
|
|
||||||
}
|
|
||||||
// 播放受击音效
|
|
||||||
if (this.playHitSoundOnHurt()) {
|
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.hurt(source, computedAmount);
|
return super.hurt(source, computedAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 受击时是否显示火花粒子效果
|
|
||||||
*/
|
|
||||||
public boolean sendFireStarParticleOnHurt() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 受击时是否播放受击音效
|
|
||||||
*/
|
|
||||||
public boolean playHitSoundOnHurt() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制载具伤害免疫
|
* 控制载具伤害免疫
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.projectile.Projectile;
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||||
|
@ -17,6 +23,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
@Mixin(ProjectileUtil.class)
|
@Mixin(ProjectileUtil.class)
|
||||||
public class ProjectileUtilMixin {
|
public class ProjectileUtilMixin {
|
||||||
|
|
||||||
|
@ -35,7 +43,14 @@ public class ProjectileUtilMixin {
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
double d1 = pStartVec.distanceToSqr(new Vec3(optional.get()));
|
double d1 = pStartVec.distanceToSqr(new Vec3(optional.get()));
|
||||||
if (d1 < Double.MAX_VALUE) {
|
if (d1 < Double.MAX_VALUE) {
|
||||||
cir.setReturnValue(new EntityHitResult(entity, new Vec3(optional.get())));
|
EntityHitResult hitResult = new EntityHitResult(entity, new Vec3(optional.get()));
|
||||||
|
cir.setReturnValue(hitResult);
|
||||||
|
if (pLevel instanceof ServerLevel serverLevel && pProjectile.getDeltaMovement().lengthSqr() > 0.01) {
|
||||||
|
Vec3 hitPos = hitResult.getLocation();
|
||||||
|
pLevel.playSound(null, BlockPos.containing(hitPos), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
|
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.2, false);
|
||||||
|
sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.01, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue