数值平衡,再次修复不能强制打断单发装填类换弹的bug

This commit is contained in:
Atsuishio 2025-04-03 23:09:58 +08:00 committed by Light_Quanta
parent 8214d9bbe9
commit 14addf7f1e
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
13 changed files with 120 additions and 50 deletions

View file

@ -353,6 +353,11 @@ public class ClickHandler {
}
} else {
PacketDistributor.sendToServer(new FireMessage(0));
if ((!(tag.getBoolean("is_normal_reloading") || tag.getBoolean("is_empty_reloading"))
&& !GunsTool.getGunBooleanTag(tag, "Reloading")
&& !GunsTool.getGunBooleanTag(tag, "Charging")
&& !GunsTool.getGunBooleanTag(tag, "NeedBoltAction"))
&& drawTime < 0.01) {
if (GunsTool.getGunIntTag(tag, "FireMode") == 1) {
if (ClientEventHandler.burstFireSize == 0) {
ClientEventHandler.burstFireSize = GunsTool.getGunIntTag(tag, "BurstSize");
@ -365,6 +370,7 @@ public class ClickHandler {
}
}
}
}
public static void handleWeaponFireRelease() {
PacketDistributor.sendToServer(new FireMessage(1));

View file

@ -337,24 +337,8 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
}
private PlayState movementPredicate(AnimationState<CannonShellEntity> event) {
if (this.animationProcedure.equals("empty")) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.cannon_shell.idle"));
}
return PlayState.STOP;
}
private PlayState procedurePredicate(AnimationState<CannonShellEntity> event) {
if (!animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
this.animationProcedure = "empty";
event.getController().forceAnimationReset();
}
} else if (animationProcedure.equals("empty")) {
return PlayState.STOP;
}
return PlayState.CONTINUE;
}
@Override
protected double getDefaultGravity() {
@ -364,7 +348,6 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
}
@Override

View file

@ -5,8 +5,8 @@ import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.tools.ChunkLoadTool;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.ProjectileTool;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
@ -26,11 +26,14 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.EventHooks;
import org.jetbrains.annotations.NotNull;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
@ -179,7 +182,7 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
Entity entity = entityHitResult.getEntity();
entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage);
if (this.level() instanceof ServerLevel) {
ProjectileTool.causeCustomExplode(this, this.damage, this.radius);
causeExplode(entityHitResult.getLocation());
this.createAreaCloud(this.level());
}
this.discard();
@ -196,7 +199,7 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
}
if (!this.level().isClientSide() && this.level() instanceof ServerLevel) {
if (this.tickCount > 1) {
ProjectileTool.causeCustomExplode(this, this.damage, this.radius);
causeExplode(blockHitResult.getLocation());
this.createAreaCloud(this.level());
}
}
@ -215,13 +218,31 @@ public class MortarShellEntity extends FastThrowableProjectile implements GeoEnt
}
if (this.tickCount > this.life || this.isInWater()) {
if (this.level() instanceof ServerLevel) {
ProjectileTool.causeCustomExplode(this, this.damage, this.radius);
causeExplode(position());
this.createAreaCloud(this.level());
}
this.discard();
}
}
private void causeExplode(Vec3 vec3) {
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
this,
this.getOwner()),
damage,
vec3.x,
vec3.y,
vec3.z,
radius,
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).
setDamageMultiplier(1.25f);
explosion.explode();
EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(this.level(), vec3);
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
}

View file

