mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Expand EntityUnleashEvent
This commit is contained in:
parent
1292627c18
commit
a85863338c
6 changed files with 161 additions and 108 deletions
|
@ -18,7 +18,7 @@
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.FenceGateBlock;
|
import net.minecraft.world.level.block.FenceGateBlock;
|
||||||
@@ -138,9 +138,142 @@
|
@@ -138,8 +138,141 @@
|
||||||
import net.minecraft.world.scores.ScoreHolder;
|
import net.minecraft.world.scores.ScoreHolder;
|
||||||
import net.minecraft.world.scores.Team;
|
import net.minecraft.world.scores.Team;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
|
|
||||||
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
|
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
|
||||||
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ private static final int CURRENT_LEVEL = 2;
|
+ private static final int CURRENT_LEVEL = 2;
|
||||||
+ public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first setPositionRotation
|
+ public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first setPositionRotation
|
||||||
|
@ -157,10 +157,9 @@
|
||||||
+ return Entity.TOTAL_AIR_SUPPLY;
|
+ return Entity.TOTAL_AIR_SUPPLY;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
public static final String ID_TAG = "id";
|
public static final String ID_TAG = "id";
|
||||||
public static final String PASSENGERS_TAG = "Passengers";
|
|
||||||
@@ -224,7 +357,7 @@
|
@@ -224,7 +357,7 @@
|
||||||
private static final EntityDataAccessor<Boolean> DATA_CUSTOM_NAME_VISIBLE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
|
private static final EntityDataAccessor<Boolean> DATA_CUSTOM_NAME_VISIBLE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
|
||||||
private static final EntityDataAccessor<Boolean> DATA_SILENT = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
|
private static final EntityDataAccessor<Boolean> DATA_SILENT = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN);
|
||||||
|
@ -170,7 +169,7 @@
|
||||||
private static final EntityDataAccessor<Integer> DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
|
private static final EntityDataAccessor<Integer> DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
|
||||||
private EntityInLevelCallback levelCallback;
|
private EntityInLevelCallback levelCallback;
|
||||||
private final VecDeltaCodec packetPositionCodec;
|
private final VecDeltaCodec packetPositionCodec;
|
||||||
@@ -253,7 +386,65 @@
|
@@ -253,6 +386,64 @@
|
||||||
private final List<Entity.Movement> movementThisTick;
|
private final List<Entity.Movement> movementThisTick;
|
||||||
private final Set<BlockState> blocksInside;
|
private final Set<BlockState> blocksInside;
|
||||||
private final LongSet visitedBlocks;
|
private final LongSet visitedBlocks;
|
||||||
|
@ -203,7 +202,7 @@
|
||||||
+ private org.bukkit.util.Vector origin;
|
+ private org.bukkit.util.Vector origin;
|
||||||
+ @javax.annotation.Nullable
|
+ @javax.annotation.Nullable
|
||||||
+ private UUID originWorld;
|
+ private UUID originWorld;
|
||||||
|
+
|
||||||
+ public void setOrigin(@javax.annotation.Nonnull Location location) {
|
+ public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||||
+ this.origin = location.toVector();
|
+ this.origin = location.toVector();
|
||||||
+ this.originWorld = location.getWorld().getUID();
|
+ this.originWorld = location.getWorld().getUID();
|
||||||
|
@ -232,10 +231,9 @@
|
||||||
+ return this.dimensions.makeBoundingBox(x, y, z);
|
+ return this.dimensions.makeBoundingBox(x, y, z);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
|
||||||
public Entity(EntityType<?> type, Level world) {
|
public Entity(EntityType<?> type, Level world) {
|
||||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||||
this.passengers = ImmutableList.of();
|
|
||||||
@@ -261,7 +452,7 @@
|
@@ -261,7 +452,7 @@
|
||||||
this.bb = Entity.INITIAL_AABB;
|
this.bb = Entity.INITIAL_AABB;
|
||||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||||
|
@ -485,15 +483,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -587,9 +874,25 @@
|
@@ -587,7 +874,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void igniteForSeconds(float seconds) {
|
public final void igniteForSeconds(float seconds) {
|
||||||
- this.igniteForTicks(Mth.floor(seconds * 20.0F));
|
- this.igniteForTicks(Mth.floor(seconds * 20.0F));
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ this.igniteForSeconds(seconds, true);
|
+ this.igniteForSeconds(seconds, true);
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ public final void igniteForSeconds(float f, boolean callEvent) {
|
+ public final void igniteForSeconds(float f, boolean callEvent) {
|
||||||
+ if (callEvent) {
|
+ if (callEvent) {
|
||||||
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f);
|
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f);
|
||||||
|
@ -507,11 +505,9 @@
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ this.igniteForTicks(Mth.floor(f * 20.0F));
|
+ this.igniteForTicks(Mth.floor(f * 20.0F));
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
public void igniteForTicks(int ticks) {
|
public void igniteForTicks(int ticks) {
|
||||||
if (this.remainingFireTicks < ticks) {
|
|
||||||
this.setRemainingFireTicks(ticks);
|
|
||||||
@@ -610,7 +913,7 @@
|
@@ -610,7 +913,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,12 +537,12 @@
|
||||||
+ bl = bl.getRelative(BlockFace.SOUTH);
|
+ bl = bl.getRelative(BlockFace.SOUTH);
|
||||||
+ } else if (movement.z < vec3d1.z) {
|
+ } else if (movement.z < vec3d1.z) {
|
||||||
+ bl = bl.getRelative(BlockFace.NORTH);
|
+ bl = bl.getRelative(BlockFace.NORTH);
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ if (!bl.getType().isAir()) {
|
+ if (!bl.getType().isAir()) {
|
||||||
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
|
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
|
||||||
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+ }
|
}
|
||||||
}
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
|
@ -958,20 +954,25 @@
|
||||||
world.addFreshEntity(entityitem);
|
world.addFreshEntity(entityitem);
|
||||||
return entityitem;
|
return entityitem;
|
||||||
}
|
}
|
||||||
@@ -2184,6 +2714,12 @@
|
@@ -2184,7 +2714,16 @@
|
||||||
if (this.isAlive() && this instanceof Leashable leashable) {
|
if (this.isAlive() && this instanceof Leashable leashable) {
|
||||||
if (leashable.getLeashHolder() == player) {
|
if (leashable.getLeashHolder() == player) {
|
||||||
if (!this.level().isClientSide()) {
|
if (!this.level().isClientSide()) {
|
||||||
|
- if (player.hasInfiniteMaterials()) {
|
||||||
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand).isCancelled()) {
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.hasInfiniteMaterials());
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
+ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder()));
|
+ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder()));
|
||||||
+ return InteractionResult.PASS;
|
+ return InteractionResult.PASS;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (player.hasInfiniteMaterials()) {
|
+ if (!event.isDropLeash()) { // Paper - Expand EntityUnleashEvent
|
||||||
leashable.removeLeash();
|
leashable.removeLeash();
|
||||||
} else {
|
} else {
|
||||||
@@ -2200,6 +2736,13 @@
|
leashable.dropLeash();
|
||||||
|
@@ -2200,6 +2739,13 @@
|
||||||
|
|
||||||
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
|
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
|
||||||
if (!this.level().isClientSide()) {
|
if (!this.level().isClientSide()) {
|
||||||
|
@ -985,7 +986,7 @@
|
||||||
leashable.setLeashedTo(player, true);
|
leashable.setLeashedTo(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2265,7 +2808,7 @@
|
@@ -2265,7 +2811,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showVehicleHealth() {
|
public boolean showVehicleHealth() {
|
||||||
|
@ -994,7 +995,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean startRiding(Entity entity, boolean force) {
|
public boolean startRiding(Entity entity, boolean force) {
|
||||||
@@ -2273,7 +2816,7 @@
|
@@ -2273,7 +2819,7 @@
|
||||||
return false;
|
return false;
|
||||||
} else if (!entity.couldAcceptPassenger()) {
|
} else if (!entity.couldAcceptPassenger()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1003,7 +1004,7 @@
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
|
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
|
||||||
@@ -2285,11 +2828,32 @@
|
@@ -2285,11 +2831,32 @@
|
||||||
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
|
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1037,7 +1038,7 @@
|
||||||
this.vehicle = entity;
|
this.vehicle = entity;
|
||||||
this.vehicle.addPassenger(this);
|
this.vehicle.addPassenger(this);
|
||||||
entity.getIndirectPassengersStream().filter((entity2) -> {
|
entity.getIndirectPassengersStream().filter((entity2) -> {
|
||||||
@@ -2314,19 +2878,30 @@
|
@@ -2314,19 +2881,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeVehicle() {
|
public void removeVehicle() {
|
||||||
|
@ -1070,7 +1071,7 @@
|
||||||
protected void addPassenger(Entity passenger) {
|
protected void addPassenger(Entity passenger) {
|
||||||
if (passenger.getVehicle() != this) {
|
if (passenger.getVehicle() != this) {
|
||||||
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
||||||
@@ -2349,21 +2924,53 @@
|
@@ -2349,21 +2927,53 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,7 +1131,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canAddPassenger(Entity passenger) {
|
protected boolean canAddPassenger(Entity passenger) {
|
||||||
@@ -2464,7 +3071,7 @@
|
@@ -2464,7 +3074,7 @@
|
||||||
if (teleporttransition != null) {
|
if (teleporttransition != null) {
|
||||||
ServerLevel worldserver1 = teleporttransition.newLevel();
|
ServerLevel worldserver1 = teleporttransition.newLevel();
|
||||||
|
|
||||||
|
@ -1139,7 +1140,7 @@
|
||||||
this.teleport(teleporttransition);
|
this.teleport(teleporttransition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2547,7 +3154,7 @@
|
@@ -2547,7 +3157,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrouching() {
|
public boolean isCrouching() {
|
||||||
|
@ -1148,7 +1149,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSprinting() {
|
public boolean isSprinting() {
|
||||||
@@ -2563,7 +3170,7 @@
|
@@ -2563,7 +3173,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisuallySwimming() {
|
public boolean isVisuallySwimming() {
|
||||||
|
@ -1157,7 +1158,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisuallyCrawling() {
|
public boolean isVisuallyCrawling() {
|
||||||
@@ -2571,6 +3178,13 @@
|
@@ -2571,6 +3181,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSwimming(boolean swimming) {
|
public void setSwimming(boolean swimming) {
|
||||||
|
@ -1171,7 +1172,7 @@
|
||||||
this.setSharedFlag(4, swimming);
|
this.setSharedFlag(4, swimming);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2609,6 +3223,7 @@
|
@@ -2609,6 +3226,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlayerTeam getTeam() {
|
public PlayerTeam getTeam() {
|
||||||
|
@ -1179,7 +1180,7 @@
|
||||||
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
|
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2624,8 +3239,12 @@
|
@@ -2624,8 +3242,12 @@
|
||||||
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
|
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,7 +1194,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getSharedFlag(int index) {
|
public boolean getSharedFlag(int index) {
|
||||||
@@ -2644,7 +3263,7 @@
|
@@ -2644,7 +3266,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxAirSupply() {
|
public int getMaxAirSupply() {
|
||||||
|
@ -1202,7 +1203,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAirSupply() {
|
public int getAirSupply() {
|
||||||
@@ -2652,7 +3271,18 @@
|
@@ -2652,7 +3274,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAirSupply(int air) {
|
public void setAirSupply(int air) {
|
||||||
|
@ -1222,18 +1223,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTicksFrozen() {
|
public int getTicksFrozen() {
|
||||||
@@ -2679,11 +3309,40 @@
|
@@ -2679,11 +3312,40 @@
|
||||||
|
|
||||||
public void thunderHit(ServerLevel world, LightningBolt lightning) {
|
public void thunderHit(ServerLevel world, LightningBolt lightning) {
|
||||||
this.setRemainingFireTicks(this.remainingFireTicks + 1);
|
this.setRemainingFireTicks(this.remainingFireTicks + 1);
|
||||||
|
- if (this.remainingFireTicks == 0) {
|
||||||
|
- this.igniteForSeconds(8.0F);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
||||||
+ final org.bukkit.entity.Entity stormBukkitEntity = lightning.getBukkitEntity();
|
+ final org.bukkit.entity.Entity stormBukkitEntity = lightning.getBukkitEntity();
|
||||||
+ final PluginManager pluginManager = Bukkit.getPluginManager();
|
+ final PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
if (this.remainingFireTicks == 0) {
|
+ if (this.remainingFireTicks == 0) {
|
||||||
- this.igniteForSeconds(8.0F);
|
|
||||||
+ // CraftBukkit start - Call a combust event when lightning strikes
|
+ // CraftBukkit start - Call a combust event when lightning strikes
|
||||||
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F);
|
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F);
|
||||||
+ pluginManager.callEvent(entityCombustEvent);
|
+ pluginManager.callEvent(entityCombustEvent);
|
||||||
|
@ -1265,7 +1267,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAboveBubbleCol(boolean drag) {
|
public void onAboveBubbleCol(boolean drag) {
|
||||||
@@ -2713,7 +3372,7 @@
|
@@ -2713,7 +3375,7 @@
|
||||||
this.resetFallDistance();
|
this.resetFallDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,7 +1276,7 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2818,7 +3477,7 @@
|
@@ -2818,7 +3480,7 @@
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String s = this.level() == null ? "~NULL~" : this.level().toString();
|
String s = this.level() == null ? "~NULL~" : this.level().toString();
|
||||||
|
|
||||||
|
@ -1283,7 +1285,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isInvulnerableToBase(DamageSource damageSource) {
|
public final boolean isInvulnerableToBase(DamageSource damageSource) {
|
||||||
@@ -2850,8 +3509,34 @@
|
@@ -2850,8 +3512,34 @@
|
||||||
public Entity teleport(TeleportTransition teleportTarget) {
|
public Entity teleport(TeleportTransition teleportTarget) {
|
||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
|
@ -1318,7 +1320,7 @@
|
||||||
ServerLevel worldserver1 = teleportTarget.newLevel();
|
ServerLevel worldserver1 = teleportTarget.newLevel();
|
||||||
boolean flag = worldserver1.dimension() != worldserver.dimension();
|
boolean flag = worldserver1.dimension() != worldserver.dimension();
|
||||||
|
|
||||||
@@ -2918,10 +3603,19 @@
|
@@ -2918,10 +3606,19 @@
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1339,7 +1341,7 @@
|
||||||
Iterator iterator1 = list1.iterator();
|
Iterator iterator1 = list1.iterator();
|
||||||
|
|
||||||
while (iterator1.hasNext()) {
|
while (iterator1.hasNext()) {
|
||||||
@@ -2947,7 +3641,7 @@
|
@@ -2947,7 +3644,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
|
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
|
||||||
|
@ -1348,18 +1350,27 @@
|
||||||
Iterator iterator = this.getIndirectPassengers().iterator();
|
Iterator iterator = this.getIndirectPassengers().iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -2995,8 +3689,9 @@
|
@@ -2995,22 +3692,45 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeAfterChangingDimensions() {
|
protected void removeAfterChangingDimensions() {
|
||||||
- this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
|
- this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
|
||||||
|
- if (this instanceof Leashable leashable) {
|
||||||
|
- leashable.removeLeash();
|
||||||
+ this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause
|
+ this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause
|
||||||
if (this instanceof Leashable leashable) {
|
+ if (this instanceof Leashable leashable && leashable.isLeashed()) { // Paper - only call if it is leashed
|
||||||
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
leashable.removeLeash();
|
+ final EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, false); // CraftBukkit
|
||||||
|
+ event.callEvent();
|
||||||
|
+ if (!event.isDropLeash()) {
|
||||||
|
+ leashable.removeLeash();
|
||||||
|
+ } else {
|
||||||
|
+ leashable.dropLeash();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3004,13 +3699,28 @@
|
}
|
||||||
|
|
||||||
public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) {
|
public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) {
|
||||||
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
|
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
|
||||||
|
@ -1388,7 +1399,7 @@
|
||||||
if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) {
|
if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) {
|
||||||
Iterator iterator = this.getPassengers().iterator();
|
Iterator iterator = this.getPassengers().iterator();
|
||||||
|
|
||||||
@@ -3134,10 +3844,16 @@
|
@@ -3134,9 +3854,15 @@
|
||||||
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
|
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1399,16 +1410,15 @@
|
||||||
+ public final boolean teleportTo(ServerLevel world, double destX, double destY, double destZ, Set<Relative> flags, float yaw, float pitch, boolean resetCamera) {
|
+ public final boolean teleportTo(ServerLevel world, double destX, double destY, double destZ, Set<Relative> flags, float yaw, float pitch, boolean resetCamera) {
|
||||||
+ return this.teleportTo(world, destX, destY, destZ, flags, yaw, pitch, resetCamera, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
+ return this.teleportTo(world, destX, destY, destZ, flags, yaw, pitch, resetCamera, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ public boolean teleportTo(ServerLevel worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
+ public boolean teleportTo(ServerLevel worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
||||||
+ float f2 = Mth.clamp(f1, -90.0F, 90.0F);
|
+ float f2 = Mth.clamp(f1, -90.0F, 90.0F);
|
||||||
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3(d0, d1, d2), Vec3.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
|
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3(d0, d1, d2), Vec3.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
return entity != null;
|
return entity != null;
|
||||||
}
|
}
|
||||||
|
@@ -3187,7 +3913,7 @@
|
||||||
@@ -3187,7 +3903,7 @@
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void fixupDimensions() {
|
protected void fixupDimensions() {
|
||||||
|
@ -1417,7 +1427,7 @@
|
||||||
EntityDimensions entitysize = this.getDimensions(entitypose);
|
EntityDimensions entitysize = this.getDimensions(entitypose);
|
||||||
|
|
||||||
this.dimensions = entitysize;
|
this.dimensions = entitysize;
|
||||||
@@ -3196,7 +3912,7 @@
|
@@ -3196,7 +3922,7 @@
|
||||||
|
|
||||||
public void refreshDimensions() {
|
public void refreshDimensions() {
|
||||||
EntityDimensions entitysize = this.dimensions;
|
EntityDimensions entitysize = this.dimensions;
|
||||||
|
@ -1426,7 +1436,7 @@
|
||||||
EntityDimensions entitysize1 = this.getDimensions(entitypose);
|
EntityDimensions entitysize1 = this.getDimensions(entitypose);
|
||||||
|
|
||||||
this.dimensions = entitysize1;
|
this.dimensions = entitysize1;
|
||||||
@@ -3258,10 +3974,29 @@
|
@@ -3258,10 +3984,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setBoundingBox(AABB boundingBox) {
|
public final void setBoundingBox(AABB boundingBox) {
|
||||||
|
@ -1458,7 +1468,7 @@
|
||||||
return this.getDimensions(pose).eyeHeight();
|
return this.getDimensions(pose).eyeHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3335,7 +4070,7 @@
|
@@ -3335,7 +4080,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -1467,7 +1477,7 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3435,7 +4170,7 @@
|
@@ -3435,7 +4180,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isControlledByLocalInstance() {
|
public boolean isControlledByLocalInstance() {
|
||||||
|
@ -1476,7 +1486,7 @@
|
||||||
|
|
||||||
if (entityliving instanceof Player entityhuman) {
|
if (entityliving instanceof Player entityhuman) {
|
||||||
return entityhuman.isLocalPlayer();
|
return entityhuman.isLocalPlayer();
|
||||||
@@ -3445,7 +4180,7 @@
|
@@ -3445,7 +4190,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isControlledByClient() {
|
public boolean isControlledByClient() {
|
||||||
|
@ -1485,7 +1495,7 @@
|
||||||
|
|
||||||
return entityliving != null && entityliving.isControlledByClient();
|
return entityliving != null && entityliving.isControlledByClient();
|
||||||
}
|
}
|
||||||
@@ -3463,7 +4198,7 @@
|
@@ -3463,7 +4208,7 @@
|
||||||
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
|
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1494,7 +1504,7 @@
|
||||||
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
|
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3489,8 +4224,37 @@
|
@@ -3489,8 +4234,37 @@
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1533,7 +1543,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
|
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
|
||||||
@@ -3551,6 +4315,11 @@
|
@@ -3551,6 +4325,11 @@
|
||||||
vec3d = vec3d.add(vec3d1);
|
vec3d = vec3d.add(vec3d1);
|
||||||
++k1;
|
++k1;
|
||||||
}
|
}
|
||||||
|
@ -1545,7 +1555,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3613,7 +4382,7 @@
|
@@ -3613,7 +4392,7 @@
|
||||||
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
|
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1554,7 +1564,7 @@
|
||||||
return this.type.getDimensions();
|
return this.type.getDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3713,8 +4482,40 @@
|
@@ -3713,8 +4492,40 @@
|
||||||
public double getRandomZ(double widthScale) {
|
public double getRandomZ(double widthScale) {
|
||||||
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
|
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
|
||||||
}
|
}
|
||||||
|
@ -1595,7 +1605,7 @@
|
||||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||||
this.position = new Vec3(x, y, z);
|
this.position = new Vec3(x, y, z);
|
||||||
int i = Mth.floor(x);
|
int i = Mth.floor(x);
|
||||||
@@ -3732,6 +4533,12 @@
|
@@ -3732,6 +4543,12 @@
|
||||||
this.levelCallback.onMove();
|
this.levelCallback.onMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,7 +1618,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkDespawn() {}
|
public void checkDespawn() {}
|
||||||
@@ -3818,8 +4625,16 @@
|
@@ -3818,8 +4635,16 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setRemoved(Entity.RemovalReason reason) {
|
public final void setRemoved(Entity.RemovalReason reason) {
|
||||||
|
@ -1626,7 +1636,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.removalReason.shouldDestroy()) {
|
if (this.removalReason.shouldDestroy()) {
|
||||||
@@ -3827,8 +4642,8 @@
|
@@ -3827,8 +4652,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getPassengers().forEach(Entity::stopRiding);
|
this.getPassengers().forEach(Entity::stopRiding);
|
||||||
|
@ -1637,7 +1647,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetRemoved() {
|
public void unsetRemoved() {
|
||||||
@@ -3887,7 +4702,7 @@
|
@@ -3887,7 +4712,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getKnownMovement() {
|
public Vec3 getKnownMovement() {
|
||||||
|
@ -1646,7 +1656,7 @@
|
||||||
|
|
||||||
if (entityliving instanceof Player entityhuman) {
|
if (entityliving instanceof Player entityhuman) {
|
||||||
if (this.isAlive()) {
|
if (this.isAlive()) {
|
||||||
@@ -3962,4 +4777,14 @@
|
@@ -3962,4 +4787,14 @@
|
||||||
|
|
||||||
void accept(Entity entity, double x, double y, double z);
|
void accept(Entity entity, double x, double y, double z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,17 +75,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendPacket) {
|
if (sendPacket) {
|
||||||
@@ -171,7 +184,8 @@
|
@@ -171,7 +184,11 @@
|
||||||
|
|
||||||
if (leashable_a != null && leashable_a.leashHolder != null) {
|
if (leashable_a != null && leashable_a.leashHolder != null) {
|
||||||
if (!entity.isAlive() || !leashable_a.leashHolder.isAlive()) {
|
if (!entity.isAlive() || !leashable_a.leashHolder.isAlive()) {
|
||||||
- if (world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
- if (world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(entity.getBukkitEntity(), (!entity.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
+ if (world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved) { // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
|
+ final EntityUnleashEvent event = new EntityUnleashEvent(entity.getBukkitEntity(), (!entity.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE, world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved);
|
||||||
|
+ event.callEvent();
|
||||||
|
+ if (event.isDropLeash()) { // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
((Leashable) entity).dropLeash();
|
((Leashable) entity).dropLeash();
|
||||||
} else {
|
} else {
|
||||||
((Leashable) entity).removeLeash();
|
((Leashable) entity).removeLeash();
|
||||||
@@ -187,7 +201,7 @@
|
@@ -187,7 +204,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,16 +97,26 @@
|
||||||
((Leashable) entity).leashTooFarBehaviour();
|
((Leashable) entity).leashTooFarBehaviour();
|
||||||
} else if ((double) f > 6.0D) {
|
} else if ((double) f > 6.0D) {
|
||||||
((Leashable) entity).elasticRangeLeashBehaviour(entity1, f);
|
((Leashable) entity).elasticRangeLeashBehaviour(entity1, f);
|
||||||
@@ -205,13 +219,18 @@
|
@@ -205,13 +222,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
default void leashTooFarBehaviour() {
|
default void leashTooFarBehaviour() {
|
||||||
|
- this.dropLeash();
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
+ boolean dropLeash = true; // Paper
|
||||||
+ if (this instanceof Entity entity) {
|
+ if (this instanceof Entity entity) {
|
||||||
+ entity.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(entity.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE));
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
|
+ final EntityUnleashEvent event = new EntityUnleashEvent(entity.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||||
|
+ if (!event.callEvent()) return;
|
||||||
|
+ dropLeash = event.isDropLeash();
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
this.dropLeash();
|
+ if (dropLeash) {
|
||||||
|
+ this.dropLeash();
|
||||||
|
+ } else {
|
||||||
|
+ this.removeLeash();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
default void closeRangeLeashBehaviour(Entity entity) {}
|
default void closeRangeLeashBehaviour(Entity entity) {}
|
||||||
|
@ -114,7 +127,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E entity, Entity leashHolder, float distance) {
|
private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E entity, Entity leashHolder, float distance) {
|
||||||
@@ -223,7 +242,7 @@
|
@@ -223,7 +254,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
default void setLeashedTo(Entity leashHolder, boolean sendPacket) {
|
default void setLeashedTo(Entity leashHolder, boolean sendPacket) {
|
||||||
|
@ -123,7 +136,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <E extends Entity & Leashable> void setLeashedTo(E entity, Entity leashHolder, boolean sendPacket) {
|
private static <E extends Entity & Leashable> void setLeashedTo(E entity, Entity leashHolder, boolean sendPacket) {
|
||||||
@@ -254,7 +273,7 @@
|
@@ -254,7 +285,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
default Entity getLeashHolder() {
|
default Entity getLeashHolder() {
|
||||||
|
|
|
@ -35,19 +35,21 @@
|
||||||
protected Mob(EntityType<? extends Mob> type, Level world) {
|
protected Mob(EntityType<? extends Mob> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||||
@@ -160,6 +174,12 @@
|
@@ -157,8 +171,14 @@
|
||||||
|
if (world instanceof ServerLevel) {
|
||||||
}
|
this.registerGoals();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public void setPersistenceRequired(boolean persistenceRequired) {
|
+ public void setPersistenceRequired(boolean persistenceRequired) {
|
||||||
+ this.persistenceRequired = persistenceRequired;
|
+ this.persistenceRequired = persistenceRequired;
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
protected void registerGoals() {}
|
protected void registerGoals() {}
|
||||||
|
|
||||||
public static AttributeSupplier.Builder createMobAttributes() {
|
|
||||||
@@ -264,11 +284,42 @@
|
@@ -264,11 +284,42 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -93,19 +95,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -399,6 +450,12 @@
|
@@ -397,7 +448,13 @@
|
||||||
|
@Nullable
|
||||||
|
protected SoundEvent getAmbientSound() {
|
||||||
return null;
|
return null;
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ // CraftBukkit start - Add delegate method
|
+ // CraftBukkit start - Add delegate method
|
||||||
+ public SoundEvent getAmbientSound0() {
|
+ public SoundEvent getAmbientSound0() {
|
||||||
+ return this.getAmbientSound();
|
+ return this.getAmbientSound();
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag nbt) {
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||||
super.addAdditionalSaveData(nbt);
|
|
||||||
@@ -473,13 +530,25 @@
|
@@ -473,13 +530,25 @@
|
||||||
nbt.putBoolean("NoAI", this.isNoAi());
|
nbt.putBoolean("NoAI", this.isNoAi());
|
||||||
}
|
}
|
||||||
|
@ -279,19 +282,20 @@
|
||||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||||
|
|
||||||
gameprofilerfiller.push("sensing");
|
gameprofilerfiller.push("sensing");
|
||||||
@@ -1011,6 +1117,12 @@
|
@@ -1009,7 +1115,13 @@
|
||||||
|
this.onEquipItem(slot, itemstack1, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (i.e fox)
|
+ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (i.e fox)
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
}
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
|
||||||
@Override
|
@Override
|
||||||
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {
|
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {
|
||||||
super.dropCustomDeathLoot(world, source, causedByPlayer);
|
|
||||||
@@ -1018,6 +1130,7 @@
|
@@ -1018,6 +1130,7 @@
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -356,13 +360,13 @@
|
||||||
+ conversionparams.type().convert(this, t0, conversionparams);
|
+ conversionparams.type().convert(this, t0, conversionparams);
|
||||||
+ if (!conversionparams_a.finalizeConversionOrCancel(t0)) return null; // Paper - entity zap event - return null if conversion was cancelled
|
+ if (!conversionparams_a.finalizeConversionOrCancel(t0)) return null; // Paper - entity zap event - return null if conversion was cancelled
|
||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (transformReason == null) {
|
+ if (transformReason == null) {
|
||||||
+ // Special handling for slime split and pig lightning
|
+ // Special handling for slime split and pig lightning
|
||||||
+ return t0;
|
+ return t0;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
|
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
|
@ -405,15 +409,24 @@
|
||||||
@Override
|
@Override
|
||||||
public Leashable.LeashData getLeashData() {
|
public Leashable.LeashData getLeashData() {
|
||||||
return this.leashData;
|
return this.leashData;
|
||||||
@@ -1458,6 +1612,7 @@
|
@@ -1458,7 +1612,15 @@
|
||||||
boolean flag1 = super.startRiding(entity, force);
|
boolean flag1 = super.startRiding(entity, force);
|
||||||
|
|
||||||
if (flag1 && this.isLeashed()) {
|
if (flag1 && this.isLeashed()) {
|
||||||
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
- this.dropLeash();
|
||||||
this.dropLeash();
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
|
||||||
|
+ if (!event.callEvent()) { return flag1; }
|
||||||
|
+ if (event.isDropLeash()) {
|
||||||
|
+ this.dropLeash();
|
||||||
|
+ } else {
|
||||||
|
+ this.removeLeash();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1542,7 +1697,7 @@
|
return flag1;
|
||||||
|
@@ -1542,7 +1704,7 @@
|
||||||
|
|
||||||
if (f1 > 0.0F && target instanceof LivingEntity) {
|
if (f1 > 0.0F && target instanceof LivingEntity) {
|
||||||
entityliving = (LivingEntity) target;
|
entityliving = (LivingEntity) target;
|
||||||
|
|
|
@ -12,16 +12,26 @@
|
||||||
|
|
||||||
public abstract class TamableAnimal extends Animal implements OwnableEntity {
|
public abstract class TamableAnimal extends Animal implements OwnableEntity {
|
||||||
|
|
||||||
@@ -96,7 +101,7 @@
|
@@ -96,8 +101,16 @@
|
||||||
@Override
|
@Override
|
||||||
public boolean handleLeashAtDistance(Entity leashHolder, float distance) {
|
public boolean handleLeashAtDistance(Entity leashHolder, float distance) {
|
||||||
if (this.isInSittingPose()) {
|
if (this.isInSittingPose()) {
|
||||||
- if (distance > 10.0F) {
|
- if (distance > 10.0F) {
|
||||||
|
- this.dropLeash();
|
||||||
+ if (distance > (float) this.level().paperConfig().misc.maxLeashDistance.or(Leashable.LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance
|
+ if (distance > (float) this.level().paperConfig().misc.maxLeashDistance.or(Leashable.LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance
|
||||||
this.dropLeash();
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
|
+ org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||||
|
+ if (!event.callEvent()) return false;
|
||||||
|
+ if (event.isDropLeash()) {
|
||||||
|
+ this.dropLeash();
|
||||||
|
+ } else {
|
||||||
|
+ this.removeLeash();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +300,14 @@
|
return false;
|
||||||
|
@@ -295,7 +308,14 @@
|
||||||
if (!this.canTeleportTo(new BlockPos(x, y, z))) {
|
if (!this.canTeleportTo(new BlockPos(x, y, z))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
leashable.setLeashedTo(this, true);
|
leashable.setLeashedTo(this, true);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@@ -93,18 +107,38 @@
|
@@ -93,18 +107,43 @@
|
||||||
boolean flag1 = false;
|
boolean flag1 = false;
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
|
@ -57,13 +57,18 @@
|
||||||
if (leashable1.isLeashed() && leashable1.getLeashHolder() == this) {
|
if (leashable1.isLeashed() && leashable1.getLeashHolder() == this) {
|
||||||
- leashable1.removeLeash();
|
- leashable1.removeLeash();
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
+ boolean dropLeash = !player.hasInfiniteMaterials();
|
||||||
+ if (leashable1 instanceof Entity leashed) {
|
+ if (leashable1 instanceof Entity leashed) {
|
||||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(leashed, player, hand).isCancelled()) {
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(leashed, player, hand, dropLeash);
|
||||||
|
+ dropLeash = event.isDropLeash();
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ // Paper end - Expand EntityUnleashEvent
|
||||||
+ die = false;
|
+ die = false;
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ if (player.getAbilities().instabuild){
|
+ if (!dropLeash) { // Paper - Expand EntityUnleashEvent
|
||||||
+ leashable1.removeLeash();
|
+ leashable1.removeLeash();
|
||||||
+ } else {
|
+ } else {
|
||||||
+ leashable1.dropLeash();
|
+ leashable1.dropLeash();
|
||||||
|
|
|
@ -1596,8 +1596,10 @@ public class CraftEventFactory {
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerRecipeBookSettingsChangeEvent(player.getBukkitEntity(), bukkitType, open, filter));
|
Bukkit.getPluginManager().callEvent(new PlayerRecipeBookSettingsChangeEvent(player.getBukkitEntity(), bukkitType, open, filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Entity entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand) {
|
// Paper start - Expand EntityUnleashEvent
|
||||||
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
|
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Entity entity, net.minecraft.world.entity.player.Player player, InteractionHand enumhand, boolean dropLeash) {
|
||||||
|
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), dropLeash);
|
||||||
|
// Paper end - Expand EntityUnleashEvent
|
||||||
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue