From 0d175a9dbcf51ef3c73b0a79803a2b635276bab7 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Sun, 13 Jul 2025 23:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=91=E5=B0=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/MediumRocketEntity.java | 5 +- .../entity/vehicle/Type63Entity.java | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MediumRocketEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MediumRocketEntity.java index 7efcc1d28..08b7551ab 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MediumRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MediumRocketEntity.java @@ -203,9 +203,10 @@ public class MediumRocketEntity extends FastThrowableProjectile implements GeoEn @Override public void onHitEntity(@NotNull EntityHitResult entityHitResult) { + if (tickCount < 2) return; if (this.level() instanceof ServerLevel) { Entity entity = entityHitResult.getEntity(); - if (this.getOwner() != null && entity == this.getOwner().getVehicle()) + if (this.getOwner() != null && entity == this.getOwner().getVehicle() && tickCount < 2) return; entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage); @@ -267,7 +268,7 @@ public class MediumRocketEntity extends FastThrowableProjectile implements GeoEn active = true; } - if (tickCount >= sparedTime && active) { + if (tickCount >= sparedTime && active && type == Type.CM) { releaseClusterMunitions((LivingEntity) getOwner()); this.discard(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java index 0381850fd..ea1040ecf 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java @@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.OBBEntity; +import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModSerializers; @@ -185,9 +186,11 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt return InteractionResult.SUCCESS; } } else { + // 撬棍发射 for (int i = 0; i < 12; i++) { if (items.get(i).getItem() instanceof MediumRocketItem) { items.set(i, ItemStack.EMPTY); + shoot(player, i); setChanged(); player.swing(InteractionHand.MAIN_HAND); return InteractionResult.SUCCESS; @@ -208,6 +211,61 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt } } + public void shoot(Player player, int i) { + if (level() instanceof ServerLevel server) { + ItemStack stack = items.get(i); + + float damage; + float radius; + float explosionDamage; + float fireProbability; + int fireTime; + MediumRocketEntity.Type type; + int sparedAmount; + + if (stack.is(ModItems.MEDIUM_ROCKET_AP.get())) { + damage = 500; + radius = 6; + explosionDamage = 100; + fireProbability = 0; + fireTime = 0; + type = MediumRocketEntity.Type.AP; + sparedAmount = 0; + } else if (stack.is(ModItems.MEDIUM_ROCKET_HE.get())) { + damage = 200; + radius = 12; + explosionDamage = 200; + fireProbability = 0.2f; + fireTime = 40; + type = MediumRocketEntity.Type.HE; + sparedAmount = 0; + } else { + damage = 300; + radius = 12; + explosionDamage = 300; + fireProbability = 0; + fireTime = 0; + type = MediumRocketEntity.Type.CM; + sparedAmount = 20; + } + + OBB obb = this.barrel[i]; + Vec3 shootPos = new Vec3(obb.center()); + + MediumRocketEntity entityToSpawn = new MediumRocketEntity(player, server, damage, radius, explosionDamage, fireProbability, fireTime, type, sparedAmount); + entityToSpawn.setPos(shootPos.x, shootPos.y, shootPos.z); + entityToSpawn.shoot(getShootVector(1).x, getShootVector(1).y, getShootVector(1).z, 10, (float) 0.25); + server.addFreshEntity(entityToSpawn); + + server.playSound(null, shootPos.x, shootPos.y, shootPos.z, ModSounds.MEDIUM_ROCKET_FIRE.get(), SoundSource.PLAYERS, 4f, random.nextFloat() * 0.1f + 0.95f); + +// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4, +// 0.007); +// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 2, 0.02, 2, 0.0005); + + } + } + @Override public void baseTick() { turretYRotO = this.getTurretYRot();