summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockBed.patch
blob: ae0c3dfdd4a6972cd3d2bed63ff26b2496a45687 (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
--- a/net/minecraft/server/BlockBed.java
+++ b/net/minecraft/server/BlockBed.java
@@ -32,7 +32,8 @@
                 }
             }
 
-            if (world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) {
+            // CraftBukkit - moved world and biome check into EntityHuman
+            if (true || world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) {
                 if (((Boolean) iblockdata.get(BlockBed.OCCUPIED)).booleanValue()) {
                     EntityHuman entityhuman1 = this.a(world, blockposition);
 
@@ -59,10 +60,22 @@
                     } else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.TOO_FAR_AWAY) {
                         entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.too_far_away", new Object[0])), true);
                     }
+                    // CraftBukkit start - handling bed explosion from below here
+                    else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) {
+                        this.explodeBed(iblockdata, world, blockposition);
+                    }
+                    // CraftBukkit end
 
                     return true;
                 }
+                // CraftBukkit start - moved bed explosion into separate method
             } else {
+                return true;
+            }
+        }
+    }
+
+    private boolean explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) {
                 world.setAir(blockposition);
                 BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite());
 
@@ -72,8 +85,7 @@
 
                 world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, true);
                 return true;
-            }
-        }
+                // CraftBukkit end
     }
 
     @Nullable