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
|
2023-07-04 10:22:56 +02:00
|
|
|
index 9c18ffb9753c135e2dd1c1119082dcbddadc31ca..6537862552818e1e9e0a684a4999e27bd46753d3 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
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -1015,5 +1015,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
2022-07-31 17:30:34 +02:00
|
|
|
|
|
|
|
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
|
2023-06-13 01:51:45 +02:00
|
|
|
index 94b41e9e3abe9cfbe09af67b03bc841fc009b75c..f7c879cf10f89eaeb41a0f40787bd2c98d8d3f31 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
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -1408,4 +1408,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2022-07-31 17:30:34 +02:00
|
|
|
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());
|
|
|
|
+
|
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(), false);
|
|
|
|
+
|
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
|
|
|
|
}
|