2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/ambient/EntityBat.java
|
|
|
|
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
|
|
|
|
@@ -30,6 +30,8 @@
|
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2018-09-16 18:57:03 +02:00
|
|
|
|
2021-03-08 22:47:33 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
+
|
2018-09-16 18:57:03 +02:00
|
|
|
public class EntityBat extends EntityAmbient {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final float FLAP_DEGREES_PER_TICK = 74.48451F;
|
|
|
|
@@ -138,16 +140,24 @@
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.level.a(EntityBat.BAT_RESTING_TARGETING, (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) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.a((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ }
|
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) {
|
2021-06-11 07:00:00 +02:00
|
|
|
this.level.a((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
- } else {
|
|
|
|
- this.setAsleep(false);
|
2020-06-25 02:00:00 +02:00
|
|
|
- if (!flag) {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.level.a((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 02:00:00 +02:00
|
|
|
- }
|
2018-09-16 18:57:03 +02:00
|
|
|
+ // CraftBukkit End - Call BatToggleSleepEvent
|
|
|
|
}
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.targetPosition != null && (!this.level.isEmpty(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) {
|
|
|
|
@@ -171,7 +181,11 @@
|
|
|
|
this.zza = 0.5F;
|
|
|
|
this.setYRot(this.getYRot() + f1);
|
|
|
|
if (this.random.nextInt(100) == 0 && this.level.getType(blockposition1).isOccluding(this.level, 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -201,7 +215,11 @@
|
2018-09-16 18:57:03 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.level.isClientSide && this.isAsleep()) {
|
2018-09-16 18:57:03 +02:00
|
|
|
- this.setAsleep(false);
|
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
|
|
|
+ this.setAsleep(false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End - Call BatToggleSleepEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.damageEntity(damagesource, f);
|