mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Fix stuck in portals
This commit is contained in:
committed by
granny
parent
de8dffe5f2
commit
fafdf0f8a7
@@ -42,7 +42,7 @@ index 7f136e044a243814372beef1400d3b6a148d2cbf..5e730cdde960603d5fa0fa7d1b70ec56
|
||||
public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 5b50bc97ccab73dcafa29e3a8c5d04b3c4e8c1d4..c03639557e498f44a53fbf223928f68e515638eb 100644
|
||||
index 78daeb23bb520774697c8d3d68aa4abe28a40cac..03d0df75dedd414aa54d88ed204cf82c3a4dfc88 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -842,6 +842,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -75,7 +75,7 @@ index 0c184da09628c0f2fd21e4cacd3ab6ae74f11e64..e569a1e0c282e43410ad321790114acc
|
||||
if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
|
||||
target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index f7e17ca9f5011503827f7141d62e556c1cc72fcf..25adb04858ad55dc80a2967e49b3dc0dafe44307 100644
|
||||
index 0c88c51f870030812fabbe4239bca2bb815fea92..cf3b9cbe7658d85fee387ede1c27fbd71d940631 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -3136,6 +3136,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -107,7 +107,7 @@ index f7e17ca9f5011503827f7141d62e556c1cc72fcf..25adb04858ad55dc80a2967e49b3dc0d
|
||||
if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) {
|
||||
this.passengers = ImmutableList.of();
|
||||
} else {
|
||||
@@ -5097,4 +5112,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5100,4 +5115,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return ((ServerLevel) this.level).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end - Expose entity id counter
|
||||
@@ -5040,7 +5040,7 @@ index 47c1ad2ef30d464abb3c804260f0fd7cde193ba5..c6b3894fe085c2b565651ab3ae2f1acb
|
||||
this.openTradingScreen(player, this.getDisplayName(), 1);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 7305ef5af0b13cb40b9a881a0364895395ff2072..27a0cb04dd50974a96ed420ef811d9c9f3182e52 100644
|
||||
index 6e84f57c90c0747403c4679bc920f9a9aa83594f..fa258b6a1795d18a053843e93349dbf9aadf7e77 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -218,6 +218,19 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
Entity entity = damageSource.getEntity();
|
||||
if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false.
|
||||
!(entity instanceof Player player && !this.canHarmPlayer(player))
|
||||
@@ -1446,6 +_,7 @@
|
||||
serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
// CraftBukkit end
|
||||
+ this.portalPos = io.papermc.paper.util.MCUtil.toBlockPosition(exit); // Purpur - Fix stuck in portals
|
||||
this.setServerLevel(level);
|
||||
this.connection.internalTeleport(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); // CraftBukkit - use internal teleport without event
|
||||
this.connection.resetPosition();
|
||||
@@ -2014,6 +_,26 @@
|
||||
this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||
}
|
||||
|
||||
@@ -47,15 +47,26 @@
|
||||
// CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||
// Paper start - Expand EntityUnleashEvent
|
||||
org.bukkit.event.player.PlayerUnleashEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.hasInfiniteMaterials());
|
||||
@@ -3250,7 +_,7 @@
|
||||
@@ -3247,15 +_,18 @@
|
||||
return Vec3.directionFromRotation(this.getRotationVector());
|
||||
}
|
||||
|
||||
+ public BlockPos portalPos = BlockPos.ZERO; // Purpur - Fix stuck in portals
|
||||
public void setAsInsidePortal(Portal portal, BlockPos pos) {
|
||||
if (this.isOnPortalCooldown()) {
|
||||
+ if (!(level().purpurConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(this.portalPos))) // Purpur - Fix stuck in portals
|
||||
this.setPortalCooldown();
|
||||
- } else {
|
||||
+ } else if (this.level.purpurConfig.entitiesCanUsePortals || this instanceof ServerPlayer) { // Purpur - Entities can use portals
|
||||
if (this.portalProcess == null || !this.portalProcess.isSamePortal(portal)) {
|
||||
this.portalProcess = new PortalProcessor(portal, pos.immutable());
|
||||
} else if (!this.portalProcess.isInsidePortalThisTick()) {
|
||||
this.portalProcess.updateEntryPosition(pos.immutable());
|
||||
this.portalProcess.setAsInsidePortalThisTick(true);
|
||||
+ this.portalPos = BlockPos.ZERO; // Purpur - Fix stuck in portals
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3955,7 +_,7 @@
|
||||
// CraftBukkit end
|
||||
|
||||
|
||||
@@ -319,6 +319,7 @@ public class PurpurWorldConfig {
|
||||
public int playerDeathExpDropMax = 100;
|
||||
public boolean teleportIfOutsideBorder = false;
|
||||
public boolean totemOfUndyingWorksInInventory = false;
|
||||
public boolean playerFixStuckPortal = false;
|
||||
private void playerSettings() {
|
||||
if (PurpurConfig.version < 19) {
|
||||
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
|
||||
@@ -334,6 +335,7 @@ public class PurpurWorldConfig {
|
||||
playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
|
||||
teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
|
||||
totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
|
||||
playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
|
||||
}
|
||||
|
||||
public boolean silkTouchEnabled = false;
|
||||
|
||||
Reference in New Issue
Block a user