From b152230b1493fbe6e7b29faa26d31a8663f54340 Mon Sep 17 00:00:00 2001 From: 12emin34 <43503468+12emin34@users.noreply.github.com> Date: Fri, 10 Sep 2021 17:33:36 +0200 Subject: [PATCH] Option for beds to explode on villager sleep (#638) --- ...or-beds-to-explode-on-villager-sleep.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 patches/server/0255-Option-for-beds-to-explode-on-villager-sleep.patch diff --git a/patches/server/0255-Option-for-beds-to-explode-on-villager-sleep.patch b/patches/server/0255-Option-for-beds-to-explode-on-villager-sleep.patch new file mode 100644 index 0000000000..6ad3f7814f --- /dev/null +++ b/patches/server/0255-Option-for-beds-to-explode-on-villager-sleep.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: 12emin34 +Date: Tue, 31 Aug 2021 16:48:29 +0200 +Subject: [PATCH] Option for beds to explode on villager sleep + + +diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java +index 597d21bd2d7dde000e02986557be205380e2aa0a..e5adfd16d132828727040b56a90c1173c9b71a44 100644 +--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java ++++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java +@@ -1175,10 +1175,16 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + + @Override + public void startSleeping(BlockPos pos) { +- super.startSleeping(pos); +- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level.getGameTime()); // CraftBukkit - decompile error +- this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); +- this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); ++ // Purpur start ++ if (level.purpurConfig.bedExplodeOnVillagerSleep && this.level.getBlockState(pos).getBlock() instanceof net.minecraft.world.level.block.BedBlock) { ++ this.level.explode(null, DamageSource.explosion((net.minecraft.world.level.Explosion) null), null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (float) this.level.purpurConfig.bedExplosionPower, this.level.purpurConfig.bedExplosionFire, this.level.purpurConfig.bedExplosionEffect); ++ } else { ++ super.startSleeping(pos); ++ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level.getGameTime()); // CraftBukkit - decompile error ++ this.brain.eraseMemory(MemoryModuleType.WALK_TARGET); ++ this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); ++ } ++ // Purpur end + } + + @Override +diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +index 467cc1e7166875c929b4d39f7ed3d7c2f12991e6..702ed3dd224982989060295f3ca07a6459072c65 100644 +--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java ++++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +@@ -731,11 +731,13 @@ public class PurpurWorldConfig { + } + + public boolean bedExplode = true; ++ public boolean bedExplodeOnVillagerSleep = false; + public double bedExplosionPower = 5.0D; + public boolean bedExplosionFire = true; + public Explosion.BlockInteraction bedExplosionEffect = Explosion.BlockInteraction.DESTROY; + private void bedSettings() { + bedExplode = getBoolean("blocks.bed.explode", bedExplode); ++ bedExplodeOnVillagerSleep = getBoolean("blocks.bed.explode-on-villager-sleep", bedExplodeOnVillagerSleep); + bedExplosionPower = getDouble("blocks.bed.explosion-power", bedExplosionPower); + bedExplosionFire = getBoolean("blocks.bed.explosion-fire", bedExplosionFire); + try {