添加低血量和锁定警告
This commit is contained in:
parent
926298a1bf
commit
ff3041ceed
16 changed files with 120 additions and 98 deletions
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.entity.AnimatedEntity;
|
import com.atsuishio.superbwarfare.entity.AnimatedEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
@ -20,11 +21,13 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.animal.Pig;
|
||||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||||
import net.minecraft.world.entity.monster.Monster;
|
import net.minecraft.world.entity.monster.Monster;
|
||||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||||
|
@ -187,6 +190,9 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
|
||||||
this.entityData.set(TARGET_X, (float) entity.getX());
|
this.entityData.set(TARGET_X, (float) entity.getX());
|
||||||
this.entityData.set(TARGET_Y, (float) entity.getEyeY());
|
this.entityData.set(TARGET_Y, (float) entity.getEyeY());
|
||||||
this.entityData.set(TARGET_Z, (float) entity.getZ());
|
this.entityData.set(TARGET_Z, (float) entity.getZ());
|
||||||
|
if ((!entity.getPassengers().isEmpty() || entity instanceof VehicleEntity) && entity.tickCount %((int)Math.max(0.04 * this.distanceTo(entity),2)) == 0) {
|
||||||
|
entity.level().playSound(null, entity.getOnPos(), entity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.MISSILE_WARNING.get(), SoundSource.PLAYERS, 2, 1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double px = this.getX();
|
double px = this.getX();
|
||||||
|
|
|
@ -177,6 +177,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.6, 0.6));
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.6, 0.6));
|
||||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), 26 + (float) (60 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), 26 + (float) (60 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lowHealthWarning();
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +444,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
projectileRight.heBullet(true, 1);
|
projectileRight.heBullet(true, 1);
|
||||||
projectileRight.bypassArmorRate(0.2f);
|
projectileRight.bypassArmorRate(0.2f);
|
||||||
projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
|
projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
|
||||||
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.025, this.getLookAngle().z, 20,
|
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20,
|
||||||
(float) 0.2);
|
(float) 0.2);
|
||||||
this.level().addFreshEntity(projectileRight);
|
this.level().addFreshEntity(projectileRight);
|
||||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
|
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
|
||||||
|
@ -460,7 +463,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
projectileLeft.heBullet(true, 1);
|
projectileLeft.heBullet(true, 1);
|
||||||
projectileLeft.bypassArmorRate(0.2f);
|
projectileLeft.bypassArmorRate(0.2f);
|
||||||
projectileLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
|
projectileLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
|
||||||
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.025, this.getLookAngle().z, 20,
|
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20,
|
||||||
(float) 0.2);
|
(float) 0.2);
|
||||||
this.level().addFreshEntity(projectileLeft);
|
this.level().addFreshEntity(projectileLeft);
|
||||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
|
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.atsuishio.superbwarfare.tools.*;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
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.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
@ -22,7 +21,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -163,31 +161,7 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
lowHealthWarning();
|
||||||
if (this.getHealth() <= 0.4 * this.getMaxHealth()) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.25 * this.getMaxHealth()) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.15 * this.getMaxHealth()) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false);
|
|
||||||
if (this.tickCount % 15 == 0) {
|
|
||||||
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float delta = Math.abs(getYRot() - yRotO);
|
float delta = Math.abs(getYRot() - yRotO);
|
||||||
while (getYRot() > 180F) {
|
while (getYRot() > 180F) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -137,38 +136,6 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getHealth() <= 0.4 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.25 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.15 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false);
|
|
||||||
}
|
|
||||||
if (this.tickCount % 15 == 0) {
|
|
||||||
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -152,37 +151,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getHealth() <= 0.4 * this.getMaxHealth()) {
|
lowHealthWarning();
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.25 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.15 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 3.2, this.getZ(), 4, 0.6, 0.1, 0.6, 0.05, false);
|
|
||||||
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 3, this.getZ(), 4, 0.1, 0.1, 0.1, 0.4, false);
|
|
||||||
}
|
|
||||||
if (this.tickCount % 15 == 0) {
|
|
||||||
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,6 +201,7 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity,
|
||||||
|
|
||||||
collideBlock();
|
collideBlock();
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
|
lowHealthWarning();
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,21 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||||
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -259,6 +264,46 @@ public class VehicleEntity extends Entity {
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void lowHealthWarning() {
|
||||||
|
if (this.getHealth() <= 0.4 * this.getMaxHealth()) {
|
||||||
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getHealth() <= 0.25 * this.getMaxHealth()) {
|
||||||
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getHealth() <= 0.15 * this.getMaxHealth()) {
|
||||||
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 1, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
|
||||||
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 0.7f * getBbHeight(), this.getZ(), 2, 0.35 * this.getBbWidth(), 0.15 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.01, false);
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.FLAME, this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.35 * this.getBbWidth(), 0.12 * this.getBbHeight(), 0.35 * this.getBbWidth(), 0.05, false);
|
||||||
|
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.85f * getBbHeight(), this.getZ(), 4, 0.1 * this.getBbWidth(), 0.05 * this.getBbHeight(), 0.1 * this.getBbWidth(), 0.4, false);
|
||||||
|
}
|
||||||
|
if (this.tickCount % 15 == 0) {
|
||||||
|
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getHealth() < 0.1f * this.getMaxHealth() && tickCount %13 == 0) {
|
||||||
|
this.level().playSound(null, this.getOnPos(), ModSounds.NO_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
|
} else if (this.getHealth() >= 0.1f && this.getHealth() < 0.4f * this.getMaxHealth() && tickCount %10 == 0) {
|
||||||
|
this.level().playSound(null, this.getOnPos(), ModSounds.LOW_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -369,5 +369,10 @@ public class ModSounds {
|
||||||
public static final RegistryObject<SoundEvent> INTO_CANNON = REGISTRY.register("into_cannon", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("into_cannon")));
|
public static final RegistryObject<SoundEvent> INTO_CANNON = REGISTRY.register("into_cannon", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("into_cannon")));
|
||||||
public static final RegistryObject<SoundEvent> INTO_MISSILE = REGISTRY.register("into_missile", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("into_missile")));
|
public static final RegistryObject<SoundEvent> INTO_MISSILE = REGISTRY.register("into_missile", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("into_missile")));
|
||||||
public static final RegistryObject<SoundEvent> MISSILE_RELOAD = REGISTRY.register("missile_reload", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_reload")));
|
public static final RegistryObject<SoundEvent> MISSILE_RELOAD = REGISTRY.register("missile_reload", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_reload")));
|
||||||
|
public static final RegistryObject<SoundEvent> LOW_HEALTH = REGISTRY.register("low_health", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("low_health")));
|
||||||
|
public static final RegistryObject<SoundEvent> NO_HEALTH = REGISTRY.register("no_health", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("no_health")));
|
||||||
|
public static final RegistryObject<SoundEvent> LOCKING_WARNING = REGISTRY.register("locking_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locking_warning")));
|
||||||
|
public static final RegistryObject<SoundEvent> LOCKED_WARNING = REGISTRY.register("locked_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("locked_warning")));
|
||||||
|
public static final RegistryObject<SoundEvent> MISSILE_WARNING = REGISTRY.register("missile_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_warning")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.client.PoseTool;
|
import com.atsuishio.superbwarfare.client.PoseTool;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.JavelinItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.JavelinItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.client.tooltip.component.LauncherImageComponent;
|
import com.atsuishio.superbwarfare.client.tooltip.component.LauncherImageComponent;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
@ -20,10 +21,13 @@ import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.animal.Pig;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||||
import net.minecraft.world.item.ItemDisplayContext;
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
|
@ -136,7 +140,7 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player && selected) {
|
||||||
var tag = stack.getOrCreateTag();
|
var tag = stack.getOrCreateTag();
|
||||||
GunsTool.setGunIntTag(stack, "MaxAmmo", getAmmoCount(player));
|
GunsTool.setGunIntTag(stack, "MaxAmmo", getAmmoCount(player));
|
||||||
|
|
||||||
|
@ -145,20 +149,28 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8);
|
Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8);
|
||||||
if (seekingEntity != null && seekingEntity == targetEntity) {
|
if (seekingEntity != null && seekingEntity == targetEntity) {
|
||||||
tag.putInt("SeekTime", tag.getInt("SeekTime") + 1);
|
tag.putInt("SeekTime", tag.getInt("SeekTime") + 1);
|
||||||
|
if (tag.getInt("SeekTime") > 0 && (!seekingEntity.getPassengers().isEmpty() || seekingEntity instanceof VehicleEntity) && seekingEntity.tickCount %3 == 0) {
|
||||||
|
seekingEntity.level().playSound(null, seekingEntity.getOnPos(), seekingEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKING_WARNING.get(), SoundSource.PLAYERS, 1, 1f);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("SeekTime", 0);
|
tag.putInt("SeekTime", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("SeekTime") == 1 && player instanceof ServerPlayer serverPlayer) {
|
if (tag.getInt("SeekTime") == 1 && player instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCK.get(), 2, 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCK.get(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seekingEntity != null && tag.getInt("SeekTime") > 20) {
|
if (seekingEntity != null && tag.getInt("SeekTime") > 20) {
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCKON.get(), 2, 1);
|
SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCKON.get(), 1, 1);
|
||||||
|
}
|
||||||
|
if ((!seekingEntity.getPassengers().isEmpty() || seekingEntity instanceof VehicleEntity) && seekingEntity.tickCount %2 == 0) {
|
||||||
|
seekingEntity.level().playSound(null, seekingEntity.getOnPos(), seekingEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKED_WARNING.get(), SoundSource.PLAYERS, 1, 0.95f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
stack.getOrCreateTag().putInt("SeekTime", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class SeekTool {
|
||||||
&& e.isAlive()
|
&& e.isAlive()
|
||||||
&& !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand)
|
&& !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand)
|
||||||
&& (e instanceof LivingEntity || e instanceof VehicleEntity)
|
&& (e instanceof LivingEntity || e instanceof VehicleEntity)
|
||||||
&& !(e instanceof Player player && (player.isCreative() || player.isSpectator()))
|
&& !(e instanceof Player player && (player.isSpectator()))
|
||||||
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
||||||
return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(),
|
return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(),
|
||||||
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK;
|
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK;
|
||||||
|
|
|
@ -2600,5 +2600,45 @@
|
||||||
"stream": false
|
"stream": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"low_health": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:warning/low_health",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"no_health": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:warning/no_health",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locking_warning": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:warning/locking",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked_warning": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:warning/locked",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"missile_warning": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:warning/missile",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue