2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/ambient/EntityBat.java
|
|
|
|
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
|
2021-11-22 09:00:00 +11:00
|
|
|
@@ -29,6 +29,8 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2018-09-16 12:57:03 -04:00
|
|
|
|
2021-03-09 08:47:33 +11:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
+
|
2018-09-16 12:57:03 -04:00
|
|
|
public class EntityBat extends EntityAmbient {
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
public static final float FLAP_DEGREES_PER_TICK = 74.48451F;
|
|
|
|
@@ -138,16 +140,24 @@
|
2018-09-16 12:57:03 -04:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
if (this.level.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
|
2018-09-16 12:57:03 -04:00
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ this.setResting(false);
|
2020-06-25 10:00:00 +10:00
|
|
|
+ if (!flag) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 10:00:00 +10:00
|
|
|
+ }
|
2018-09-16 12:57:03 -04:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
this.setResting(false);
|
2020-06-25 10:00:00 +10:00
|
|
|
if (!flag) {
|
2021-11-22 09:00:00 +11:00
|
|
|
this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 10:00:00 +10:00
|
|
|
}
|
2018-09-16 12:57:03 -04:00
|
|
|
}
|
|
|
|
- } else {
|
2021-11-22 09:00:00 +11:00
|
|
|
- this.setResting(false);
|
2020-06-25 10:00:00 +10:00
|
|
|
- if (!flag) {
|
2021-11-22 09:00:00 +11:00
|
|
|
- this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
2020-06-25 10:00:00 +10:00
|
|
|
- }
|
2018-09-16 12:57:03 -04:00
|
|
|
+ // CraftBukkit End - Call BatToggleSleepEvent
|
|
|
|
}
|
|
|
|
} else {
|
2021-11-22 09:00:00 +11:00
|
|
|
if (this.targetPosition != null && (!this.level.isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) {
|
2021-06-11 15:00:00 +10:00
|
|
|
@@ -171,7 +181,11 @@
|
|
|
|
this.zza = 0.5F;
|
|
|
|
this.setYRot(this.getYRot() + f1);
|
2021-11-22 09:00:00 +11:00
|
|
|
if (this.random.nextInt(100) == 0 && this.level.getBlockState(blockposition1).isRedstoneConductor(this.level, blockposition1)) {
|
|
|
|
- this.setResting(true);
|
2018-09-16 12:57:03 -04:00
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ this.setResting(true);
|
2018-09-16 12:57:03 -04:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
@@ -201,7 +215,11 @@
|
2018-09-16 12:57:03 -04:00
|
|
|
return false;
|
|
|
|
} else {
|
2021-11-22 09:00:00 +11:00
|
|
|
if (!this.level.isClientSide && this.isResting()) {
|
|
|
|
- this.setResting(false);
|
2018-09-16 12:57:03 -04:00
|
|
|
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
|
|
|
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ this.setResting(false);
|
2018-09-16 12:57:03 -04:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit End - Call BatToggleSleepEvent
|
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
return super.hurt(damagesource, f);
|