craftbukkit/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch

68 lines
2.9 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/ambient/EntityBat.java
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
2022-03-01 02:00:00 +11:00
@@ -28,6 +28,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;
2022-12-08 03:00:00 +11:00
@@ -140,16 +142,24 @@
2018-09-16 12:57:03 -04:00
}
2023-06-08 01:30:00 +10: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) {
2023-06-08 01:30:00 +10: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) {
2023-06-08 01:30:00 +10: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) {
2023-06-08 01:30:00 +10: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 {
2023-06-08 01:30:00 +10:00
if (this.targetPosition != null && (!this.level().isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level().getMinBuildHeight())) {
2022-12-08 03:00:00 +11:00
@@ -173,7 +183,11 @@
2021-06-11 15:00:00 +10:00
this.zza = 0.5F;
this.setYRot(this.getYRot() + f1);
2023-06-08 01:30:00 +10:00
if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
2021-11-22 09:00:00 +11:00
- 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
}
}
2023-03-15 03:30:00 +11:00
@@ -198,7 +212,11 @@
2018-09-16 12:57:03 -04:00
return false;
} else {
2023-06-08 01:30:00 +10:00
if (!this.level().isClientSide && this.isResting()) {
2021-11-22 09:00:00 +11:00
- 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);