mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Add PlayerBedFailEnterEvent
This commit is contained in:
parent
80878ac918
commit
472880fdde
@ -10,7 +10,7 @@
|
|||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
BlockPos blockposition1 = pos.relative(((Direction) state.getValue(BedBlock.FACING)).getOpposite());
|
BlockPos blockposition1 = pos.relative(((Direction) state.getValue(BedBlock.FACING)).getOpposite());
|
||||||
|
|
||||||
@@ -114,7 +115,16 @@
|
@@ -114,19 +115,59 @@
|
||||||
|
|
||||||
return InteractionResult.SUCCESS_SERVER;
|
return InteractionResult.SUCCESS_SERVER;
|
||||||
} else {
|
} else {
|
||||||
@ -19,18 +19,31 @@
|
|||||||
+ BlockPos finalblockposition = pos;
|
+ BlockPos finalblockposition = pos;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
|
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
|
||||||
|
+ // Paper start - PlayerBedFailEnterEvent
|
||||||
|
+ if (entityhuman_enumbedresult != null) {
|
||||||
|
+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.values()[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), !world.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage()));
|
||||||
|
+ if (!event.callEvent()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PlayerBedFailEnterEvent
|
||||||
+ // CraftBukkit start - handling bed explosion from below here
|
+ // CraftBukkit start - handling bed explosion from below here
|
||||||
+ if (!world.dimensionType().bedWorks()) {
|
+ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent
|
||||||
+ this.explodeBed(finaliblockdata, world, finalblockposition);
|
+ this.explodeBed(finaliblockdata, world, finalblockposition);
|
||||||
+ } else
|
+ } else
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (entityhuman_enumbedresult.getMessage() != null) {
|
if (entityhuman_enumbedresult.getMessage() != null) {
|
||||||
player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
|
- player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
|
||||||
|
+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent
|
||||||
|
+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent
|
||||||
}
|
}
|
||||||
@@ -125,8 +135,30 @@
|
+ } // Paper - PlayerBedFailEnterEvent
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
|
return InteractionResult.SUCCESS_SERVER;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ private InteractionResult explodeBed(BlockState iblockdata, Level world, BlockPos blockposition) {
|
+ private InteractionResult explodeBed(BlockState iblockdata, Level world, BlockPos blockposition) {
|
||||||
+ {
|
+ {
|
||||||
@ -47,11 +60,11 @@
|
|||||||
+
|
+
|
||||||
+ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state
|
+ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, blockState), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state
|
||||||
+ return InteractionResult.SUCCESS;
|
+ return InteractionResult.SUCCESS;
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
public static boolean canSetSpawn(Level world) {
|
public static boolean canSetSpawn(Level world) {
|
||||||
- return world.dimensionType().bedWorks();
|
- return world.dimensionType().bedWorks();
|
||||||
+ // CraftBukkit - moved world and biome check into EntityHuman
|
+ // CraftBukkit - moved world and biome check into EntityHuman
|
||||||
@ -59,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean kickVillagerOutOfBed(Level world, BlockPos pos) {
|
private boolean kickVillagerOutOfBed(Level world, BlockPos pos) {
|
||||||
@@ -320,6 +352,11 @@
|
@@ -320,6 +361,11 @@
|
||||||
BlockPos blockposition1 = pos.relative((Direction) state.getValue(BedBlock.FACING));
|
BlockPos blockposition1 = pos.relative((Direction) state.getValue(BedBlock.FACING));
|
||||||
|
|
||||||
world.setBlock(blockposition1, (BlockState) state.setValue(BedBlock.PART, BedPart.HEAD), 3);
|
world.setBlock(blockposition1, (BlockState) state.setValue(BedBlock.PART, BedPart.HEAD), 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user