diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java index 1fc68ad5c..8f1f403e9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java @@ -24,7 +24,7 @@ public class SpeedboatModel extends GeoModel { @Override public ResourceLocation getModelResource(SpeedboatEntity entity) { - return ModUtils.loc("geo/speedboat.geo.json"); + return new ResourceLocation(ModUtils.MODID, "geo/speedboat.geo.json"); } @Override @@ -42,9 +42,8 @@ public class SpeedboatModel extends GeoModel { rotorSpeed = Mth.lerp(0.1f * times, rotorSpeed, 10 * animatable.getEntityData().get(POWER)); rotor.setRotZ(rotor.getRotZ() + rotorSpeed); + lerpRotY = Mth.lerp(0.5f * times, lerpRotY, animatable.getEntityData().get(POWER) > 0 ? animatable.getEntityData().get(DELTA_ROT) : -animatable.getEntityData().get(DELTA_ROT)); - lerpRotY = Mth.lerp(0.5f * times, lerpRotY, animatable.getEntityData().get(DELTA_ROT)); - - duo.setRotY((animatable.getEntityData().get(POWER) > 0 ? 0.5f : -0.5f) * lerpRotY); + duo.setRotY(0.5f * lerpRotY); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java index 79e5fee21..1d2d0249a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java @@ -15,8 +15,6 @@ import software.bernie.geckolib.renderer.GeoEntityRenderer; public class SpeedboatRenderer extends GeoEntityRenderer { - public static float lerpRotY = 0f; - public SpeedboatRenderer(EntityRendererProvider.Context renderManager) { super(renderManager, new SpeedboatModel()); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/KillMessageOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/KillMessageOverlay.java index c0ead8e1c..5c2618406 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/KillMessageOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/KillMessageOverlay.java @@ -44,6 +44,7 @@ public class KillMessageOverlay { private static final ResourceLocation BURN = ModUtils.loc("textures/screens/damage_types/burn.png"); private static final ResourceLocation DRONE = ModUtils.loc("textures/screens/damage_types/drone.png"); private static final ResourceLocation LASER = ModUtils.loc("textures/screens/damage_types/laser.png"); + private static final ResourceLocation VEHICLE = ModUtils.loc("textures/screens/damage_types/vehicle_strike.png"); private static final ResourceLocation WORLD_PEACE_STAFF = ModUtils.loc("textures/gun_icon/compat/world_peace_staff.png"); @@ -278,6 +279,8 @@ public class KillMessageOverlay { icon = DRONE; } else if (record.damageType == ModDamageTypes.LASER || record.damageType == ModDamageTypes.LASER_HEADSHOT) { icon = LASER; + } else if (record.damageType == ModDamageTypes.VEHICLE_STRIKE) { + icon = VEHICLE; } else { icon = GENERIC; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index b4bd4781f..208e90965 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -87,11 +87,15 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, public void addAdditionalSaveData(CompoundTag compound) { compound.putFloat("Health", this.entityData.get(HEALTH)); compound.putFloat("Energy", this.entityData.get(ENERGY)); + compound.putFloat("Power", this.entityData.get(POWER)); + compound.putFloat("DeltaRot", this.entityData.get(DELTA_ROT)); } @Override public void readAdditionalSaveData(CompoundTag compound) { this.entityData.set(ENERGY, compound.getFloat("Energy")); + this.entityData.set(POWER, compound.getFloat("Power")); + this.entityData.set(DELTA_ROT, compound.getFloat("DeltaRot")); if (compound.contains("Health")) { this.entityData.set(HEALTH, compound.getFloat("Health")); } else { @@ -109,13 +113,14 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, } //TODO 创飞碰到的碰撞箱小于该船的实体,且本体速度不会减少太多 + public static boolean canVehicleCollide(Entity pVehicle, Entity pEntity) { return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !pVehicle.isPassengerOfSameVehicle(pEntity); } @Override public boolean canBeCollidedWith() { - return super.canBeCollidedWith(); + return false; } @Override @@ -212,10 +217,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, // player.displayClientMessage(Component.literal("Angle" + new java.text.DecimalFormat("##.##").format(Mth.abs(90 - (float)calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90)), true); // } - this.inputLeft = this.getPersistentData().getBoolean("left"); - this.inputRight = this.getPersistentData().getBoolean("right"); - this.inputUp = this.getPersistentData().getBoolean("forward"); - this.inputDown = this.getPersistentData().getBoolean("backward"); + double fluidFloat = -0.04; @@ -223,7 +225,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, if (this.isInWater()) { fluidFloat = -0.025 + 0.05 * getSubmergedHeight(this); - float f = 0.85f + 0.09f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; + float f = 0.87f + 0.09f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.04 * this.getDeltaMovement().length()))); this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.85, f)); } else if (this.onGround()) { @@ -255,7 +257,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, crushEntities(this.getDeltaMovement()); } - collideBlock(); + collBlock(); this.refreshDimensions(); } @@ -267,73 +269,86 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, double entitySize = entity.getBbWidth() * entity.getBbHeight(); double thisSize = this.getBbWidth() * this.getBbHeight(); - double f = Math.min(entitySize / thisSize, 2); - double f1 = thisSize / entitySize; + double f = Math.min(entitySize / thisSize, 2); + double f1 = Math.min(thisSize / entitySize, 4); entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z); - this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z); + if (!(entity instanceof TargetEntity)) { + this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z); + } + + if (velocity.length() > 0.2 && entity.isAlive()) { + if (!this.level().isClientSide) { + this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1); + } + entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger() ), (float) (25 * velocity.length())); + entity.invulnerableTime = 10; + } + } } - public void collideBlock() { + public void collBlock() { AABB aabb = AABB.ofSize(new Vec3(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ()), 5, 2.6, 5); - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - BlockState blockstate = this.level().getBlockState(pos); + BlockPos.betweenClosedStream(aabb).forEach((block) -> { + BlockState blockstate = this.level().getBlockState(block); if (blockstate.is(Blocks.LILY_PAD)) { - this.level().destroyBlock(pos, true); + BlockPos blockPos = BlockPos.containing(new Vec3(block.getX(), block.getY(), block.getY())); + this.level().destroyBlock(blockPos, true); } + }); } private void controlBoat() { - if (this.isVehicle()) { - Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); + Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); - float diffY = 0; + float diffY = 0; - diffY = (float) Mth.lerp(0.1 * diffY, diffY, 0); + diffY = (float) Mth.lerp(0.1 * diffY, diffY, 0); - if (this.inputUp) { - this.entityData.set(POWER, this.entityData.get(POWER) + 0.08f); + if (this.getPersistentData().getBoolean("forward")) { + this.entityData.set(POWER, this.entityData.get(POWER) + 0.08f); + } + + if (this.getPersistentData().getBoolean("backward")) { + this.entityData.set(POWER, this.entityData.get(POWER) - 0.12f); + if (this.getPersistentData().getBoolean("left")) { + diffY = Mth.clamp(diffY + 1f, 0, 5); + handleSetDiffY(diffY); + } else if (this.getPersistentData().getBoolean("right")) { + diffY = Mth.clamp(diffY - 1f, -5, 0); + handleSetDiffY(diffY); } - - if (this.inputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) - 0.12f); - if (this.inputLeft) { - diffY = Mth.clamp(diffY + 1f, 0, 5); - handleSetDiffY(diffY); - } else if (this.inputRight) { - diffY = Mth.clamp(diffY - 1f, -5, 0); - handleSetDiffY(diffY); - } - } else { - if (this.inputLeft) { - diffY = Mth.clamp(diffY - 1f, -5, 0); - handleSetDiffY(diffY); - } else if (this.inputRight) { - diffY = Mth.clamp(diffY + 1f, 0, 5); - handleSetDiffY(diffY); - } + } else { + if (this.getPersistentData().getBoolean("left")) { + diffY = Mth.clamp(diffY - 1f, -5, 0); + handleSetDiffY(diffY); + } else if (this.getPersistentData().getBoolean("right")) { + diffY = Mth.clamp(diffY + 1f, 0, 5); + handleSetDiffY(diffY); } + } - if (level().isClientSide) { - level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.inputUp || this.inputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 0.7f), false); - } + if (level().isClientSide) { + level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.inputUp || this.inputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1f), false); + } - this.entityData.set(POWER, this.entityData.get(POWER) * 0.3f); + this.entityData.set(POWER, this.entityData.get(POWER) * 0.3f); - this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.8f); + this.flyDist = this.entityData.get(POWER); - if (this.isInWater() || this.isUnderWater()) { - this.setYRot(this.entityData.get(ROT_Y) + this.entityData.get(DELTA_ROT)); - this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale(this.entityData.get(POWER)))); - } + this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.8f); + + if (this.isInWater() || this.isUnderWater()) { + this.setYRot(this.entityData.get(ROT_Y) + this.entityData.get(DELTA_ROT)); + this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale(this.entityData.get(POWER)))); } } private void handleSetDiffY(float diffY) { - this.entityData.set(DELTA_ROT, (float) Mth.clamp(diffY * 1.3 * Math.max(4 * this.getDeltaMovement().length(), 0.5), -2, 2)); + this.entityData.set(DELTA_ROT, (float) Mth.clamp(diffY * 1.3 * Math.max(4 * this.getDeltaMovement().length(), 0.5), -2 ,2)); } private void handleClientSync() { @@ -440,6 +455,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, this.clampRotation(entity); } + @Override public void registerControllers(AnimatableManager.ControllerRegistrar data) { diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java index 6c653e65c..345f316fe 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java @@ -30,6 +30,7 @@ public class ModDamageTypes { public static final ResourceKey DRONE_HIT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "drone_hit")); public static final ResourceKey LASER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser")); public static final ResourceKey LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser_headshot")); + public static final ResourceKey VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "vehicle_strike")); public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) { return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker); @@ -83,6 +84,10 @@ public class ModDamageTypes { return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(LASER_HEADSHOT), directEntity, attacker); } + public static DamageSource causeVehicleStrikeDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) { + return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(VEHICLE_STRIKE), directEntity, attacker); + } + private static class DamageMessages extends DamageSource { public DamageMessages(Holder.Reference typeReference) { super(typeReference); diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java index 90e727077..2a0bf9154 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModSounds.java @@ -344,5 +344,6 @@ public class ModSounds { public static final RegistryObject ANNIHILATOR_RELOAD = REGISTRY.register("annihilator_reload", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "annihilator_reload"))); public static final RegistryObject BOAT_ENGINE = REGISTRY.register("boat_engine", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "boat_engine"))); + public static final RegistryObject VEHICLE_STRIKE = REGISTRY.register("vehicle_strike", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "vehicle_strike"))); } diff --git a/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json b/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json new file mode 100644 index 000000000..934dbe5df --- /dev/null +++ b/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json @@ -0,0 +1,32 @@ +{ + "format_version": "1.8.0", + "animations": { + "animation.speedboat.idle": { + "loop": true + }, + "animation.speedboat.forward": { + "loop": true, + "animation_length": 0.5, + "bones": { + "Rotor": { + "rotation": { + "0.0": [0, 0, 0], + "0.5": [0, 0, 720] + } + } + } + }, + "animation.speedboat.backward": { + "loop": true, + "animation_length": 0.5, + "bones": { + "Rotor": { + "rotation": { + "0.0": [0, 0, 0], + "0.5": [0, 0, -720] + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index ab8acc52b..96a96bafd 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -335,6 +335,9 @@ "death.attack.laser_headshot": "%1$s的脑子被激光洞穿了", "death.attack.laser_headshot.entity": "%1$s被%2$s用激光射穿了脑袋", "death.attack.laser_headshot.item": "%1$s的脑子被%2$s用%3$s发射的激光洞穿了", + "death.attack.vehicle_strike": "%1$s被创死了", + "death.attack.vehicle_strike.entity": "%1$s被%2$s创死了", + "death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了", "entity.superbwarfare.projectile": "Bullet", "entity.superbwarfare.projectile_mortar_shell": "Mortar Shell", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 059687680..4e83da58d 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -335,6 +335,9 @@ "death.attack.laser_headshot": "%1$s的脑子被激光洞穿了", "death.attack.laser_headshot.entity": "%1$s被%2$s用激光射穿了脑袋", "death.attack.laser_headshot.item": "%1$s的脑子被%2$s用%3$s发射的激光洞穿了", + "death.attack.vehicle_strike": "%1$s被创死了", + "death.attack.vehicle_strike.entity": "%1$s被%2$s创死了", + "death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了", "entity.superbwarfare.projectile": "子弹", "entity.superbwarfare.projectile_mortar_shell": "迫击炮弹", diff --git a/src/main/resources/assets/superbwarfare/sounds.json b/src/main/resources/assets/superbwarfare/sounds.json index 3361c5184..93642f6de 100644 --- a/src/main/resources/assets/superbwarfare/sounds.json +++ b/src/main/resources/assets/superbwarfare/sounds.json @@ -2437,5 +2437,13 @@ "stream": false } ] + }, + "vehicle_strike": { + "sounds": [ + { + "name": "superbwarfare:vehicle_strike", + "stream": false + } + ] } } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/sounds/speedboat/engine.ogg b/src/main/resources/assets/superbwarfare/sounds/speedboat/engine.ogg index 171079285..b20383a23 100644 Binary files a/src/main/resources/assets/superbwarfare/sounds/speedboat/engine.ogg and b/src/main/resources/assets/superbwarfare/sounds/speedboat/engine.ogg differ diff --git a/src/main/resources/assets/superbwarfare/sounds/vehicle_strike.ogg b/src/main/resources/assets/superbwarfare/sounds/vehicle_strike.ogg new file mode 100644 index 000000000..1f9d61e33 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/sounds/vehicle_strike.ogg differ diff --git a/src/main/resources/assets/superbwarfare/textures/screens/damage_types/vehicle_strike.png b/src/main/resources/assets/superbwarfare/textures/screens/damage_types/vehicle_strike.png new file mode 100644 index 000000000..9247a56a7 Binary files /dev/null and b/src/main/resources/assets/superbwarfare/textures/screens/damage_types/vehicle_strike.png differ diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json index 350f5c2a4..564095052 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -6,6 +6,7 @@ "superbwarfare:shock", "superbwarfare:cannon_fire", "superbwarfare:laser", - "superbwarfare:laser_headshot" + "superbwarfare:laser_headshot", + "superbwarfare:vehicle_strike" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json index 350f5c2a4..564095052 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json @@ -6,6 +6,7 @@ "superbwarfare:shock", "superbwarfare:cannon_fire", "superbwarfare:laser", - "superbwarfare:laser_headshot" + "superbwarfare:laser_headshot", + "superbwarfare:vehicle_strike" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json index 350f5c2a4..564095052 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json @@ -6,6 +6,7 @@ "superbwarfare:shock", "superbwarfare:cannon_fire", "superbwarfare:laser", - "superbwarfare:laser_headshot" + "superbwarfare:laser_headshot", + "superbwarfare:vehicle_strike" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json index 350f5c2a4..564095052 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json @@ -6,6 +6,7 @@ "superbwarfare:shock", "superbwarfare:cannon_fire", "superbwarfare:laser", - "superbwarfare:laser_headshot" + "superbwarfare:laser_headshot", + "superbwarfare:vehicle_strike" ] } \ No newline at end of file diff --git a/src/main/resources/data/superbwarfare/damage_type/vehicle_strike.json b/src/main/resources/data/superbwarfare/damage_type/vehicle_strike.json new file mode 100644 index 000000000..cc82344de --- /dev/null +++ b/src/main/resources/data/superbwarfare/damage_type/vehicle_strike.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "message_id": "vehicle_strike", + "scaling": "never" +} \ No newline at end of file