2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/entity/animal/EntityFox.java
+++ b/net/minecraft/world/entity/animal/EntityFox.java
2024-04-23 17:15:00 +02:00
@@ -93,6 +93,10 @@
import net.minecraft.world.level.pathfinder.PathType;
2024-02-21 10:55:34 +01:00
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityFox extends EntityAnimal implements VariantHolder<EntityFox.Type> {
private static final DataWatcherObject<Integer> DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT);
2024-04-23 17:15:00 +02:00
@@ -518,7 +522,8 @@
2021-11-21 23:00:00 +01:00
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
2019-05-20 03:27:00 +02:00
2021-11-21 23:00:00 +01:00
- if (this.canHoldItem(itemstack)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canHoldItem(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent
+ itemstack = entityitem.getItem(); // CraftBukkit - update ItemStack from event
2019-05-20 03:27:00 +02:00
int i = itemstack.getCount();
if (i > 1) {
2024-04-23 17:15:00 +02:00
@@ -530,7 +535,7 @@
2024-02-21 10:55:34 +01:00
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1));
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
this.take(entityitem, itemstack.getCount());
- entityitem.discard();
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
this.ticksSinceEaten = 0;
}
2024-04-23 17:15:00 +02:00
@@ -868,6 +873,16 @@
2019-08-09 04:34:33 +02:00
if (entityplayer1 != null && entityplayer != entityplayer1) {
2021-11-21 23:00:00 +01:00
entityfox.addTrustedUUID(entityplayer1.getUUID());
2019-08-09 04:34:33 +02:00
}
+ // CraftBukkit start - call EntityBreedEvent
2021-11-21 23:00:00 +01:00
+ entityfox.setAge(-24000);
+ entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
2019-08-09 04:34:33 +02:00
+ int experience = this.animal.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityfox, animal, partner, entityplayer, this.animal.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
+ return;
+ }
+ experience = entityBreedEvent.getExperience();
+ // CraftBukkit end
if (entityplayer2 != null) {
2021-11-21 23:00:00 +01:00
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
2024-04-23 17:15:00 +02:00
@@ -878,12 +893,14 @@
2021-11-21 23:00:00 +01:00
this.partner.setAge(6000);
2021-05-11 10:33:28 +02:00
this.animal.resetLove();
2019-08-09 04:34:33 +02:00
this.partner.resetLove();
2021-11-21 23:00:00 +01:00
- entityfox.setAge(-24000);
- entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
- worldserver.addFreshEntityWithPassengers(entityfox);
+ worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.level.broadcastEntityEvent(this.animal, (byte) 18);
2021-06-11 07:00:00 +02:00
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
2021-11-21 23:00:00 +01:00
- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
2019-08-09 04:34:33 +02:00
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
2021-11-21 23:00:00 +01:00
+ this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience));
2019-08-09 04:34:33 +02:00
+ }
+ // CraftBukkit end
}
}
2024-04-23 17:15:00 +02:00
@@ -1279,6 +1296,11 @@
2021-11-21 23:00:00 +01:00
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
2021-06-11 07:00:00 +02:00
2021-11-21 23:00:00 +01:00
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
2021-06-11 07:00:00 +02:00
+ // CraftBukkit start - call EntityChangeBlockEvent
2023-06-24 09:15:05 +02:00
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1))) {
2021-06-11 07:00:00 +02:00
+ return;
+ }
+ // CraftBukkit end
2023-06-07 17:30:00 +02:00
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
2021-11-21 23:00:00 +01:00
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
2021-06-11 07:00:00 +02:00
2024-04-23 17:15:00 +02:00
@@ -1436,7 +1458,7 @@
2021-06-11 07:00:00 +02:00
private EntityLiving trustedLastHurt;
private int timestamp;
2024-04-23 17:15:00 +02:00
- public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate predicate) {
+ public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
2021-06-11 07:00:00 +02:00
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
}