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()));