2018-09-16 18:57:03 +02:00
|
|
|
--- a/net/minecraft/server/EntityBat.java
|
|
|
|
+++ b/net/minecraft/server/EntityBat.java
|
2019-06-21 12:00:00 +02:00
|
|
|
@@ -4,6 +4,7 @@
|
2018-09-16 18:57:03 +02:00
|
|
|
import java.time.temporal.ChronoField;
|
2019-06-21 12:00:00 +02:00
|
|
|
import java.util.Random;
|
2018-09-16 18:57:03 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
|
|
|
|
public class EntityBat extends EntityAmbient {
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -105,16 +106,24 @@
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
if (this.world.a(EntityBat.c, (EntityLiving) this) != null) {
|
2018-09-16 18:57:03 +02:00
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
|
|
|
+ this.setAsleep(false);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ if (!flag) {
|
|
|
|
+ this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
|
|
|
+ }
|
2018-09-16 18:57:03 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
|
|
|
this.setAsleep(false);
|
2020-06-25 02:00:00 +02:00
|
|
|
if (!flag) {
|
|
|
|
this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
|
|
|
}
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
- } else {
|
|
|
|
- this.setAsleep(false);
|
2020-06-25 02:00:00 +02:00
|
|
|
- if (!flag) {
|
|
|
|
- this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
|
|
|
- }
|
2018-09-16 18:57:03 +02:00
|
|
|
+ // CraftBukkit End - Call BatToggleSleepEvent
|
|
|
|
}
|
|
|
|
} else {
|
2019-04-23 04:00:00 +02:00
|
|
|
if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -138,7 +147,11 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
this.aT = 0.5F;
|
2018-09-16 18:57:03 +02:00
|
|
|
this.yaw += f1;
|
2019-04-23 04:00:00 +02:00
|
|
|
if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) {
|
2018-09-16 18:57:03 +02:00
|
|
|
- this.setAsleep(true);
|
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
|
|
|
|
+ this.setAsleep(true);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -168,7 +181,11 @@
|
2018-09-16 18:57:03 +02:00
|
|
|
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);
|