Paper/patches/server/0772-Collision-API.patch

49 lines
2.7 KiB
Diff
Raw Normal View History

2022-07-31 17:30:34 +02:00
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 fbcf1320ef9c1817b24aa8724cd6cf07319c20b9..5680e9772a2d90e997d2d0aacdda9eddb7edef56 100644
2022-07-31 17:30:34 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -539,5 +539,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
2022-07-31 17:30:34 +02:00
2023-12-06 20:40:37 +01:00
return this.getHandle().clip(new net.minecraft.world.level.ClipContext(start, end, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, net.minecraft.world.phys.shapes.CollisionContext.empty())).getType() == net.minecraft.world.phys.HitResult.Type.MISS;
2022-07-31 17:30:34 +02:00
}
+
+ @Override
+ public boolean hasCollisionsIn(@org.jetbrains.annotations.NotNull org.bukkit.util.BoundingBox boundingBox) {
+ net.minecraft.world.phys.AABB aabb = new net.minecraft.world.phys.AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
2022-07-31 17:30:34 +02:00
+
+ 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 a47e8994b52576d88fa90b7a86cbe0fb7493fa6d..3cdc8787c6a481da6cb294208eebce0636a58d4f 100644
2022-07-31 17:30:34 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1138,4 +1138,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
this.getHandle().setSharedFlag(Entity.FLAG_INVISIBLE, invisible);
2022-07-31 17:30:34 +02:00
}
// Paper end - move up invisibility
+
+ // Paper start - Collision API
2022-07-31 17:30:34 +02:00
+ @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());
+
2023-06-08 21:35:20 +02:00
+ return !this.getHandle().level().noCollision(this.getHandle(), aabb);
2022-07-31 17:30:34 +02:00
+ }
+
+ @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());
2022-07-31 17:30:34 +02:00
+
2023-06-08 21:35:20 +02:00
+ return !this.getHandle().level().noCollision(this.getHandle(), aabb);
2022-07-31 17:30:34 +02:00
+ }
+ // Paper end - Collision API
2022-07-31 17:30:34 +02:00
}