From a1b062504d2d63d98131cee3458375da18e0ad09 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Mon, 16 Jun 2025 12:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96obb=E5=91=BD=E4=B8=AD?= =?UTF-8?q?=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/mixins/LevelMixin.java | 31 ++++++++++++++----- .../mixins/ProjectileUtilMixin.java | 3 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/LevelMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/LevelMixin.java index a9b94a32d..0660cab2a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/LevelMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/LevelMixin.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.mixins; import com.atsuishio.superbwarfare.entity.OBBEntity; +import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.tools.OBB; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; @@ -24,16 +25,30 @@ public abstract class LevelMixin { @Inject(method = "getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;", at = @At("RETURN")) public void getEntities(Entity pEntity, AABB pBoundingBox, Predicate pPredicate, CallbackInfoReturnable> cir) { - this.getEntities().get(pBoundingBox, entity -> { - if (entity instanceof OBBEntity obbEntity) { - for (OBB obb : obbEntity.getOBBs()) { - if (OBB.isColliding(obb, pBoundingBox)) { - if (!cir.getReturnValue().contains(entity)) { - cir.getReturnValue().add(entity); + if (pEntity instanceof ProjectileEntity) { + this.getEntities().get(pBoundingBox.inflate(2), entity -> { + if (entity instanceof OBBEntity obbEntity) { + for (OBB obb : obbEntity.getOBBs()) { + if (OBB.isColliding(obb, pBoundingBox)) { + if (!cir.getReturnValue().contains(entity)) { + cir.getReturnValue().add(entity); + } } } } - } - }); + }); + } else { + this.getEntities().get(pBoundingBox, entity -> { + if (entity instanceof OBBEntity obbEntity) { + for (OBB obb : obbEntity.getOBBs()) { + if (OBB.isColliding(obb, pBoundingBox)) { + if (!cir.getReturnValue().contains(entity)) { + cir.getReturnValue().add(entity); + } + } + } + } + }); + } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java index 4c042a50e..acd600c22 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java @@ -23,7 +23,7 @@ public class ProjectileUtilMixin { @Inject(method = "getEntityHitResult(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;F)Lnet/minecraft/world/phys/EntityHitResult;", at = @At("HEAD"), cancellable = true) private static void getEntityHitResult(Level pLevel, Entity pProjectile, Vec3 pStartVec, Vec3 pEndVec, AABB pBoundingBox, Predicate pFilter, float pInflationAmount, CallbackInfoReturnable cir) { - for (var entity : pLevel.getEntities(pProjectile, pBoundingBox, pFilter)) { + for (var entity : pLevel.getEntities(pProjectile, pBoundingBox.inflate(2), pFilter)) { if (entity instanceof OBBEntity obbEntity) { if (pProjectile instanceof Projectile projectile && (projectile.getOwner() == entity || entity.getPassengers().contains(projectile.getOwner()))) { @@ -31,7 +31,6 @@ public class ProjectileUtilMixin { } var obbList = obbEntity.getOBBs(); for (var obb : obbList) { - obb = obb.inflate(6); Optional optional = obb.clip(pStartVec.toVector3f(), pEndVec.toVector3f()); if (optional.isPresent()) { double d1 = pStartVec.distanceToSqr(new Vec3(optional.get()));