调整无人机数据,修复无人机投弹时炸到自身的bug

This commit is contained in:
Atsuihsio 2024-11-22 23:51:42 +08:00
parent 3092d53067
commit 3b26081e1c
3 changed files with 15 additions and 8 deletions

View file

@ -186,21 +186,24 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
if (!this.onGround()) { if (!this.onGround()) {
if (this.getPersistentData().getBoolean("left")) { if (this.getPersistentData().getBoolean("left")) {
this.entityData.set(MOVE_X, -1.5f); this.entityData.set(MOVE_X, -1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.25f, this.entityData.get(ROT_X), 0.5f)); this.entityData.set(ROT_X, Mth.lerp(0.1f, this.entityData.get(ROT_X), 0.3f));
} }
if (this.getPersistentData().getBoolean("right")) { if (this.getPersistentData().getBoolean("right")) {
this.entityData.set(MOVE_X, 1.5f); this.entityData.set(MOVE_X, 1.5f);
this.entityData.set(ROT_X, Mth.lerp(0.25f, this.entityData.get(ROT_X), -0.5f)); this.entityData.set(ROT_X, Mth.lerp(0.1f, this.entityData.get(ROT_X), -0.3f));
} }
if (this.getPersistentData().getBoolean("forward")) { if (this.getPersistentData().getBoolean("forward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.11f); this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.1f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), -0.5f)); this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), -0.5f));
} }
if (this.getPersistentData().getBoolean("backward")) { if (this.getPersistentData().getBoolean("backward")) {
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.11f); this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.1f);
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), 0.5f)); this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), 0.5f));
} }
} else {
this.entityData.set(ROT_X, 0f);
this.entityData.set(ROT_Z, 0f);
} }
this.entityData.set(ROT_X, Mth.lerp(0.05f, this.entityData.get(ROT_X), 0)); this.entityData.set(ROT_X, Mth.lerp(0.05f, this.entityData.get(ROT_X), 0));

View file

@ -53,7 +53,7 @@ public class DroneModel extends GeoModel<DroneEntity> {
ammo1.setHidden(animatable.getEntityData().get(AMMO) <= 0); ammo1.setHidden(animatable.getEntityData().get(AMMO) <= 0);
shell.setHidden(!animatable.getEntityData().get(KAMIKAZE)); shell.setHidden(!animatable.getEntityData().get(KAMIKAZE));
float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8); float times = (float) (0.5f * Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8));
rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X)); rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z)); rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));

View file

@ -2,6 +2,7 @@ package net.mcreator.superbwarfare.entity.projectile;
import net.mcreator.superbwarfare.ModUtils; import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.entity.AnimatedEntity; import net.mcreator.superbwarfare.entity.AnimatedEntity;
import net.mcreator.superbwarfare.entity.DroneEntity;
import net.mcreator.superbwarfare.init.ModEntities; import net.mcreator.superbwarfare.init.ModEntities;
import net.mcreator.superbwarfare.init.ModItems; import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModSounds; import net.mcreator.superbwarfare.init.ModSounds;
@ -28,6 +29,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock; import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
@ -83,12 +85,14 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
if (state.getBlock() instanceof BellBlock bell) { if (state.getBlock() instanceof BellBlock bell) {
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection()); bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
} }
if (this.tickCount > 4) { if (this.tickCount > 2) {
ProjectileTool.causeCustomExplode(this, 135f, 6.75f, 1.5f); ProjectileTool.causeCustomExplode(this, 135f, 6.75f, 1.5f);
} }
break; break;
case ENTITY: case ENTITY:
EntityHitResult entityResult = (EntityHitResult) result;
Entity entity = entityResult.getEntity();
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
if (!living.level().isClientSide() && living instanceof ServerPlayer player) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
@ -96,7 +100,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
} }
} }
if (this.tickCount > 4) { if (this.tickCount > 2 && !(entity instanceof DroneEntity)) {
ProjectileTool.causeCustomExplode(this, 150f, 4.75f, 2f); ProjectileTool.causeCustomExplode(this, 150f, 4.75f, 2f);
} }
break; break;
@ -117,7 +121,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
} }
} }
if (this.tickCount > 4) { if (this.tickCount > 2) {
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo, ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.xo, this.yo, this.zo,
1, 0, 0, 0, 0.01, true); 1, 0, 0, 0, 0.01, true);