Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 04:50:06 +01:00
SPIGOT-5735: Add EntityEnterLoveModeEvent
Dieser Commit ist enthalten in:
Ursprung
a1d23114fa
Commit
d1fb662ec5
@ -1,6 +1,15 @@
|
|||||||
--- a/net/minecraft/server/EntityAnimal.java
|
--- a/net/minecraft/server/EntityAnimal.java
|
||||||
+++ b/net/minecraft/server/EntityAnimal.java
|
+++ b/net/minecraft/server/EntityAnimal.java
|
||||||
@@ -8,6 +8,7 @@
|
@@ -3,11 +3,16 @@
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+// CraftBukkit start
|
||||||
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
|
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||||
|
+// CraftBukkit end
|
||||||
|
|
||||||
|
public abstract class EntityAnimal extends EntityAgeable {
|
||||||
|
|
||||||
public int loveTicks;
|
public int loveTicks;
|
||||||
public UUID breedCause;
|
public UUID breedCause;
|
||||||
@ -8,7 +17,7 @@
|
|||||||
|
|
||||||
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
||||||
super(entitytypes, world);
|
super(entitytypes, world);
|
||||||
@@ -44,6 +45,9 @@
|
@@ -44,6 +49,9 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +27,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||||
if (this.isInvulnerable(damagesource)) {
|
if (this.isInvulnerable(damagesource)) {
|
||||||
@@ -53,6 +57,7 @@
|
@@ -53,6 +61,7 @@
|
||||||
return super.damageEntity(damagesource, f);
|
return super.damageEntity(damagesource, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +35,18 @@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
||||||
@@ -147,6 +152,7 @@
|
@@ -143,10 +152,17 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public void g(@Nullable EntityHuman entityhuman) {
|
||||||
|
- this.loveTicks = 600;
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
|
||||||
|
+ if (entityEnterLoveModeEvent.isCancelled()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ this.loveTicks = entityEnterLoveModeEvent.getTicksInLove();
|
||||||
|
+ // CraftBukkit end
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
this.breedCause = entityhuman.getUniqueID();
|
this.breedCause = entityhuman.getUniqueID();
|
||||||
}
|
}
|
||||||
@ -34,7 +54,7 @@
|
|||||||
|
|
||||||
this.world.broadcastEntityEffect(this, (byte) 18);
|
this.world.broadcastEntityEffect(this, (byte) 18);
|
||||||
}
|
}
|
||||||
@@ -186,11 +192,24 @@
|
@@ -186,11 +202,24 @@
|
||||||
EntityAgeable entityageable = this.createChild(entityanimal);
|
EntityAgeable entityageable = this.createChild(entityanimal);
|
||||||
|
|
||||||
if (entityageable != null) {
|
if (entityageable != null) {
|
||||||
@ -59,7 +79,7 @@
|
|||||||
|
|
||||||
if (entityplayer != null) {
|
if (entityplayer != null) {
|
||||||
entityplayer.a(StatisticList.ANIMALS_BRED);
|
entityplayer.a(StatisticList.ANIMALS_BRED);
|
||||||
@@ -203,10 +222,14 @@
|
@@ -203,10 +232,14 @@
|
||||||
entityanimal.resetLove();
|
entityanimal.resetLove();
|
||||||
entityageable.a(true);
|
entityageable.a(true);
|
||||||
entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
|
entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
|
||||||
|
@ -97,12 +97,14 @@ import org.bukkit.craftbukkit.util.CraftDamageSource;
|
|||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.AbstractHorse;
|
import org.bukkit.entity.AbstractHorse;
|
||||||
|
import org.bukkit.entity.Animals;
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LightningStrike;
|
import org.bukkit.entity.LightningStrike;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -151,6 +153,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.entity.EntityPlaceEvent;
|
import org.bukkit.event.entity.EntityPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityPortalEvent;
|
import org.bukkit.event.entity.EntityPortalEvent;
|
||||||
@ -272,6 +275,15 @@ public class CraftEventFactory {
|
|||||||
return nmsBedResult;
|
return nmsBedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entity Enter Love Mode Event
|
||||||
|
*/
|
||||||
|
public static EntityEnterLoveModeEvent callEntityEnterLoveModeEvent(EntityHuman entityHuman, EntityAnimal entityAnimal, int loveTicks) {
|
||||||
|
EntityEnterLoveModeEvent entityEnterLoveModeEvent = new EntityEnterLoveModeEvent((Animals) entityAnimal.getBukkitEntity(), entityHuman != null ? (HumanEntity) entityHuman.getBukkitEntity() : null, loveTicks);
|
||||||
|
Bukkit.getPluginManager().callEvent(entityEnterLoveModeEvent);
|
||||||
|
return entityEnterLoveModeEvent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trade Index Change Event
|
* Trade Index Change Event
|
||||||
*/
|
*/
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren