PaperMC/paper-server/nms-patches/net/minecraft/world/entity/ambient/EntityBat.patch
CraftBukkit/Spigot 43702a9e10 Update to Minecraft 1.18-pre5
By: md_5 <git@md-5.net>
2021-11-22 09:00:00 +11:00

67 lines
2.8 KiB
Diff

--- a/net/minecraft/world/entity/ambient/EntityBat.java
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
@@ -29,6 +29,8 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityBat extends EntityAmbient {
public static final float FLAP_DEGREES_PER_TICK = 74.48451F;
@@ -138,16 +140,24 @@
}
if (this.level.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setResting(false);
+ if (!flag) {
+ this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
+ }
+ }
+ // CraftBukkit End
+ }
+ } else {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
this.setResting(false);
if (!flag) {
this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
- this.setResting(false);
- if (!flag) {
- this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
- }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
} else {
if (this.targetPosition != null && (!this.level.isEmptyBlock(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.getBlockState(blockposition1).isRedstoneConductor(this.level, blockposition1)) {
- this.setResting(true);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
+ this.setResting(true);
+ }
+ // CraftBukkit End
}
}
@@ -201,7 +215,11 @@
return false;
} else {
if (!this.level.isClientSide && this.isResting()) {
- this.setResting(false);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setResting(false);
+ }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
return super.hurt(damagesource, f);