PaperMC/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch
CraftBukkit/Spigot 18496e998f Repackage patches
By: md_5 <git@md-5.net>
2021-03-16 09:00:00 +11:00

67 lines
2.7 KiB
Diff

--- a/net/minecraft/server/EntityBat.java
+++ b/net/minecraft/server/EntityBat.java
@@ -5,6 +5,8 @@
import java.util.Random;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityBat extends EntityAmbient {
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntityBat.class, DataWatcherRegistry.a);
@@ -105,16 +107,24 @@
}
if (this.world.a(EntityBat.c, (EntityLiving) this) != null) {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setAsleep(false);
+ if (!flag) {
+ this.world.a((EntityHuman) null, 1025, blockposition, 0);
+ }
+ }
+ // CraftBukkit End
+ }
+ } else {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
this.setAsleep(false);
if (!flag) {
this.world.a((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
- this.setAsleep(false);
- if (!flag) {
- this.world.a((EntityHuman) null, 1025, blockposition, 0);
- }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
} else {
if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) {
@@ -138,7 +148,11 @@
this.aT = 0.5F;
this.yaw += f1;
if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) {
- this.setAsleep(true);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
+ this.setAsleep(true);
+ }
+ // CraftBukkit End
}
}
@@ -168,7 +182,11 @@
return false;
} else {
if (!this.world.isClientSide && this.isAsleep()) {
- this.setAsleep(false);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setAsleep(false);
+ }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
return super.damageEntity(damagesource, f);