mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-25 06:56:14 +00:00
90 lines
4.7 KiB
Diff
90 lines
4.7 KiB
Diff
--- a/net/minecraft/world/entity/animal/EntityFox.java
|
|
+++ b/net/minecraft/world/entity/animal/EntityFox.java
|
|
@@ -91,6 +91,10 @@
|
|
import net.minecraft.world.level.pathfinder.PathType;
|
|
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);
|
|
@@ -503,7 +507,8 @@
|
|
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
|
ItemStack itemstack = entityitem.getItem();
|
|
|
|
- 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
|
|
int i = itemstack.getCount();
|
|
|
|
if (i > 1) {
|
|
@@ -515,7 +520,7 @@
|
|
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;
|
|
}
|
|
|
|
@@ -853,6 +858,16 @@
|
|
if (entityplayer1 != null && entityplayer != entityplayer1) {
|
|
entityfox.addTrustedUUID(entityplayer1.getUUID());
|
|
}
|
|
+ // CraftBukkit start - call EntityBreedEvent
|
|
+ entityfox.setAge(-24000);
|
|
+ entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
|
|
+ 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) {
|
|
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
|
|
@@ -863,12 +878,14 @@
|
|
this.partner.setAge(6000);
|
|
this.animal.resetLove();
|
|
this.partner.resetLove();
|
|
- 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);
|
|
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
|
- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
|
|
+ // CraftBukkit start - use event experience
|
|
+ if (experience > 0) {
|
|
+ this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -1264,6 +1281,11 @@
|
|
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
|
|
|
|
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
|
|
+ // CraftBukkit start - call EntityChangeBlockEvent
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1))) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
|
|
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
|
|
|
|
@@ -1494,7 +1516,7 @@
|
|
}
|
|
|
|
public static EntityFox.Type byName(String s) {
|
|
- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED);
|
|
+ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error
|
|
}
|
|
|
|
public static EntityFox.Type byId(int i) {
|