优化部分代码
This commit is contained in:
parent
cf76e84186
commit
a39ecda5d8
1 changed files with 4 additions and 13 deletions
|
@ -61,12 +61,8 @@ public class LivingEventHandler {
|
||||||
public static void onEntityAttacked(LivingIncomingDamageEvent event) {
|
public static void onEntityAttacked(LivingIncomingDamageEvent event) {
|
||||||
if (!event.getSource().is(ModDamageTypes.VEHICLE_EXPLOSION) && event.getEntity().getVehicle() instanceof VehicleEntity vehicle) {
|
if (!event.getSource().is(ModDamageTypes.VEHICLE_EXPLOSION) && event.getEntity().getVehicle() instanceof VehicleEntity vehicle) {
|
||||||
if (event.getEntity().getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.hidePassenger(event.getEntity())) {
|
if (event.getEntity().getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.hidePassenger(event.getEntity())) {
|
||||||
if (!(event.getSource().is(DamageTypes.EXPLOSION)
|
if (!event.getSource().is(ModTags.DamageTypes.VEHICLE_NOT_ABSORB)) {
|
||||||
|| event.getSource().is(DamageTypes.PLAYER_EXPLOSION)
|
vehicle.hurt(event.getSource(), event.getAmount());
|
||||||
|| event.getSource().is(ModDamageTypes.CUSTOM_EXPLOSION)
|
|
||||||
|| event.getSource().is(ModDamageTypes.MINE)
|
|
||||||
|| event.getSource().is(ModDamageTypes.PROJECTILE_BOOM))) {
|
|
||||||
vehicle.hurt(event.getSource(), event.getContainer().getOriginalDamage());
|
|
||||||
}
|
}
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
@ -146,10 +142,8 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
var tag = NBTTool.getTag(armor);
|
var tag = NBTTool.getTag(armor);
|
||||||
if (armor != ItemStack.EMPTY && tag.contains("ArmorPlate")) {
|
if (armor != ItemStack.EMPTY && tag.contains("ArmorPlate")) {
|
||||||
double armorValue;
|
double armorValue = tag.getDouble("ArmorPlate");
|
||||||
armorValue = tag.getDouble("ArmorPlate");
|
|
||||||
tag.putDouble("ArmorPlate", Math.max(armorValue - damage, 0));
|
tag.putDouble("ArmorPlate", Math.max(armorValue - damage, 0));
|
||||||
NBTTool.saveTag(armor, tag);
|
|
||||||
damage = Math.max(damage - armorValue, 0);
|
damage = Math.max(damage - armorValue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,10 +422,7 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void stopGunReloadSound(ServerPlayer player, GunItem gun) {
|
private static void stopGunReloadSound(ServerPlayer player, GunItem gun) {
|
||||||
gun.getReloadSound().forEach(sound -> {
|
gun.getReloadSound().forEach(sound -> player.connection.send(new ClientboundStopSoundPacket(sound.getLocation(), SoundSource.PLAYERS)));
|
||||||
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(sound.getLocation(), SoundSource.PLAYERS);
|
|
||||||
player.connection.send(clientboundstopsoundpacket);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue