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-09-15 21:39:53 +02:00
|
|
|
index 5c869feaecd95dbdd658e16f5739bb41540f18bd..6959f36023b12ec2dece9b91a3b8a5d07b635430 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-09-15 21:39:53 +02:00
|
|
|
@@ -4722,6 +4722,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-09-27 18:28:04 +02:00
|
|
|
index 9b0a3b4a62387d07143341756b858e15e61a9c03..cfa49e21feec7226e83e97e1053388f854b70337 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
|
2024-09-27 18:28:04 +02:00
|
|
|
@@ -486,6 +486,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-06-29 10:58:37 +02:00
|
|
|
index f4a739d8022d19a7ae0ee9bf93eb5c4846b4bd40..94e1278340c0d9d2be9edc68f645414380aab353 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-09-22 20:09:41 +02:00
|
|
|
index fc21405a18bac88678653674f9d42a08b3d7cb9b..0fa0fa4aaf55710030a2220dee98e11764d8d27a 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-09-22 20:09:41 +02:00
|
|
|
@@ -3507,4 +3507,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
|
|
|
|
}
|