回滚载具近战受伤粒子和音效
This commit is contained in:
parent
5ccf5c48fc
commit
dc6a704048
7 changed files with 65 additions and 4 deletions
|
@ -165,6 +165,11 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
this.entityData.set(LOADED_MISSILE, compound.getInt("LoadedMissile"));
|
this.entityData.set(LOADED_MISSILE, compound.getInt("LoadedMissile"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) {
|
protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) {
|
||||||
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);
|
||||||
|
|
|
@ -112,6 +112,16 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitSounds() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
|
|
|
@ -55,6 +55,11 @@ public class MortarEntity extends VehicleEntity implements GeoEntity {
|
||||||
this.entityData.set(YAW, yRot);
|
this.entityData.set(YAW, yRot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||||
super.defineSynchedData(builder);
|
super.defineSynchedData(builder);
|
||||||
|
@ -65,7 +70,7 @@ public class MortarEntity extends VehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCollidedWith() {
|
public boolean canBeCollidedWith() {
|
||||||
return false;
|
return super.canBeCollidedWith();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -94,6 +94,11 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.entityData.set(MELON, compound.getBoolean("Melon"));
|
this.entityData.set(MELON, compound.getBoolean("Melon"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
protected void playStepSound(BlockPos pPos, BlockState pState) {
|
protected void playStepSound(BlockPos pPos, BlockState pState) {
|
||||||
|
|
|
@ -85,6 +85,11 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) {
|
protected void playStepSound(@NotNull BlockPos pPos, @NotNull BlockState pState) {
|
||||||
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);
|
||||||
|
|
|
@ -291,6 +291,20 @@ public abstract class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 受击时是否出现粒子效果
|
||||||
|
*/
|
||||||
|
public boolean shouldSendHitParticles() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 受击时是否出现音效
|
||||||
|
*/
|
||||||
|
public boolean shouldSendHitSounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public VehicleEntity(EntityType<?> pEntityType, Level pLevel) {
|
public VehicleEntity(EntityType<?> pEntityType, Level pLevel) {
|
||||||
super(pEntityType, pLevel);
|
super(pEntityType, pLevel);
|
||||||
this.setHealth(this.getMaxHealth());
|
this.setHealth(this.getMaxHealth());
|
||||||
|
|
|
@ -4,9 +4,8 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
|
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.MiscConfig;
|
import com.atsuishio.superbwarfare.config.server.MiscConfig;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.network.message.receive.SimulationDistanceMessage;
|
import com.atsuishio.superbwarfare.network.message.receive.SimulationDistanceMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||||
|
@ -24,10 +23,13 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.neoforge.event.AnvilUpdateEvent;
|
import net.neoforged.neoforge.event.AnvilUpdateEvent;
|
||||||
|
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
@EventBusSubscriber
|
@EventBusSubscriber
|
||||||
public class PlayerEventHandler {
|
public class PlayerEventHandler {
|
||||||
|
|
||||||
|
@ -189,4 +191,19 @@ public class PlayerEventHandler {
|
||||||
event.setMaterialCost(1);
|
event.setMaterialCost(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onAttackEntity(AttackEntityEvent event) {
|
||||||
|
var target = event.getTarget();
|
||||||
|
if (target instanceof VehicleEntity vehicle) {
|
||||||
|
if (vehicle.shouldSendHitSounds()) {
|
||||||
|
vehicle.level().playSound(null, vehicle.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vehicle.shouldSendHitParticles() && vehicle.level() instanceof ServerLevel serverLevel) {
|
||||||
|
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), vehicle.getX(), vehicle.getY() + 0.5 * vehicle.getBbHeight(), vehicle.getZ(),
|
||||||
|
2, 0.4, 0.4, 0.4, 0.2, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue