Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
58 Zeilen
2.7 KiB
Diff
58 Zeilen
2.7 KiB
Diff
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
|
|
|
|
== 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 6ec8ebdd702424d94821180f65f6344be1a0527a..016f58f452e19a00d72a277d41bcbbb107e4232b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -482,6 +482,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 7b9e943b391c061782fccd2b8d705ceec8db50fe..966ac60daebb7bb211ab8096fc0c5f33db67320a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
@@ -324,4 +324,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 84c71a28b16160c2eae53707e29bc6242ac08b26..1cf2c29e4fc7073b19f62368ce4569ce54a4b13d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -577,6 +577,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.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
|
|
|
|
/**
|