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 0499699f0a211d83eb3353c00f63baf87147ee7b..84911c7c6d038aadd3d84ac4797feaa91a556c3e 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -481,6 +481,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 bac01b70eadcf76121e6e2f20bd57edaa78fd0f8..30dfdbace0f60074d0cb056d2916331882ade295 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -574,6 +574,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 /**