ServerPlayer, ServerLevel, ServerEntity

net/minecraft/world/entity/vehicle/

Nothing much to note, reworked the loot table inventory serialization a bit

net/minecraft/world/level/

net/minecraft/world/entity/player
This commit is contained in:
Owen1212055
2025-05-29 20:18:30 -04:00
parent 62c4dda5f4
commit 4a82168542
14 changed files with 517 additions and 605 deletions

View File

@@ -1,154 +0,0 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/BaseSpawner.java b/net/minecraft/world/level/BaseSpawner.java
index 8431477838095d7ff9289ad2f00f1dd32df31246..650ebce14d618076cec2066d134d2ae51a87076a 100644
--- a/net/minecraft/world/level/BaseSpawner.java
+++ b/net/minecraft/world/level/BaseSpawner.java
@@ -46,13 +46,15 @@ public abstract class BaseSpawner {
public int maxNearbyEntities = 6;
public int requiredPlayerRange = 16;
public int spawnRange = 4;
+ private int tickDelay = 0; // Paper - Configurable mob spawner tick rate
public void setEntityId(EntityType<?> type, @Nullable Level level, RandomSource random, BlockPos pos) {
this.getOrCreateNextSpawnData(level, random, pos).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(type).toString());
+ this.spawnPotentials = WeightedList.of(); // CraftBukkit - SPIGOT-3496, MC-92282
}
public boolean isNearPlayer(Level level, BlockPos pos) {
- return level.hasNearbyAlivePlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, this.requiredPlayerRange);
+ return level.hasNearbyAlivePlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, this.requiredPlayerRange); // Paper - Affects Spawning API
}
public void clientTick(Level level, BlockPos pos) {
@@ -75,13 +77,19 @@ public abstract class BaseSpawner {
}
public void serverTick(ServerLevel serverLevel, BlockPos pos) {
+ if (spawnCount <= 0 || maxNearbyEntities <= 0) return; // Paper - Ignore impossible spawn tick
+ // Paper start - Configurable mob spawner tick rate
+ if (spawnDelay > 0 && --tickDelay > 0) return;
+ tickDelay = serverLevel.paperConfig().tickRates.mobSpawner;
+ if (tickDelay == -1) { return; } // If disabled
+ // Paper end - Configurable mob spawner tick rate
if (this.isNearPlayer(serverLevel, pos)) {
- if (this.spawnDelay == -1) {
+ if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate
this.delay(serverLevel, pos);
}
if (this.spawnDelay > 0) {
- this.spawnDelay--;
+ this.spawnDelay -= tickDelay; // Paper - Configurable mob spawner tick rate
} else {
boolean flag = false;
RandomSource random = serverLevel.getRandom();
@@ -118,6 +126,21 @@ public abstract class BaseSpawner {
continue;
}
+ // Paper start - PreCreatureSpawnEvent
+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent(
+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(vec3, serverLevel.getWorld()),
+ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(optional.get()),
+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, serverLevel)
+ );
+ if (!event.callEvent()) {
+ flag = true;
+ if (event.shouldAbortSpawn()) {
+ break;
+ }
+ continue;
+ }
+ // Paper end - PreCreatureSpawnEvent
+
Entity entity = EntityType.loadEntityRecursive(entityToSpawn, serverLevel, EntitySpawnReason.SPAWNER, entity1 -> {
entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot());
return entity1;
@@ -138,6 +161,7 @@ public abstract class BaseSpawner {
return;
}
+ entity.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; preserve entity motion from tag
entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), random.nextFloat() * 360.0F, 0.0F);
if (entity instanceof Mob mob) {
if (nextSpawnData.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(serverLevel, EntitySpawnReason.SPAWNER)
@@ -152,9 +176,22 @@ public abstract class BaseSpawner {
}
nextSpawnData.getEquipment().ifPresent(mob::equip);
+ // Spigot start
+ if (mob.level().spigotConfig.nerfSpawnerMobs) {
+ mob.aware = false;
+ }
+ // Spigot end
}
- if (!serverLevel.tryAddFreshEntityWithPassengers(entity)) {
+ entity.spawnedViaMobSpawner = true; // Paper
+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; // Paper - Entity#getEntitySpawnReason
+ flag = true; // Paper
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
+ continue;
+ }
+ if (!serverLevel.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) {
+ // CraftBukkit end
this.delay(serverLevel, pos);
return;
}
@@ -165,7 +202,7 @@ public abstract class BaseSpawner {
((Mob)entity).spawnAnim();
}
- flag = true;
+ //flag = true; // Paper - moved up above cancellable event
}
}
@@ -189,12 +226,14 @@ public abstract class BaseSpawner {
}
public void load(@Nullable Level level, BlockPos pos, CompoundTag tag) {
- this.spawnDelay = tag.getShortOr("Delay", (short)20);
+ this.spawnDelay = tag.getIntOr("Paper.Delay", tag.getShortOr("Delay", (short) 20)); // Paper - use int if set
tag.read("SpawnData", SpawnData.CODEC).ifPresent(spawnData -> this.setNextSpawnData(level, pos, spawnData));
this.spawnPotentials = tag.read("SpawnPotentials", SpawnData.LIST_CODEC)
- .orElseGet(() -> WeightedList.of(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData()));
- this.minSpawnDelay = tag.getIntOr("MinSpawnDelay", 200);
- this.maxSpawnDelay = tag.getIntOr("MaxSpawnDelay", 800);
+ .orElseGet(() -> WeightedList.of(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData()));
+ // Paper start - use int if set
+ this.minSpawnDelay = tag.getIntOr("Paper.MinSpawnDelay", tag.getIntOr("MinSpawnDelay", 200));
+ this.maxSpawnDelay = tag.getIntOr("Paper.MaxSpawnDelay", tag.getIntOr("MaxSpawnDelay", 800));
+ // Paper end - use int if set
this.spawnCount = tag.getIntOr("SpawnCount", 4);
this.maxNearbyEntities = tag.getIntOr("MaxNearbyEntities", 6);
this.requiredPlayerRange = tag.getIntOr("RequiredPlayerRange", 16);
@@ -203,9 +242,19 @@ public abstract class BaseSpawner {
}
public CompoundTag save(CompoundTag tag) {
- tag.putShort("Delay", (short)this.spawnDelay);
- tag.putShort("MinSpawnDelay", (short)this.minSpawnDelay);
- tag.putShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
+ // Paper start
+ if (this.spawnDelay > Short.MAX_VALUE) {
+ tag.putInt("Paper.Delay", this.spawnDelay);
+ }
+ tag.putShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
+
+ if (this.minSpawnDelay > Short.MAX_VALUE || this.maxSpawnDelay > Short.MAX_VALUE) {
+ tag.putInt("Paper.MinSpawnDelay", this.minSpawnDelay);
+ tag.putInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
+ }
+ tag.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
+ tag.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
+ // Paper end
tag.putShort("SpawnCount", (short)this.spawnCount);
tag.putShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
tag.putShort("RequiredPlayerRange", (short)this.requiredPlayerRange);

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5ca2673620 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java --- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -63,10 +63,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -63,10 +_,10 @@
static final Logger LOGGER = LogUtils.getLogger(); static final Logger LOGGER = LogUtils.getLogger();
private static final int CONVERSION_RETRY_DELAY_MS = 5000; private static final int CONVERSION_RETRY_DELAY_MS = 5000;
private static final int CONVERSION_RETRIES = 2; private static final int CONVERSION_RETRIES = 2;
@@ -21,7 +13,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
@Nullable @Nullable
private RconThread rconThread; private RconThread rconThread;
public DedicatedServerSettings settings; public DedicatedServerSettings settings;
@@ -81,6 +81,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -81,6 +_,7 @@
public ServerLinks serverLinks; public ServerLinks serverLinks;
public DedicatedServer( public DedicatedServer(
@@ -29,7 +21,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
Thread serverThread, Thread serverThread,
LevelStorageSource.LevelStorageAccess storageSource, LevelStorageSource.LevelStorageAccess storageSource,
PackRepository packRepository, PackRepository packRepository,
@@ -90,9 +91,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -90,9 +_,9 @@
Services services, Services services,
ChunkProgressListenerFactory progressListenerFactory ChunkProgressListenerFactory progressListenerFactory
) { ) {
@@ -41,7 +33,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties());
this.serverLinks = createServerLinks(settings); this.serverLinks = createServerLinks(settings);
} }
@@ -102,6 +103,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -102,6 +_,10 @@
Thread thread = new Thread("Server console handler") { Thread thread = new Thread("Server console handler") {
@Override @Override
public void run() { public void run() {
@@ -52,7 +44,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
String string1; String string1;
@@ -111,17 +116,41 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -111,17 +_,41 @@
} }
} catch (IOException var4) { } catch (IOException var4) {
DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4);
@@ -78,7 +70,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
- thread.start(); - thread.start();
+ // thread.start(); // Paper - Enhance console tab completions for brigadier commands; moved down + // thread.start(); // Paper - Enhance console tab completions for brigadier commands; moved down
LOGGER.info("Starting minecraft server version {}", SharedConstants.getCurrentVersion().getName()); LOGGER.info("Starting minecraft server version {}", SharedConstants.getCurrentVersion().name());
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
} }
@@ -96,7 +88,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
LOGGER.info("Loading properties"); LOGGER.info("Loading properties");
DedicatedServerProperties properties = this.settings.getProperties(); DedicatedServerProperties properties = this.settings.getProperties();
if (this.isSingleplayer()) { if (this.isSingleplayer()) {
@@ -132,13 +161,51 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -132,13 +_,51 @@
this.setLocalIp(properties.serverIp); this.setLocalIp(properties.serverIp);
} }
@@ -149,7 +141,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
InetAddress inetAddress = null; InetAddress inetAddress = null;
if (!this.getLocalIp().isEmpty()) { if (!this.getLocalIp().isEmpty()) {
inetAddress = InetAddress.getByName(this.getLocalIp()); inetAddress = InetAddress.getByName(this.getLocalIp());
@@ -147,36 +214,61 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -147,36 +_,61 @@
if (this.getPort() < 0) { if (this.getPort() < 0) {
this.setPort(properties.serverPort); this.setPort(properties.serverPort);
} }
@@ -216,7 +208,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList()); this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
this.tickTimeLogger = new RemoteSampleLogger( this.tickTimeLogger = new RemoteSampleLogger(
TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME
@@ -185,12 +277,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -185,12 +_,12 @@
SkullBlockEntity.setup(this.services, this); SkullBlockEntity.setup(this.services, this);
GameProfileCache.setUsesAuthentication(this.usesAuthentication()); GameProfileCache.setUsesAuthentication(this.usesAuthentication());
LOGGER.info("Preparing level \"{}\"", this.getLevelIdName()); LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
@@ -232,7 +224,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
if (properties.enableQuery) { if (properties.enableQuery) {
@@ -203,7 +295,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -203,7 +_,7 @@
this.rconThread = RconThread.create(this); this.rconThread = RconThread.create(this);
} }
@@ -241,7 +233,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
Thread thread1 = new Thread(new ServerWatchdog(this)); Thread thread1 = new Thread(new ServerWatchdog(this));
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER)); thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER));
thread1.setName("Server Watchdog"); thread1.setName("Server Watchdog");
@@ -220,6 +312,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -220,6 +_,12 @@
} }
} }
@@ -254,7 +246,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
@Override @Override
public boolean isSpawningMonsters() { public boolean isSpawningMonsters() {
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters(); return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
@@ -232,7 +330,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -232,7 +_,7 @@
@Override @Override
public void forceDifficulty() { public void forceDifficulty() {
@@ -263,7 +255,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
@Override @Override
@@ -271,12 +369,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -271,12 +_,15 @@
} }
if (this.rconThread != null) { if (this.rconThread != null) {
@@ -281,7 +273,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
@Override @Override
@@ -291,13 +392,23 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -291,13 +_,23 @@
} }
public void handleConsoleInput(String msg, CommandSourceStack source) { public void handleConsoleInput(String msg, CommandSourceStack source) {
@@ -309,7 +301,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
} }
@@ -430,7 +541,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -430,7 +_,11 @@
@Override @Override
public boolean enforceSecureProfile() { public boolean enforceSecureProfile() {
DedicatedServerProperties properties = this.getProperties(); DedicatedServerProperties properties = this.getProperties();
@@ -322,7 +314,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
@Override @Override
@@ -515,14 +630,54 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -515,14 +_,54 @@
@Override @Override
public String getPluginNames() { public String getPluginNames() {
@@ -381,7 +373,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
} }
public void storeUsingWhiteList(boolean isStoreUsingWhiteList) { public void storeUsingWhiteList(boolean isStoreUsingWhiteList) {
@@ -532,7 +687,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -532,7 +_,7 @@
@Override @Override
public void stopServer() { public void stopServer() {
super.stopServer(); super.stopServer();
@@ -390,7 +382,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
SkullBlockEntity.clear(); SkullBlockEntity.clear();
} }
@@ -626,4 +781,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -626,4 +_,15 @@
} }
} }
} }

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268ddb81fcc6 100644
--- a/net/minecraft/server/level/ServerEntity.java --- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java
@@ -69,11 +69,12 @@ public class ServerEntity { @@ -69,11 +_,12 @@
private Vec3 lastSentMovement; private Vec3 lastSentMovement;
private int tickCount; private int tickCount;
private int teleportDelay; private int teleportDelay;
@@ -22,7 +14,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
public ServerEntity( public ServerEntity(
ServerLevel level, ServerLevel level,
@@ -81,8 +82,12 @@ public class ServerEntity { @@ -81,8 +_,12 @@
int updateInterval, int updateInterval,
boolean trackDelta, boolean trackDelta,
Consumer<Packet<?>> broadcast, Consumer<Packet<?>> broadcast,
@@ -36,7 +28,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
this.level = level; this.level = level;
this.broadcast = broadcast; this.broadcast = broadcast;
this.entity = entity; this.entity = entity;
@@ -103,16 +108,22 @@ public class ServerEntity { @@ -103,16 +_,22 @@
if (!passengers.equals(this.lastPassengers)) { if (!passengers.equals(this.lastPassengers)) {
List<UUID> list = this.mountedOrDismounted(passengers).map(Entity::getUUID).toList(); List<UUID> list = this.mountedOrDismounted(passengers).map(Entity::getUUID).toList();
this.broadcastWithIgnore.accept(new ClientboundSetPassengersPacket(this.entity), list); this.broadcastWithIgnore.accept(new ClientboundSetPassengersPacket(this.entity), list);
@@ -63,7 +55,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
savedData.tickCarriedBy(serverPlayer, item); savedData.tickCarriedBy(serverPlayer, item);
Packet<?> updatePacket = savedData.getUpdatePacket(mapId, serverPlayer); Packet<?> updatePacket = savedData.getUpdatePacket(mapId, serverPlayer);
if (updatePacket != null) { if (updatePacket != null) {
@@ -145,7 +156,13 @@ public class ServerEntity { @@ -145,7 +_,13 @@
} else { } else {
this.teleportDelay++; this.teleportDelay++;
Vec3 vec3 = this.entity.trackingPosition(); Vec3 vec3 = this.entity.trackingPosition();
@@ -78,7 +70,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
Packet<?> packet = null; Packet<?> packet = null;
boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag2 = flag1 || this.tickCount % 60 == 0;
boolean flag3 = false; boolean flag3 = false;
@@ -223,6 +240,25 @@ public class ServerEntity { @@ -227,6 +_,25 @@
this.tickCount++; this.tickCount++;
if (this.entity.hurtMarked) { if (this.entity.hurtMarked) {
@@ -104,7 +96,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
this.entity.hurtMarked = false; this.entity.hurtMarked = false;
this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity)); this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity));
} }
@@ -280,7 +316,10 @@ public class ServerEntity { @@ -284,7 +_,10 @@
public void sendPairingData(ServerPlayer player, Consumer<Packet<ClientGamePacketListener>> consumer) { public void sendPairingData(ServerPlayer player, Consumer<Packet<ClientGamePacketListener>> consumer) {
if (this.entity.isRemoved()) { if (this.entity.isRemoved()) {
@@ -116,11 +108,10 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
} }
Packet<ClientGamePacketListener> addEntityPacket = this.entity.getAddEntityPacket(this); Packet<ClientGamePacketListener> addEntityPacket = this.entity.getAddEntityPacket(this);
@@ -292,6 +331,12 @@ public class ServerEntity { @@ -295,6 +_,11 @@
boolean flag = this.trackDelta;
if (this.entity instanceof LivingEntity) { if (this.entity instanceof LivingEntity livingEntity) {
Collection<AttributeInstance> syncableAttributes = ((LivingEntity)this.entity).getAttributes().getSyncableAttributes(); Collection<AttributeInstance> syncableAttributes = livingEntity.getAttributes().getSyncableAttributes();
+
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
+ if (this.entity.getId() == player.getId()) { + if (this.entity.getId() == player.getId()) {
+ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(syncableAttributes, false); + ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(syncableAttributes, false);
@@ -129,7 +120,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
if (!syncableAttributes.isEmpty()) { if (!syncableAttributes.isEmpty()) {
consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes)); consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes));
} }
@@ -316,8 +361,9 @@ public class ServerEntity { @@ -311,8 +_,9 @@
} }
if (!list.isEmpty()) { if (!list.isEmpty()) {
@@ -140,7 +131,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
} }
if (!this.entity.getPassengers().isEmpty()) { if (!this.entity.getPassengers().isEmpty()) {
@@ -364,6 +410,11 @@ public class ServerEntity { @@ -359,6 +_,11 @@
if (this.entity instanceof LivingEntity) { if (this.entity instanceof LivingEntity) {
Set<AttributeInstance> attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); Set<AttributeInstance> attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync();
if (!attributesToSync.isEmpty()) { if (!attributesToSync.isEmpty()) {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb47288cf3feba 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -178,7 +178,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -180,7 +_,7 @@
final List<ServerPlayer> players = Lists.newArrayList(); final List<ServerPlayer> players = Lists.newArrayList();
public final ServerChunkCache chunkSource; public final ServerChunkCache chunkSource;
private final MinecraftServer server; private final MinecraftServer server;
@@ -16,8 +8,8 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
+ public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type + public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
private int lastSpawnChunkRadius; private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList(); final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager; private final ServerWaypointManager waypointManager;
@@ -205,11 +205,131 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -208,11 +_,131 @@
private final boolean tickTime; private final boolean tickTime;
private final RandomSequences randomSequences; private final RandomSequences randomSequences;
@@ -150,7 +142,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
ResourceKey<Level> dimension, ResourceKey<Level> dimension,
LevelStem levelStem, LevelStem levelStem,
ChunkProgressListener progressListener, ChunkProgressListener progressListener,
@@ -217,14 +337,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -220,14 +_,38 @@
long biomeZoomSeed, long biomeZoomSeed,
List<CustomSpawner> customSpawners, List<CustomSpawner> customSpawners,
boolean tickTime, boolean tickTime,
@@ -191,7 +183,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
boolean flag = server.forceSynchronousWrites(); boolean flag = server.forceSynchronousWrites();
DataFixer fixerUpper = server.getFixerUpper(); DataFixer fixerUpper = server.getFixerUpper();
EntityPersistentStorage<Entity> entityPersistentStorage = new EntityStorage( EntityPersistentStorage<Entity> entityPersistentStorage = new EntityStorage(
@@ -246,8 +390,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -249,8 +_,8 @@
server.getStructureManager(), server.getStructureManager(),
dispatcher, dispatcher,
chunkGenerator, chunkGenerator,
@@ -202,7 +194,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
flag, flag,
progressListener, progressListener,
this.entityManager::updateChunkStatus, this.entityManager::updateChunkStatus,
@@ -268,7 +412,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -271,7 +_,7 @@
this.chunkSource.chunkScanner(), this.chunkSource.chunkScanner(),
this.registryAccess(), this.registryAccess(),
server.getStructureManager(), server.getStructureManager(),
@@ -211,7 +203,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
chunkGenerator, chunkGenerator,
this.chunkSource.randomState(), this.chunkSource.randomState(),
this, this,
@@ -276,9 +420,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -279,9 +_,9 @@
seed, seed,
fixerUpper fixerUpper
); );
@@ -224,10 +216,11 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} else { } else {
this.dragonFight = null; this.dragonFight = null;
} }
@@ -286,7 +430,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -290,7 +_,15 @@
this.sleepStatus = new SleepStatus();
this.gameEventDispatcher = new GameEventDispatcher(this); this.gameEventDispatcher = new GameEventDispatcher(this);
this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE));
this.waypointManager = new ServerWaypointManager();
- }
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
+ } + }
+ +
@@ -235,12 +228,12 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
+ @Override + @Override
+ public boolean hasChunk(int chunkX, int chunkZ) { + public boolean hasChunk(int chunkX, int chunkZ) {
+ return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null; + return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null;
} + }
+ // Paper end + // Paper end
@Deprecated @Deprecated
@VisibleForTesting @VisibleForTesting
@@ -298,8 +450,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -302,8 +_,8 @@
this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setClearWeatherTime(clearTime);
this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setRainTime(weatherTime);
this.serverLevelData.setThunderTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime);
@@ -251,7 +244,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
@Override @Override
@@ -326,12 +478,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -330,12 +_,25 @@
int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) {
@@ -280,7 +273,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle(); this.resetWeatherCycle();
} }
@@ -346,9 +511,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -350,9 +_,9 @@
if (!this.isDebug() && runsNormally) { if (!this.isDebug() && runsNormally) {
long l = this.getGameTime(); long l = this.getGameTime();
profilerFiller.push("blockTicks"); profilerFiller.push("blockTicks");
@@ -292,7 +285,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
profilerFiller.pop(); profilerFiller.pop();
} }
@@ -366,7 +531,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -370,7 +_,7 @@
this.handlingTick = false; this.handlingTick = false;
profilerFiller.pop(); profilerFiller.pop();
@@ -301,7 +294,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (flag) { if (flag) {
this.resetEmptyTime(); this.resetEmptyTime();
} }
@@ -455,11 +620,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -459,11 +_,13 @@
ProfilerFiller profilerFiller = Profiler.get(); ProfilerFiller profilerFiller = Profiler.get();
profilerFiller.push("iceandsnow"); profilerFiller.push("iceandsnow");
@@ -315,7 +308,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
profilerFiller.popPush("tickBlocks"); profilerFiller.popPush("tickBlocks");
if (randomTickSpeed > 0) { if (randomTickSpeed > 0) {
@@ -502,12 +669,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -506,12 +_,12 @@
int minBlockZ = pos.getMinBlockZ(); int minBlockZ = pos.getMinBlockZ();
ProfilerFiller profilerFiller = Profiler.get(); ProfilerFiller profilerFiller = Profiler.get();
profilerFiller.push("thunder"); profilerFiller.push("thunder");
@@ -330,7 +323,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
&& !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD); && !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD);
if (flag) { if (flag) {
SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
@@ -515,7 +682,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -519,7 +_,7 @@
skeletonHorse.setTrap(true); skeletonHorse.setTrap(true);
skeletonHorse.setAge(0); skeletonHorse.setAge(0);
skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ());
@@ -339,7 +332,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
} }
@@ -523,7 +690,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -527,7 +_,7 @@
if (lightningBolt != null) { if (lightningBolt != null) {
lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos));
lightningBolt.setVisualOnly(flag); lightningBolt.setVisualOnly(flag);
@@ -348,7 +341,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
} }
} }
@@ -537,7 +704,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -541,7 +_,7 @@
BlockPos blockPos1 = heightmapPos.below(); BlockPos blockPos1 = heightmapPos.below();
Biome biome = this.getBiome(heightmapPos).value(); Biome biome = this.getBiome(heightmapPos).value();
if (biome.shouldFreeze(this, blockPos1)) { if (biome.shouldFreeze(this, blockPos1)) {
@@ -357,7 +350,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
if (this.isRaining()) { if (this.isRaining()) {
@@ -549,10 +716,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -553,10 +_,10 @@
if (layersValue < Math.min(_int, 8)) { if (layersValue < Math.min(_int, 8)) {
BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1);
Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos);
@@ -370,7 +363,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
} }
@@ -577,6 +744,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -581,6 +_,12 @@
} }
protected BlockPos findLightningTargetAround(BlockPos pos) { protected BlockPos findLightningTargetAround(BlockPos pos) {
@@ -383,7 +376,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
Optional<BlockPos> optional = this.findLightningRod(heightmapPos); Optional<BlockPos> optional = this.findLightningRod(heightmapPos);
if (optional.isPresent()) { if (optional.isPresent()) {
@@ -584,11 +757,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -588,11 +_,12 @@
} else { } else {
AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0);
List<LivingEntity> entitiesOfClass = this.getEntitiesOfClass( List<LivingEntity> entitiesOfClass = this.getEntitiesOfClass(
@@ -397,7 +390,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (heightmapPos.getY() == this.getMinY() - 1) { if (heightmapPos.getY() == this.getMinY() - 1) {
heightmapPos = heightmapPos.above(2); heightmapPos = heightmapPos.above(2);
} }
@@ -675,8 +849,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -683,8 +_,8 @@
this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setThunderTime(thunderTime);
this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setRainTime(rainTime);
this.serverLevelData.setClearWeatherTime(clearWeatherTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime);
@@ -408,7 +401,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
this.oThunderLevel = this.thunderLevel; this.oThunderLevel = this.thunderLevel;
@@ -697,6 +871,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -705,6 +_,7 @@
this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F);
} }
@@ -416,7 +409,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (this.oRainLevel != this.rainLevel) { if (this.oRainLevel != this.rainLevel) {
this.server this.server
.getPlayerList() .getPlayerList()
@@ -719,14 +894,47 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -727,14 +_,47 @@
this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
@@ -468,7 +461,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -748,18 +956,46 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -756,18 +_,46 @@
} }
} }
@@ -515,7 +508,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { private void tickPassenger(Entity ridingEntity, Entity passengerEntity) {
@@ -768,10 +1004,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -776,10 +_,12 @@
} else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) {
passengerEntity.setOldPosAndRot(); passengerEntity.setOldPosAndRot();
passengerEntity.tickCount++; passengerEntity.tickCount++;
@@ -528,7 +521,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
profilerFiller.pop(); profilerFiller.pop();
for (Entity entity : passengerEntity.getPassengers()) { for (Entity entity : passengerEntity.getPassengers()) {
@@ -788,6 +1026,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -810,6 +_,7 @@
public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) {
ServerChunkCache chunkSource = this.getChunkSource(); ServerChunkCache chunkSource = this.getChunkSource();
if (!skipSave) { if (!skipSave) {
@@ -536,7 +529,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (progress != null) { if (progress != null) {
progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); progress.progressStartNoAbort(Component.translatable("menu.savingLevel"));
} }
@@ -804,11 +1043,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -826,11 +_,19 @@
this.entityManager.autoSave(); this.entityManager.autoSave();
} }
} }
@@ -557,7 +550,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage();
@@ -873,18 +1120,40 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -895,18 +_,40 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {
@@ -601,7 +594,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
} }
@@ -907,40 +1176,119 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -929,40 +_,119 @@
this.entityManager.addNewEntity(player); this.entityManager.addNewEntity(player);
} }
@@ -675,14 +668,15 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
public void removePlayerImmediately(ServerPlayer player, Entity.RemovalReason reason) { public void removePlayerImmediately(ServerPlayer player, Entity.RemovalReason reason) {
- player.remove(reason); - player.remove(reason);
- }
+ player.remove(reason, null); // CraftBukkit - add Bukkit remove cause + player.remove(reason, null); // CraftBukkit - add Bukkit remove cause
+ } + }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ public boolean strikeLightning(Entity entitylightning) { + public boolean strikeLightning(Entity entitylightning) {
+ return this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.UNKNOWN); + return this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.UNKNOWN);
} + }
+
+ public boolean strikeLightning(Entity entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause cause) { + public boolean strikeLightning(Entity entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause cause) {
+ org.bukkit.event.weather.LightningStrikeEvent lightning = org.bukkit.craftbukkit.event.CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + org.bukkit.event.weather.LightningStrikeEvent lightning = org.bukkit.craftbukkit.event.CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
+ +
@@ -693,7 +687,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
+ return this.addFreshEntity(entitylightning); + return this.addFreshEntity(entitylightning);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
@Override @Override
public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) { public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) {
+ // CraftBukkit start + // CraftBukkit start
@@ -725,7 +719,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (d * d + d1 * d1 + d2 * d2 < 1024.0) { if (d * d + d1 * d1 + d2 * d2 < 1024.0) {
serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress));
} }
@@ -1015,7 +1363,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1037,7 +_,7 @@
pos.getX(), pos.getX(),
pos.getY(), pos.getY(),
pos.getZ(), pos.getZ(),
@@ -734,7 +728,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
this.dimension(), this.dimension(),
new ClientboundLevelEventPacket(type, pos, data, false) new ClientboundLevelEventPacket(type, pos, data, false)
); );
@@ -1027,6 +1375,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1049,6 +_,11 @@
@Override @Override
public void gameEvent(Holder<GameEvent> gameEvent, Vec3 pos, GameEvent.Context context) { public void gameEvent(Holder<GameEvent> gameEvent, Vec3 pos, GameEvent.Context context) {
@@ -746,7 +740,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
this.gameEventDispatcher.post(gameEvent, pos, context); this.gameEventDispatcher.post(gameEvent, pos, context);
} }
@@ -1039,17 +1392,28 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1061,17 +_,28 @@
this.getChunkSource().blockChanged(pos); this.getChunkSource().blockChanged(pos);
this.pathTypesByPosCache.invalidate(pos); this.pathTypesByPosCache.invalidate(pos);
@@ -775,7 +769,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
try { try {
this.isUpdatingNavigations = true; this.isUpdatingNavigations = true;
@@ -1061,15 +1425,23 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1083,15 +_,23 @@
this.isUpdatingNavigations = false; this.isUpdatingNavigations = false;
} }
} }
@@ -799,7 +793,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation);
} }
@@ -1118,6 +1490,42 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1140,6 +_,42 @@
ParticleOptions largeExplosionParticles, ParticleOptions largeExplosionParticles,
Holder<SoundEvent> explosionSound Holder<SoundEvent> explosionSound
) { ) {
@@ -842,7 +836,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) {
case NONE -> Explosion.BlockInteraction.KEEP; case NONE -> Explosion.BlockInteraction.KEEP;
case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY);
@@ -1126,10 +1534,17 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1148,10 +_,17 @@
: Explosion.BlockInteraction.KEEP; : Explosion.BlockInteraction.KEEP;
case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
@@ -860,7 +854,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
for (ServerPlayer serverPlayer : this.players) { for (ServerPlayer serverPlayer : this.players) {
@@ -1138,6 +1553,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1160,6 +_,8 @@
serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound)); serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound));
} }
} }
@@ -869,7 +863,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) { private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) {
@@ -1208,7 +1625,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1230,7 +_,7 @@
public <T extends ParticleOptions> int sendParticles( public <T extends ParticleOptions> int sendParticles(
T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed
) { ) {
@@ -878,7 +872,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
public <T extends ParticleOptions> int sendParticles( public <T extends ParticleOptions> int sendParticles(
@@ -1224,13 +1641,49 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1246,13 +_,49 @@
double zOffset, double zOffset,
double speed double speed
) { ) {
@@ -930,7 +924,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) { if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) {
i++; i++;
} }
@@ -1293,7 +1746,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1315,7 +_,7 @@
@Nullable @Nullable
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipExistingChunks) { public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipExistingChunks) {
@@ -939,7 +933,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
return null; return null;
} else { } else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
@@ -1340,10 +1793,36 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1362,10 +_,36 @@
@Nullable @Nullable
@Override @Override
public MapItemSavedData getMapData(MapId mapId) { public MapItemSavedData getMapData(MapId mapId) {
@@ -977,7 +971,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data);
} }
@@ -1355,17 +1834,27 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1377,17 +_,27 @@
BlockPos spawnPos = this.levelData.getSpawnPos(); BlockPos spawnPos = this.levelData.getSpawnPos();
float spawnAngle = this.levelData.getSpawnAngle(); float spawnAngle = this.levelData.getSpawnAngle();
if (!spawnPos.equals(pos) || spawnAngle != angle) { if (!spawnPos.equals(pos) || spawnAngle != angle) {
@@ -1007,7 +1001,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
this.lastSpawnChunkRadius = i; this.lastSpawnChunkRadius = i;
@@ -1400,6 +1889,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1422,6 +_,11 @@
DebugPackets.sendPoiRemovedPacket(this, blockPos); DebugPackets.sendPoiRemovedPacket(this, blockPos);
})); }));
optional1.ifPresent(holder -> this.getServer().execute(() -> { optional1.ifPresent(holder -> this.getServer().execute(() -> {
@@ -1019,7 +1013,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
this.getPoiManager().add(blockPos, (Holder<PoiType>)holder); this.getPoiManager().add(blockPos, (Holder<PoiType>)holder);
DebugPackets.sendPoiAddedPacket(this, blockPos); DebugPackets.sendPoiAddedPacket(this, blockPos);
})); }));
@@ -1552,12 +2046,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1574,12 +_,12 @@
} }
public boolean isFlat() { public boolean isFlat() {
@@ -1034,7 +1028,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
@Nullable @Nullable
@@ -1608,6 +2102,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1630,6 +_,7 @@
@Override @Override
public LevelEntityGetter<Entity> getEntities() { public LevelEntityGetter<Entity> getEntities() {
@@ -1042,7 +1036,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
return this.entityManager.getEntityGetter(); return this.entityManager.getEntityGetter();
} }
@@ -1697,6 +2192,28 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1736,6 +_,28 @@
return this.serverLevelData.getGameRules(); return this.serverLevelData.getGameRules();
} }
@@ -1071,15 +1065,15 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
@Override @Override
public CrashReportCategory fillReportDetails(CrashReport report) { public CrashReportCategory fillReportDetails(CrashReport report) {
CrashReportCategory crashReportCategory = super.fillReportDetails(report); CrashReportCategory crashReportCategory = super.fillReportDetails(report);
@@ -1712,6 +2229,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1754,6 +_,7 @@
final class EntityCallbacks implements LevelCallback<Entity> { if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) {
@Override ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter);
public void onCreated(Entity entity) { }
+ entity.setOldPosAndRot(); // Paper - update old pos / rot for new entities as it will default to Vec3.ZERO + entity.setOldPosAndRot(); // Paper - update old pos / rot for new entities as it will default to Vec3.ZERO
} }
@Override @Override
@@ -1721,24 +2239,32 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1767,17 +_,25 @@
@Override @Override
public void onTickingStart(Entity entity) { public void onTickingStart(Entity entity) {
@@ -1105,7 +1099,8 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
+ // ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true + // ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true
if (entity instanceof ServerPlayer serverPlayer) { if (entity instanceof ServerPlayer serverPlayer) {
ServerLevel.this.players.add(serverPlayer); ServerLevel.this.players.add(serverPlayer);
ServerLevel.this.updateSleepingPlayerList(); if (serverPlayer.isReceivingWaypoints()) {
@@ -1792,7 +_,7 @@
} }
if (entity instanceof Mob mob) { if (entity instanceof Mob mob) {
@@ -1114,7 +1109,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
String string = "onTrackingStart called during navigation iteration"; String string = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde( Util.logAndPauseIfInIde(
"onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")
@@ -1755,10 +2281,52 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1809,10 +_,52 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@@ -1167,7 +1162,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
ServerLevel.this.getChunkSource().removeEntity(entity); ServerLevel.this.getChunkSource().removeEntity(entity);
if (entity instanceof ServerPlayer serverPlayer) { if (entity instanceof ServerPlayer serverPlayer) {
ServerLevel.this.players.remove(serverPlayer); ServerLevel.this.players.remove(serverPlayer);
@@ -1766,7 +2334,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1821,7 +_,7 @@
} }
if (entity instanceof Mob mob) { if (entity instanceof Mob mob) {
@@ -1176,7 +1171,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
String string = "onTrackingStart called during navigation iteration"; String string = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde( Util.logAndPauseIfInIde(
"onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")
@@ -1783,6 +2351,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1838,6 +_,15 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
@@ -1192,7 +1187,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
} }
@Override @Override
@@ -1790,4 +2367,24 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1845,4 +_,24 @@
entity.updateDynamicGameEventListener(DynamicGameEventListener::move); entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
} }
} }

View File

@@ -1,22 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617ec9506999 100644
--- a/net/minecraft/server/level/ServerPlayer.java --- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java
@@ -65,7 +65,6 @@ import net.minecraft.network.protocol.game.ClientboundHorseScreenOpenPacket; @@ -245,7 +_,8 @@
import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket;
import net.minecraft.network.protocol.game.ClientboundMerchantOffersPacket;
import net.minecraft.network.protocol.game.ClientboundOpenBookPacket;
-import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerCombatEndPacket;
@@ -235,7 +234,8 @@ public class ServerPlayer extends Player {
private int levitationStartTime; private int levitationStartTime;
private boolean disconnected; private boolean disconnected;
private int requestedViewDistance = 2; private int requestedViewDistance = 2;
@@ -26,7 +10,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
@Nullable @Nullable
private Vec3 startingToFallPosition; private Vec3 startingToFallPosition;
@Nullable @Nullable
@@ -281,6 +281,13 @@ public class ServerPlayer extends Player { @@ -291,6 +_,13 @@
} }
} }
@@ -40,7 +24,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
@Override @Override
public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack itemStack) { public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack itemStack) {
ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, itemStack)); ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, itemStack));
@@ -316,6 +323,32 @@ public class ServerPlayer extends Player { @@ -326,6 +_,32 @@
} }
} }
@@ -73,7 +57,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
@Override @Override
public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) {
} }
@@ -344,9 +377,43 @@ public class ServerPlayer extends Player { @@ -354,9 +_,43 @@
public void sendSystemMessage(Component component) { public void sendSystemMessage(Component component) {
ServerPlayer.this.sendSystemMessage(component); ServerPlayer.this.sendSystemMessage(component);
} }
@@ -116,22 +100,20 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event + public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile); super(level, gameProfile);
@@ -356,16 +423,22 @@ public class ServerPlayer extends Player { @@ -366,15 +_,21 @@
this.server = server; this.server = server;
this.stats = server.getPlayerList().getPlayerStats(this); this.stats = server.getPlayerList().getPlayerStats(this);
this.advancements = server.getPlayerList().getPlayerAdvancements(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this);
- this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
- this.updateOptions(clientInformation); - this.updateOptions(clientInformation);
+ // this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn
+ this.updateOptionsNoEvents(clientInformation); // Paper - don't call options events on login + this.updateOptionsNoEvents(clientInformation); // Paper - don't call options events on login
this.object = null; this.object = null;
+
+ // CraftBukkit start + // CraftBukkit start
+ this.displayName = this.getScoreboardName(); + this.displayName = this.getScoreboardName();
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper + this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
+ this.bukkitPickUpLoot = true; + this.bukkitPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth(); + this.maxHealthCache = this.getMaxHealth();
+ // CraftBukkit end
} }
@Override @Override
@@ -143,22 +125,22 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
int max = Math.max(0, this.server.getSpawnRadius(level)); int max = Math.max(0, this.server.getSpawnRadius(level));
int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ())); int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ()));
if (floor < max) { if (floor < max) {
@@ -436,6 +509,7 @@ public class ServerPlayer extends Player { @@ -446,6 +_,7 @@
this.enteredNetherPosition = compound.read("entered_nether_pos", Vec3.CODEC).orElse(null); this.seenCredits = input.getBooleanOr("seenCredits", false);
this.seenCredits = compound.getBooleanOr("seenCredits", false); input.read("recipeBook", ServerRecipeBook.Packed.CODEC)
this.recipeBook.fromNbt(compound.getCompoundOrEmpty("recipeBook"), key -> this.server.getRecipeManager().byKey(key).isPresent()); .ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent()));
+ this.getBukkitEntity().readExtraData(compound); // CraftBukkit + this.getBukkitEntity().readExtraData(input); // CraftBukkit
if (this.isSleeping()) { if (this.isSleeping()) {
this.stopSleeping(); this.stopSleeping();
} }
@@ -459,12 +533,24 @@ public class ServerPlayer extends Player { @@ -469,12 +_,24 @@
compound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); output.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
compound.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition); output.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition);
this.saveEnderPearls(compound); this.saveEnderPearls(output);
+ this.getBukkitEntity().setExtraData(compound); // CraftBukkit + this.getBukkitEntity().setExtraData(output); // CraftBukkit
} }
private void saveParentVehicle(CompoundTag tag) { private void saveParentVehicle(ValueOutput output) {
Entity rootVehicle = this.getRootVehicle(); Entity rootVehicle = this.getRootVehicle();
Entity vehicle = this.getVehicle(); Entity vehicle = this.getVehicle();
- if (vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger()) { - if (vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger()) {
@@ -174,19 +156,19 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ } + }
+ if (persistVehicle && vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger() && !rootVehicle.isRemoved()) { // Paper - Ensure valid vehicle status + if (persistVehicle && vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger() && !rootVehicle.isRemoved()) { // Paper - Ensure valid vehicle status
+ // CraftBukkit end + // CraftBukkit end
CompoundTag compoundTag = new CompoundTag(); ValueOutput valueOutput = output.child("RootVehicle");
CompoundTag compoundTag1 = new CompoundTag(); valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID());
rootVehicle.save(compoundTag1); rootVehicle.save(valueOutput.child("Entity"));
@@ -479,7 +565,7 @@ public class ServerPlayer extends Player { @@ -486,7 +_,7 @@
if (!compound.isEmpty()) { if (!optional.isEmpty()) {
ServerLevel serverLevel = this.serverLevel(); ServerLevel serverLevel = this.level();
Entity entity = EntityType.loadEntityRecursive( Entity entity = EntityType.loadEntityRecursive(
- compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2 - optional.get().childOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2
+ compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason + optional.get().childOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason
); );
if (entity != null) { if (entity != null) {
UUID uuid = compound.get().read("Attach", UUIDUtil.CODEC).orElse(null); UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null);
@@ -496,10 +582,10 @@ public class ServerPlayer extends Player { @@ -503,10 +_,10 @@
if (!this.isPassenger()) { if (!this.isPassenger()) {
LOGGER.warn("Couldn't reattach entity to player"); LOGGER.warn("Couldn't reattach entity to player");
@@ -199,15 +181,15 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
} }
@@ -511,6 +597,7 @@ public class ServerPlayer extends Player { @@ -518,6 +_,7 @@
ListTag listTag = new ListTag(); ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls");
for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) {
+ if (thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) continue; // Paper - Allow using old ender pearl behavior + if (thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) continue; // Paper - Allow using old ender pearl behavior
if (thrownEnderpearl.isRemoved()) { if (thrownEnderpearl.isRemoved()) {
LOGGER.warn("Trying to save removed ender pearl, skipping"); LOGGER.warn("Trying to save removed ender pearl, skipping");
} else { } else {
@@ -546,6 +633,16 @@ public class ServerPlayer extends Player { @@ -550,6 +_,16 @@
} }
} }
@@ -224,7 +206,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
public void setExperiencePoints(int experiencePoints) { public void setExperiencePoints(int experiencePoints) {
float f = this.getXpNeededForNextLevel(); float f = this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f; float f1 = (f - 1.0F) / f;
@@ -603,6 +700,11 @@ public class ServerPlayer extends Player { @@ -607,6 +_,11 @@
@Override @Override
public void tick() { public void tick() {
@@ -236,7 +218,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.tickClientLoadTimeout(); this.tickClientLoadTimeout();
this.gameMode.tick(); this.gameMode.tick();
this.wardenSpawnTracker.tick(); this.wardenSpawnTracker.tick();
@@ -610,9 +712,14 @@ public class ServerPlayer extends Player { @@ -614,9 +_,14 @@
this.invulnerableTime--; this.invulnerableTime--;
} }
@@ -254,7 +236,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
@@ -662,7 +769,7 @@ public class ServerPlayer extends Player { @@ -675,7 +_,7 @@
public void doTick() { public void doTick() {
try { try {
@@ -263,7 +245,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
super.tick(); super.tick();
} }
@@ -676,7 +783,7 @@ public class ServerPlayer extends Player { @@ -689,7 +_,7 @@
if (this.getHealth() != this.lastSentHealth if (this.getHealth() != this.lastSentHealth
|| this.lastSentFood != this.foodData.getFoodLevel() || this.lastSentFood != this.foodData.getFoodLevel()
|| this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -272,7 +254,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.lastSentHealth = this.getHealth(); this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel(); this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -707,6 +814,12 @@ public class ServerPlayer extends Player { @@ -720,6 +_,12 @@
this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience));
} }
@@ -285,7 +267,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (this.experienceLevel != this.lastRecordedLevel) { if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel; this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel));
@@ -720,6 +833,21 @@ public class ServerPlayer extends Player { @@ -733,6 +_,21 @@
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
CriteriaTriggers.LOCATION.trigger(this); CriteriaTriggers.LOCATION.trigger(this);
} }
@@ -307,8 +289,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} catch (Throwable var4) { } catch (Throwable var4) {
CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player");
CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked");
@@ -744,7 +872,7 @@ public class ServerPlayer extends Player { @@ -757,7 +_,7 @@
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
if (this.getHealth() < this.getMaxHealth()) { if (this.getHealth() < this.getMaxHealth()) {
- this.heal(1.0F); - this.heal(1.0F);
@@ -316,20 +298,22 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
float saturationLevel = this.foodData.getSaturationLevel(); float saturationLevel = this.foodData.getSaturationLevel();
@@ -793,15 +921,36 @@ public class ServerPlayer extends Player { @@ -806,15 +_,36 @@
} }
private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) {
- this.getScoreboard().forAllObjectives(criteria, this, score -> score.set(points)); - this.getScoreboard().forAllObjectives(criteria, this, score -> score.set(points));
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(points)); // CraftBukkit - Use our scores instead - }
} -
- @Override - @Override
- public void die(DamageSource cause) { - public void die(DamageSource cause) {
- this.gameEvent(GameEvent.ENTITY_DIE); - this.gameEvent(GameEvent.ENTITY_DIE);
- boolean _boolean = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); - boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
- if (_boolean) { - if (_boolean) {
- Component deathMessage = this.getCombatTracker().getDeathMessage(); - Component deathMessage = this.getCombatTracker().getDeathMessage();
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(points)); // CraftBukkit - Use our scores instead
+ }
+
+ // Paper start - PlayerDeathEvent#getItemsToKeep + // Paper start - PlayerDeathEvent#getItemsToKeep
+ private static boolean shouldKeepDeathEventItem( + private static boolean shouldKeepDeathEventItem(
+ final org.bukkit.event.entity.PlayerDeathEvent event, + final org.bukkit.event.entity.PlayerDeathEvent event,
@@ -360,7 +344,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.connection this.connection
.send( .send(
new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage),
@@ -818,6 +967,65 @@ public class ServerPlayer extends Player { @@ -831,6 +_,65 @@
} }
) )
); );
@@ -372,13 +356,13 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ @Override + @Override
+ public void die(DamageSource cause) { + public void die(DamageSource cause) {
+ // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check + // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check
+ boolean _boolean = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER + boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER
+ // CraftBukkit start - fire PlayerDeathEvent + // CraftBukkit start - fire PlayerDeathEvent
+ if (this.isRemoved()) { + if (this.isRemoved()) {
+ return; + return;
+ } + }
+ List<DefaultDrop> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior + List<DefaultDrop> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior
+ boolean keepInventory = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); + boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
+ if (!keepInventory) { + if (!keepInventory) {
+ for (ItemStack item : this.getInventory().getContents()) { + for (ItemStack item : this.getInventory().getContents()) {
+ if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { + if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
@@ -386,9 +370,9 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ } + }
+ } + }
+ } + }
+ if (this.shouldDropLoot() && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false + if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
+ this.dropFromLootTable(this.serverLevel(), cause, this.lastHurtByPlayerMemoryTime > 0); + this.dropFromLootTable(this.level(), cause, this.lastHurtByPlayerMemoryTime > 0);
+ // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove. + // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove.
+ loot.addAll(this.drops); + loot.addAll(this.drops);
+ this.drops.clear(); // SPIGOT-5188: make sure to clear + this.drops.clear(); // SPIGOT-5188: make sure to clear
@@ -426,7 +410,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
Team team = this.getTeam(); Team team = this.getTeam();
if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) { if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) {
this.server.getPlayerList().broadcastSystemMessage(deathMessage, false); this.server.getPlayerList().broadcastSystemMessage(deathMessage, false);
@@ -827,7 +1035,7 @@ public class ServerPlayer extends Player { @@ -840,7 +_,7 @@
this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage); this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage);
} }
} else { } else {
@@ -435,14 +419,14 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
this.removeEntitiesOnShoulder(); this.removeEntitiesOnShoulder();
@@ -835,11 +1043,35 @@ public class ServerPlayer extends Player { @@ -848,11 +_,35 @@
this.tellNeutralMobsThatIDied(); this.tellNeutralMobsThatIDied();
} }
- if (!this.isSpectator()) { - if (!this.isSpectator()) {
- this.dropAllDeathLoot(this.serverLevel(), cause); - this.dropAllDeathLoot(this.level(), cause);
+ // SPIGOT-5478 must be called manually now + // SPIGOT-5478 must be called manually now
+ if (event.shouldDropExperience()) this.dropExperience(this.serverLevel(), cause.getEntity()); // Paper - tie to event + if (event.shouldDropExperience()) this.dropExperience(this.level(), cause.getEntity()); // Paper - tie to event
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
+ if (!event.getKeepInventory()) { + if (!event.getKeepInventory()) {
+ // Paper start - PlayerDeathEvent#getItemsToKeep + // Paper start - PlayerDeathEvent#getItemsToKeep
@@ -474,7 +458,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
LivingEntity killCredit = this.getKillCredit(); LivingEntity killCredit = this.getKillCredit();
if (killCredit != null) { if (killCredit != null) {
this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType()));
@@ -872,10 +1104,10 @@ public class ServerPlayer extends Player { @@ -885,10 +_,10 @@
public void awardKillScore(Entity entity, DamageSource damageSource) { public void awardKillScore(Entity entity, DamageSource damageSource) {
if (entity != this) { if (entity != this) {
super.awardKillScore(entity, damageSource); super.awardKillScore(entity, damageSource);
@@ -487,7 +471,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} else { } else {
this.awardStat(Stats.MOB_KILLS); this.awardStat(Stats.MOB_KILLS);
} }
@@ -891,7 +1123,7 @@ public class ServerPlayer extends Player { @@ -904,7 +_,7 @@
if (playersTeam != null) { if (playersTeam != null) {
int id = playersTeam.getColor().getId(); int id = playersTeam.getColor().getId();
if (id >= 0 && id < crtieria.length) { if (id >= 0 && id < crtieria.length) {
@@ -496,7 +480,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
} }
@@ -902,9 +1134,20 @@ public class ServerPlayer extends Player { @@ -915,9 +_,20 @@
return false; return false;
} else { } else {
Entity entity = damageSource.getEntity(); Entity entity = damageSource.getEntity();
@@ -519,7 +503,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
@@ -914,23 +1157,77 @@ public class ServerPlayer extends Player { @@ -927,23 +_,77 @@
} }
private boolean isPvpAllowed() { private boolean isPvpAllowed() {
@@ -552,6 +536,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} else { } else {
- return new TeleportTransition(this.server.overworld(), this, postTeleportTransition); - return new TeleportTransition(this.server.overworld(), this, postTeleportTransition);
- }
+ teleportTransition = new TeleportTransition(this.server.overworld(), this, postTeleportTransition); // CraftBukkit + teleportTransition = new TeleportTransition(this.server.overworld(), this, postTeleportTransition); // CraftBukkit
+ } + }
+ // CraftBukkit start + // CraftBukkit start
@@ -581,7 +566,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ // Spigot start + // Spigot start
+ if (this.connection.isDisconnected()) { + if (this.connection.isDisconnected()) {
+ return null; + return null;
} + }
+ // Spigot end + // Spigot end
+ +
+ location = respawnEvent.getRespawnLocation(); + location = respawnEvent.getRespawnLocation();
@@ -601,8 +586,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ // CraftBukkit end + // CraftBukkit end
} }
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock( public boolean isReceivingWaypoints() {
@@ -947,10 +1244,10 @@ public class ServerPlayer extends Player { @@ -978,10 +_,10 @@
level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3); level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3);
} }
@@ -615,7 +600,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} else if (!flag) { } else if (!flag) {
return Optional.empty(); return Optional.empty();
} else { } else {
@@ -958,7 +1255,7 @@ public class ServerPlayer extends Player { @@ -989,7 +_,7 @@
BlockState blockState1 = level.getBlockState(blockPos.above()); BlockState blockState1 = level.getBlockState(blockPos.above());
boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1);
return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 return isPossibleToRespawnInThis && isPossibleToRespawnInThis1
@@ -624,7 +609,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
: Optional.empty(); : Optional.empty();
} }
} }
@@ -976,6 +1273,7 @@ public class ServerPlayer extends Player { @@ -1007,6 +_,7 @@
@Nullable @Nullable
@Override @Override
public ServerPlayer teleport(TeleportTransition teleportTransition) { public ServerPlayer teleport(TeleportTransition teleportTransition) {
@@ -632,10 +617,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (this.isRemoved()) { if (this.isRemoved()) {
return null; return null;
} else { } else {
@@ -985,17 +1283,52 @@ public class ServerPlayer extends Player { @@ -1016,17 +_,52 @@
ServerLevel level = teleportTransition.newLevel(); ServerLevel level = teleportTransition.newLevel();
ServerLevel serverLevel = this.serverLevel(); ServerLevel serverLevel = this.level();
- ResourceKey<Level> resourceKey = serverLevel.dimension(); - ResourceKey<Level> resourceKey = serverLevel.dimension();
+ // CraftBukkit start + // CraftBukkit start
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> resourceKey = serverLevel.getTypeKey(); + ResourceKey<net.minecraft.world.level.dimension.LevelStem> resourceKey = serverLevel.getTypeKey();
@@ -688,7 +673,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.isChangingDimension = true; this.isChangingDimension = true;
LevelData levelData = level.getLevelData(); LevelData levelData = level.getLevelData();
this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(level), (byte)3)); this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(level), (byte)3));
@@ -1004,16 +1337,30 @@ public class ServerPlayer extends Player { @@ -1035,16 +_,30 @@
playerList.sendPlayerPermissionLevel(this); playerList.sendPlayerPermissionLevel(this);
serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved(); this.unsetRemoved();
@@ -721,12 +706,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.connection.resetPosition(); this.connection.resetPosition();
level.addDuringTeleport(this); level.addDuringTeleport(this);
profilerFiller.pop(); profilerFiller.pop();
@@ -1027,11 +1374,40 @@ public class ServerPlayer extends Player { @@ -1059,10 +_,37 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
+ this.teleportSpectators(teleportTransition, serverLevel);
+
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld()); + org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld());
+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent); + this.level().getCraftServer().getPluginManager().callEvent(changeEvent);
@@ -740,7 +723,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
} }
+
+ // CraftBukkit start + // CraftBukkit start
+ @Override + @Override
+ public @Nullable org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent( + public @Nullable org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent(
@@ -758,11 +741,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ return new org.bukkit.craftbukkit.event.CraftPortalEvent(event); + return new org.bukkit.craftbukkit.event.CraftPortalEvent(event);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
@Override @Override
public void forceSetRotation(float yRot, float xRot) { public void forceSetRotation(float yRot, float xRot) {
this.connection.send(new ClientboundPlayerRotationPacket(yRot, xRot)); @@ -1072,12 +_,26 @@
@@ -1040,12 +1416,26 @@ public class ServerPlayer extends Player {
public void triggerDimensionChangeTriggers(ServerLevel level) { public void triggerDimensionChangeTriggers(ServerLevel level) {
ResourceKey<Level> resourceKey = level.dimension(); ResourceKey<Level> resourceKey = level.dimension();
ResourceKey<Level> resourceKey1 = this.level().dimension(); ResourceKey<Level> resourceKey1 = this.level().dimension();
@@ -792,7 +774,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.enteredNetherPosition = null; this.enteredNetherPosition = null;
} }
} }
@@ -1061,19 +1451,18 @@ public class ServerPlayer extends Player { @@ -1093,19 +_,18 @@
this.containerMenu.broadcastChanges(); this.containerMenu.broadcastChanges();
} }
@@ -816,7 +798,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (this.level().isBrightOutside()) { if (this.level().isBrightOutside()) {
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
} else { } else {
@@ -1092,7 +1481,34 @@ public class ServerPlayer extends Player { @@ -1124,7 +_,34 @@
} }
} }
@@ -852,7 +834,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.awardStat(Stats.SLEEP_IN_BED); this.awardStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger(this); CriteriaTriggers.SLEPT_IN_BED.trigger(this);
}); });
@@ -1128,21 +1544,29 @@ public class ServerPlayer extends Player { @@ -1160,21 +_,29 @@
@Override @Override
public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) {
@@ -865,7 +847,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (this.isSleeping()) { if (this.isSleeping()) {
this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(this, 2)); this.level().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(this, 2));
} }
super.stopSleepInBed(wakeImmediately, updateLevelForSleepingPlayers); super.stopSleepInBed(wakeImmediately, updateLevelForSleepingPlayers);
@@ -885,8 +867,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
@Override @Override
@@ -1185,8 +1609,9 @@ public class ServerPlayer extends Player { @@ -1222,8 +_,9 @@
this.connection.send(new ClientboundOpenSignEditorPacket(signEntity.getBlockPos(), isFrontText)); this.connection.send(new ClientboundShowDialogPacket(dialog));
} }
- public void nextContainerCounter() { - public void nextContainerCounter() {
@@ -896,7 +878,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
@Override @Override
@@ -1194,12 +1619,39 @@ public class ServerPlayer extends Player { @@ -1231,12 +_,39 @@
if (menu == null) { if (menu == null) {
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@@ -937,7 +919,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (abstractContainerMenu == null) { if (abstractContainerMenu == null) {
if (this.isSpectator()) { if (this.isSpectator()) {
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
@@ -1207,10 +1659,14 @@ public class ServerPlayer extends Player { @@ -1244,10 +_,14 @@
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@@ -954,7 +936,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
return OptionalInt.of(this.containerCounter); return OptionalInt.of(this.containerCounter);
} }
} }
@@ -1223,14 +1679,25 @@ public class ServerPlayer extends Player { @@ -1260,14 +_,25 @@
@Override @Override
public void openHorseInventory(AbstractHorse horse, Container inventory) { public void openHorseInventory(AbstractHorse horse, Container inventory) {
@@ -983,7 +965,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.initMenu(this.containerMenu); this.initMenu(this.containerMenu);
} }
@@ -1252,10 +1719,30 @@ public class ServerPlayer extends Player { @@ -1289,10 +_,30 @@
@Override @Override
public void closeContainer() { public void closeContainer() {
@@ -1014,7 +996,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
@Override @Override
public void doCloseContainer() { public void doCloseContainer() {
this.containerMenu.removed(this); this.containerMenu.removed(this);
@@ -1278,19 +1765,19 @@ public class ServerPlayer extends Player { @@ -1315,19 +_,19 @@
int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
if (rounded > 0) { if (rounded > 0) {
this.awardStat(Stats.SWIM_ONE_CM, rounded); this.awardStat(Stats.SWIM_ONE_CM, rounded);
@@ -1037,7 +1019,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} else if (this.onClimbable()) { } else if (this.onClimbable()) {
if (dy > 0.0) { if (dy > 0.0) {
@@ -1301,13 +1788,13 @@ public class ServerPlayer extends Player { @@ -1338,13 +_,13 @@
if (rounded > 0) { if (rounded > 0) {
if (this.isSprinting()) { if (this.isSprinting()) {
this.awardStat(Stats.SPRINT_ONE_CM, rounded); this.awardStat(Stats.SPRINT_ONE_CM, rounded);
@@ -1054,7 +1036,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
} else if (this.isFallFlying()) { } else if (this.isFallFlying()) {
@@ -1347,13 +1834,13 @@ public class ServerPlayer extends Player { @@ -1386,13 +_,13 @@
@Override @Override
public void awardStat(Stat<?> stat, int amount) { public void awardStat(Stat<?> stat, int amount) {
this.stats.increment(this, stat, amount); this.stats.increment(this, stat, amount);
@@ -1070,7 +1052,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
@Override @Override
@@ -1384,9 +1871,9 @@ public class ServerPlayer extends Player { @@ -1423,9 +_,9 @@
super.jumpFromGround(); super.jumpFromGround();
this.awardStat(Stats.JUMP); this.awardStat(Stats.JUMP);
if (this.isSprinting()) { if (this.isSprinting()) {
@@ -1082,7 +1064,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
@@ -1399,6 +1886,13 @@ public class ServerPlayer extends Player { @@ -1438,6 +_,13 @@
public void disconnect() { public void disconnect() {
this.disconnected = true; this.disconnected = true;
this.ejectPassengers(); this.ejectPassengers();
@@ -1096,7 +1078,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (this.isSleeping()) { if (this.isSleeping()) {
this.stopSleepInBed(true, false); this.stopSleepInBed(true, false);
} }
@@ -1410,6 +1904,7 @@ public class ServerPlayer extends Player { @@ -1449,6 +_,7 @@
public void resetSentInfo() { public void resetSentInfo() {
this.lastSentHealth = -1.0E8F; this.lastSentHealth = -1.0E8F;
@@ -1104,7 +1086,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
@Override @Override
@@ -1444,12 +1939,12 @@ public class ServerPlayer extends Player { @@ -1483,12 +_,12 @@
this.onUpdateAbilities(); this.onUpdateAbilities();
if (keepEverything) { if (keepEverything) {
this.getAttributes().assignBaseValues(that.getAttributes()); this.getAttributes().assignBaseValues(that.getAttributes());
@@ -1119,16 +1101,16 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
this.getInventory().replaceWith(that.getInventory()); this.getInventory().replaceWith(that.getInventory());
@@ -1460,7 +1955,7 @@ public class ServerPlayer extends Player { @@ -1499,7 +_,7 @@
this.portalProcess = that.portalProcess; this.portalProcess = that.portalProcess;
} else { } else {
this.getAttributes().assignBaseValues(that.getAttributes()); this.getAttributes().assignBaseValues(that.getAttributes());
- this.setHealth(this.getMaxHealth()); - this.setHealth(this.getMaxHealth());
+ // this.setHealth(this.getMaxHealth()); // CraftBukkit + // this.setHealth(this.getMaxHealth()); // CraftBukkit
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) {
this.getInventory().replaceWith(that.getInventory()); this.getInventory().replaceWith(that.getInventory());
this.experienceLevel = that.experienceLevel; this.experienceLevel = that.experienceLevel;
@@ -1476,7 +1971,7 @@ public class ServerPlayer extends Player { @@ -1515,7 +_,7 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
@@ -1137,7 +1119,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.seenCredits = that.seenCredits; this.seenCredits = that.seenCredits;
this.enteredNetherPosition = that.enteredNetherPosition; this.enteredNetherPosition = that.enteredNetherPosition;
this.chunkTrackingView = that.chunkTrackingView; this.chunkTrackingView = that.chunkTrackingView;
@@ -1529,7 +2024,7 @@ public class ServerPlayer extends Player { @@ -1568,7 +_,7 @@
} }
@Override @Override
@@ -1146,7 +1128,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (this.isSleeping()) { if (this.isSleeping()) {
this.stopSleepInBed(true, true); this.stopSleepInBed(true, true);
} }
@@ -1538,7 +2033,7 @@ public class ServerPlayer extends Player { @@ -1577,7 +_,7 @@
this.setCamera(this); this.setCamera(this);
} }
@@ -1155,7 +1137,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (flag) { if (flag) {
this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw);
} }
@@ -1575,9 +2070,17 @@ public class ServerPlayer extends Player { @@ -1615,9 +_,17 @@
} }
public boolean setGameMode(GameType gameMode) { public boolean setGameMode(GameType gameMode) {
@@ -1175,7 +1157,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} else { } else {
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId()));
if (gameMode == GameType.SPECTATOR) { if (gameMode == GameType.SPECTATOR) {
@@ -1593,7 +2096,7 @@ public class ServerPlayer extends Player { @@ -1633,7 +_,7 @@
this.onUpdateAbilities(); this.onUpdateAbilities();
this.updateEffectVisibility(); this.updateEffectVisibility();
@@ -1184,7 +1166,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
@@ -1649,8 +2152,13 @@ public class ServerPlayer extends Player { @@ -1689,8 +_,13 @@
} }
public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) { public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) {
@@ -1199,7 +1181,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
} }
@@ -1661,7 +2169,42 @@ public class ServerPlayer extends Player { @@ -1701,7 +_,42 @@
} }
public void updateOptions(ClientInformation clientInformation) { public void updateOptions(ClientInformation clientInformation) {
@@ -1242,7 +1224,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
this.requestedViewDistance = clientInformation.viewDistance(); this.requestedViewDistance = clientInformation.viewDistance();
this.chatVisibility = clientInformation.chatVisibility(); this.chatVisibility = clientInformation.chatVisibility();
this.canChatColor = clientInformation.chatColors(); this.canChatColor = clientInformation.chatColors();
@@ -1747,8 +2290,23 @@ public class ServerPlayer extends Player { @@ -1787,8 +_,23 @@
Entity camera = this.getCamera(); Entity camera = this.getCamera();
this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate);
if (camera != this.camera) { if (camera != this.camera) {
@@ -1267,7 +1249,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
if (entityToSpectate != null) { if (entityToSpectate != null) {
@@ -1782,11 +2340,11 @@ public class ServerPlayer extends Player { @@ -1822,11 +_,11 @@
@Nullable @Nullable
public Component getTabListDisplayName() { public Component getTabListDisplayName() {
@@ -1281,7 +1263,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
@Override @Override
@@ -1817,11 +2375,56 @@ public class ServerPlayer extends Player { @@ -1857,11 +_,56 @@
} }
public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) {
@@ -1340,7 +1322,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
public SectionPos getLastSectionPos() { public SectionPos getLastSectionPos() {
@@ -1851,16 +2454,23 @@ public class ServerPlayer extends Player { @@ -1891,16 +_,23 @@
} }
@Override @Override
@@ -1368,24 +1350,24 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
return itemEntity; return itemEntity;
} }
@@ -1888,6 +2498,16 @@ public class ServerPlayer extends Player { @@ -1928,6 +_,16 @@
} }
public void loadGameTypes(@Nullable CompoundTag tag) { public void loadGameTypes(@Nullable ValueInput input) {
+ // Paper start - Expand PlayerGameModeChangeEvent + // Paper start - Expand PlayerGameModeChangeEvent
+ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(tag, "playerGameType")) { + if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(tag, "playerGameType")) {
+ if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { + if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
+ this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE); + this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE);
+ } else { + } else {
+ this.gameMode.setGameModeForPlayer(readPlayerMode(tag,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType")); + this.gameMode.setGameModeForPlayer(readPlayerMode(input,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType"));
+ } + }
+ return; + return;
+ } + }
+ // Paper end - Expand PlayerGameModeChangeEvent + // Paper end - Expand PlayerGameModeChangeEvent
this.gameMode this.gameMode
.setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(tag, "playerGameType")), readPlayerMode(tag, "previousPlayerGameType")); .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType"));
} }
@@ -1989,8 +2609,14 @@ public class ServerPlayer extends Player { @@ -2029,8 +_,14 @@
@Override @Override
public void removeVehicle() { public void removeVehicle() {
@@ -1401,7 +1383,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
if (vehicle instanceof LivingEntity livingEntity) { if (vehicle instanceof LivingEntity livingEntity) {
for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) {
this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect()));
@@ -2089,7 +2715,7 @@ public class ServerPlayer extends Player { @@ -2129,7 +_,7 @@
} }
public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) {
@@ -1410,7 +1392,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
return TicketType.ENDER_PEARL.timeout(); return TicketType.ENDER_PEARL.timeout();
} }
@@ -2113,9 +2739,11 @@ public class ServerPlayer extends Player { @@ -2153,9 +_,11 @@
} }
} }
@@ -1425,7 +1407,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
} }
private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) {
@@ -2123,4 +2751,143 @@ public class ServerPlayer extends Player { @@ -2163,4 +_,143 @@
return (float)Mth.wrapDegrees(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI - 90.0); return (float)Mth.wrapDegrees(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI - 90.0);
} }
} }

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f41f0c6f67 100644
--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
@@ -122,6 +122,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -123,6 +_,7 @@
protected int gallopSoundCounter; protected int gallopSoundCounter;
@Nullable @Nullable
public EntityReference<LivingEntity> owner; public EntityReference<LivingEntity> owner;
@@ -16,7 +8,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
protected AbstractHorse(EntityType<? extends AbstractHorse> entityType, Level level) { protected AbstractHorse(EntityType<? extends AbstractHorse> entityType, Level level) {
super(entityType, level); super(entityType, level);
@@ -250,7 +251,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -252,7 +_,7 @@
} }
@Override @Override
@@ -25,7 +17,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
return !this.isVehicle(); return !this.isVehicle();
} }
@@ -301,7 +302,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -303,7 +_,7 @@
public void createInventory() { public void createInventory() {
SimpleContainer simpleContainer = this.inventory; SimpleContainer simpleContainer = this.inventory;
@@ -34,7 +26,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
if (simpleContainer != null) { if (simpleContainer != null) {
int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize());
@@ -395,7 +396,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -397,7 +_,7 @@
} }
public int getMaxTemper() { public int getMaxTemper() {
@@ -43,7 +35,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
} }
@Override @Override
@@ -450,7 +451,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -456,7 +_,7 @@
i1 = 5; i1 = 5;
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true; flag = true;
@@ -52,7 +44,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
} }
} else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) {
f = 10.0F; f = 10.0F;
@@ -458,12 +459,12 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -464,12 +_,12 @@
i1 = 10; i1 = 10;
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true; flag = true;
@@ -67,7 +59,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
flag = true; flag = true;
} }
@@ -534,7 +535,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -540,7 +_,7 @@
super.aiStep(); super.aiStep();
if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
@@ -76,7 +68,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
} }
if (this.canEatGrass()) { if (this.canEatGrass()) {
@@ -637,6 +638,16 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -642,6 +_,16 @@
} }
} }
@@ -93,36 +85,23 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
@Override @Override
public InteractionResult mobInteract(Player player, InteractionHand hand) { public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (this.isVehicle() || this.isBaby()) { if (this.isVehicle() || this.isBaby()) {
@@ -674,6 +685,12 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -788,6 +_,7 @@
this.setFlag(16, eating); output.putInt("Temper", this.getTemper());
} output.putBoolean("Tame", this.isTamed());
EntityReference.store(this.owner, output, "Owner");
+ // Paper start - Horse API
+ public void setForceStanding(boolean standing) {
+ this.setFlag(FLAG_STANDING, standing);
+ }
+ // Paper end - Horse API
+
public void setStanding(boolean standing) {
if (standing) {
this.setEating(false);
@@ -785,6 +802,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
if (this.owner != null) {
this.owner.store(compound, "Owner");
}
+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // Paper - max domestication + compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // Paper - max domestication
} }
@Override @Override
@@ -795,6 +813,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -798,6 +_,7 @@
this.setTemper(compound.getIntOr("Temper", 0)); this.setTemper(input.getIntOr("Temper", 0));
this.setTamed(compound.getBooleanOr("Tame", false)); this.setTamed(input.getBooleanOr("Tame", false));
this.owner = EntityReference.readWithOldOwnerConversion(compound, "Owner", this.level()); this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level());
+ this.maxDomestication = compound.getIntOr("Bukkit.MaxDomestication", this instanceof Llama ? 30 : 100); // Paper - max domestication + this.maxDomestication = compound.getIntOr("Bukkit.MaxDomestication", this instanceof Llama ? 30 : 100); // Paper - max domestication
} }
@Override @Override
@@ -883,6 +902,17 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory @@ -886,6 +_,17 @@
@Override @Override
public void handleStartJump(int jumpPower) { public void handleStartJump(int jumpPower) {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c237c92b6 100644
--- a/net/minecraft/world/entity/player/Player.java --- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java
@@ -169,7 +169,7 @@ public abstract class Player extends LivingEntity { @@ -178,7 +_,7 @@
private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0;
private long timeEntitySatOnShoulder; private long timeEntitySatOnShoulder;
final Inventory inventory; final Inventory inventory;
@@ -17,7 +9,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
public final InventoryMenu inventoryMenu; public final InventoryMenu inventoryMenu;
public AbstractContainerMenu containerMenu; public AbstractContainerMenu containerMenu;
protected FoodData foodData = new FoodData(); protected FoodData foodData = new FoodData();
@@ -208,6 +208,18 @@ public abstract class Player extends LivingEntity { @@ -217,6 +_,18 @@
public Entity currentExplosionCause; public Entity currentExplosionCause;
private boolean ignoreFallDamageFromCurrentImpulse = false; private boolean ignoreFallDamageFromCurrentImpulse = false;
private int currentImpulseContextResetGraceTime = 0; private int currentImpulseContextResetGraceTime = 0;
@@ -34,9 +26,9 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
+ } + }
+ // CraftBukkit end + // CraftBukkit end
public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) { public Player(Level level, GameProfile gameProfile) {
super(EntityType.PLAYER, level); super(EntityType.PLAYER, level);
@@ -276,6 +288,13 @@ public abstract class Player extends LivingEntity { @@ -286,6 +_,13 @@
if (this.isSleeping()) { if (this.isSleeping()) {
this.sleepCounter++; this.sleepCounter++;
@@ -50,7 +42,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
if (this.sleepCounter > 100) { if (this.sleepCounter > 100) {
this.sleepCounter = 100; this.sleepCounter = 100;
} }
@@ -293,7 +312,7 @@ public abstract class Player extends LivingEntity { @@ -303,7 +_,7 @@
this.updateIsUnderwater(); this.updateIsUnderwater();
super.tick(); super.tick();
if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) { if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) {
@@ -59,7 +51,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
@@ -380,7 +399,7 @@ public abstract class Player extends LivingEntity { @@ -390,7 +_,7 @@
} }
private void turtleHelmetTick() { private void turtleHelmetTick() {
@@ -68,7 +60,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
private boolean isEquipped(Item item) { private boolean isEquipped(Item item) {
@@ -527,6 +546,18 @@ public abstract class Player extends LivingEntity { @@ -537,6 +_,18 @@
} }
} }
@@ -87,7 +79,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
public void closeContainer() { public void closeContainer() {
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
@@ -538,8 +569,14 @@ public abstract class Player extends LivingEntity { @@ -548,8 +_,14 @@
public void rideTick() { public void rideTick() {
if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) { if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
this.stopRiding(); this.stopRiding();
@@ -104,7 +96,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
super.rideTick(); super.rideTick();
this.oBob = this.bob; this.oBob = this.bob;
this.bob = 0.0F; this.bob = 0.0F;
@@ -598,6 +635,7 @@ public abstract class Player extends LivingEntity { @@ -608,6 +_,7 @@
this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft());
this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight());
if (!this.level().isClientSide && (this.fallDistance > 0.5 || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) { if (!this.level().isClientSide && (this.fallDistance > 0.5 || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) {
@@ -112,7 +104,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
this.removeEntitiesOnShoulder(); this.removeEntitiesOnShoulder();
} }
} }
@@ -841,10 +879,10 @@ public abstract class Player extends LivingEntity { @@ -850,10 +_,10 @@
if (this.isDeadOrDying()) { if (this.isDeadOrDying()) {
return false; return false;
} else { } else {
@@ -125,7 +117,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
if (level.getDifficulty() == Difficulty.EASY) { if (level.getDifficulty() == Difficulty.EASY) {
@@ -856,7 +894,14 @@ public abstract class Player extends LivingEntity { @@ -865,7 +_,14 @@
} }
} }
@@ -141,7 +133,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
} }
} }
@@ -868,7 +913,7 @@ public abstract class Player extends LivingEntity { @@ -877,7 +_,7 @@
BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null;
float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); float secondsToDisableBlocking = entity.getSecondsToDisableBlocking();
if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) {
@@ -150,7 +142,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
} }
@@ -878,9 +923,29 @@ public abstract class Player extends LivingEntity { @@ -887,9 +_,29 @@
} }
public boolean canHarmPlayer(Player other) { public boolean canHarmPlayer(Player other) {
@@ -183,7 +175,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
@Override @Override
@@ -894,7 +959,12 @@ public abstract class Player extends LivingEntity { @@ -903,7 +_,12 @@
} }
@Override @Override
@@ -197,7 +189,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
if (!this.isInvulnerableTo(level, damageSource)) { if (!this.isInvulnerableTo(level, damageSource)) {
amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterArmorAbsorb(damageSource, amount);
amount = this.getDamageAfterMagicAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount);
@@ -906,7 +976,7 @@ public abstract class Player extends LivingEntity { @@ -915,7 +_,7 @@
} }
if (var8 != 0.0F) { if (var8 != 0.0F) {
@@ -206,7 +198,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
this.getCombatTracker().recordDamage(damageSource, var8); this.getCombatTracker().recordDamage(damageSource, var8);
this.setHealth(this.getHealth() - var8); this.setHealth(this.getHealth() - var8);
if (var8 < 3.4028235E37F) { if (var8 < 3.4028235E37F) {
@@ -916,6 +986,7 @@ public abstract class Player extends LivingEntity { @@ -925,6 +_,7 @@
this.gameEvent(GameEvent.ENTITY_DAMAGE); this.gameEvent(GameEvent.ENTITY_DAMAGE);
} }
} }
@@ -214,7 +206,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
public boolean isTextFilteringEnabled() { public boolean isTextFilteringEnabled() {
@@ -997,13 +1068,19 @@ public abstract class Player extends LivingEntity { @@ -1009,13 +_,19 @@
@Override @Override
public void removeVehicle() { public void removeVehicle() {
@@ -236,7 +228,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
@Override @Override
@@ -1082,8 +1159,17 @@ public abstract class Player extends LivingEntity { @@ -1094,8 +_,17 @@
} }
public void attack(Entity target) { public void attack(Entity target) {
@@ -256,7 +248,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
ItemStack weaponItem = this.getWeaponItem(); ItemStack weaponItem = this.getWeaponItem();
DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this)); DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this));
@@ -1091,18 +1177,25 @@ public abstract class Player extends LivingEntity { @@ -1103,18 +_,25 @@
float attackStrengthScale = this.getAttackStrengthScale(0.5F); float attackStrengthScale = this.getAttackStrengthScale(0.5F);
f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F;
f1 *= attackStrengthScale; f1 *= attackStrengthScale;
@@ -289,7 +281,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
flag1 = true; flag1 = true;
} else { } else {
flag1 = false; flag1 = false;
@@ -1118,7 +1211,9 @@ public abstract class Player extends LivingEntity { @@ -1130,7 +_,9 @@
&& !this.isPassenger() && !this.isPassenger()
&& target instanceof LivingEntity && target instanceof LivingEntity
&& !this.isSprinting(); && !this.isSprinting();
@@ -299,7 +291,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
f *= 1.5F; f *= 1.5F;
} }
@@ -1145,17 +1240,23 @@ public abstract class Player extends LivingEntity { @@ -1157,17 +_,23 @@
if (target instanceof LivingEntity livingEntity1) { if (target instanceof LivingEntity livingEntity1) {
livingEntity1.knockback( livingEntity1.knockback(
f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))
@@ -323,7 +315,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
if (flag3) { if (flag3) {
@@ -1169,42 +1270,59 @@ public abstract class Player extends LivingEntity { @@ -1181,42 +_,59 @@
&& !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker()) && !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker())
&& this.distanceToSqr(livingEntity2) < 9.0) { && this.distanceToSqr(livingEntity2) < 9.0) {
float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale; float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale;
@@ -394,7 +386,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
); );
} }
} }
@@ -1252,10 +1370,11 @@ public abstract class Player extends LivingEntity { @@ -1264,10 +_,11 @@
} }
} }
@@ -409,7 +401,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
} }
} }
@@ -1290,8 +1409,8 @@ public abstract class Player extends LivingEntity { @@ -1302,8 +_,8 @@
} }
@Override @Override
@@ -420,7 +412,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
this.inventoryMenu.removed(this); this.inventoryMenu.removed(this);
if (this.containerMenu != null && this.hasContainerOpen()) { if (this.containerMenu != null && this.hasContainerOpen()) {
this.doCloseContainer(); this.doCloseContainer();
@@ -1355,6 +1474,12 @@ public abstract class Player extends LivingEntity { @@ -1367,6 +_,12 @@
} }
public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos bedPos) { public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos bedPos) {
@@ -433,7 +425,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
this.startSleeping(bedPos); this.startSleeping(bedPos);
this.sleepCounter = 0; this.sleepCounter = 0;
return Either.right(Unit.INSTANCE); return Either.right(Unit.INSTANCE);
@@ -1466,7 +1591,7 @@ public abstract class Player extends LivingEntity { @@ -1478,7 +_,7 @@
@Override @Override
public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) {
@@ -442,7 +434,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
return false; return false;
} else { } else {
if (fallDistance >= 2.0) { if (fallDistance >= 2.0) {
@@ -1507,7 +1632,15 @@ public abstract class Player extends LivingEntity { @@ -1519,7 +_,15 @@
} }
public void startFallFlying() { public void startFallFlying() {
@@ -459,7 +451,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
@Override @Override
@@ -1613,15 +1746,35 @@ public abstract class Player extends LivingEntity { @@ -1625,15 +_,35 @@
public int getXpNeededForNextLevel() { public int getXpNeededForNextLevel() {
if (this.experienceLevel >= 30) { if (this.experienceLevel >= 30) {
return 112 + (this.experienceLevel - 30) * 9; return 112 + (this.experienceLevel - 30) * 9;
@@ -497,7 +489,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
} }
} }
} }
@@ -1715,24 +1868,53 @@ public abstract class Player extends LivingEntity { @@ -1727,31 +_,60 @@
public void removeEntitiesOnShoulder() { public void removeEntitiesOnShoulder() {
if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
@@ -534,30 +526,38 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
- private void respawnEntityOnShoulder(CompoundTag entityCompound) { - private void respawnEntityOnShoulder(CompoundTag entityCompound) {
+ private boolean respawnEntityOnShoulder(CompoundTag entityCompound) { // CraftBukkit void->boolean + private boolean respawnEntityOnShoulder(CompoundTag entityCompound) { // CraftBukkit void->boolean
+ // Paper start - release entity api - return entity - overload + // Paper start - release entity api - return entity - overload
+ return this.respawnEntityOnShoulder0(entityCompound) != null; + return this.respawnEntityOnShoulder0(entityCompound) != null;
+ } + }
+ @Nullable + @Nullable
+ private Entity respawnEntityOnShoulder0(CompoundTag entityCompound) { // CraftBukkit void->boolean + private Entity respawnEntityOnShoulder0(CompoundTag entityCompound) { // CraftBukkit void->boolean
+ // Paper end - release entity api - return entity - overload + // Paper end - release entity api - return entity - overload
if (!this.level().isClientSide && !entityCompound.isEmpty()) { if (this.level() instanceof ServerLevel serverLevel && !entityCompound.isEmpty()) {
- EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).ifPresent(entity -> { try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) {
+ return EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit - EntityType.create(
if (entity instanceof TamableAnimal tamableAnimal) { + return EntityType.create(
tamableAnimal.setOwner(this); TagValueInput.create(scopedCollector.forChild(() -> ".shoulder"), serverLevel.registryAccess(), entityCompound),
} serverLevel,
EntitySpawnReason.LOAD
)
- .ifPresent(entity -> {
+ .map(entity -> { // Paper
if (entity instanceof TamableAnimal tamableAnimal) {
tamableAnimal.setOwner(this);
}
entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ()); entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ());
- ((ServerLevel)this.level()).addWithUUID(entity); - serverLevel.addWithUUID(entity);
- }); - });
+ return ((ServerLevel)this.level()).addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // CraftBukkit // Paper start - release entity api - return entity + return serverLevel.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // Paper
+ }).orElse(null); // CraftBukkit // Paper end - release entity api - return entity + }).orElse(null); // Paper - release entity api - return entity
}
} }
+ return null; // Paper - return null + return null; // Paper - return null
} }
@Nullable @Nullable
@@ -1926,17 +2108,32 @@ public abstract class Player extends LivingEntity { @@ -1945,17 +_,32 @@
return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING);
} }
@@ -592,7 +592,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
for (int i = 0; i < this.inventory.getContainerSize(); i++) { for (int i = 0; i < this.inventory.getContainerSize(); i++) {
ItemStack item = this.inventory.getItem(i); ItemStack item = this.inventory.getItem(i);
@@ -1945,6 +2142,7 @@ public abstract class Player extends LivingEntity { @@ -1964,6 +_,7 @@
} }
} }
@@ -600,7 +600,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY;
} }
} }
@@ -2027,12 +2225,20 @@ public abstract class Player extends LivingEntity { @@ -2046,12 +_,20 @@
} }
public boolean hasClientLoaded() { public boolean hasClientLoaded() {

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786fd04c89a 100644
--- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -94,6 +94,17 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -93,6 +_,17 @@
} }
) )
); );
@@ -26,7 +18,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
protected AbstractMinecart(EntityType<?> entityType, Level level) { protected AbstractMinecart(EntityType<?> entityType, Level level) {
super(entityType, level); super(entityType, level);
@@ -153,11 +164,19 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -152,11 +_,19 @@
@Override @Override
public boolean canCollideWith(Entity entity) { public boolean canCollideWith(Entity entity) {
@@ -48,7 +40,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
return true; return true;
} }
@@ -258,6 +277,14 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -257,6 +_,14 @@
@Override @Override
public void tick() { public void tick() {
@@ -63,7 +55,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
if (this.getHurtTime() > 0) { if (this.getHurtTime() > 0) {
this.setHurtTime(this.getHurtTime() - 1); this.setHurtTime(this.getHurtTime() - 1);
} }
@@ -267,8 +294,20 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -266,8 +_,20 @@
} }
this.checkBelowWorld(); this.checkBelowWorld();
@@ -85,7 +77,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
this.updateInWaterStateAndDoFluidPushing(); this.updateInWaterStateAndDoFluidPushing();
if (this.isInLava()) { if (this.isInLava()) {
this.lavaIgnite(); this.lavaIgnite();
@@ -350,12 +389,16 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -356,12 +_,16 @@
Vec3 deltaMovement = this.getDeltaMovement(); Vec3 deltaMovement = this.getDeltaMovement();
this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed));
if (this.onGround()) { if (this.onGround()) {
@@ -104,12 +96,12 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
} }
} }
@@ -457,6 +500,15 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -463,6 +_,15 @@
this.setDisplayOffset(compound.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset()));
this.flipped = compound.getBooleanOr("FlippedRotation", false); this.flipped = input.getBooleanOr("FlippedRotation", false);
this.firstTick = compound.getBooleanOr("HasTicked", false); this.firstTick = input.getBooleanOr("HasTicked", false);
+ // Paper start - Friction API + // Paper start - Friction API
+ compound.getString("Paper.FrictionState").ifPresent(frictionState -> { + input.getString("Paper.FrictionState").ifPresent(frictionState -> {
+ try { + try {
+ this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState); + this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState);
+ } catch (Exception ignored) { + } catch (Exception ignored) {
@@ -120,14 +112,13 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
} }
@Override @Override
@@ -472,13 +524,27 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -475,13 +_,26 @@
compound.putBoolean("FlippedRotation", this.flipped); output.putBoolean("FlippedRotation", this.flipped);
compound.putBoolean("HasTicked", this.firstTick); output.putBoolean("HasTicked", this.firstTick);
+
+ // Paper start - Friction API + // Paper start - Friction API
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) { + if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
+ compound.putString("Paper.FrictionState", this.frictionState.toString()); + output.putString("Paper.FrictionState", this.frictionState.toString());
+ } + }
+ // Paper end - Friction API + // Paper end - Friction API
} }
@@ -148,7 +139,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
double d = entity.getX() - this.getX(); double d = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ(); double d1 = entity.getZ() - this.getZ();
double d2 = d * d + d1 * d1; double d2 = d * d + d1 * d1;
@@ -587,4 +653,26 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -590,4 +_,26 @@
public boolean isFurnace() { public boolean isFurnace() {
return false; return false;
} }

View File

@@ -1,43 +1,35 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java
index 498e188a4b5fa22378fe146bba689fff595575af..feebd1610ebd3c26a337259c14f5c774dc72b937 100644
--- a/net/minecraft/world/entity/vehicle/ContainerEntity.java --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java
+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java
@@ -60,12 +60,12 @@ public interface ContainerEntity extends Container, MenuProvider { @@ -60,12 +_,14 @@
default void addChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) { default void addChestVehicleSaveData(ValueOutput output) {
if (this.getContainerLootTable() != null) { if (this.getContainerLootTable() != null) {
tag.putString("LootTable", this.getContainerLootTable().location().toString()); output.putString("LootTable", this.getContainerLootTable().location().toString());
+ this.lootableData().saveNbt(tag); // Paper + this.lootableData().saveNbt(output); // Paper
if (this.getContainerLootTableSeed() != 0L) { if (this.getContainerLootTableSeed() != 0L) {
tag.putLong("LootTableSeed", this.getContainerLootTableSeed()); output.putLong("LootTableSeed", this.getContainerLootTableSeed());
} }
- } else { } else {
- ContainerHelper.saveAllItems(tag, this.getItemStacks(), levelRegistry); ContainerHelper.saveAllItems(output, this.getItemStacks());
} }
+ ContainerHelper.saveAllItems(tag, this.getItemStacks(), levelRegistry); // Paper - always save the items, table may still remain + ContainerHelper.saveAllItems(output, this.getItemStacks()); // Paper - always save the items, table may still remain
} }
default void readChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) { default void readChestVehicleSaveData(ValueInput input) {
@@ -73,7 +73,12 @@ public interface ContainerEntity extends Container, MenuProvider { @@ -73,7 +_,12 @@
ResourceKey<LootTable> resourceKey = tag.read("LootTable", LootTable.KEY_CODEC).orElse(null); ResourceKey<LootTable> resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null);
this.setContainerLootTable(resourceKey); this.setContainerLootTable(resourceKey);
this.setContainerLootTableSeed(tag.getLongOr("LootTableSeed", 0L)); this.setContainerLootTableSeed(input.getLongOr("LootTableSeed", 0L));
- if (resourceKey == null) { - if (resourceKey == null) {
+ // Paper start - LootTable API + // Paper start - LootTable API
+ if (this.getContainerLootTable() != null) { + if (this.getContainerLootTable() != null) {
+ this.lootableData().loadNbt(tag); + this.lootableData().loadNbt(input);
+ } + }
+ // Paper end - LootTable API + // Paper end - LootTable API
+ if (true || resourceKey == null) { // Paper - always read the items, table may still remain + if (true || resourceKey == null) { // Paper - always read the items, table may still remain
ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry); ContainerHelper.loadAllItems(input, this.getItemStacks());
} }
} }
@@ -89,19 +94,27 @@ public interface ContainerEntity extends Container, MenuProvider { @@ -89,19 +_,27 @@
} }
default InteractionResult interactWithContainerVehicle(Player player) { default InteractionResult interactWithContainerVehicle(Player player) {
@@ -68,7 +60,7 @@ index 498e188a4b5fa22378fe146bba689fff595575af..feebd1610ebd3c26a337259c14f5c774
LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position());
if (player != null) { if (player != null) {
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
@@ -171,4 +184,14 @@ public interface ContainerEntity extends Container, MenuProvider { @@ -171,4 +_,14 @@
default boolean isChestVehicleStillValid(Player player) { default boolean isChestVehicleStillValid(Player player) {
return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0); return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0);
} }

View File

@@ -0,0 +1,142 @@
--- a/net/minecraft/world/level/BaseSpawner.java
+++ b/net/minecraft/world/level/BaseSpawner.java
@@ -53,13 +_,15 @@
public int maxNearbyEntities = 6;
public int requiredPlayerRange = 16;
public int spawnRange = 4;
+ private int tickDelay = 0; // Paper - Configurable mob spawner tick rate
public void setEntityId(EntityType<?> type, @Nullable Level level, RandomSource random, BlockPos pos) {
this.getOrCreateNextSpawnData(level, random, pos).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(type).toString());
+ this.spawnPotentials = WeightedList.of(); // CraftBukkit - SPIGOT-3496, MC-92282
}
public boolean isNearPlayer(Level level, BlockPos pos) {
- return level.hasNearbyAlivePlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, this.requiredPlayerRange);
+ return level.hasNearbyAlivePlayerThatAffectsSpawning(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, this.requiredPlayerRange); // Paper - Affects Spawning API
}
public void clientTick(Level level, BlockPos pos) {
@@ -82,13 +_,19 @@
}
public void serverTick(ServerLevel serverLevel, BlockPos pos) {
+ if (spawnCount <= 0 || maxNearbyEntities <= 0) return; // Paper - Ignore impossible spawn tick
+ // Paper start - Configurable mob spawner tick rate
+ if (spawnDelay > 0 && --tickDelay > 0) return;
+ tickDelay = serverLevel.paperConfig().tickRates.mobSpawner;
+ if (tickDelay == -1) { return; } // If disabled
+ // Paper end - Configurable mob spawner tick rate
if (this.isNearPlayer(serverLevel, pos)) {
- if (this.spawnDelay == -1) {
+ if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate
this.delay(serverLevel, pos);
}
if (this.spawnDelay > 0) {
- this.spawnDelay--;
+ this.spawnDelay -= tickDelay; // Paper - Configurable mob spawner tick rate
} else {
boolean flag = false;
RandomSource random = serverLevel.getRandom();
@@ -128,6 +_,21 @@
continue;
}
+ // Paper start - PreCreatureSpawnEvent
+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent(
+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(vec3, serverLevel.getWorld()),
+ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(optional.get()),
+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, serverLevel)
+ );
+ if (!event.callEvent()) {
+ flag = true;
+ if (event.shouldAbortSpawn()) {
+ break;
+ }
+ continue;
+ }
+ // Paper end - PreCreatureSpawnEvent
+
Entity entity = EntityType.loadEntityRecursive(valueInput, serverLevel, EntitySpawnReason.SPAWNER, entity1 -> {
entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot());
return entity1;
@@ -148,6 +_,7 @@
return;
}
+ entity.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; preserve entity motion from tag
entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), random.nextFloat() * 360.0F, 0.0F);
if (entity instanceof Mob mob) {
if (nextSpawnData.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(serverLevel, EntitySpawnReason.SPAWNER)
@@ -162,9 +_,22 @@
}
nextSpawnData.getEquipment().ifPresent(mob::equip);
+ // Spigot start
+ if (mob.level().spigotConfig.nerfSpawnerMobs) {
+ mob.aware = false;
+ }
+ // Spigot end
}
- if (!serverLevel.tryAddFreshEntityWithPassengers(entity)) {
+ // Paper start
+ entity.spawnedViaMobSpawner = true;
+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER;
+ flag = true;
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
+ continue;
+ }
+ if (!serverLevel.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) {
+ // Paprt end
this.delay(serverLevel, pos);
return;
}
@@ -175,7 +_,7 @@
((Mob)entity).spawnAnim();
}
- flag = true;
+ //flag = true; // Paper - moved up above cancellable event
}
}
}
@@ -202,12 +_,14 @@
}
public void load(@Nullable Level level, BlockPos pos, ValueInput input) {
- this.spawnDelay = input.getShortOr("Delay", (short)20);
+ this.spawnDelay = input.getIntOr("Paper.Delay", input.getShortOr("Delay", (short) 20)); // Paper - use int if set
input.read("SpawnData", SpawnData.CODEC).ifPresent(spawnData -> this.setNextSpawnData(level, pos, spawnData));
this.spawnPotentials = input.read("SpawnPotentials", SpawnData.LIST_CODEC)
.orElseGet(() -> WeightedList.of(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData()));
- this.minSpawnDelay = input.getIntOr("MinSpawnDelay", 200);
- this.maxSpawnDelay = input.getIntOr("MaxSpawnDelay", 800);
+ // Paper start - use int if set
+ this.minSpawnDelay = input.getIntOr("Paper.MinSpawnDelay", input.getIntOr("MinSpawnDelay", 200));
+ this.maxSpawnDelay = input.getIntOr("Paper.MaxSpawnDelay", input.getIntOr("MaxSpawnDelay", 800));
+ // Paper end - use int if set
this.spawnCount = input.getIntOr("SpawnCount", 4);
this.maxNearbyEntities = input.getIntOr("MaxNearbyEntities", 6);
this.requiredPlayerRange = input.getIntOr("RequiredPlayerRange", 16);
@@ -216,6 +_,19 @@
}
public void save(ValueOutput output) {
+ // Paper start
+ if (this.spawnDelay > Short.MAX_VALUE) {
+ output.putInt("Paper.Delay", this.spawnDelay);
+ }
+ output.putShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
+
+ if (this.minSpawnDelay > Short.MAX_VALUE || this.maxSpawnDelay > Short.MAX_VALUE) {
+ output.putInt("Paper.MinSpawnDelay", this.minSpawnDelay);
+ output.putInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
+ }
+ output.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
+ output.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
+ // Paper end
output.putShort("Delay", (short)this.spawnDelay);
output.putShort("MinSpawnDelay", (short)this.minSpawnDelay);
output.putShort("MaxSpawnDelay", (short)this.maxSpawnDelay);

View File

@@ -1,14 +1,6 @@
From 09671551669244ef4f259d8b27547e463d6795d4 Mon Sep 17 00:00:00 2001
From: File <noreply+automated@papermc.io>
Date: Sun, 20 Apr 1997 15:37:42 +0200
Subject: [PATCH] paper File Patches
diff --git a/net/minecraft/world/level/GameRules.java b/net/minecraft/world/level/GameRules.java
index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fdb4b9e954 100644
--- a/net/minecraft/world/level/GameRules.java --- a/net/minecraft/world/level/GameRules.java
+++ b/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java
@@ -34,6 +34,14 @@ import net.minecraft.world.flag.FeatureFlags; @@ -35,6 +_,14 @@
import org.slf4j.Logger; import org.slf4j.Logger;
public class GameRules { public class GameRules {
@@ -23,7 +15,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
public static final int DEFAULT_RANDOM_TICK_SPEED = 3; public static final int DEFAULT_RANDOM_TICK_SPEED = 3;
static final Logger LOGGER = LogUtils.getLogger(); static final Logger LOGGER = LogUtils.getLogger();
public static final Map<GameRules.Key<?>, GameRules.Type<?>> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id)); public static final Map<GameRules.Key<?>, GameRules.Type<?>> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id));
@@ -86,10 +94,10 @@ public class GameRules { @@ -87,10 +_,10 @@
"sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true) "sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true)
); );
public static final GameRules.Key<GameRules.BooleanValue> RULE_REDUCEDDEBUGINFO = register( public static final GameRules.Key<GameRules.BooleanValue> RULE_REDUCEDDEBUGINFO = register(
@@ -36,7 +28,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b));
} }
}) })
@@ -113,8 +121,8 @@ public class GameRules { @@ -114,8 +_,8 @@
"doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true) "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true)
); );
public static final GameRules.Key<GameRules.BooleanValue> RULE_LIMITED_CRAFTING = register( public static final GameRules.Key<GameRules.BooleanValue> RULE_LIMITED_CRAFTING = register(
@@ -47,7 +39,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F));
} }
}) })
@@ -138,8 +146,8 @@ public class GameRules { @@ -139,8 +_,8 @@
"doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true)
); );
public static final GameRules.Key<GameRules.BooleanValue> RULE_DO_IMMEDIATE_RESPAWN = register( public static final GameRules.Key<GameRules.BooleanValue> RULE_DO_IMMEDIATE_RESPAWN = register(
@@ -58,7 +50,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F));
} }
}) })
@@ -210,11 +218,11 @@ public class GameRules { @@ -211,11 +_,11 @@
public static final GameRules.Key<GameRules.IntegerValue> RULE_MINECART_MAX_SPEED = register( public static final GameRules.Key<GameRules.IntegerValue> RULE_MINECART_MAX_SPEED = register(
"minecartMaxSpeed", "minecartMaxSpeed",
GameRules.Category.MISC, GameRules.Category.MISC,
@@ -73,7 +65,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
serverLevel.setDefaultSpawnPos(serverLevel.getSharedSpawnPos(), serverLevel.getSharedSpawnAngle()); serverLevel.setDefaultSpawnPos(serverLevel.getSharedSpawnPos(), serverLevel.getSharedSpawnAngle());
}) })
); );
@@ -223,6 +231,7 @@ public class GameRules { @@ -234,6 +_,7 @@
); );
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules; private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
private final FeatureFlagSet enabledFeatures; private final FeatureFlagSet enabledFeatures;
@@ -81,7 +73,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
public static <T extends GameRules.Value<T>> GameRules.Type<T> getType(GameRules.Key<T> key) { public static <T extends GameRules.Value<T>> GameRules.Type<T> getType(GameRules.Key<T> key) {
return (GameRules.Type<T>)GAME_RULE_TYPES.get(key); return (GameRules.Type<T>)GAME_RULE_TYPES.get(key);
@@ -270,10 +279,21 @@ public class GameRules { @@ -281,10 +_,21 @@
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) { private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) {
this.rules = rules; this.rules = rules;
this.enabledFeatures = enabledFeatures; this.enabledFeatures = enabledFeatures;
@@ -104,7 +96,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
if (value == null) { if (value == null) {
throw new IllegalArgumentException("Tried to access invalid game rule"); throw new IllegalArgumentException("Tried to access invalid game rule");
} else { } else {
@@ -314,13 +334,13 @@ public class GameRules { @@ -325,13 +_,13 @@
} }
} }
@@ -122,16 +114,25 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
public boolean getBoolean(GameRules.Key<GameRules.BooleanValue> key) { public boolean getBoolean(GameRules.Key<GameRules.BooleanValue> key) {
@@ -334,7 +354,7 @@ public class GameRules { @@ -346,7 +_,7 @@
public static class BooleanValue extends GameRules.Value<GameRules.BooleanValue> {
private boolean value; private boolean value;
private static GameRules.Type<GameRules.BooleanValue> create(
- boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeListener, FeatureFlagSet requiredFeatures
+ boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener, FeatureFlagSet requiredFeatures // Paper
) {
return new GameRules.Type<>(
BoolArgumentType::bool,
@@ -358,7 +_,7 @@
);
}
- static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeListener) { - static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeListener) {
+ static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener) { // CraftBukkit - per-world + static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener) { // Paper
return new GameRules.Type<>( return new GameRules.Type<>(
BoolArgumentType::bool, BoolArgumentType::bool,
type -> new GameRules.BooleanValue(type, defaultValue), type -> new GameRules.BooleanValue(type, defaultValue),
@@ -355,17 +375,21 @@ public class GameRules { @@ -379,17 +_,21 @@
} }
@Override @Override
@@ -157,7 +158,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
@Override @Override
@@ -394,9 +418,9 @@ public class GameRules { @@ -418,9 +_,9 @@
} }
@Override @Override
@@ -169,7 +170,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
} }
@@ -434,7 +458,7 @@ public class GameRules { @@ -458,7 +_,7 @@
public static class IntegerValue extends GameRules.Value<GameRules.IntegerValue> { public static class IntegerValue extends GameRules.Value<GameRules.IntegerValue> {
private int value; private int value;
@@ -178,7 +179,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
return new GameRules.Type<>( return new GameRules.Type<>(
IntegerArgumentType::integer, IntegerArgumentType::integer,
type -> new GameRules.IntegerValue(type, defaultValue), type -> new GameRules.IntegerValue(type, defaultValue),
@@ -446,7 +470,7 @@ public class GameRules { @@ -470,7 +_,7 @@
} }
static GameRules.Type<GameRules.IntegerValue> create( static GameRules.Type<GameRules.IntegerValue> create(
@@ -187,7 +188,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
) { ) {
return new GameRules.Type<>( return new GameRules.Type<>(
() -> IntegerArgumentType.integer(min, max), () -> IntegerArgumentType.integer(min, max),
@@ -468,17 +492,21 @@ public class GameRules { @@ -492,17 +_,21 @@
} }
@Override @Override
@@ -213,7 +214,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
@Override @Override
@@ -529,13 +557,17 @@ public class GameRules { @@ -553,13 +_,17 @@
} }
@Override @Override
@@ -233,7 +234,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
final String id; final String id;
private final GameRules.Category category; private final GameRules.Category category;
@@ -575,7 +607,7 @@ public class GameRules { @@ -599,7 +_,7 @@
public static class Type<T extends GameRules.Value<T>> { public static class Type<T extends GameRules.Value<T>> {
final Supplier<ArgumentType<?>> argument; final Supplier<ArgumentType<?>> argument;
private final Function<GameRules.Type<T>, T> constructor; private final Function<GameRules.Type<T>, T> constructor;
@@ -242,7 +243,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
private final GameRules.VisitorCaller<T> visitorCaller; private final GameRules.VisitorCaller<T> visitorCaller;
final Class<T> valueClass; final Class<T> valueClass;
final FeatureFlagSet requiredFeatures; final FeatureFlagSet requiredFeatures;
@@ -583,7 +615,7 @@ public class GameRules { @@ -607,7 +_,7 @@
Type( Type(
Supplier<ArgumentType<?>> argument, Supplier<ArgumentType<?>> argument,
Function<GameRules.Type<T>, T> constructor, Function<GameRules.Type<T>, T> constructor,
@@ -251,7 +252,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
GameRules.VisitorCaller<T> visitorCaller, GameRules.VisitorCaller<T> visitorCaller,
Class<T> valueClass, Class<T> valueClass,
FeatureFlagSet requiredFeatures FeatureFlagSet requiredFeatures
@@ -611,6 +643,12 @@ public class GameRules { @@ -635,6 +_,12 @@
public FeatureFlagSet requiredFeatures() { public FeatureFlagSet requiredFeatures() {
return this.requiredFeatures; return this.requiredFeatures;
} }
@@ -264,7 +265,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
public abstract static class Value<T extends GameRules.Value<T>> { public abstract static class Value<T extends GameRules.Value<T>> {
@@ -620,16 +658,16 @@ public class GameRules { @@ -644,16 +_,16 @@
this.type = type; this.type = type;
} }
@@ -288,7 +289,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
} }
} }
@@ -648,7 +686,7 @@ public class GameRules { @@ -672,7 +_,7 @@
protected abstract T copy(); protected abstract T copy();

View File

@@ -1,5 +1,7 @@
package com.destroystokyo.paper.loottable; package com.destroystokyo.paper.loottable;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.papermc.paper.configuration.WorldConfiguration; import io.papermc.paper.configuration.WorldConfiguration;
import io.papermc.paper.configuration.type.DurationOrDisabled; import io.papermc.paper.configuration.type.DurationOrDisabled;
import java.util.HashMap; import java.util.HashMap;
@@ -14,6 +16,8 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.world.RandomizableContainer; import net.minecraft.world.RandomizableContainer;
import net.minecraft.world.entity.vehicle.ContainerEntity; import net.minecraft.world.entity.vehicle.ContainerEntity;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@@ -164,31 +168,24 @@ public class PaperLootableInventoryData {
private static final String NUM_REFILLS = "numRefills"; private static final String NUM_REFILLS = "numRefills";
private static final String LOOTED_PLAYERS = "lootedPlayers"; private static final String LOOTED_PLAYERS = "lootedPlayers";
public void loadNbt(final CompoundTag base) { public void loadNbt(final ValueInput base) {
final Optional<CompoundTag> compOpt = base.getCompound(ROOT); final Optional<ValueInput> compOpt = base.child(ROOT);
if (compOpt.isEmpty()) { if (compOpt.isEmpty()) {
return; return;
} }
CompoundTag comp = compOpt.get(); final ValueInput comp = compOpt.get();
this.lastFill = comp.getLongOr(LAST_FILL, -1); this.lastFill = comp.getLongOr(LAST_FILL, -1);
this.nextRefill = comp.getLongOr(NEXT_REFILL, -1); this.nextRefill = comp.getLongOr(NEXT_REFILL, -1);
this.numRefills = comp.getIntOr(NUM_REFILLS, 0); this.numRefills = comp.getIntOr(NUM_REFILLS, 0);
final ListTag list = comp.getListOrEmpty(LOOTED_PLAYERS); final ValueInput.TypedInputList<SerializedLootedPlayerEntry> list = comp.listOrEmpty(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
final int size = list.size(); if (!list.isEmpty()) {
if (size > 0) { this.lootedPlayers = new HashMap<>();
this.lootedPlayers = new HashMap<>(list.size()); list.forEach(serializedLootedPlayerEntry -> lootedPlayers.put(serializedLootedPlayerEntry.uuid, serializedLootedPlayerEntry.time));
}
for (int i = 0; i < size; i++) {
list.getCompound(i).ifPresent(tag -> {
tag.read("UUID", UUIDUtil.CODEC).ifPresent(uuid -> {
this.lootedPlayers.put(uuid, tag.getLongOr("Time", 0));
});
});
} }
} }
public void saveNbt(final CompoundTag base) { public void saveNbt(final ValueOutput base) {
final CompoundTag comp = new CompoundTag(); final ValueOutput comp = base.child(ROOT);
if (this.nextRefill != -1) { if (this.nextRefill != -1) {
comp.putLong(NEXT_REFILL, this.nextRefill); comp.putLong(NEXT_REFILL, this.nextRefill);
} }
@@ -199,18 +196,14 @@ public class PaperLootableInventoryData {
comp.putInt(NUM_REFILLS, this.numRefills); comp.putInt(NUM_REFILLS, this.numRefills);
} }
if (this.lootedPlayers != null && !this.lootedPlayers.isEmpty()) { if (this.lootedPlayers != null && !this.lootedPlayers.isEmpty()) {
final ListTag list = new ListTag(); final ValueOutput.TypedOutputList<SerializedLootedPlayerEntry> list = comp.list(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
for (final Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) { for (final Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) {
final CompoundTag cmp = new CompoundTag(); list.add(new SerializedLootedPlayerEntry(entry.getKey(), entry.getValue()));
cmp.store("UUID", UUIDUtil.CODEC, entry.getKey());
cmp.putLong("Time", entry.getValue());
list.add(cmp);
} }
comp.put(LOOTED_PLAYERS, list);
} }
if (!comp.isEmpty()) { if (comp.isEmpty()) {
base.put(ROOT, comp); base.discard(ROOT);
} }
} }
@@ -242,4 +235,14 @@ public class PaperLootableInventoryData {
@Nullable Long getLastLooted(final UUID player) { @Nullable Long getLastLooted(final UUID player) {
return this.lootedPlayers != null ? this.lootedPlayers.get(player) : null; return this.lootedPlayers != null ? this.lootedPlayers.get(player) : null;
} }
record SerializedLootedPlayerEntry(UUID uuid, long time) {
public static final Codec<SerializedLootedPlayerEntry> CODEC = RecordCodecBuilder.create(
instance -> instance.group(
UUIDUtil.CODEC.fieldOf("UUID").forGetter(SerializedLootedPlayerEntry::uuid),
Codec.LONG.optionalFieldOf("Time", 0L).forGetter(SerializedLootedPlayerEntry::time)
)
.apply(instance, SerializedLootedPlayerEntry::new)
);
}
} }

View File

@@ -139,7 +139,11 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
@Override @Override
public void setRearing(boolean rearing) { public void setRearing(boolean rearing) {
this.getHandle().setForceStanding(rearing); if (rearing) {
this.getHandle().setStanding(Integer.MAX_VALUE);
} else {
this.getHandle().clearStanding();
}
} }
@Override @Override

View File

@@ -120,6 +120,8 @@ import net.minecraft.world.level.border.BorderChangeListener;
import net.minecraft.world.level.saveddata.maps.MapDecoration; import net.minecraft.world.level.saveddata.maps.MapDecoration;
import net.minecraft.world.level.saveddata.maps.MapId; import net.minecraft.world.level.saveddata.maps.MapId;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import org.bukkit.BanEntry; import org.bukkit.BanEntry;
import org.bukkit.BanList; import org.bukkit.BanList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -2351,9 +2353,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
// Paper end - getLastPlayed replacement API // Paper end - getLastPlayed replacement API
public void readExtraData(CompoundTag tag) { public void readExtraData(ValueInput tag) {
this.hasPlayedBefore = true; this.hasPlayedBefore = true;
tag.getCompound("bukkit").ifPresent(data -> { tag.child("bukkit").ifPresent(data -> {
this.firstPlayed = data.getLongOr("firstPlayed", 0); this.firstPlayed = data.getLongOr("firstPlayed", 0);
this.lastPlayed = data.getLongOr("lastPlayed", 0); this.lastPlayed = data.getLongOr("lastPlayed", 0);
@@ -2366,14 +2368,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}); });
} }
public void setExtraData(CompoundTag tag) { public void setExtraData(ValueOutput tag) {
this.lastSaveTime = System.currentTimeMillis(); // Paper this.lastSaveTime = System.currentTimeMillis(); // Paper
if (!tag.contains("bukkit")) { ValueOutput data = tag.child("bukkit");
tag.put("bukkit", new CompoundTag());
}
CompoundTag data = tag.getCompoundOrEmpty("bukkit");
ServerPlayer handle = this.getHandle(); ServerPlayer handle = this.getHandle();
data.putInt("newExp", handle.newExp); data.putInt("newExp", handle.newExp);
data.putInt("newTotalExp", handle.newTotalExp); data.putInt("newTotalExp", handle.newTotalExp);
@@ -2385,11 +2383,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
data.putString("lastKnownName", handle.getScoreboardName()); data.putString("lastKnownName", handle.getScoreboardName());
// Paper start - persist for use in offline save data // Paper start - persist for use in offline save data
if (!tag.contains("Paper")) { ValueOutput paper = tag.child("Paper");
tag.put("Paper", new CompoundTag());
}
CompoundTag paper = tag.getCompoundOrEmpty("Paper");
paper.putLong("LastLogin", handle.loginTime); paper.putLong("LastLogin", handle.loginTime);
paper.putLong("LastSeen", System.currentTimeMillis()); paper.putLong("LastSeen", System.currentTimeMillis());
// Paper end // Paper end