geforkt von Mirrors/Paper
48 Zeilen
2.7 KiB
Diff
48 Zeilen
2.7 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||
|
Date: Wed, 6 Oct 2021 20:10:44 -0400
|
||
|
Subject: [PATCH] Collision API
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||
|
index 6445c2e4c97860e1c98f5263188d309cf55936f0..62bca85da6c5d9877e21fecb702370506ddf671c 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||
|
@@ -962,5 +962,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||
|
|
||
|
return this.getHandle().clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, null)).getType() == net.minecraft.world.phys.HitResult.Type.MISS;
|
||
|
}
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean hasCollisionsIn(@org.jetbrains.annotations.NotNull org.bukkit.util.BoundingBox boundingBox) {
|
||
|
+ net.minecraft.world.phys.AABB aabb = new AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ(), false);
|
||
|
+
|
||
|
+ return !this.getHandle().noCollision(aabb);
|
||
|
+ }
|
||
|
// Paper end
|
||
|
}
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
index b80cc0938b2b3928f4450f1314a9fbd7ea9c116b..6549ade8e19807c523e5a1dc68b66585aad438b1 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
@@ -1340,4 +1340,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||
|
return getHandle().isInPowderSnow || getHandle().wasInPowderSnow; // depending on the location in the entity "tick" either could be needed.
|
||
|
}
|
||
|
// Paper end
|
||
|
+ // Paper Start - Collision API
|
||
|
+ @Override
|
||
|
+ public boolean collidesAt(@org.jetbrains.annotations.NotNull Location location) {
|
||
|
+ net.minecraft.world.phys.AABB aabb = this.getHandle().getBoundingBoxAt(location.getX(), location.getY(), location.getZ());
|
||
|
+
|
||
|
+ return !this.getHandle().level.noCollision(this.getHandle(), aabb);
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public boolean wouldCollideUsing(@org.jetbrains.annotations.NotNull BoundingBox boundingBox) {
|
||
|
+ net.minecraft.world.phys.AABB aabb = new AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ(), false);
|
||
|
+
|
||
|
+ return !this.getHandle().level.noCollision(this.getHandle(), aabb);
|
||
|
+ }
|
||
|
+ // Paper End - Collision API
|
||
|
}
|