2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java
2024-04-23 17:15:00 +02:00
@@ -89,6 +89,20 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
2023-09-21 18:40:00 +02:00
import net.minecraft.world.phys.AxisAlignedBB;
2014-11-25 22:32:16 +01:00
+// CraftBukkit start
2021-03-15 23:00:00 +01:00
+import net.minecraft.server.level.EntityPlayer;
2014-11-25 22:32:16 +01:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
2020-06-25 02:00:00 +02:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
2018-07-15 02:00:00 +02:00
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
2024-02-21 10:55:34 +01:00
+import org.bukkit.event.entity.EntityRemoveEvent;
2014-11-25 22:32:16 +01:00
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
2020-06-25 02:00:00 +02:00
+import org.bukkit.event.entity.EntityTransformEvent;
2014-11-25 22:32:16 +01:00
+import org.bukkit.event.entity.EntityUnleashEvent;
+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
+// CraftBukkit end
+
2024-04-23 17:15:00 +02:00
public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Targeting {
2014-11-25 22:32:16 +01:00
2021-11-21 23:00:00 +01:00
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
2024-04-23 17:15:00 +02:00
@@ -138,6 +152,8 @@
2021-06-11 07:00:00 +02:00
private BlockPosition restrictCenter;
private float restrictRadius;
2020-02-19 11:50:21 +01:00
+ public boolean aware = true; // CraftBukkit
+
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
2021-11-21 23:00:00 +01:00
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
2024-04-23 17:15:00 +02:00
@@ -165,6 +181,12 @@
2015-02-26 23:41:06 +01:00
2022-05-03 15:13:03 +02:00
}
+ // CraftBukkit start
2021-07-22 01:53:26 +02:00
+ public void setPersistenceRequired(boolean persistenceRequired) {
+ this.persistenceRequired = persistenceRequired;
2022-05-03 15:13:03 +02:00
+ }
2021-07-22 01:53:26 +02:00
+ // CraftBukkit end
2022-05-03 15:13:03 +02:00
+
2021-11-21 23:00:00 +01:00
protected void registerGoals() {}
2021-07-22 01:53:26 +02:00
2022-05-03 15:13:03 +02:00
public static AttributeProvider.Builder createMobAttributes() {
2024-04-23 17:15:00 +02:00
@@ -269,11 +291,42 @@
@Nullable
protected final EntityLiving getTargetFromBrain() {
- return (EntityLiving) this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null);
+ return (EntityLiving) this.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error
2016-05-10 13:47:39 +02:00
}
2021-11-21 23:00:00 +01:00
public void setTarget(@Nullable EntityLiving entityliving) {
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - fire event
2021-11-21 23:00:00 +01:00
+ setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
2014-11-25 22:32:16 +01:00
+ }
2015-02-26 23:41:06 +01:00
+
2021-11-21 23:00:00 +01:00
+ public boolean setTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
+ if (getTarget() == entityliving) return false;
2014-11-25 22:32:16 +01:00
+ if (fireEvent) {
2021-11-21 23:00:00 +01:00
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getTarget() != null && entityliving == null) {
+ reason = getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
2014-11-25 22:32:16 +01:00
+ }
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
2023-06-07 17:30:00 +02:00
+ this.level().getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
2014-11-25 22:32:16 +01:00
+ }
+ CraftLivingEntity ctarget = null;
+ if (entityliving != null) {
+ ctarget = (CraftLivingEntity) entityliving.getBukkitEntity();
+ }
+ EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason);
2023-06-07 17:30:00 +02:00
+ this.level().getCraftServer().getPluginManager().callEvent(event);
2014-11-25 22:32:16 +01:00
+ if (event.isCancelled()) {
2016-04-20 12:40:16 +02:00
+ return false;
2014-11-25 22:32:16 +01:00
+ }
2015-02-26 23:41:06 +01:00
+
2014-11-25 22:32:16 +01:00
+ if (event.getTarget() != null) {
+ entityliving = ((CraftLivingEntity) event.getTarget()).getHandle();
+ } else {
+ entityliving = null;
+ }
+ }
2021-06-11 07:00:00 +02:00
this.target = entityliving;
2016-04-20 12:40:16 +02:00
+ return true;
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
}
2019-04-23 04:00:00 +02:00
@Override
2024-04-23 17:15:00 +02:00
@@ -412,6 +465,12 @@
2022-09-11 14:24:15 +02:00
return null;
}
+ // CraftBukkit start - Add delegate method
+ public SoundEffect getAmbientSound0() {
+ return getAmbientSound();
+ }
+ // CraftBukkit end
+
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
2024-04-24 22:51:14 +02:00
@@ -486,7 +545,10 @@
2024-04-23 17:15:00 +02:00
}
2023-11-30 22:01:44 +01:00
}
2024-04-23 17:15:00 +02:00
- if (either != null) {
2024-04-24 22:51:14 +02:00
+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
+ Entity leashHolder = this.leashHolder;
+ if (either != null && (leashHolder == null || !leashHolder.pluginRemoved)) {
+ // CraftBukkit end
2024-04-23 17:15:00 +02:00
nbttagcompound.put("leash", (NBTBase) either.map((uuid) -> {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
2024-04-24 22:51:14 +02:00
@@ -507,16 +569,26 @@
2021-11-21 23:00:00 +01:00
nbttagcompound.putBoolean("NoAI", this.isNoAi());
2020-02-21 00:09:47 +01:00
}
2021-11-21 23:00:00 +01:00
+ nbttagcompound.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
2020-02-21 00:09:47 +01:00
}
2019-04-23 04:00:00 +02:00
@Override
2021-11-21 23:00:00 +01:00
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
2016-02-29 22:32:46 +01:00
+
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
2021-11-21 23:00:00 +01:00
if (nbttagcompound.contains("CanPickUpLoot", 1)) {
- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
2014-11-25 22:32:16 +01:00
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
2021-11-21 23:00:00 +01:00
+ this.setCanPickUpLoot(data);
2014-11-25 22:32:16 +01:00
+ }
}
2021-06-11 07:00:00 +02:00
- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired");
2014-11-25 22:32:16 +01:00
+ boolean data = nbttagcompound.getBoolean("PersistenceRequired");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
2021-06-11 07:00:00 +02:00
+ this.persistenceRequired = data;
2014-11-25 22:32:16 +01:00
+ }
+ // CraftBukkit end
NBTTagList nbttaglist;
2024-04-23 17:15:00 +02:00
NBTTagCompound nbttagcompound1;
2014-11-25 22:32:16 +01:00
int i;
2024-04-24 22:51:14 +02:00
@@ -565,7 +637,7 @@
2024-04-23 17:15:00 +02:00
if (nbttagcompound.contains("leash", 10)) {
this.delayedLeashInfo = Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"));
} else if (nbttagcompound.contains("leash", 11)) {
- this.delayedLeashInfo = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse((Object) null);
+ this.delayedLeashInfo = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse(null); // CraftBukkit - decompile error
} else {
this.delayedLeashInfo = null;
}
2024-04-24 22:51:14 +02:00
@@ -577,6 +649,11 @@
2020-02-21 00:09:47 +01:00
}
2021-11-21 23:00:00 +01:00
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
2020-02-21 00:09:47 +01:00
+ // CraftBukkit start
2021-11-21 23:00:00 +01:00
+ if (nbttagcompound.contains("Bukkit.Aware")) {
2020-02-21 00:09:47 +01:00
+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware");
+ }
+ // CraftBukkit end
}
@Override
2024-04-24 22:51:14 +02:00
@@ -651,20 +728,26 @@
2022-12-07 17:00:00 +01:00
2021-11-21 23:00:00 +01:00
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
2022-12-07 17:00:00 +01:00
- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy());
+ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), entityitem); // CraftBukkit - add item
2021-11-21 23:00:00 +01:00
2022-12-07 17:00:00 +01:00
if (!itemstack1.isEmpty()) {
2021-11-21 23:00:00 +01:00
this.onItemPickup(entityitem);
2024-02-21 10:55:34 +01:00
this.take(entityitem, itemstack1.getCount());
itemstack.shrink(itemstack1.getCount());
if (itemstack.isEmpty()) {
- entityitem.discard();
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
}
}
2020-06-25 02:00:00 +02:00
}
2022-12-07 17:00:00 +01:00
public ItemStack equipItemIfPossible(ItemStack itemstack) {
2020-06-25 02:00:00 +02:00
+ // CraftBukkit start - add item
2021-11-21 23:00:00 +01:00
+ return this.equipItemIfPossible(itemstack, null);
2020-06-25 02:00:00 +02:00
+ }
+
2022-12-07 17:00:00 +01:00
+ public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) {
2020-06-25 02:00:00 +02:00
+ // CraftBukkit end
2023-03-14 17:30:00 +01:00
EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
2021-11-21 23:00:00 +01:00
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
2024-04-24 22:51:14 +02:00
@@ -675,11 +758,19 @@
2023-06-07 17:30:00 +02:00
flag = itemstack1.isEmpty();
2023-03-14 17:30:00 +01:00
}
2017-07-28 09:47:59 +02:00
2021-11-21 23:00:00 +01:00
- if (flag && this.canHoldItem(itemstack)) {
2017-07-28 09:47:59 +02:00
+ // CraftBukkit start
2021-11-21 23:00:00 +01:00
+ boolean canPickup = flag && this.canHoldItem(itemstack);
2020-06-25 02:00:00 +02:00
+ if (entityitem != null) {
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
+ }
2017-07-28 09:47:59 +02:00
+ if (canPickup) {
+ // CraftBukkit end
2021-11-21 23:00:00 +01:00
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
2017-04-09 01:05:32 +02:00
2019-12-10 23:00:00 +01:00
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
2017-04-09 01:05:32 +02:00
+ this.forceDrops = true; // CraftBukkit
2021-11-21 23:00:00 +01:00
this.spawnAtLocation(itemstack1);
2017-04-09 01:05:32 +02:00
+ this.forceDrops = false; // CraftBukkit
}
2022-12-07 17:00:00 +01:00
if (enumitemslot.isArmor() && itemstack.getCount() > 1) {
2024-04-24 22:51:14 +02:00
@@ -813,7 +904,7 @@
2024-02-21 10:55:34 +01:00
@Override
public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D);
2024-04-24 22:51:14 +02:00
@@ -823,14 +914,14 @@
2024-02-21 10:55:34 +01:00
int j = i * i;
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
int k = this.getType().getCategory().getNoDespawnDistance();
int l = k * k;
if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (d0 < (double) l) {
this.noActionTime = 0;
}
2024-04-24 22:51:14 +02:00
@@ -844,6 +935,7 @@
2020-02-19 11:50:21 +01:00
@Override
2021-11-21 23:00:00 +01:00
protected final void serverAiStep() {
2021-06-11 07:00:00 +02:00
++this.noActionTime;
2020-02-19 11:50:21 +01:00
+ if (!this.aware) return; // CraftBukkit
2024-04-23 17:15:00 +02:00
GameProfilerFiller gameprofilerfiller = this.level().getProfiler();
gameprofilerfiller.push("sensing");
2024-04-24 22:51:14 +02:00
@@ -1311,6 +1403,12 @@
2019-04-23 04:00:00 +02:00
if (!this.isAlive()) {
2020-06-25 02:00:00 +02:00
return EnumInteractionResult.PASS;
2019-04-23 04:00:00 +02:00
} else if (this.getLeashHolder() == entityhuman) {
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
2022-10-02 00:07:14 +02:00
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman, enumhand).isCancelled()) {
2021-11-21 23:00:00 +01:00
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
2020-06-25 02:00:00 +02:00
+ return EnumInteractionResult.PASS;
2014-11-25 22:32:16 +01:00
+ }
+ // CraftBukkit end
2024-04-23 17:15:00 +02:00
this.dropLeash(true, !entityhuman.hasInfiniteMaterials());
2023-03-14 17:30:00 +01:00
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
2023-06-07 17:30:00 +02:00
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
2024-04-27 23:27:19 +02:00
@@ -1336,6 +1434,13 @@
2021-11-21 23:00:00 +01:00
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
2020-06-25 02:00:00 +02:00
2021-11-21 23:00:00 +01:00
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
2020-06-25 02:00:00 +02:00
+ // CraftBukkit start - fire PlayerLeashEntityEvent
2022-10-02 00:07:14 +02:00
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman, enumhand).isCancelled()) {
2024-04-27 23:27:19 +02:00
+ ((EntityPlayer) entityhuman).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item
2021-11-21 23:00:00 +01:00
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
2020-06-25 02:00:00 +02:00
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
2021-11-21 23:00:00 +01:00
this.setLeashedTo(entityhuman, true);
itemstack.shrink(1);
2023-06-07 17:30:00 +02:00
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
2024-04-27 23:27:19 +02:00
@@ -1351,7 +1456,7 @@
2020-06-25 02:00:00 +02:00
if (itemstack.getItem() instanceof ItemMonsterEgg) {
2023-06-07 17:30:00 +02:00
if (this.level() instanceof WorldServer) {
2020-06-25 02:00:00 +02:00
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
2023-06-07 17:30:00 +02:00
- Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level(), this.position(), itemstack);
+ Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getType(), (WorldServer) this.level(), this.position(), itemstack); // CraftBukkit - decompile error
2020-06-25 02:00:00 +02:00
optional.ifPresent((entityinsentient) -> {
2021-11-21 23:00:00 +01:00
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
2024-04-27 23:27:19 +02:00
@@ -1401,12 +1506,19 @@
2021-06-11 07:00:00 +02:00
return this.restrictRadius != -1.0F;
2020-08-11 23:00:00 +02:00
}
+ // CraftBukkit start
@Nullable
2021-11-21 23:00:00 +01:00
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag) {
+ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
2020-08-11 23:00:00 +02:00
+ }
+
+ @Nullable
2021-11-21 23:00:00 +01:00
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
2020-08-11 23:00:00 +02:00
+ // CraftBukkit end
2021-06-11 07:00:00 +02:00
if (this.isRemoved()) {
2020-06-25 02:00:00 +02:00
return null;
2016-11-17 02:41:03 +01:00
} else {
2023-06-07 17:30:00 +02:00
- T t0 = (EntityInsentient) entitytypes.create(this.level());
+ T t0 = entitytypes.create(this.level()); // CraftBukkit - decompile error
2020-06-25 02:00:00 +02:00
2022-12-07 17:00:00 +01:00
if (t0 == null) {
return null;
2024-04-27 23:27:19 +02:00
@@ -1440,7 +1552,12 @@
2022-12-07 17:00:00 +01:00
}
2020-06-25 02:00:00 +02:00
}
2023-06-07 17:30:00 +02:00
- this.level().addFreshEntity(t0);
2022-12-07 17:00:00 +01:00
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
+ return null;
+ }
2023-06-07 17:30:00 +02:00
+ this.level().addFreshEntity(t0, spawnReason);
2022-12-07 17:00:00 +01:00
+ // CraftBukkit end
if (this.isPassenger()) {
Entity entity = this.getVehicle();
2020-08-11 23:00:00 +02:00
2024-04-27 23:27:19 +02:00
@@ -1448,7 +1565,7 @@
2024-02-21 10:55:34 +01:00
t0.startRiding(entity, true);
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
return t0;
}
}
2024-04-27 23:27:19 +02:00
@@ -1461,7 +1578,8 @@
2016-11-17 02:41:03 +01:00
2019-04-23 04:00:00 +02:00
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
2023-11-30 22:01:44 +01:00
- this.dropLeash(true, true);
2023-06-07 17:30:00 +02:00
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
2023-11-30 22:01:44 +01:00
+ this.dropLeash(true, !this.leashHolder.pluginRemoved);// CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
2014-11-25 22:32:16 +01:00
}
2023-11-30 22:01:44 +01:00
}
2024-04-27 23:27:19 +02:00
@@ -1473,7 +1591,9 @@
2024-04-23 17:15:00 +02:00
this.delayedLeashInfo = null;
this.clearRestriction();
2023-06-07 17:30:00 +02:00
if (!this.level().isClientSide && flag1) {
2016-03-11 09:24:57 +01:00
+ this.forceDrops = true; // CraftBukkit
2021-11-21 23:00:00 +01:00
this.spawnAtLocation((IMaterial) Items.LEAD);
2016-03-11 09:24:57 +01:00
+ this.forceDrops = false; // CraftBukkit
}
2023-06-07 17:30:00 +02:00
if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) {
2024-04-27 23:27:19 +02:00
@@ -1527,6 +1647,7 @@
2021-11-21 23:00:00 +01:00
boolean flag1 = super.startRiding(entity, flag);
2014-11-25 22:32:16 +01:00
2020-06-25 02:00:00 +02:00
if (flag1 && this.isLeashed()) {
2023-06-07 17:30:00 +02:00
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
2021-11-21 23:00:00 +01:00
this.dropLeash(true, true);
2020-06-25 02:00:00 +02:00
}
2019-04-23 04:00:00 +02:00
2024-04-27 23:27:19 +02:00
@@ -1555,7 +1676,9 @@
2024-04-23 17:15:00 +02:00
}
2021-12-24 23:39:27 +01:00
2024-04-23 17:15:00 +02:00
if (this.tickCount > 100) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation((IMaterial) Items.LEAD);
+ this.forceDrops = false; // CraftBukkit
this.delayedLeashInfo = null;
}
2021-12-24 23:39:27 +01:00
}
2024-04-27 23:27:19 +02:00
@@ -1638,14 +1761,21 @@
2021-11-21 23:00:00 +01:00
int i = EnchantmentManager.getFireAspect(this);
2019-04-23 04:00:00 +02:00
if (i > 0) {
2024-04-23 17:15:00 +02:00
- entity.igniteForSeconds(i * 4);
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
2018-07-15 02:00:00 +02:00
+
2019-04-23 04:00:00 +02:00
+ if (!combustEvent.isCancelled()) {
2024-04-23 17:15:00 +02:00
+ entity.igniteForSeconds(combustEvent.getDuration(), false);
2019-04-23 04:00:00 +02:00
+ }
+ // CraftBukkit end
}
2018-07-15 02:00:00 +02:00
2023-03-14 17:30:00 +01:00
boolean flag = entity.hurt(this.damageSources().mobAttack(this), f);
2024-01-27 04:53:41 +01:00
if (flag) {
if (f1 > 0.0F && entity instanceof EntityLiving) {
- ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
+ ((EntityLiving) entity).knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot())) * 0.017453292F, this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
}
2024-04-27 23:27:19 +02:00
@@ -1695,6 +1825,7 @@
2020-06-25 02:00:00 +02:00
@Override
2021-11-21 23:00:00 +01:00
protected void removeAfterChangingDimensions() {
super.removeAfterChangingDimensions();
2023-06-07 17:30:00 +02:00
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
2021-11-21 23:00:00 +01:00
this.dropLeash(true, false);
this.getAllSlots().forEach((itemstack) -> {
2023-06-07 17:30:00 +02:00
if (!itemstack.isEmpty()) {