2021-11-06 20:43:24 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Thu, 4 Nov 2021 11:50:35 -0700
|
2024-05-23 19:32:02 +02:00
|
|
|
Subject: [PATCH] Add hasCollision methods to various places
|
2021-11-06 20:43:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
2024-06-13 16:45:27 +02:00
|
|
|
index a011123035a96c05921f0a206b92bef15732b443..889f760e0c8de3f567d86936e6fc317a43993b10 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/Material.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Material.java
|
2024-05-23 19:32:02 +02:00
|
|
|
@@ -4788,6 +4788,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
2021-11-06 20:43:24 +01:00
|
|
|
}
|
2024-05-23 19:32:02 +02:00
|
|
|
// Paper end - item default attributes API
|
|
|
|
|
|
|
|
+ // Paper start - isCollidable API
|
2021-11-06 20:43:24 +01:00
|
|
|
+ /**
|
|
|
|
+ * Checks if this material is collidable.
|
|
|
|
+ *
|
|
|
|
+ * @return true if collidable
|
|
|
|
+ * @throws IllegalArgumentException if {@link #isBlock()} is false
|
|
|
|
+ */
|
|
|
|
+ public boolean isCollidable() {
|
2024-05-23 19:32:02 +02:00
|
|
|
+ if (this.isBlock()) {
|
|
|
|
+ return this.asBlockType().hasCollision();
|
|
|
|
+ }
|
|
|
|
+ throw new IllegalArgumentException(this + " isn't a block type");
|
2021-11-06 20:43:24 +01:00
|
|
|
+ }
|
2024-05-23 19:32:02 +02:00
|
|
|
+ // Paper end - isCollidable API
|
2021-11-06 20:43:24 +01:00
|
|
|
+
|
2024-05-23 19:32:02 +02:00
|
|
|
/**
|
|
|
|
* Do not use for any reason.
|
|
|
|
*
|
2021-11-06 20:43:24 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
2024-06-13 16:45:27 +02:00
|
|
|
index 6ada8c036f1a112f11a9fbc3baf1f79b3f1bfc8e..02361d58ac723d02d93db80a721b27d37f7dc3c1 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/block/Block.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/Block.java
|
2023-02-15 23:10:14 +01:00
|
|
|
@@ -482,6 +482,13 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
|
2021-11-06 20:43:24 +01:00
|
|
|
* @return true if block is solid
|
|
|
|
*/
|
|
|
|
boolean isSolid();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks if this block is collidable.
|
|
|
|
+ *
|
|
|
|
+ * @return true if collidable
|
|
|
|
+ */
|
|
|
|
+ boolean isCollidable();
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
/**
|
|
|
|
diff --git a/src/main/java/org/bukkit/block/BlockState.java b/src/main/java/org/bukkit/block/BlockState.java
|
2024-04-23 19:02:08 +02:00
|
|
|
index fd4a9bdcfb6775dfbdb7492e6c9eb90722d2ecdc..e573e70d9e74e444783a7363e6cdac126124d86d 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/block/BlockState.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/BlockState.java
|
2024-04-23 19:02:08 +02:00
|
|
|
@@ -245,4 +245,13 @@ public interface BlockState extends Metadatable {
|
2021-11-06 20:43:24 +01:00
|
|
|
* or 'virtual' (e.g. on an itemstack)
|
|
|
|
*/
|
|
|
|
boolean isPlaced();
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Checks if this block state is collidable.
|
|
|
|
+ *
|
|
|
|
+ * @return true if collidable
|
|
|
|
+ */
|
|
|
|
+ boolean isCollidable();
|
|
|
|
+ // Paper end
|
|
|
|
}
|
2024-05-23 19:32:02 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
|
2024-06-13 16:45:27 +02:00
|
|
|
index 56bc4cbc9af40e7fa400293ddc2479c7d2754c55..8ba422ce7eecdfdfb4edbc0d56f99eeaa3f16e9b 100644
|
2024-05-23 19:32:02 +02:00
|
|
|
--- a/src/main/java/org/bukkit/block/BlockType.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/BlockType.java
|
2024-06-13 16:45:27 +02:00
|
|
|
@@ -3612,4 +3612,13 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran
|
2024-05-23 19:32:02 +02:00
|
|
|
@Override
|
|
|
|
@NotNull String getTranslationKey();
|
|
|
|
// Paper end - add Translatable
|
|
|
|
+
|
|
|
|
+ // Paper start - hasCollision API
|
|
|
|
+ /**
|
|
|
|
+ * Checks if this block type has collision.
|
|
|
|
+ * <p>
|
|
|
|
+ * @return false if this block never has collision, true if it <b>might</b> have collision
|
|
|
|
+ */
|
|
|
|
+ boolean hasCollision();
|
|
|
|
+ // Paper end - hasCollision API
|
|
|
|
}
|