diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java index e6ee5adea..ad70a0745 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java @@ -1,11 +1,13 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.LoudlyEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModItems; 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; @@ -21,11 +23,13 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.item.Item; +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.level.block.Block; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.network.PacketDistributor; import org.jetbrains.annotations.NotNull; import software.bernie.geckolib.animatable.GeoEntity; @@ -90,7 +94,7 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit } @Override - public void addAdditionalSaveData(CompoundTag pCompound) { + public void addAdditionalSaveData(@NotNull CompoundTag pCompound) { super.addAdditionalSaveData(pCompound); pCompound.putFloat("Damage", this.damage); pCompound.putFloat("ExplosionDamage", this.explosionDamage); @@ -98,7 +102,7 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit } @Override - public void readAdditionalSaveData(CompoundTag pCompound) { + public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { super.readAdditionalSaveData(pCompound); if (pCompound.contains("Damage")) { this.damage = pCompound.getFloat("Damage"); @@ -155,21 +159,47 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit @Override public void onHitBlock(@NotNull BlockHitResult blockHitResult) { - super.onHitBlock(blockHitResult); - BlockPos resultPos = blockHitResult.getBlockPos(); - BlockState state = this.level().getBlockState(resultPos); + if (this.level() instanceof ServerLevel) { + double x = blockHitResult.getLocation().x; + double y = blockHitResult.getLocation().y; + double z = blockHitResult.getLocation().z; - if (state.getBlock() instanceof BellBlock bell) { - bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection()); - } + if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + float hardness = this.level().getBlockState(BlockPos.containing(x, y, z)).getBlock().defaultDestroyTime(); + if (hardness <= 50) { + BlockPos blockPos = BlockPos.containing(x, y, z); + Block.dropResources(this.level().getBlockState(blockPos), this.level(), BlockPos.containing(x, y, z), null); + this.level().destroyBlock(blockPos, true); + } + } - if (this.tickCount > 1) { - if (this.level() instanceof ServerLevel) { - ProjectileTool.causeCustomExplode(this, this.explosionDamage, this.explosionRadius, this.monsterMultiplier); + if (this.tickCount > 1) { + for (int i = 1; i < 3; i++) { + apExplode(blockHitResult, i); + } + + if (this.level() instanceof ServerLevel) { + ProjectileTool.causeCustomExplode(this, this.explosionDamage, this.explosionRadius, this.monsterMultiplier); + } } } + } - this.discard(); + private void apExplode(HitResult result, int index) { + CustomExplosion explosion = new CustomExplosion(this.level(), this, + ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), + this, + this.getOwner()), + explosionDamage, + result.getLocation().x + index * getDeltaMovement().normalize().x, + result.getLocation().y + index * getDeltaMovement().normalize().y, + result.getLocation().z + index * getDeltaMovement().normalize().z, + 0.5f * explosionRadius, + ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). + setDamageMultiplier(this.monsterMultiplier); + explosion.explode(); + EventHooks.onExplosionStart(this.level(), explosion); + explosion.finalizeExplosion(false); } @Override @@ -218,12 +248,12 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit } @Override - public SoundEvent getCloseSound() { + public @NotNull SoundEvent getCloseSound() { return ModSounds.ROCKET_ENGINE.get(); } @Override - public SoundEvent getSound() { + public @NotNull SoundEvent getSound() { return ModSounds.ROCKET_FLY.get(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java index afa617685..8ca3920a9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -193,10 +193,10 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity lockingTargetO = getTargetUuid(); super.baseTick(); - float f = (float) Mth.clamp(Math.max((onGround() ? 0.815f : 0.82f) - 0.0035 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); + float f = (float) Mth.clamp(Math.max((onGround() ? 0.819f : 0.82f) - 0.0035 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); boolean forward = getDeltaMovement().dot(getViewVector(1)) > 0; - this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((forward ? 0.23 : 0.1) * getDeltaMovement().dot(getViewVector(1))))); + this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((forward ? 0.227 : 0.1) * getDeltaMovement().dot(getViewVector(1))))); this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f)); if (this.isInWater() && this.tickCount % 4 == 0) { @@ -471,7 +471,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity } else if (passenger instanceof Player) { if (getEnergy() > 0) { if (forwardInputDown) { - this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.004f, 1f)); + this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.004f, sprintInputDown ? 1f : 0.0575f)); } if (backInputDown) { @@ -488,7 +488,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity } // 刹车 - if (upInputDown) { + if (downInputDown) { if (onGround()) { this.entityData.set(POWER, this.entityData.get(POWER) * 0.8f); this.setDeltaMovement(this.getDeltaMovement().multiply(0.97, 1, 0.97)); @@ -530,8 +530,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER)); // 起落架 - if (downInputDown) { - downInputDown = false; + if (upInputDown) { + upInputDown = false; if (entityData.get(GEAR_ROT) == 0 && !onGround()) { entityData.set(GEAR_UP, true); } else if (entityData.get(GEAR_ROT) == 85) { @@ -587,7 +587,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity setDeltaMovement(getDeltaMovement().add(force.scale(getDeltaMovement().dot(getViewVector(1)) * 0.022 * (1 + Math.sin((onGround() ? 25 : flapAngle + 25) * Mth.DEG_TO_RAD))))); - this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(0.08 * this.entityData.get(POWER)))); + this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(0.2 * this.entityData.get(POWER)))); } @Override @@ -638,7 +638,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity } collisionCoolDown = 4; crash = true; - this.entityData.set(POWER, 0.8f * entityData.get(POWER)); } } } @@ -650,7 +649,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity @Override public float getEngineSoundVolume() { - return entityData.get(POWER) * 1.5f; + return entityData.get(POWER) * (sprintInputDown ? 5.5f : 3f); } protected void clampRotation(Entity entity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java index a71ed4685..51266b002 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java @@ -80,6 +80,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements public boolean downInputDown; public boolean decoyInputDown; public boolean fireInputDown; + public boolean sprintInputDown; public double lastTickSpeed; public double lastTickVerticalSpeed; public int collisionCoolDown; @@ -147,21 +148,23 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements @Override public void processInput(short keys) { leftInputDown - = (keys & 0b00000001) > 0; + = (keys & 0b000000001) > 0; rightInputDown - = (keys & 0b00000010) > 0; + = (keys & 0b000000010) > 0; forwardInputDown - = (keys & 0b00000100) > 0; + = (keys & 0b000000100) > 0; backInputDown - = (keys & 0b00001000) > 0; + = (keys & 0b000001000) > 0; upInputDown - = (keys & 0b00010000) > 0; + = (keys & 0b000010000) > 0; downInputDown - = (keys & 0b00100000) > 0; + = (keys & 0b000100000) > 0; decoyInputDown - = (keys & 0b01000000) > 0; + = (keys & 0b001000000) > 0; fireInputDown - = (keys & 0b10000000) > 0; + = (keys & 0b010000000) > 0; + sprintInputDown + = (keys & 0b100000000) > 0; } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 8c48ae8b1..9eab4045f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -249,28 +249,31 @@ public class ClientEventHandler { && tag.getBoolean("Linked")) ) { if (options.keyLeft.isDown()) { - keys |= 0b00000001; + keys |= 0b000000001; } if (options.keyRight.isDown()) { - keys |= 0b00000010; + keys |= 0b000000010; } if (options.keyUp.isDown()) { - keys |= 0b00000100; + keys |= 0b000000100; } if (options.keyDown.isDown()) { - keys |= 0b00001000; + keys |= 0b000001000; } if (options.keyJump.isDown()) { - keys |= 0b00010000; + keys |= 0b000010000; } if (options.keyShift.isDown()) { - keys |= 0b00100000; + keys |= 0b000100000; } if (ModKeyMappings.RELEASE_DECOY.isDown()) { - keys |= 0b01000000; + keys |= 0b001000000; } if (holdFireVehicle) { - keys |= 0b10000000; + keys |= 0b010000000; + } + if (options.keySprint.isDown()) { + keys |= 0b100000000; } }