aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/level/block/BedBlock.java.patch
blob: 9c276d1845773e45aee79ebf76684c9362096f72 (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
--- a/net/minecraft/world/level/block/BedBlock.java
+++ b/net/minecraft/world/level/block/BedBlock.java
@@ -92,7 +94,8 @@
                 }
             }
 
-            if (!canSetSpawn(level)) {
+            // CraftBukkit - moved world and biome check into EntityHuman
+            if (false && !canSetSpawn(level)) {
                 level.removeBlock(pos, false);
                 BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite());
                 if (level.getBlockState(blockPos).is(this)) {
@@ -109,9 +114,18 @@
 
                 return InteractionResult.SUCCESS;
             } else {
-                player.startSleepInBed(pos).ifLeft(bedSleepingProblem -> {
-                    if (bedSleepingProblem.getMessage() != null) {
-                        player.displayClientMessage(bedSleepingProblem.getMessage(), true);
+                // CraftBukkit start
+                IBlockData finaliblockdata = state;
+                BlockPos finalblockposition = pos;
+                // CraftBukkit end
+                player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
+                    // CraftBukkit start - handling bed explosion from below here
+                    if (!level.dimensionType().bedWorks()) {
+                        this.explodeBed(finaliblockdata, level, finalblockposition);
+                    } else
+                    // CraftBukkit end
+                    if (entityhuman_enumbedresult.getMessage() != null) {
+                        player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
                     }
                 });
                 return InteractionResult.SUCCESS;
@@ -119,8 +134,29 @@
         }
     }
 
+    // CraftBukkit start
+    private InteractionResult explodeBed(IBlockData iblockdata, Level world, BlockPos blockposition) {
+        {
+            {
+                world.removeBlock(blockposition, false);
+                BlockPos blockposition1 = blockposition.relative(((Direction) iblockdata.getValue(BedBlock.FACING)).getOpposite());
+
+                if (world.getBlockState(blockposition1).getBlock() == this) {
+                    world.removeBlock(blockposition1, false);
+                }
+
+                Vec3 vec3d = blockposition.getCenter();
+
+                world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.a.BLOCK);
+                return InteractionResult.SUCCESS;
+            }
+        }
+    }
+    // CraftBukkit end
+
     public static boolean canSetSpawn(Level level) {
-        return level.dimensionType().bedWorks();
+        // CraftBukkit - moved world and biome check into EntityHuman
+        return true || level.dimensionType().bedWorks();
     }
 
     private boolean kickVillagerOutOfBed(Level level, BlockPos pos) {
@@ -305,8 +352,14 @@
     public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
         super.setPlacedBy(level, pos, state, placer, stack);
         if (!level.isClientSide) {
-            BlockPos blockPos = pos.relative(state.getValue(FACING));
-            level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), 3);
+            BlockPos blockposition1 = pos.relative((Direction) state.getValue(BedBlock.FACING));
+
+            level.setBlock(blockposition1, (IBlockData) state.setValue(BedBlock.PART, BedPart.HEAD), 3);
+            // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states
+            if (level.captureBlockStates) {
+                return;
+            }
+            // CraftBukkit end
             level.blockUpdated(pos, Blocks.AIR);
             state.updateNeighbourShapes(level, pos, 3);
         }