papermc/patches/server/0578-Additional-Block-Material-API-s.patch

41 lines
1.6 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 30 Dec 2020 19:43:01 -0500
Subject: [PATCH] Additional Block Material API's
Faster version for isSolid() that utilizes NMS's state for isSolid instead of the slower
process to do this in the Bukkit API
Adds API for buildable, replaceable, burnable too.
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 2209587fbc4240561aeea6e525fbf22f5041e145..2379b61fff76fa39a37348a740ca5ad18fadff4f 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
2021-06-14 18:50:22 +00:00
@@ -623,6 +623,25 @@ public class CraftBlock implements Block {
return this.getNMS().getMaterial().isLiquid();
2021-06-11 12:02:28 +00:00
}
+ // Paper start
+ @Override
+ public boolean isBuildable() {
2021-06-14 18:50:22 +00:00
+ return getNMS().getMaterial().isSolid(); // This is in fact isSolid, despite the fact that isSolid below returns blocksMotion
2021-06-11 12:02:28 +00:00
+ }
+ @Override
+ public boolean isBurnable() {
2021-06-14 18:50:22 +00:00
+ return getNMS().getMaterial().isFlammable();
2021-06-11 12:02:28 +00:00
+ }
+ @Override
+ public boolean isReplaceable() {
+ return getNMS().getMaterial().isReplaceable();
+ }
+ @Override
+ public boolean isSolid() {
+ return getNMS().getMaterial().blocksMotion();
+ }
+ // Paper end
+
@Override
public PistonMoveReaction getPistonMoveReaction() {
2021-06-14 18:50:22 +00:00
return PistonMoveReaction.getById(this.getNMS().getPistonPushReaction().ordinal());