aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0143-Fix-FallingBlocks-being-stuck-on-fences.patch
blob: 949f82abd7f1d4e125b0e0508acd3c73b7bf4766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From de89b530131780b4ecccb3f8487c45ae17a4bd86 Mon Sep 17 00:00:00 2001
From: Martin Panzer <postremus1996@googlemail.com>
Date: Fri, 3 Jun 2016 23:13:39 +0200
Subject: [PATCH] Fix FallingBlocks being stuck on fences

Fallingblocks would previously only check if directly beneath them a block exists. They also
hover on top of the 1.5 block tall hitbox of fences during these check. This
resulted in them always thinking they would be on air.

We now first check, if if we are already on the ground.
if not, we check if the falling block is inside of the hitbox of the block at y - 1.

diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index c4acb7597..7bd745a27 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -335,4 +335,9 @@ public class PaperWorldConfig {
             log("Old Cannon Behaviors: This feature may not be working entirely properly at the moment");
         }
     }
+
+    public boolean altFallingBlockOnGround;
+    private void altFallingBlockOnGround() {
+        altFallingBlockOnGround = getBoolean("use-alternate-fallingblock-onGround-detection", false);
+    }
 }
diff --git a/src/main/java/net/minecraft/server/BlockFalling.java b/src/main/java/net/minecraft/server/BlockFalling.java
index dcdae998c..3c777418b 100644
--- a/src/main/java/net/minecraft/server/BlockFalling.java
+++ b/src/main/java/net/minecraft/server/BlockFalling.java
@@ -71,6 +71,12 @@ public class BlockFalling extends Block {
         return block == Blocks.FIRE || material == Material.AIR || material == Material.WATER || material == Material.LAVA;
     }
 
+    // Paper start - OBFHELPER
+    public static boolean canMoveThrough(IBlockData blockdata) {
+        return BlockFalling.i(blockdata);
+    }
+    // Paper end
+
     public void a_(World world, BlockPosition blockposition) {}
 
     public void b(World world, BlockPosition blockposition) {}
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index bb01929e8..8059e6dcd 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -2,7 +2,9 @@ package net.minecraft.server;
 
 import com.google.common.collect.Lists;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
 import javax.annotation.Nullable;
 
 import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
@@ -97,10 +99,9 @@ public class EntityFallingBlock extends Entity {
                 blockposition = new BlockPosition(this);
                 if (this.onGround) {
                     IBlockData iblockdata = this.world.getType(blockposition);
-
-                    if (BlockFalling.i(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) {
+                    if (!isOnGround()) {
                         this.onGround = false;
-                        // return; // CraftBukkit
+                        if (this.world.paperConfig.altFallingBlockOnGround) return; // Paper
                     }
 
                     this.motX *= 0.699999988079071D;
@@ -159,6 +160,32 @@ public class EntityFallingBlock extends Entity {
         }
     }
 
+    // Paper start
+    private boolean isOnGround() {
+        BlockPosition where = new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ);
+        boolean cannotMoveThrough = !BlockFalling.canMoveThrough(this.world.getType(where));
+        if (!this.world.paperConfig.altFallingBlockOnGround) return cannotMoveThrough;
+
+        if (cannotMoveThrough) {
+            return true;
+        }
+
+        IBlockData blockData = this.world.getType(where.down());
+        if (BlockFalling.canMoveThrough(blockData)) {
+            return false;
+        }
+
+        List<AxisAlignedBB> list = new ArrayList<>();
+        addCollisions(blockData, getWorld(), where, this.getBoundingBox(), list, this);
+        return list.size() > 0;
+    }
+
+    // OBFHELPER
+    private void addCollisions(IBlockData blockData, World world, BlockPosition where, AxisAlignedBB collider, List<AxisAlignedBB> list, Entity entity) {
+        blockData.a(world, where, collider, list, entity, false);
+    }
+    // Paper end
+
     public void e(float f, float f1) {
         Block block = this.block.getBlock();
 
-- 
2.12.0.windows.1