@ -8,7 +8,6 @@ import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.ProjectileTool;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
@ -85,10 +84,8 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
entity.invulnerableTime = 0;
}
if (this.tickCount > 0) {
if (this.level() instanceof ServerLevel) {
causeExplode(entity);
}
if (this.tickCount > 0 && this.level() instanceof ServerLevel) {
causeExplode(result.getLocation());
}
this.discard();
}
@ -102,30 +99,27 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
}
if (this.level() instanceof ServerLevel) {
causeExplodeBlock(blockHitResult);
causeExplode(blockHitResult.getLocation());
}
this.discard();
}
private void causeExplode(Entity entity) {
private void causeExplode(Vec3 vec3) {
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
this,
this.getOwner()),
explosionDamage,
entity.getX(),
entity.getY() + 0.6 * entity.getBbHeight(),
entity.getZ(),
vec3.x,
vec3.y,
vec3.z,
explosionRadius,
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).
setDamageMultiplier(1.25f);
explosion.explode();
EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnSmallExplosionParticles(this.level(),
new Vec3(entity.getX(),
entity.getEyeY(),
entity.getZ()));
ParticleTool.spawnSmallExplosionParticles(this.level(), vec3);
}
private void causeExplodeBlock(HitResult result) {
@ -161,9 +155,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
if (this.tickCount > 200 || this.isInWater()) {
if (this.level() instanceof ServerLevel && !onGround()) {
ProjectileTool.causeCustomExplode(this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
this, this.explosionDamage, this.explosionRadius, 1.25f);
causeExplode(position());
}
this.discard();
}

View file

@ -154,6 +154,15 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
.multiply(0.16f, ModTags.DamageTypes.PROJECTILE)
.multiply(10, ModDamageTypes.VEHICLE_STRIKE)
.custom((source, damage) -> {
if (source.getDirectEntity() instanceof CannonShellEntity) {
return 0.9f * damage;
}
if (source.getDirectEntity() instanceof SmallCannonShellEntity) {
return 1.3f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 2.2f * damage;
}
if (source.getDirectEntity() instanceof MelonBombEntity) {
return 2f * damage;
}

View file

@ -5,6 +5,8 @@ import com.atsuishio.superbwarfare.component.ModDataComponents;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.C4Entity;
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.EnergyVehicleEntity;
@ -221,6 +223,12 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
if (source.getDirectEntity() instanceof MelonBombEntity) {
return 8f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 3f * damage;
}
if (source.getDirectEntity() instanceof CannonShellEntity) {
return 3f * damage;
}
return damage;
})
.reduce(12);

View file

@ -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.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
@ -155,6 +156,9 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
if (source.getDirectEntity() instanceof MortarShellEntity) {
return 3f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 1.5f * damage;
}
return damage;
})
.reduce(8);

View file

@ -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.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
@ -137,6 +138,9 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
if (source.getDirectEntity() instanceof MortarShellEntity) {
return 3f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 1.5f * damage;
}
return damage;
})
.reduce(7);

View file

@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.client.gui.RangeHelper;
import com.atsuishio.superbwarfare.component.ModDataComponents;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
@ -188,6 +189,12 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
.multiply(0.85f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
.multiply(10f, ModDamageTypes.VEHICLE_STRIKE)
.custom((source, damage) -> getSourceAngle(source, 1f) * damage)
.custom((source, damage) -> {
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 1.5f * damage;
}
return damage;
})
.reduce(8);
}

View file

@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.client.gui.RangeHelper;
import com.atsuishio.superbwarfare.component.ModDataComponents;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
@ -213,6 +214,12 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
.multiply(0.85f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
.multiply(10f, ModDamageTypes.VEHICLE_STRIKE)
.custom((source, damage) -> getSourceAngle(source, 1f) * damage)
.custom((source, damage) -> {
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 1.5f * damage;
}
return damage;
})
.reduce(8);
}

View file

@ -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.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
@ -150,6 +151,9 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
if (source.getDirectEntity() instanceof MortarShellEntity) {
return 3f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 1.5f * damage;
}
return damage;
})
.reduce(9);

View file

@ -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.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.*;
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon;
@ -105,6 +106,30 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
.multiply(0.8f, ModDamageTypes.CANNON_FIRE)
.multiply(0.16f, ModTags.DamageTypes.PROJECTILE)
.multiply(2, ModDamageTypes.VEHICLE_STRIKE)
.custom((source, damage) -> {
if (source.getDirectEntity() instanceof CannonShellEntity) {
return 0.9f * damage;
}
if (source.getDirectEntity() instanceof SmallCannonShellEntity) {
return 1.3f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 2.2f * damage;
}
if (source.getDirectEntity() instanceof MelonBombEntity) {
return 2f * damage;
}
if (source.getDirectEntity() instanceof RgoGrenadeEntity) {
return 6f * damage;
}
if (source.getDirectEntity() instanceof HandGrenadeEntity) {
return 5f * damage;
}
if (source.getDirectEntity() instanceof MortarShellEntity) {
return 4f * damage;
}
return damage;
})
.reduce(2);
}

View file

@ -3,10 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.C4Entity;
import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity;
import com.atsuishio.superbwarfare.entity.projectile.RpgRocketEntity;
import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity;
import com.atsuishio.superbwarfare.entity.projectile.*;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
@ -205,6 +202,9 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
if (source.getDirectEntity() instanceof RpgRocketEntity) {
return 1.5f * damage;
}
if (source.getDirectEntity() instanceof GunGrenadeEntity) {
return 2f * damage;
}
return damage;
})
.reduce(9);