mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
48 lines
2.7 KiB
Diff
48 lines
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 57bb76050919d187adef4bfa8b21416a70867d23..254cdf5efe85583c5ef126d46af7c5246daa97c2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
@@ -1021,5 +1021,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
|
|
|
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, 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 863d5a2c6729f8675b03a0575a7eb69ccaf04f4b..f4a9b72f76742b128632183720866df9283ca753 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -1418,4 +1418,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
|
|
}
|