geforkt von Mirrors/Paper
Implement BatToggleSleepEvent
Dieser Commit ist enthalten in:
Ursprung
79ada744cb
Commit
a222e4a252
60
nms-patches/EntityBat.patch
Normale Datei
60
nms-patches/EntityBat.patch
Normale Datei
@ -0,0 +1,60 @@
|
||||
--- a/net/minecraft/server/EntityBat.java
|
||||
+++ b/net/minecraft/server/EntityBat.java
|
||||
@@ -3,6 +3,7 @@
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoField;
|
||||
import javax.annotation.Nullable;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
|
||||
public class EntityBat extends EntityAmbient {
|
||||
|
||||
@@ -94,12 +95,20 @@
|
||||
}
|
||||
|
||||
if (this.world.b(this, 4.0D) != null) {
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
+ this.setAsleep(false);
|
||||
+ this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
+ }
|
||||
+ } else {
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
this.setAsleep(false);
|
||||
this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
}
|
||||
- } else {
|
||||
- this.setAsleep(false);
|
||||
- this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
+ // CraftBukkit End - Call BatToggleSleepEvent
|
||||
}
|
||||
} else {
|
||||
if (this.b != null && (!this.world.isEmpty(this.b) || this.b.getY() < 1)) {
|
||||
@@ -123,7 +132,11 @@
|
||||
this.bj = 0.5F;
|
||||
this.yaw += f1;
|
||||
if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding()) {
|
||||
- this.setAsleep(true);
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
|
||||
+ this.setAsleep(true);
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +159,11 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.world.isClientSide && this.isAsleep()) {
|
||||
- this.setAsleep(false);
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
+ this.setAsleep(false);
|
||||
+ }
|
||||
+ // CraftBukkit End - Call BatToggleSleepEvent
|
||||
}
|
||||
|
||||
return super.damageEntity(damagesource, f);
|
@ -36,6 +36,7 @@ import org.bukkit.craftbukkit.util.CraftDamageSource;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
@ -1122,4 +1123,10 @@ public class CraftEventFactory {
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
public static boolean handleBatToggleSleepEvent(Entity bat, boolean awake) {
|
||||
BatToggleSleepEvent event = new BatToggleSleepEvent((Bat) bat.getBukkitEntity(), awake);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren