craftbukkit/nms-patches/net/minecraft/world/entity/animal/EntityDolphin.patch

72 lines
3 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
2023-06-24 17:15:05 +10:00
@@ -61,8 +61,19 @@
import net.minecraft.world.level.pathfinder.PathMode;
import net.minecraft.world.phys.Vec3D;
2023-06-24 17:15:05 +10:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityPotionEffectEvent;
+// CraftBukkit end
+
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);
2023-06-24 17:15:05 +10:00
@@ -190,7 +201,7 @@
@Override
public int getMaxAirSupply() {
- return 4800;
+ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
}
@Override
2023-06-24 17:15:05 +10:00
@@ -231,6 +242,12 @@
2021-11-22 09:00:00 +11:00
ItemStack itemstack = entityitem.getItem();
2019-04-23 12:00:00 +10:00
2021-11-22 09:00:00 +11:00
if (this.canHoldItem(itemstack)) {
+ // CraftBukkit start - call EntityPickupItemEvent
2023-06-24 17:15:05 +10:00
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
+ return;
+ }
2023-06-24 17:15:05 +10:00
+ itemstack = entityitem.getItem(); // CraftBukkit- update ItemStack from event
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
this.onItemPickup(entityitem);
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
2022-06-08 02:00:00 +10:00
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
2023-06-24 17:15:05 +10:00
@@ -389,7 +406,7 @@
@Override
2021-11-22 09:00:00 +11:00
public boolean canUse() {
- return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100;
2023-06-08 01:30:00 +10:00
+ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level().getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
}
@Override
2023-06-24 17:15:05 +10:00
@@ -489,7 +506,7 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public void start() {
2021-06-11 15:00:00 +10:00
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
2023-06-24 17:15:05 +10:00
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
2019-04-23 12:00:00 +10:00
@Override
2023-06-24 17:15:05 +10:00
@@ -508,7 +525,7 @@
}
2023-06-08 01:30:00 +10:00
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
2021-06-11 15:00:00 +10:00
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
2023-06-24 17:15:05 +10:00
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
}