From ed023bebeade755fb7c73eba71e190102877d83f Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Mon, 17 Mar 2025 14:49:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=BD=BD=E5=85=B7=E7=A2=B0?= =?UTF-8?q?=E6=92=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vehicle/Bmp2Entity.java | 2 +- .../entity/vehicle/Lav150Entity.java | 2 +- .../entity/vehicle/Yx100Entity.java | 2 +- .../vehicle/base/MobileVehicleEntity.java | 40 +++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 5d295e7f7..8df602d87 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -211,7 +211,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit } collideBlock(); - if (this.getDeltaMovement().length() > 0.15) { + if (this.getDeltaMovement().length() > 0.1) { collideHardBlock(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 679059271..fdbcfd2cf 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -185,7 +185,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt } collideBlock(); - if (this.getDeltaMovement().length() > 0.2) { + if (this.getDeltaMovement().length() > 0.125) { collideHardBlock(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index b92f1efa6..34da1fd3e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -240,7 +240,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti } collideBlock(); - if (this.getDeltaMovement().length() > 0.15) { + if (this.getDeltaMovement().length() > 0.075) { collideHardBlock(); } 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 76929c171..aacb32a4e 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 @@ -1,11 +1,7 @@ package com.atsuishio.superbwarfare.entity.vehicle.base; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.C4Entity; import com.atsuishio.superbwarfare.entity.TargetEntity; -import com.atsuishio.superbwarfare.entity.projectile.FlareDecoyEntity; -import com.atsuishio.superbwarfare.entity.projectile.LaserEntity; -import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModSounds; @@ -22,20 +18,19 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; -import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.MoverType; -import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.entity.vehicle.Minecart; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.entity.EntityTypeTest; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; import org.joml.Math; import org.joml.Vector3f; @@ -202,7 +197,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity { BlockState blockstate = this.level().getBlockState(pos); if (blockstate.is(ModTags.Blocks.SOFT_COLLISION)) { this.level().destroyBlock(pos, true); - this.setDeltaMovement(this.getDeltaMovement().scale(0.96)); + this.setDeltaMovement(this.getDeltaMovement().scale(0.98)); } }); } @@ -217,7 +212,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity { BlockState blockstate = this.level().getBlockState(pos); if (blockstate.is(ModTags.Blocks.HARD_COLLISION)) { this.level().destroyBlock(pos, true); - this.setDeltaMovement(this.getDeltaMovement().scale(0.6)); + this.setDeltaMovement(this.getDeltaMovement().scale(0.9)); } }); } @@ -322,11 +317,18 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity { entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null) .stream().filter(entity -> { if (entity.isAlive() - && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity || entity instanceof LaserEntity || entity instanceof FlareDecoyEntity || entity instanceof AreaEffectCloud || entity instanceof C4Entity) - && !(entity instanceof Player player && (player.isSpectator() || player.isCreative()))) { - var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()); - if (type == null) return false; - return !VehicleConfig.COLLISION_ENTITY_BLACKLIST.get().contains(type.toString()); + && (entity instanceof VehicleEntity + || entity instanceof Boat + || entity instanceof Minecart + || (entity instanceof LivingEntity living && !(living instanceof Player player && player.isSpectator()))) + ) { + return true; + + // todo 添加碰撞白名单 + +// var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()); +// if (type == null) return false; +// return !VehicleConfig.COLLISION_ENTITY_BLACKLIST.get().contains(type.toString()); } return false; } @@ -346,7 +348,13 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity { if (!(entity instanceof TargetEntity)) { this.pushNew(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z); } - entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z); + + if (entity instanceof MobileVehicleEntity mobileVehicle) { + mobileVehicle.pushNew(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z); + } else { + entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z); + } + entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (thisSize * 20 * ((velocity.length() - 0.3) * (velocity.length() - 0.3)))); if (entities instanceof VehicleEntity) { this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), entity, entity.getFirstPassenger() == null ? entity : entity.getFirstPassenger()), (float) (entitySize * 10 * ((velocity.length() - 0.3) * (velocity.length() - 0.3))));