mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
25f3b50f6b
By: md_5 <git@md-5.net>
64 lines
2.9 KiB
Diff
64 lines
2.9 KiB
Diff
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
|
|
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
|
|
@@ -63,6 +63,12 @@
|
|
|
|
public class EntityDolphin extends EntityWaterAnimal {
|
|
|
|
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
|
+ @Override
|
|
+ public int getDefaultMaxAirSupply() {
|
|
+ return TOTAL_AIR_SUPPLY;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
private static final DataWatcherObject<BlockPosition> TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS);
|
|
private static final DataWatcherObject<Boolean> GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN);
|
|
private static final DataWatcherObject<Integer> MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT);
|
|
@@ -190,7 +196,7 @@
|
|
|
|
@Override
|
|
public int getMaxAirSupply() {
|
|
- return 4800;
|
|
+ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
|
}
|
|
|
|
@Override
|
|
@@ -231,6 +237,12 @@
|
|
ItemStack itemstack = entityitem.getItem();
|
|
|
|
if (this.canHoldItem(itemstack)) {
|
|
+ // CraftBukkit start - call EntityPickupItemEvent
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ itemstack = entityitem.getItem(); // update ItemStack from event
|
|
+ // CraftBukkit end
|
|
this.onItemPickup(entityitem);
|
|
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
|
|
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
|
|
@@ -389,7 +401,7 @@
|
|
|
|
@Override
|
|
public boolean canUse() {
|
|
- return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100;
|
|
+ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
|
|
}
|
|
|
|
@Override
|
|
@@ -489,7 +501,7 @@
|
|
|
|
@Override
|
|
public void start() {
|
|
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
|
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -508,7 +520,7 @@
|
|
}
|
|
|
|
if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) {
|
|
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
|
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
|
}
|
|
|
|
}
|