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:40 -0700
|
|
|
|
Subject: [PATCH] Add isCollidable methods to various places
|
|
|
|
|
2022-11-20 00:53:20 +01:00
|
|
|
== AT ==
|
|
|
|
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
|
2021-11-06 20:43:24 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2023-09-23 04:06:03 +02:00
|
|
|
index 4c4e242305edf7b8bfa6761cd7e8c9498982608c..5fa6a77ccd01deb929d86efc227439f4f280ba53 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2023-09-23 04:06:03 +02:00
|
|
|
@@ -456,6 +456,11 @@ public class CraftBlock implements Block {
|
2021-11-06 20:43:24 +01:00
|
|
|
public boolean isSolid() {
|
2023-06-08 04:12:38 +02:00
|
|
|
return this.getNMS().blocksMotion();
|
2021-11-06 20:43:24 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
2023-06-13 01:51:45 +02:00
|
|
|
index b722a207c0e745bb172d93b90e1241d7bfa173ce..792bfc7eab33b26462e76a1912bd712e8af70073 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -317,4 +317,11 @@ public class CraftBlockState implements BlockState {
|
|
|
|
protected void requirePlaced() {
|
|
|
|
Preconditions.checkState(this.isPlaced(), "The blockState must be placed to call this method");
|
2021-11-06 20:43:24 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
2023-09-23 04:06:03 +02:00
|
|
|
index b697619abf1bce42a15a38d959dad37d49055c30..ce6b2198db6a48e9e1899db94c49a6c108950f61 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2023-09-23 04:06:03 +02:00
|
|
|
@@ -562,6 +562,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2022-12-08 04:24:00 +01:00
|
|
|
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
2021-11-06 20:43:24 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
/**
|