添加projectile对于obb entity的检测

This commit is contained in:
17146 2025-06-15 19:14:15 +08:00 committed by Light_Quanta
parent c8c141e4bb
commit 5d90e12169
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 34 additions and 1 deletions

View file

@ -156,7 +156,6 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
@Nullable
protected List<EntityResult> findEntitiesOnPath(Vec3 startVec, Vec3 endVec) {
List<EntityResult> hitEntities = new ArrayList<>();
// TODO 换一个允许检测obb的方法
List<Entity> entities = this.level().getEntities(
this,
this.getBoundingBox()

View file

@ -0,0 +1,33 @@
package com.atsuishio.superbwarfare.mixins;
import com.atsuishio.superbwarfare.entity.OBBEntity;
import com.atsuishio.superbwarfare.tools.OBB;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.LevelEntityGetter;
import net.minecraft.world.phys.AABB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.function.Predicate;
@Mixin(Level.class)
public abstract class LevelMixin {
@Shadow
protected abstract LevelEntityGetter<Entity> getEntities();
@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<? super Entity> pPredicate, CallbackInfoReturnable<List<Entity>> cir) {
this.getEntities().get(pBoundingBox, entity -> {
if (entity instanceof OBBEntity obbEntity && OBB.isColliding(obbEntity.getOBB(), pBoundingBox)) {
cir.getReturnValue().add(entity);
}
});
}
}

View file

@ -8,6 +8,7 @@
"ClientboundSetPassengersPacketMixin",
"EntityMixin",
"FishingHookMixin",
"LevelMixin",
"LivingEntityMixin",
"PlayerMixin",
"VillagerMixin"