aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0309-Add-hasCollision-methods-to-various-places.patch
blob: a886e61316c12ecb8078df26afcf7f450bd5823b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
Subject: [PATCH] Add hasCollision methods to various places


diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 5c869feaecd95dbdd658e16f5739bb41540f18bd..6959f36023b12ec2dece9b91a3b8a5d07b635430 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4722,6 +4722,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
     }
     // Paper end - item default attributes API
 
+    // Paper start - isCollidable API
+    /**
+     * Checks if this material is collidable.
+     *
+     * @return true if collidable
+     * @throws IllegalArgumentException if {@link #isBlock()} is false
+     */
+    public boolean isCollidable() {
+        if (this.isBlock()) {
+            return this.asBlockType().hasCollision();
+        }
+        throw new IllegalArgumentException(this + " isn't a block type");
+    }
+    // Paper end - isCollidable API
+
     /**
      * Do not use for any reason.
      *
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 6ada8c036f1a112f11a9fbc3baf1f79b3f1bfc8e..02361d58ac723d02d93db80a721b27d37f7dc3c1 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -482,6 +482,13 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
      * @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
index f4a739d8022d19a7ae0ee9bf93eb5c4846b4bd40..94e1278340c0d9d2be9edc68f645414380aab353 100644
--- a/src/main/java/org/bukkit/block/BlockState.java
+++ b/src/main/java/org/bukkit/block/BlockState.java
@@ -245,4 +245,13 @@ public interface BlockState extends Metadatable {
      *         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
 }
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
index fc21405a18bac88678653674f9d42a08b3d7cb9b..0fa0fa4aaf55710030a2220dee98e11764d8d27a 100644
--- a/src/main/java/org/bukkit/block/BlockType.java
+++ b/src/main/java/org/bukkit/block/BlockType.java
@@ -3507,4 +3507,13 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran
     @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
 }