Skip to content

Commit

Permalink
Option for beds to explode on villager sleep (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
12emin34 authored Sep 10, 2021
1 parent b376172 commit b152230
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 12emin34 <macanovic.emin@gmail.com>
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 {

0 comments on commit b152230

Please sign in to comment.