2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/ambient/EntityBat.java
|
|
|
|
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -27,6 +27,10 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2018-09-16 18:57:03 +02:00
|
|
|
|
2023-06-24 09:15:05 +02:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2018-09-16 18:57:03 +02:00
|
|
|
public class EntityBat extends EntityAmbient {
|
|
|
|
|
2023-12-05 17:40:00 +01:00
|
|
|
public static final float FLAP_LENGTH_SECONDS = 0.5F;
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -141,13 +145,13 @@
|
2023-06-24 09:15:05 +02:00
|
|
|
this.yHeadRot = (float) this.random.nextInt(360);
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
|
2023-06-24 09:15:05 +02:00
|
|
|
- if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
|
|
|
|
+ if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
2021-11-21 23:00:00 +01:00
|
|
|
this.setResting(false);
|
2020-06-25 02:00:00 +02:00
|
|
|
if (!flag) {
|
2023-06-07 17:30:00 +02:00
|
|
|
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
- } else {
|
2023-06-24 09:15:05 +02:00
|
|
|
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
|
|
|
this.setResting(false);
|
|
|
|
if (!flag) {
|
|
|
|
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -174,7 +178,7 @@
|
2023-06-24 09:15:05 +02:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
this.zza = 0.5F;
|
|
|
|
this.setYRot(this.getYRot() + f1);
|
2023-06-24 09:15:05 +02:00
|
|
|
- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
|
|
|
|
+ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
|
|
|
|
this.setResting(true);
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
}
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -199,7 +203,7 @@
|
2023-06-24 09:15:05 +02:00
|
|
|
if (this.isInvulnerableTo(damagesource)) {
|
2018-09-16 18:57:03 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
2023-06-24 09:15:05 +02:00
|
|
|
- if (!this.level().isClientSide && this.isResting()) {
|
|
|
|
+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
|
|
|
this.setResting(false);
|
2018-09-16 18:57:03 +02:00
|
|
|
}
|
|
|
|
|