From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 4 Nov 2021 11:50:40 -0700 Subject: [PATCH] Add isCollidable methods to various places == AT == public net.minecraft.world.level.block.state.BlockBehaviour hasCollision diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 9fa50da214ad9a134008c91e1e07223904a8e6a3..d0102a0e7cf3a52b5a2a89f2dc0994fa463eb8c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -484,6 +484,11 @@ public class CraftBlock implements Block { public boolean isSolid() { return getNMS().getMaterial().blocksMotion(); } + + @Override + public boolean isCollidable() { + return getNMS().getBlock().hasCollision; + } // Paper end @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 9068557ac50cfb26e7e3ec4ac64bac583baa582e..3e1d36a8c65e6567ac3b78903a25d5828ab74ea5 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -325,4 +325,11 @@ public class CraftBlockState implements BlockState { throw new IllegalStateException("The blockState must be placed to call this method"); } } + + // Paper start + @Override + public boolean isCollidable() { + return this.data.getBlock().hasCollision; + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index bb0c75d5e2e642576fb19a03e71ac692912d76b1..c47821a81b9367e1c59d8428384bfd4752d0303e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -582,6 +582,12 @@ public final class CraftMagicNumbers implements UnsafeValues { var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey))); return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier); } + + @Override + public boolean isCollidable(Material material) { + Preconditions.checkArgument(material.isBlock(), material + " is not a block"); + return getBlock(material).hasCollision; + } // Paper end /**