mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Improve PortalEvents
This commit is contained in:
parent
b141cd3d99
commit
18a23db6f2
@ -882,7 +882,7 @@
|
|||||||
|
|
||||||
+ Location enter = this.getBukkitEntity().getLocation();
|
+ Location enter = this.getBukkitEntity().getLocation();
|
||||||
+ 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 exit = (worldserver == null) ? null : CraftLocation.toBukkit(absolutePosition.position(), worldserver.getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
|
+ Location exit = /* (worldserver == null) ? null : // Paper - always non-null */CraftLocation.toBukkit(absolutePosition.position(), worldserver.getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
|
||||||
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleportTarget.cause());
|
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleportTarget.cause());
|
||||||
+ // Paper start - gateway-specific teleport event
|
+ // Paper start - gateway-specific teleport event
|
||||||
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
|
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
|
||||||
|
@ -269,7 +269,7 @@
|
|||||||
datawatcher_a.define(Entity.DATA_TICKS_FROZEN, 0);
|
datawatcher_a.define(Entity.DATA_TICKS_FROZEN, 0);
|
||||||
this.defineSynchedData(datawatcher_a);
|
this.defineSynchedData(datawatcher_a);
|
||||||
this.entityData = datawatcher_a.build();
|
this.entityData = datawatcher_a.build();
|
||||||
@@ -362,12 +561,18 @@
|
@@ -362,20 +561,36 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill(ServerLevel world) {
|
public void kill(ServerLevel world) {
|
||||||
@ -282,15 +282,16 @@
|
|||||||
- this.remove(Entity.RemovalReason.DISCARDED);
|
- this.remove(Entity.RemovalReason.DISCARDED);
|
||||||
+ // CraftBukkit start - add Bukkit remove cause
|
+ // CraftBukkit start - add Bukkit remove cause
|
||||||
+ this.discard(null);
|
+ this.discard(null);
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ public final void discard(EntityRemoveEvent.Cause cause) {
|
+ public final void discard(EntityRemoveEvent.Cause cause) {
|
||||||
+ this.remove(Entity.RemovalReason.DISCARDED, cause);
|
+ this.remove(Entity.RemovalReason.DISCARDED, cause);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
protected abstract void defineSynchedData(SynchedEntityData.Builder builder);
|
protected abstract void defineSynchedData(SynchedEntityData.Builder builder);
|
||||||
@@ -376,6 +581,16 @@
|
|
||||||
|
public SynchedEntityData getEntityData() {
|
||||||
return this.entityData;
|
return this.entityData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,13 +538,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFree(double offsetX, double offsetY, double offsetZ) {
|
public boolean isFree(double offsetX, double offsetY, double offsetZ) {
|
||||||
@@ -747,8 +1052,30 @@
|
@@ -750,6 +1055,28 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (movement.y != vec3d1.y) {
|
|
||||||
block.updateEntityMovementAfterFallOn(this.level(), this);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) {
|
+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) {
|
||||||
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||||
@ -557,26 +555,29 @@
|
|||||||
+ 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
|
||||||
|
+
|
||||||
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 +1460,20 @@
|
|
||||||
return SoundEvents.GENERIC_SPLASH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -1131,8 +1458,22 @@
|
||||||
|
|
||||||
|
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();
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ public SoundEvent getSwimSplashSound0() {
|
+ public SoundEvent getSwimSplashSound0() {
|
||||||
+ return this.getSwimSplashSound();
|
+ return this.getSwimSplashSound();
|
||||||
+ }
|
+ }
|
||||||
@ -968,19 +969,20 @@
|
|||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
||||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
||||||
@@ -2101,6 +2630,12 @@
|
@@ -2099,7 +2628,13 @@
|
||||||
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
|
ResourceLocation minecraftkey = EntityType.getKey(entitytypes);
|
||||||
}
|
|
||||||
|
|
||||||
|
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // CraftBukkit start - allow excluding certain data when saving
|
+ // CraftBukkit start - allow excluding certain data when saving
|
||||||
+ protected void addAdditionalSaveData(CompoundTag nbttagcompound, boolean includeAll) {
|
+ protected void addAdditionalSaveData(CompoundTag nbttagcompound, boolean includeAll) {
|
||||||
+ this.addAdditionalSaveData(nbttagcompound);
|
+ this.addAdditionalSaveData(nbttagcompound);
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
protected abstract void readAdditionalSaveData(CompoundTag nbt);
|
protected abstract void readAdditionalSaveData(CompoundTag nbt);
|
||||||
|
|
||||||
protected abstract void addAdditionalSaveData(CompoundTag nbt);
|
|
||||||
@@ -2153,9 +2688,31 @@
|
@@ -2153,9 +2688,31 @@
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@ -1472,7 +1474,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3006,11 +3772,26 @@
|
@@ -3006,11 +3772,34 @@
|
||||||
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
|
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,7 +1483,15 @@
|
|||||||
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
|
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
|
||||||
+ Location enter = bukkitEntity.getLocation();
|
+ Location enter = bukkitEntity.getLocation();
|
||||||
+
|
+
|
||||||
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, true, creationRadius);
|
+ // Paper start
|
||||||
|
+ final org.bukkit.PortalType portalType = switch (cause) {
|
||||||
|
+ case END_PORTAL -> org.bukkit.PortalType.ENDER;
|
||||||
|
+ case NETHER_PORTAL -> org.bukkit.PortalType.NETHER;
|
||||||
|
+ case END_GATEWAY -> org.bukkit.PortalType.END_GATEWAY; // not actually used yet
|
||||||
|
+ default -> org.bukkit.PortalType.CUSTOM;
|
||||||
|
+ };
|
||||||
|
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, true, creationRadius, portalType);
|
||||||
|
+ // Paper end
|
||||||
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
||||||
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) {
|
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) {
|
||||||
+ return null;
|
+ return null;
|
||||||
@ -1499,7 +1509,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 +3915,16 @@
|
@@ -3134,10 +3923,16 @@
|
||||||
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
|
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,7 +1529,7 @@
|
|||||||
return entity != null;
|
return entity != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3187,7 +3974,7 @@
|
@@ -3187,7 +3982,7 @@
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected void fixupDimensions() {
|
protected void fixupDimensions() {
|
||||||
@ -1528,7 +1538,7 @@
|
|||||||
EntityDimensions entitysize = this.getDimensions(entitypose);
|
EntityDimensions entitysize = this.getDimensions(entitypose);
|
||||||
|
|
||||||
this.dimensions = entitysize;
|
this.dimensions = entitysize;
|
||||||
@@ -3196,7 +3983,7 @@
|
@@ -3196,7 +3991,7 @@
|
||||||
|
|
||||||
public void refreshDimensions() {
|
public void refreshDimensions() {
|
||||||
EntityDimensions entitysize = this.dimensions;
|
EntityDimensions entitysize = this.dimensions;
|
||||||
@ -1537,7 +1547,7 @@
|
|||||||
EntityDimensions entitysize1 = this.getDimensions(entitypose);
|
EntityDimensions entitysize1 = this.getDimensions(entitypose);
|
||||||
|
|
||||||
this.dimensions = entitysize1;
|
this.dimensions = entitysize1;
|
||||||
@@ -3258,10 +4045,29 @@
|
@@ -3258,10 +4053,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setBoundingBox(AABB boundingBox) {
|
public final void setBoundingBox(AABB boundingBox) {
|
||||||
@ -1569,7 +1579,7 @@
|
|||||||
return this.getDimensions(pose).eyeHeight();
|
return this.getDimensions(pose).eyeHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3300,7 +4106,14 @@
|
@@ -3300,7 +4114,14 @@
|
||||||
|
|
||||||
public void startSeenByPlayer(ServerPlayer player) {}
|
public void startSeenByPlayer(ServerPlayer player) {}
|
||||||
|
|
||||||
@ -1585,7 +1595,7 @@
|
|||||||
|
|
||||||
public float rotate(Rotation rotation) {
|
public float rotate(Rotation rotation) {
|
||||||
float f = Mth.wrapDegrees(this.getYRot());
|
float f = Mth.wrapDegrees(this.getYRot());
|
||||||
@@ -3335,7 +4148,7 @@
|
@@ -3335,7 +4156,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -1594,7 +1604,7 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3373,20 +4186,34 @@
|
@@ -3373,20 +4194,34 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<Entity> getIndirectPassengersStream() {
|
private Stream<Entity> getIndirectPassengersStream() {
|
||||||
@ -1629,7 +1639,7 @@
|
|||||||
return () -> {
|
return () -> {
|
||||||
return this.getIndirectPassengersStream().iterator();
|
return this.getIndirectPassengersStream().iterator();
|
||||||
};
|
};
|
||||||
@@ -3399,6 +4226,7 @@
|
@@ -3399,6 +4234,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasExactlyOnePlayerPassenger() {
|
public boolean hasExactlyOnePlayerPassenger() {
|
||||||
@ -1637,7 +1647,7 @@
|
|||||||
return this.countPlayerPassengers() == 1;
|
return this.countPlayerPassengers() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3435,7 +4263,7 @@
|
@@ -3435,7 +4271,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isControlledByLocalInstance() {
|
public boolean isControlledByLocalInstance() {
|
||||||
@ -1646,7 +1656,7 @@
|
|||||||
|
|
||||||
if (entityliving instanceof Player entityhuman) {
|
if (entityliving instanceof Player entityhuman) {
|
||||||
return entityhuman.isLocalPlayer();
|
return entityhuman.isLocalPlayer();
|
||||||
@@ -3445,7 +4273,7 @@
|
@@ -3445,7 +4281,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isControlledByClient() {
|
public boolean isControlledByClient() {
|
||||||
@ -1655,7 +1665,7 @@
|
|||||||
|
|
||||||
return entityliving != null && entityliving.isControlledByClient();
|
return entityliving != null && entityliving.isControlledByClient();
|
||||||
}
|
}
|
||||||
@@ -3463,7 +4291,7 @@
|
@@ -3463,7 +4299,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1664,7 +1674,7 @@
|
|||||||
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
|
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3489,8 +4317,37 @@
|
@@ -3489,8 +4325,37 @@
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1703,19 +1713,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
|
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
|
||||||
@@ -3551,6 +4408,11 @@
|
@@ -3550,7 +4415,12 @@
|
||||||
|
|
||||||
vec3d = vec3d.add(vec3d1);
|
vec3d = vec3d.add(vec3d1);
|
||||||
++k1;
|
++k1;
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit start - store last lava contact location
|
+ // CraftBukkit start - store last lava contact location
|
||||||
+ if (tag == FluidTags.LAVA) {
|
+ if (tag == FluidTags.LAVA) {
|
||||||
+ this.lastLavaContact = blockposition_mutableblockposition.immutable();
|
+ this.lastLavaContact = blockposition_mutableblockposition.immutable();
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3613,7 +4475,7 @@
|
@@ -3613,7 +4483,7 @@
|
||||||
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
|
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1724,7 +1735,7 @@
|
|||||||
return this.type.getDimensions();
|
return this.type.getDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3714,7 +4576,39 @@
|
@@ -3714,7 +4584,39 @@
|
||||||
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
|
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1764,7 +1775,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 +4626,12 @@
|
@@ -3732,6 +4634,12 @@
|
||||||
this.levelCallback.onMove();
|
this.levelCallback.onMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1777,7 +1788,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkDespawn() {}
|
public void checkDespawn() {}
|
||||||
@@ -3818,8 +4718,16 @@
|
@@ -3818,8 +4726,16 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setRemoved(Entity.RemovalReason reason) {
|
public final void setRemoved(Entity.RemovalReason reason) {
|
||||||
@ -1795,7 +1806,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.removalReason.shouldDestroy()) {
|
if (this.removalReason.shouldDestroy()) {
|
||||||
@@ -3827,8 +4735,8 @@
|
@@ -3827,8 +4743,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getPassengers().forEach(Entity::stopRiding);
|
this.getPassengers().forEach(Entity::stopRiding);
|
||||||
@ -1806,7 +1817,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unsetRemoved() {
|
public void unsetRemoved() {
|
||||||
@@ -3887,7 +4795,7 @@
|
@@ -3887,7 +4803,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getKnownMovement() {
|
public Vec3 getKnownMovement() {
|
||||||
@ -1815,7 +1826,7 @@
|
|||||||
|
|
||||||
if (entityliving instanceof Player entityhuman) {
|
if (entityliving instanceof Player entityhuman) {
|
||||||
if (this.isAlive()) {
|
if (this.isAlive()) {
|
||||||
@@ -3962,4 +4870,14 @@
|
@@ -3962,4 +4878,14 @@
|
||||||
|
|
||||||
void accept(Entity entity, double x, double y, double z);
|
void accept(Entity entity, double x, double y, double z);
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,20 @@
|
|||||||
|
|
||||||
public class EndGatewayBlock extends BaseEntityBlock implements Portal {
|
public class EndGatewayBlock extends BaseEntityBlock implements Portal {
|
||||||
|
|
||||||
@@ -89,6 +92,7 @@
|
@@ -89,7 +92,12 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
||||||
if (entity.canUsePortal(false)) {
|
if (entity.canUsePortal(false)) {
|
||||||
|
+ // Paper start - call EntityPortalEnterEvent
|
||||||
|
+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.END_GATEWAY); // Paper - add portal type
|
||||||
|
+ if (!event.callEvent()) return;
|
||||||
|
+ // Paper end - call EntityPortalEnterEvent
|
||||||
BlockEntity tileentity = world.getBlockEntity(pos);
|
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||||
|
|
||||||
@@ -112,7 +116,7 @@
|
if (!world.isClientSide && tileentity instanceof TheEndGatewayBlockEntity) {
|
||||||
|
@@ -112,7 +120,7 @@
|
||||||
if (tileentity instanceof TheEndGatewayBlockEntity tileentityendgateway) {
|
if (tileentity instanceof TheEndGatewayBlockEntity tileentityendgateway) {
|
||||||
Vec3 vec3d = tileentityendgateway.getPortalPosition(world, pos);
|
Vec3 vec3d = tileentityendgateway.getPortalPosition(world, pos);
|
||||||
|
|
||||||
|
@ -24,15 +24,16 @@
|
|||||||
|
|
||||||
public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
||||||
|
|
||||||
@@ -57,10 +68,16 @@
|
@@ -57,10 +68,17 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
||||||
if (entity.canUsePortal(false)) {
|
if (entity.canUsePortal(false)) {
|
||||||
+ // CraftBukkit start - Entity in portal
|
+ // CraftBukkit start - Entity in portal
|
||||||
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.ENDER); // Paper - add portal type
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled()) return; // Paper - make cancellable
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (!world.isClientSide && world.dimension() == Level.END && entity instanceof ServerPlayer) {
|
if (!world.isClientSide && world.dimension() == Level.END && entity instanceof ServerPlayer) {
|
||||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||||
@ -41,7 +42,7 @@
|
|||||||
if (!entityplayer.seenCredits) {
|
if (!entityplayer.seenCredits) {
|
||||||
entityplayer.showEndCredits();
|
entityplayer.showEndCredits();
|
||||||
return;
|
return;
|
||||||
@@ -74,11 +91,11 @@
|
@@ -74,11 +92,11 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TeleportTransition getPortalDestination(ServerLevel world, Entity entity, BlockPos pos) {
|
public TeleportTransition getPortalDestination(ServerLevel world, Entity entity, BlockPos pos) {
|
||||||
@ -51,11 +52,11 @@
|
|||||||
|
|
||||||
if (worldserver1 == null) {
|
if (worldserver1 == null) {
|
||||||
- return null;
|
- return null;
|
||||||
+ return new TeleportTransition(PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit- always fire event in case plugins wish to change it
|
+ return null; // Paper - keep previous behavior of not firing PlayerTeleportEvent if the target world doesn't exist
|
||||||
} else {
|
} else {
|
||||||
boolean flag = resourcekey == Level.END;
|
boolean flag = resourcekey == Level.END;
|
||||||
BlockPos blockposition1 = flag ? ServerLevel.END_SPAWN_POINT : worldserver1.getSharedSpawnPos();
|
BlockPos blockposition1 = flag ? ServerLevel.END_SPAWN_POINT : worldserver1.getSharedSpawnPos();
|
||||||
@@ -87,7 +104,7 @@
|
@@ -87,7 +105,7 @@
|
||||||
Set set;
|
Set set;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@ -64,7 +65,7 @@
|
|||||||
f = Direction.WEST.toYRot();
|
f = Direction.WEST.toYRot();
|
||||||
set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT));
|
set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT));
|
||||||
if (entity instanceof ServerPlayer) {
|
if (entity instanceof ServerPlayer) {
|
||||||
@@ -99,13 +116,21 @@
|
@@ -99,13 +117,21 @@
|
||||||
if (entity instanceof ServerPlayer) {
|
if (entity instanceof ServerPlayer) {
|
||||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||||
|
|
||||||
|
@ -44,20 +44,21 @@
|
|||||||
Entity entity1 = entity.getVehicle();
|
Entity entity1 = entity.getVehicle();
|
||||||
|
|
||||||
if (entity1 != null) {
|
if (entity1 != null) {
|
||||||
@@ -103,7 +115,12 @@
|
@@ -103,7 +115,13 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
||||||
if (entity.canUsePortal(false)) {
|
if (entity.canUsePortal(false)) {
|
||||||
+ // CraftBukkit start - Entity in portal
|
+ // CraftBukkit start - Entity in portal
|
||||||
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.NETHER); // Paper - add portal type
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled()) return; // Paper - make cancellable
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
entity.setAsInsidePortal(this, pos);
|
entity.setAsInsidePortal(this, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,51 +138,80 @@
|
@@ -121,51 +139,80 @@
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TeleportTransition getPortalDestination(ServerLevel world, Entity entity, BlockPos pos) {
|
public TeleportTransition getPortalDestination(ServerLevel world, Entity entity, BlockPos pos) {
|
||||||
@ -76,7 +77,7 @@
|
|||||||
|
|
||||||
if (worldserver1 == null) {
|
if (worldserver1 == null) {
|
||||||
- return null;
|
- return null;
|
||||||
+ return new TeleportTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it
|
+ return null; // Paper - keep previous behavior of not firing PlayerTeleportEvent if the target world doesn't exist
|
||||||
} else {
|
} else {
|
||||||
- boolean flag = worldserver1.dimension() == Level.NETHER;
|
- boolean flag = worldserver1.dimension() == Level.NETHER;
|
||||||
+ boolean flag = worldserver1.getTypeKey() == LevelStem.NETHER;
|
+ boolean flag = worldserver1.getTypeKey() == LevelStem.NETHER;
|
||||||
@ -151,7 +152,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static TeleportTransition getDimensionTransitionFromExit(Entity entity, BlockPos pos, BlockUtil.FoundRectangle exitPortalRectangle, ServerLevel world, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
private static TeleportTransition getDimensionTransitionFromExit(Entity entity, BlockPos pos, BlockUtil.FoundRectangle exitPortalRectangle, ServerLevel world, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||||
@@ -203,7 +249,7 @@
|
@@ -203,7 +250,7 @@
|
||||||
Vec3 vec3d1 = new Vec3((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2));
|
Vec3 vec3d1 = new Vec3((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2));
|
||||||
Vec3 vec3d2 = PortalShape.findCollisionFreePosition(vec3d1, world, entity, entitysize);
|
Vec3 vec3d2 = PortalShape.findCollisionFreePosition(vec3d1, world, entity, entitysize);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user