Add EntityTeleportEndGatewayEvent

This commit is contained in:
Shane Freeder
2018-06-09 14:08:39 +02:00
parent 0efee74644
commit d6d2d75fe6

View File

@@ -200,12 +200,12 @@
+ 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();
+ } + }
+
+ @javax.annotation.Nullable + @javax.annotation.Nullable
+ public org.bukkit.util.Vector getOriginVector() { + public org.bukkit.util.Vector getOriginVector() {
+ return this.origin != null ? this.origin.clone() : null; + return this.origin != null ? this.origin.clone() : null;
@@ -289,7 +289,7 @@
public SynchedEntityData getEntityData() { public SynchedEntityData getEntityData() {
return this.entityData; return this.entityData;
+ } }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ public void refreshEntityData(ServerPlayer to) { + public void refreshEntityData(ServerPlayer to) {
@@ -298,7 +298,7 @@
+ if (list != null) { + if (list != null) {
+ to.connection.send(new ClientboundSetEntityDataPacket(this.getId(), list)); + to.connection.send(new ClientboundSetEntityDataPacket(this.getId(), list));
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
public boolean equals(Object object) { public boolean equals(Object object) {
@@ -470,15 +470,15 @@
} }
} }
@@ -587,7 +871,23 @@ @@ -587,9 +871,25 @@
} }
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);
@@ -492,9 +492,11 @@
+ } + }
+ // 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 +910,7 @@ @@ -610,7 +910,7 @@
} }
@@ -533,10 +535,12 @@
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission(); Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1133,6 +1455,20 @@ @@ -1131,7 +1453,21 @@
return SoundEvents.GENERIC_SPLASH;
}
protected SoundEvent getSwimHighSpeedSplashSound() {
return SoundEvents.GENERIC_SPLASH;
+ }
+
+ // CraftBukkit start - Add delegate methods + // CraftBukkit start - Add delegate methods
+ public SoundEvent getSwimSound0() { + public SoundEvent getSwimSound0() {
+ return this.getSwimSound(); + return this.getSwimSound();
@@ -544,16 +548,15 @@
+ +
+ public SoundEvent getSwimSplashSound0() { + public SoundEvent getSwimSplashSound0() {
+ return this.getSwimSplashSound(); + return this.getSwimSplashSound();
+ } }
+ +
+ public SoundEvent getSwimHighSpeedSplashSound0() { + public SoundEvent getSwimHighSpeedSplashSound0() {
+ return this.getSwimHighSpeedSplashSound(); + return this.getSwimHighSpeedSplashSound();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) { public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) {
this.movementThisTick.add(new Entity.Movement(oldPos, newPos)); this.movementThisTick.add(new Entity.Movement(oldPos, newPos));
}
@@ -1609,6 +1945,7 @@ @@ -1609,6 +1945,7 @@
this.yo = y; this.yo = y;
this.zo = d4; this.zo = d4;
@@ -772,11 +775,10 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved");
@@ -2079,7 +2490,67 @@ @@ -2080,6 +2491,66 @@
}
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
+ } }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ // Spigot start + // Spigot start
@@ -832,7 +834,7 @@
+ } + }
+ this.originWorld = originWorld; + this.originWorld = originWorld;
+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2)); + origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
} + }
+ +
+ spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status + spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
+ // Paper end + // Paper end
@@ -1165,15 +1167,23 @@
return true; return true;
} }
@@ -2852,6 +3457,18 @@ @@ -2852,6 +3457,26 @@
if (world instanceof ServerLevel worldserver) { if (world instanceof ServerLevel worldserver) {
if (!this.isRemoved()) { if (!this.isRemoved()) {
+ // CraftBukkit start + // CraftBukkit start
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); + PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTarget), teleportTarget.relatives());
+ Location to = CraftLocation.toBukkit(absolutePosition.position(), teleportTarget.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + Location to = CraftLocation.toBukkit(absolutePosition.position(), teleportTarget.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
+ EntityTeleportEvent teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to); + // Paper start - gateway-specific teleport event
+ if (teleEvent.isCancelled()) { + final EntityTeleportEvent teleEvent;
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level.getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
+ teleEvent = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(to.getWorld(), theEndGatewayBlockEntity));
+ teleEvent.callEvent();
+ } else {
+ teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to);
+ }
+ // Paper end - gateway-specific teleport event
+ if (teleEvent.isCancelled() || teleEvent.getTo() == null) {
+ return null; + return null;
+ } + }
+ if (!to.equals(teleEvent.getTo())) { + if (!to.equals(teleEvent.getTo())) {
@@ -1184,7 +1194,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel(); ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension(); boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2920,8 +3537,12 @@ @@ -2920,8 +3545,12 @@
} else { } else {
entity.restoreFrom(this); entity.restoreFrom(this);
this.removeAfterChangingDimensions(); this.removeAfterChangingDimensions();
@@ -1198,7 +1208,7 @@
Iterator iterator1 = list1.iterator(); Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -2947,7 +3568,7 @@ @@ -2947,7 +3576,7 @@
} }
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@@ -1207,7 +1217,7 @@
Iterator iterator = this.getIndirectPassengers().iterator(); Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -2995,8 +3616,9 @@ @@ -2995,8 +3624,9 @@
} }
protected void removeAfterChangingDimensions() { protected void removeAfterChangingDimensions() {
@@ -1218,10 +1228,12 @@
leashable.removeLeash(); leashable.removeLeash();
} }
@@ -3006,6 +3628,20 @@ @@ -3004,7 +3634,21 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
}
public Vec3 getRelativePortalPosition(Direction.Axis portalAxis, BlockUtil.FoundRectangle portalRect) {
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
+ }
+
+ // CraftBukkit start + // CraftBukkit start
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
@@ -1233,13 +1245,12 @@
+ return null; + return null;
+ } + }
+ return new CraftPortalEvent(event); + return new CraftPortalEvent(event);
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
public boolean canUsePortal(boolean allowVehicles) { public boolean canUsePortal(boolean allowVehicles) {
return (allowVehicles || !this.isPassenger()) && this.isAlive(); return (allowVehicles || !this.isPassenger()) && this.isAlive();
} @@ -3134,9 +3778,15 @@
@@ -3134,9 +3770,15 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
} }
@@ -1258,7 +1269,7 @@
return entity != null; return entity != null;
} }
@@ -3187,7 +3829,7 @@ @@ -3187,7 +3837,7 @@
/** @deprecated */ /** @deprecated */
@Deprecated @Deprecated
protected void fixupDimensions() { protected void fixupDimensions() {
@@ -1267,7 +1278,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose); EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize; this.dimensions = entitysize;
@@ -3196,7 +3838,7 @@ @@ -3196,7 +3846,7 @@
public void refreshDimensions() { public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions; EntityDimensions entitysize = this.dimensions;
@@ -1276,7 +1287,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose); EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1; this.dimensions = entitysize1;
@@ -3258,10 +3900,29 @@ @@ -3258,10 +3908,29 @@
} }
public final void setBoundingBox(AABB boundingBox) { public final void setBoundingBox(AABB boundingBox) {
@@ -1308,7 +1319,7 @@
return this.getDimensions(pose).eyeHeight(); return this.getDimensions(pose).eyeHeight();
} }
@@ -3335,7 +3996,7 @@ @@ -3335,7 +4004,7 @@
} }
@Nullable @Nullable
@@ -1317,7 +1328,7 @@
return null; return null;
} }
@@ -3435,7 +4096,7 @@ @@ -3435,7 +4104,7 @@
} }
public boolean isControlledByLocalInstance() { public boolean isControlledByLocalInstance() {
@@ -1326,7 +1337,7 @@
if (entityliving instanceof Player entityhuman) { if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer(); return entityhuman.isLocalPlayer();
@@ -3445,7 +4106,7 @@ @@ -3445,7 +4114,7 @@
} }
public boolean isControlledByClient() { public boolean isControlledByClient() {
@@ -1335,7 +1346,7 @@
return entityliving != null && entityliving.isControlledByClient(); return entityliving != null && entityliving.isControlledByClient();
} }
@@ -3463,7 +4124,7 @@ @@ -3463,7 +4132,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);
} }
@@ -1344,10 +1355,11 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
} }
@@ -3489,8 +4150,37 @@ @@ -3488,9 +4157,38 @@
public int getFireImmuneTicks() {
return 1; return 1;
} }
+
+ // CraftBukkit start + // CraftBukkit start
+ private final CommandSource commandSource = new CommandSource() { + private final CommandSource commandSource = new CommandSource() {
+ +
@@ -1376,14 +1388,14 @@
+ } + }
+ }; + };
+ // CraftBukkit end + // CraftBukkit end
+
public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel world) { public CommandSourceStack createCommandSourceStackForNameResolution(ServerLevel world) {
- return new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this); - return new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this);
+ return new CommandSourceStack(this.commandSource, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this); // CraftBukkit + return new CommandSourceStack(this.commandSource, this.position(), this.getRotationVector(), world, 0, this.getName().getString(), this.getDisplayName(), world.getServer(), this); // CraftBukkit
} }
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3550,7 +4240,12 @@ @@ -3550,7 +4248,12 @@
vec3d = vec3d.add(vec3d1); vec3d = vec3d.add(vec3d1);
++k1; ++k1;
@@ -1396,7 +1408,7 @@
} }
} }
} }
@@ -3613,7 +4308,7 @@ @@ -3613,7 +4316,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry); return new ClientboundAddEntityPacket(this, entityTrackerEntry);
} }
@@ -1405,7 +1417,7 @@
return this.type.getDimensions(); return this.type.getDimensions();
} }
@@ -3818,8 +4513,16 @@ @@ -3818,8 +4521,16 @@
@Override @Override
public final void setRemoved(Entity.RemovalReason reason) { public final void setRemoved(Entity.RemovalReason reason) {
@@ -1423,7 +1435,7 @@
} }
if (this.removalReason.shouldDestroy()) { if (this.removalReason.shouldDestroy()) {
@@ -3827,8 +4530,8 @@ @@ -3827,8 +4538,8 @@
} }
this.getPassengers().forEach(Entity::stopRiding); this.getPassengers().forEach(Entity::stopRiding);
@@ -1434,7 +1446,7 @@
} }
public void unsetRemoved() { public void unsetRemoved() {
@@ -3887,7 +4590,7 @@ @@ -3887,7 +4598,7 @@
} }
public Vec3 getKnownMovement() { public Vec3 getKnownMovement() {