0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 13:56:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch
2024-10-23 02:15:00 +11:00

48 lines
2.2 KiB
Diff

--- a/net/minecraft/world/entity/ambient/EntityBat.java
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
@@ -30,6 +30,10 @@
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityBat extends EntityAmbient {
public static final float FLAP_LENGTH_SECONDS = 0.5F;
@@ -144,13 +148,13 @@
this.yHeadRot = (float) this.random.nextInt(360);
}
- if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
@@ -177,7 +181,7 @@
this.zza = 0.5F;
this.setYRot(this.getYRot() + f1);
- if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1)) {
+ if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(true);
}
}
@@ -202,7 +206,7 @@
if (this.isInvulnerableTo(worldserver, damagesource)) {
return false;
} else {
- if (this.isResting()) {
+ if (this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
}