添加projectile对于obb entity的检测
This commit is contained in:
parent
c8c141e4bb
commit
5d90e12169
3 changed files with 34 additions and 1 deletions
|
@ -156,7 +156,6 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
|
||||||
@Nullable
|
@Nullable
|
||||||
protected List<EntityResult> findEntitiesOnPath(Vec3 startVec, Vec3 endVec) {
|
protected List<EntityResult> findEntitiesOnPath(Vec3 startVec, Vec3 endVec) {
|
||||||
List<EntityResult> hitEntities = new ArrayList<>();
|
List<EntityResult> hitEntities = new ArrayList<>();
|
||||||
// TODO 换一个允许检测obb的方法
|
|
||||||
List<Entity> entities = this.level().getEntities(
|
List<Entity> entities = this.level().getEntities(
|
||||||
this,
|
this,
|
||||||
this.getBoundingBox()
|
this.getBoundingBox()
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
"ClientboundSetPassengersPacketMixin",
|
"ClientboundSetPassengersPacketMixin",
|
||||||
"EntityMixin",
|
"EntityMixin",
|
||||||
"FishingHookMixin",
|
"FishingHookMixin",
|
||||||
|
"LevelMixin",
|
||||||
"LivingEntityMixin",
|
"LivingEntityMixin",
|
||||||
"PlayerMixin",
|
"PlayerMixin",
|
||||||
"VillagerMixin"
|
"VillagerMixin"
|
||||||
|
|
Loading…
Add table
Reference in a new issue