修改坠机方法
This commit is contained in:
parent
b15d4a9a36
commit
06a1f0b827
10 changed files with 44 additions and 26 deletions
|
@ -16,6 +16,7 @@ import com.google.common.collect.Lists;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
|
@ -35,6 +36,7 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.vehicle.DismountHelper;
|
import net.minecraft.world.entity.vehicle.DismountHelper;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.gameevent.GameEvent;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
|
@ -53,6 +55,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
|
||||||
|
@ -325,16 +328,48 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
|
if (crash) {
|
||||||
|
List<Entity> passenger = this.getPassengers();
|
||||||
|
for (var e : passenger) {
|
||||||
|
if (e instanceof LivingEntity living) {
|
||||||
|
if (e instanceof ServerPlayer victim) {
|
||||||
|
living.setHealth(0);
|
||||||
|
if (attacker == null || attacker == victim) {
|
||||||
|
living.level().players().forEach(
|
||||||
|
p -> p.sendSystemMessage(
|
||||||
|
Component.translatable("death.attack.air_crash", victim.getDisplayName())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
living.level().players().forEach(
|
||||||
|
p -> p.sendSystemMessage(
|
||||||
|
Component.translatable("death.attack.air_crash_entity",
|
||||||
|
victim.getDisplayName(),
|
||||||
|
attacker.getDisplayName()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
living.setHealth(0);
|
||||||
|
living.level().broadcastEntityEvent(living, (byte) 60);
|
||||||
|
living.remove(RemovalReason.KILLED);
|
||||||
|
living.gameEvent(GameEvent.ENTITY_DIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
crash ? ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), this, attacker) : ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, attacker), 300.0f,
|
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, attacker), 300.0f,
|
||||||
this.getX(), this.getY(), this.getZ(), 8f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
this.getX(), this.getY(), this.getZ(), 8f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
|
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
|
||||||
this.remove(RemovalReason.KILLED);
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,6 @@ public class VehicleEntity extends Entity {
|
||||||
handleClientSync();
|
handleClientSync();
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel && this.getHealth() <= 0) {
|
if (this.level() instanceof ServerLevel && this.getHealth() <= 0) {
|
||||||
this.ejectPassengers();
|
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class ModDamageTypes {
|
||||||
public static final ResourceKey<DamageType> LASER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser"));
|
public static final ResourceKey<DamageType> LASER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser"));
|
||||||
public static final ResourceKey<DamageType> LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser_headshot"));
|
public static final ResourceKey<DamageType> LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser_headshot"));
|
||||||
public static final ResourceKey<DamageType> VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "vehicle_strike"));
|
public static final ResourceKey<DamageType> VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "vehicle_strike"));
|
||||||
public static final ResourceKey<DamageType> AIR_CRASH = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "air_crash"));
|
|
||||||
|
|
||||||
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
||||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
|
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
|
||||||
|
@ -89,10 +88,6 @@ public class ModDamageTypes {
|
||||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(VEHICLE_STRIKE), directEntity, attacker);
|
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(VEHICLE_STRIKE), directEntity, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DamageSource causeAirCrashDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
|
||||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(AIR_CRASH), directEntity, attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DamageMessages extends DamageSource {
|
private static class DamageMessages extends DamageSource {
|
||||||
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
||||||
super(typeReference);
|
super(typeReference);
|
||||||
|
|
|
@ -351,8 +351,7 @@
|
||||||
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
|
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
|
||||||
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
|
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
|
||||||
"death.attack.air_crash": "%1$s坠机了",
|
"death.attack.air_crash": "%1$s坠机了",
|
||||||
"death.attack.air_crash.entity": "%1$s坠机了",
|
"death.attack.air_crash_entity": "%1$s坠机了,凶手是%2$s",
|
||||||
"death.attack.air_crash.item": "%1$s坠机了",
|
|
||||||
|
|
||||||
"entity.superbwarfare.projectile": "Bullet",
|
"entity.superbwarfare.projectile": "Bullet",
|
||||||
"entity.superbwarfare.projectile_mortar_shell": "Mortar Shell",
|
"entity.superbwarfare.projectile_mortar_shell": "Mortar Shell",
|
||||||
|
|
|
@ -351,8 +351,7 @@
|
||||||
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
|
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
|
||||||
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
|
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
|
||||||
"death.attack.air_crash": "%1$s坠机了",
|
"death.attack.air_crash": "%1$s坠机了",
|
||||||
"death.attack.air_crash.entity": "%1$s坠机了",
|
"death.attack.air_crash_entity": "%1$s坠机了,凶手是%2$s",
|
||||||
"death.attack.air_crash.item": "%1$s坠机了",
|
|
||||||
|
|
||||||
"entity.superbwarfare.projectile": "子弹",
|
"entity.superbwarfare.projectile": "子弹",
|
||||||
"entity.superbwarfare.projectile_mortar_shell": "迫击炮弹",
|
"entity.superbwarfare.projectile_mortar_shell": "迫击炮弹",
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
"superbwarfare:cannon_fire",
|
"superbwarfare:cannon_fire",
|
||||||
"superbwarfare:laser",
|
"superbwarfare:laser",
|
||||||
"superbwarfare:laser_headshot",
|
"superbwarfare:laser_headshot",
|
||||||
"superbwarfare:vehicle_strike",
|
"superbwarfare:vehicle_strike"
|
||||||
"superbwarfare:air_crash"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@
|
||||||
"superbwarfare:cannon_fire",
|
"superbwarfare:cannon_fire",
|
||||||
"superbwarfare:laser",
|
"superbwarfare:laser",
|
||||||
"superbwarfare:laser_headshot",
|
"superbwarfare:laser_headshot",
|
||||||
"superbwarfare:vehicle_strike",
|
"superbwarfare:vehicle_strike"
|
||||||
"superbwarfare:air_crash"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@
|
||||||
"superbwarfare:cannon_fire",
|
"superbwarfare:cannon_fire",
|
||||||
"superbwarfare:laser",
|
"superbwarfare:laser",
|
||||||
"superbwarfare:laser_headshot",
|
"superbwarfare:laser_headshot",
|
||||||
"superbwarfare:vehicle_strike",
|
"superbwarfare:vehicle_strike"
|
||||||
"superbwarfare:air_crash"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,7 +7,6 @@
|
||||||
"superbwarfare:cannon_fire",
|
"superbwarfare:cannon_fire",
|
||||||
"superbwarfare:laser",
|
"superbwarfare:laser",
|
||||||
"superbwarfare:laser_headshot",
|
"superbwarfare:laser_headshot",
|
||||||
"superbwarfare:vehicle_strike",
|
"superbwarfare:vehicle_strike"
|
||||||
"superbwarfare:air_crash"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"exhaustion": 0,
|
|
||||||
"message_id": "air_crash",
|
|
||||||
"scaling": "never"
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue