mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-09 00:22:08 -07:00
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:
@@ -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);
|
@@ -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
|
||||
+++ 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();
|
||||
private static final int CONVERSION_RETRY_DELAY_MS = 5000;
|
||||
private static final int CONVERSION_RETRIES = 2;
|
||||
@@ -21,7 +13,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
@Nullable
|
||||
private RconThread rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -81,6 +81,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -81,6 +_,7 @@
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
public DedicatedServer(
|
||||
@@ -29,7 +21,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
Thread serverThread,
|
||||
LevelStorageSource.LevelStorageAccess storageSource,
|
||||
PackRepository packRepository,
|
||||
@@ -90,9 +91,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -90,9 +_,9 @@
|
||||
Services services,
|
||||
ChunkProgressListenerFactory progressListenerFactory
|
||||
) {
|
||||
@@ -41,7 +33,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties());
|
||||
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") {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -52,7 +44,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||
|
||||
String string1;
|
||||
@@ -111,17 +116,41 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -111,17 +_,41 @@
|
||||
}
|
||||
} catch (IOException var4) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4);
|
||||
@@ -78,7 +70,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
|
||||
- thread.start();
|
||||
+ // 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) {
|
||||
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");
|
||||
DedicatedServerProperties properties = this.settings.getProperties();
|
||||
if (this.isSingleplayer()) {
|
||||
@@ -132,13 +161,51 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -132,13 +_,51 @@
|
||||
this.setLocalIp(properties.serverIp);
|
||||
}
|
||||
|
||||
@@ -149,7 +141,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
InetAddress inetAddress = null;
|
||||
if (!this.getLocalIp().isEmpty()) {
|
||||
inetAddress = InetAddress.getByName(this.getLocalIp());
|
||||
@@ -147,36 +214,61 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -147,36 +_,61 @@
|
||||
if (this.getPort() < 0) {
|
||||
this.setPort(properties.serverPort);
|
||||
}
|
||||
@@ -216,7 +208,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(
|
||||
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);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@@ -232,7 +224,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
}
|
||||
|
||||
if (properties.enableQuery) {
|
||||
@@ -203,7 +295,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -203,7 +_,7 @@
|
||||
this.rconThread = RconThread.create(this);
|
||||
}
|
||||
|
||||
@@ -241,7 +233,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(LOGGER));
|
||||
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
|
||||
public boolean isSpawningMonsters() {
|
||||
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
||||
@@ -232,7 +330,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -232,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void forceDifficulty() {
|
||||
@@ -263,7 +255,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,12 +369,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -271,12 +_,15 @@
|
||||
}
|
||||
|
||||
if (this.rconThread != null) {
|
||||
@@ -281,7 +273,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,13 +392,23 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -291,13 +_,23 @@
|
||||
}
|
||||
|
||||
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
|
||||
public boolean enforceSecureProfile() {
|
||||
DedicatedServerProperties properties = this.getProperties();
|
||||
@@ -322,7 +314,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -515,14 +630,54 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -515,14 +_,54 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@@ -381,7 +373,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean isStoreUsingWhiteList) {
|
||||
@@ -532,7 +687,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -532,7 +_,7 @@
|
||||
@Override
|
||||
public void stopServer() {
|
||||
super.stopServer();
|
||||
@@ -390,7 +382,7 @@ index 6c49c5a88d2dcee911cd862da01a009fba4b50c9..0c861f882d3e8f8ce417ce2ace0f3f5c
|
||||
SkullBlockEntity.clear();
|
||||
}
|
||||
|
||||
@@ -626,4 +781,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -626,4 +_,15 @@
|
||||
}
|
||||
}
|
||||
}
|
@@ -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
|
||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -69,11 +69,12 @@ public class ServerEntity {
|
||||
@@ -69,11 +_,12 @@
|
||||
private Vec3 lastSentMovement;
|
||||
private int tickCount;
|
||||
private int teleportDelay;
|
||||
@@ -22,7 +14,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
|
||||
public ServerEntity(
|
||||
ServerLevel level,
|
||||
@@ -81,8 +82,12 @@ public class ServerEntity {
|
||||
@@ -81,8 +_,12 @@
|
||||
int updateInterval,
|
||||
boolean trackDelta,
|
||||
Consumer<Packet<?>> broadcast,
|
||||
@@ -36,7 +28,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
this.level = level;
|
||||
this.broadcast = broadcast;
|
||||
this.entity = entity;
|
||||
@@ -103,16 +108,22 @@ public class ServerEntity {
|
||||
@@ -103,16 +_,22 @@
|
||||
if (!passengers.equals(this.lastPassengers)) {
|
||||
List<UUID> list = this.mountedOrDismounted(passengers).map(Entity::getUUID).toList();
|
||||
this.broadcastWithIgnore.accept(new ClientboundSetPassengersPacket(this.entity), list);
|
||||
@@ -63,7 +55,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
savedData.tickCarriedBy(serverPlayer, item);
|
||||
Packet<?> updatePacket = savedData.getUpdatePacket(mapId, serverPlayer);
|
||||
if (updatePacket != null) {
|
||||
@@ -145,7 +156,13 @@ public class ServerEntity {
|
||||
@@ -145,7 +_,13 @@
|
||||
} else {
|
||||
this.teleportDelay++;
|
||||
Vec3 vec3 = this.entity.trackingPosition();
|
||||
@@ -78,7 +70,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
Packet<?> packet = null;
|
||||
boolean flag2 = flag1 || this.tickCount % 60 == 0;
|
||||
boolean flag3 = false;
|
||||
@@ -223,6 +240,25 @@ public class ServerEntity {
|
||||
@@ -227,6 +_,25 @@
|
||||
|
||||
this.tickCount++;
|
||||
if (this.entity.hurtMarked) {
|
||||
@@ -104,7 +96,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
this.entity.hurtMarked = false;
|
||||
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) {
|
||||
if (this.entity.isRemoved()) {
|
||||
@@ -116,11 +108,10 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
}
|
||||
|
||||
Packet<ClientGamePacketListener> addEntityPacket = this.entity.getAddEntityPacket(this);
|
||||
@@ -292,6 +331,12 @@ public class ServerEntity {
|
||||
boolean flag = this.trackDelta;
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
Collection<AttributeInstance> syncableAttributes = ((LivingEntity)this.entity).getAttributes().getSyncableAttributes();
|
||||
+
|
||||
@@ -295,6 +_,11 @@
|
||||
|
||||
if (this.entity instanceof LivingEntity livingEntity) {
|
||||
Collection<AttributeInstance> syncableAttributes = livingEntity.getAttributes().getSyncableAttributes();
|
||||
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
||||
+ if (this.entity.getId() == player.getId()) {
|
||||
+ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(syncableAttributes, false);
|
||||
@@ -129,7 +120,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
if (!syncableAttributes.isEmpty()) {
|
||||
consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes));
|
||||
}
|
||||
@@ -316,8 +361,9 @@ public class ServerEntity {
|
||||
@@ -311,8 +_,9 @@
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
@@ -140,7 +131,7 @@ index 9b13a536dc7a9d5d71eb8dbf75597ccdc4bc8f2a..69fbcd734c269bbc9858b0ad0b3b268d
|
||||
}
|
||||
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
@@ -364,6 +410,11 @@ public class ServerEntity {
|
||||
@@ -359,6 +_,11 @@
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
Set<AttributeInstance> attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync();
|
||||
if (!attributesToSync.isEmpty()) {
|
@@ -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
|
||||
+++ 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();
|
||||
public final ServerChunkCache chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@@ -16,8 +8,8 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
+ public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList = new EntityTickList();
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -205,11 +205,131 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
private final ServerWaypointManager waypointManager;
|
||||
@@ -208,11 +_,131 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
@@ -150,7 +142,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
ResourceKey<Level> dimension,
|
||||
LevelStem levelStem,
|
||||
ChunkProgressListener progressListener,
|
||||
@@ -217,14 +337,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -220,14 +_,38 @@
|
||||
long biomeZoomSeed,
|
||||
List<CustomSpawner> customSpawners,
|
||||
boolean tickTime,
|
||||
@@ -191,7 +183,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
boolean flag = server.forceSynchronousWrites();
|
||||
DataFixer fixerUpper = server.getFixerUpper();
|
||||
EntityPersistentStorage<Entity> entityPersistentStorage = new EntityStorage(
|
||||
@@ -246,8 +390,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -249,8 +_,8 @@
|
||||
server.getStructureManager(),
|
||||
dispatcher,
|
||||
chunkGenerator,
|
||||
@@ -202,7 +194,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
flag,
|
||||
progressListener,
|
||||
this.entityManager::updateChunkStatus,
|
||||
@@ -268,7 +412,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -271,7 +_,7 @@
|
||||
this.chunkSource.chunkScanner(),
|
||||
this.registryAccess(),
|
||||
server.getStructureManager(),
|
||||
@@ -211,7 +203,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
chunkGenerator,
|
||||
this.chunkSource.randomState(),
|
||||
this,
|
||||
@@ -276,9 +420,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -279,9 +_,9 @@
|
||||
seed,
|
||||
fixerUpper
|
||||
);
|
||||
@@ -224,10 +216,11 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -286,7 +430,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
this.sleepStatus = new SleepStatus();
|
||||
@@ -290,7 +_,15 @@
|
||||
this.gameEventDispatcher = new GameEventDispatcher(this);
|
||||
this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE));
|
||||
this.waypointManager = new ServerWaypointManager();
|
||||
- }
|
||||
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
@@ -235,12 +228,12 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
+ @Override
|
||||
+ public boolean hasChunk(int chunkX, int chunkZ) {
|
||||
+ return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null;
|
||||
}
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Deprecated
|
||||
@VisibleForTesting
|
||||
@@ -298,8 +450,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -302,8 +_,8 @@
|
||||
this.serverLevelData.setClearWeatherTime(clearTime);
|
||||
this.serverLevelData.setRainTime(weatherTime);
|
||||
this.serverLevelData.setThunderTime(weatherTime);
|
||||
@@ -251,7 +244,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
@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);
|
||||
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()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -346,9 +511,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -350,9 +_,9 @@
|
||||
if (!this.isDebug() && runsNormally) {
|
||||
long l = this.getGameTime();
|
||||
profilerFiller.push("blockTicks");
|
||||
@@ -292,7 +285,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
profilerFiller.pop();
|
||||
}
|
||||
|
||||
@@ -366,7 +531,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -370,7 +_,7 @@
|
||||
|
||||
this.handlingTick = false;
|
||||
profilerFiller.pop();
|
||||
@@ -301,7 +294,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
}
|
||||
@@ -455,11 +620,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -459,11 +_,13 @@
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("iceandsnow");
|
||||
|
||||
@@ -315,7 +308,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
|
||||
profilerFiller.popPush("tickBlocks");
|
||||
if (randomTickSpeed > 0) {
|
||||
@@ -502,12 +669,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -506,12 +_,12 @@
|
||||
int minBlockZ = pos.getMinBlockZ();
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("thunder");
|
||||
@@ -330,7 +323,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
&& !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD);
|
||||
if (flag) {
|
||||
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.setAge(0);
|
||||
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) {
|
||||
lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos));
|
||||
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();
|
||||
Biome biome = this.getBiome(heightmapPos).value();
|
||||
if (biome.shouldFreeze(this, blockPos1)) {
|
||||
@@ -357,7 +350,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -549,10 +716,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -553,10 +_,10 @@
|
||||
if (layersValue < Math.min(_int, 8)) {
|
||||
BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1);
|
||||
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) {
|
||||
@@ -383,7 +376,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
Optional<BlockPos> optional = this.findLightningRod(heightmapPos);
|
||||
if (optional.isPresent()) {
|
||||
@@ -584,11 +757,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -588,11 +_,12 @@
|
||||
} else {
|
||||
AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0);
|
||||
List<LivingEntity> entitiesOfClass = this.getEntitiesOfClass(
|
||||
@@ -397,7 +390,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (heightmapPos.getY() == this.getMinY() - 1) {
|
||||
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.setRainTime(rainTime);
|
||||
this.serverLevelData.setClearWeatherTime(clearWeatherTime);
|
||||
@@ -408,7 +401,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -416,7 +409,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server
|
||||
.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.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
}
|
||||
@@ -468,7 +461,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -768,10 +1004,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -776,10 +_,12 @@
|
||||
} else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) {
|
||||
passengerEntity.setOldPosAndRot();
|
||||
passengerEntity.tickCount++;
|
||||
@@ -528,7 +521,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
profilerFiller.pop();
|
||||
|
||||
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) {
|
||||
ServerChunkCache chunkSource = this.getChunkSource();
|
||||
if (!skipSave) {
|
||||
@@ -536,7 +529,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (progress != null) {
|
||||
progress.progressStartNoAbort(Component.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -804,11 +1043,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -826,11 +_,19 @@
|
||||
this.entityManager.autoSave();
|
||||
}
|
||||
}
|
||||
@@ -557,7 +550,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage();
|
||||
@@ -873,18 +1120,40 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -895,18 +_,40 @@
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -675,14 +668,15 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
|
||||
public void removePlayerImmediately(ServerPlayer player, Entity.RemovalReason reason) {
|
||||
- player.remove(reason);
|
||||
- }
|
||||
+ player.remove(reason, null); // CraftBukkit - add Bukkit remove cause
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean strikeLightning(Entity entitylightning) {
|
||||
+ return this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ 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);
|
||||
+
|
||||
@@ -693,7 +687,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
+ return this.addFreshEntity(entitylightning);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public void destroyBlockProgress(int breakerId, BlockPos pos, int progress) {
|
||||
+ // CraftBukkit start
|
||||
@@ -725,7 +719,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (d * d + d1 * d1 + d2 * d2 < 1024.0) {
|
||||
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.getY(),
|
||||
pos.getZ(),
|
||||
@@ -734,7 +728,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
this.dimension(),
|
||||
new ClientboundLevelEventPacket(type, pos, data, false)
|
||||
);
|
||||
@@ -1027,6 +1375,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1049,6 +_,11 @@
|
||||
|
||||
@Override
|
||||
public void gameEvent(Holder<GameEvent> gameEvent, Vec3 pos, GameEvent.Context context) {
|
||||
@@ -746,7 +740,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
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.pathTypesByPosCache.invalidate(pos);
|
||||
@@ -775,7 +769,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
|
||||
try {
|
||||
this.isUpdatingNavigations = true;
|
||||
@@ -1061,15 +1425,23 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1083,15 +_,23 @@
|
||||
this.isUpdatingNavigations = false;
|
||||
}
|
||||
}
|
||||
@@ -799,7 +793,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation);
|
||||
}
|
||||
|
||||
@@ -1118,6 +1490,42 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1140,6 +_,42 @@
|
||||
ParticleOptions largeExplosionParticles,
|
||||
Holder<SoundEvent> explosionSound
|
||||
) {
|
||||
@@ -842,7 +836,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) {
|
||||
case NONE -> Explosion.BlockInteraction.KEEP;
|
||||
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;
|
||||
case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
|
||||
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
@@ -860,7 +854,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -869,7 +863,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
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(
|
||||
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(
|
||||
@@ -1224,13 +1641,49 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1246,13 +_,49 @@
|
||||
double zOffset,
|
||||
double speed
|
||||
) {
|
||||
@@ -930,7 +924,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) {
|
||||
i++;
|
||||
}
|
||||
@@ -1293,7 +1746,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1315,7 +_,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipExistingChunks) {
|
||||
@@ -939,7 +933,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
return null;
|
||||
} else {
|
||||
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
|
||||
@Override
|
||||
public MapItemSavedData getMapData(MapId mapId) {
|
||||
@@ -977,7 +971,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
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();
|
||||
float spawnAngle = this.levelData.getSpawnAngle();
|
||||
if (!spawnPos.equals(pos) || spawnAngle != angle) {
|
||||
@@ -1007,7 +1001,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
this.lastSpawnChunkRadius = i;
|
||||
@@ -1400,6 +1889,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1422,6 +_,11 @@
|
||||
DebugPackets.sendPoiRemovedPacket(this, blockPos);
|
||||
}));
|
||||
optional1.ifPresent(holder -> this.getServer().execute(() -> {
|
||||
@@ -1019,7 +1013,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
this.getPoiManager().add(blockPos, (Holder<PoiType>)holder);
|
||||
DebugPackets.sendPoiAddedPacket(this, blockPos);
|
||||
}));
|
||||
@@ -1552,12 +2046,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1574,12 +_,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -1034,7 +1028,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1608,6 +2102,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1630,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntities() {
|
||||
@@ -1042,7 +1036,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
return this.entityManager.getEntityGetter();
|
||||
}
|
||||
|
||||
@@ -1697,6 +2192,28 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1736,6 +_,28 @@
|
||||
return this.serverLevelData.getGameRules();
|
||||
}
|
||||
|
||||
@@ -1071,15 +1065,15 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
@Override
|
||||
public CrashReportCategory fillReportDetails(CrashReport report) {
|
||||
CrashReportCategory crashReportCategory = super.fillReportDetails(report);
|
||||
@@ -1712,6 +2229,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
final class EntityCallbacks implements LevelCallback<Entity> {
|
||||
@Override
|
||||
public void onCreated(Entity entity) {
|
||||
@@ -1754,6 +_,7 @@
|
||||
if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) {
|
||||
ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter);
|
||||
}
|
||||
+ entity.setOldPosAndRot(); // Paper - update old pos / rot for new entities as it will default to Vec3.ZERO
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1721,24 +2239,32 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1767,17 +_,25 @@
|
||||
|
||||
@Override
|
||||
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
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
ServerLevel.this.players.add(serverPlayer);
|
||||
ServerLevel.this.updateSleepingPlayerList();
|
||||
if (serverPlayer.isReceivingWaypoints()) {
|
||||
@@ -1792,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (entity instanceof Mob mob) {
|
||||
@@ -1114,7 +1109,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
String string = "onTrackingStart called during navigation iteration";
|
||||
Util.logAndPauseIfInIde(
|
||||
"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);
|
||||
@@ -1167,7 +1162,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer 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) {
|
||||
@@ -1176,7 +1171,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
String string = "onTrackingStart called during navigation iteration";
|
||||
Util.logAndPauseIfInIde(
|
||||
"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);
|
||||
@@ -1192,7 +1187,7 @@ index 52092ab5a57968e3ce37d996d522975d162b001f..81c615d00323bdf86bdb76db17bb4728
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1790,4 +2367,24 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -1845,4 +_,24 @@
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
|
||||
}
|
||||
}
|
@@ -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
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -65,7 +65,6 @@ import net.minecraft.network.protocol.game.ClientboundHorseScreenOpenPacket;
|
||||
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 {
|
||||
@@ -245,7 +_,8 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance = 2;
|
||||
@@ -26,7 +10,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
@Nullable
|
||||
private Vec3 startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -281,6 +281,13 @@ public class ServerPlayer extends Player {
|
||||
@@ -291,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +24,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
@Override
|
||||
public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack 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
|
||||
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) {
|
||||
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 ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
|
||||
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile);
|
||||
@@ -356,16 +423,22 @@ public class ServerPlayer extends Player {
|
||||
super(level, gameProfile);
|
||||
@@ -366,15 +_,21 @@
|
||||
this.server = server;
|
||||
this.stats = server.getPlayerList().getPlayerStats(this);
|
||||
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
|
||||
- this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
|
||||
- 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.object = null;
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ this.displayName = this.getScoreboardName();
|
||||
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,22 +125,22 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
int max = Math.max(0, this.server.getSpawnRadius(level));
|
||||
int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ()));
|
||||
if (floor < max) {
|
||||
@@ -436,6 +509,7 @@ public class ServerPlayer extends Player {
|
||||
this.enteredNetherPosition = compound.read("entered_nether_pos", Vec3.CODEC).orElse(null);
|
||||
this.seenCredits = compound.getBooleanOr("seenCredits", false);
|
||||
this.recipeBook.fromNbt(compound.getCompoundOrEmpty("recipeBook"), key -> this.server.getRecipeManager().byKey(key).isPresent());
|
||||
+ this.getBukkitEntity().readExtraData(compound); // CraftBukkit
|
||||
@@ -446,6 +_,7 @@
|
||||
this.seenCredits = input.getBooleanOr("seenCredits", false);
|
||||
input.read("recipeBook", ServerRecipeBook.Packed.CODEC)
|
||||
.ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent()));
|
||||
+ this.getBukkitEntity().readExtraData(input); // CraftBukkit
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleeping();
|
||||
}
|
||||
@@ -459,12 +533,24 @@ public class ServerPlayer extends Player {
|
||||
compound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
compound.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition);
|
||||
this.saveEnderPearls(compound);
|
||||
+ this.getBukkitEntity().setExtraData(compound); // CraftBukkit
|
||||
@@ -469,12 +_,24 @@
|
||||
output.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
output.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition);
|
||||
this.saveEnderPearls(output);
|
||||
+ this.getBukkitEntity().setExtraData(output); // CraftBukkit
|
||||
}
|
||||
|
||||
private void saveParentVehicle(CompoundTag tag) {
|
||||
private void saveParentVehicle(ValueOutput output) {
|
||||
Entity rootVehicle = this.getRootVehicle();
|
||||
Entity vehicle = this.getVehicle();
|
||||
- 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
|
||||
+ // CraftBukkit end
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
CompoundTag compoundTag1 = new CompoundTag();
|
||||
rootVehicle.save(compoundTag1);
|
||||
@@ -479,7 +565,7 @@ public class ServerPlayer extends Player {
|
||||
if (!compound.isEmpty()) {
|
||||
ServerLevel serverLevel = this.serverLevel();
|
||||
ValueOutput valueOutput = output.child("RootVehicle");
|
||||
valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID());
|
||||
rootVehicle.save(valueOutput.child("Entity"));
|
||||
@@ -486,7 +_,7 @@
|
||||
if (!optional.isEmpty()) {
|
||||
ServerLevel serverLevel = this.level();
|
||||
Entity entity = EntityType.loadEntityRecursive(
|
||||
- compound.get().getCompoundOrEmpty("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) ? null : entity2
|
||||
+ 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) {
|
||||
UUID uuid = compound.get().read("Attach", UUIDUtil.CODEC).orElse(null);
|
||||
@@ -496,10 +582,10 @@ public class ServerPlayer extends Player {
|
||||
UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null);
|
||||
@@ -503,10 +_,10 @@
|
||||
|
||||
if (!this.isPassenger()) {
|
||||
LOGGER.warn("Couldn't reattach entity to player");
|
||||
@@ -199,15 +181,15 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,6 +597,7 @@ public class ServerPlayer extends Player {
|
||||
ListTag listTag = new ListTag();
|
||||
@@ -518,6 +_,7 @@
|
||||
ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls");
|
||||
|
||||
for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) {
|
||||
+ if (thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) continue; // Paper - Allow using old ender pearl behavior
|
||||
if (thrownEnderpearl.isRemoved()) {
|
||||
LOGGER.warn("Trying to save removed ender pearl, skipping");
|
||||
} 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) {
|
||||
float f = this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -603,6 +700,11 @@ public class ServerPlayer extends Player {
|
||||
@@ -607,6 +_,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -236,7 +218,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
@@ -610,9 +712,14 @@ public class ServerPlayer extends Player {
|
||||
@@ -614,9 +_,14 @@
|
||||
this.invulnerableTime--;
|
||||
}
|
||||
|
||||
@@ -254,7 +236,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
|
||||
@@ -662,7 +769,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -675,7 +_,7 @@
|
||||
|
||||
public void doTick() {
|
||||
try {
|
||||
@@ -263,7 +245,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@@ -676,7 +783,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -689,7 +_,7 @@
|
||||
if (this.getHealth() != this.lastSentHealth
|
||||
|| this.lastSentFood != this.foodData.getFoodLevel()
|
||||
|| this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@@ -272,7 +254,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -285,7 +267,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
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) {
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
@@ -307,8 +289,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
} catch (Throwable var4) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked");
|
||||
@@ -744,7 +872,7 @@ public class ServerPlayer extends Player {
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
@@ -757,7 +_,7 @@
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (this.tickCount % 20 == 0) {
|
||||
if (this.getHealth() < this.getMaxHealth()) {
|
||||
- this.heal(1.0F);
|
||||
@@ -316,20 +298,22 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
float saturationLevel = this.foodData.getSaturationLevel();
|
||||
@@ -793,15 +921,36 @@ public class ServerPlayer extends Player {
|
||||
@@ -806,15 +_,36 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(ObjectiveCriteria criteria, int 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
|
||||
- public void die(DamageSource cause) {
|
||||
- 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) {
|
||||
- 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
|
||||
+ private static boolean shouldKeepDeathEventItem(
|
||||
+ final org.bukkit.event.entity.PlayerDeathEvent event,
|
||||
@@ -360,7 +344,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.connection
|
||||
.send(
|
||||
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
|
||||
+ public void die(DamageSource cause) {
|
||||
+ // 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
|
||||
+ if (this.isRemoved()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ 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) {
|
||||
+ for (ItemStack item : this.getInventory().getContents()) {
|
||||
+ 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)
|
||||
+ 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.
|
||||
+ loot.addAll(this.drops);
|
||||
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
|
||||
@@ -426,7 +410,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
Team team = this.getTeam();
|
||||
if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) {
|
||||
this.server.getPlayerList().broadcastSystemMessage(deathMessage, false);
|
||||
@@ -827,7 +1035,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -840,7 +_,7 @@
|
||||
this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage);
|
||||
}
|
||||
} else {
|
||||
@@ -435,14 +419,14 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
this.removeEntitiesOnShoulder();
|
||||
@@ -835,11 +1043,35 @@ public class ServerPlayer extends Player {
|
||||
@@ -848,11 +_,35 @@
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
|
||||
- if (!this.isSpectator()) {
|
||||
- this.dropAllDeathLoot(this.serverLevel(), cause);
|
||||
- this.dropAllDeathLoot(this.level(), cause);
|
||||
+ // 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.
|
||||
+ if (!event.getKeepInventory()) {
|
||||
+ // Paper start - PlayerDeathEvent#getItemsToKeep
|
||||
@@ -474,7 +458,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
LivingEntity killCredit = this.getKillCredit();
|
||||
if (killCredit != null) {
|
||||
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) {
|
||||
if (entity != this) {
|
||||
super.awardKillScore(entity, damageSource);
|
||||
@@ -487,7 +471,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
} else {
|
||||
this.awardStat(Stats.MOB_KILLS);
|
||||
}
|
||||
@@ -891,7 +1123,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -904,7 +_,7 @@
|
||||
if (playersTeam != null) {
|
||||
int id = playersTeam.getColor().getId();
|
||||
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;
|
||||
} else {
|
||||
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() {
|
||||
@@ -552,6 +536,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
} else {
|
||||
- return new TeleportTransition(this.server.overworld(), this, postTeleportTransition);
|
||||
- }
|
||||
+ teleportTransition = new TeleportTransition(this.server.overworld(), this, postTeleportTransition); // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit start
|
||||
@@ -581,7 +566,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
+ // Spigot start
|
||||
+ if (this.connection.isDisconnected()) {
|
||||
+ return null;
|
||||
}
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
@@ -601,8 +586,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(
|
||||
@@ -947,10 +1244,10 @@ public class ServerPlayer extends Player {
|
||||
public boolean isReceivingWaypoints() {
|
||||
@@ -978,10 +_,10 @@
|
||||
level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3);
|
||||
}
|
||||
|
||||
@@ -615,7 +600,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
} else if (!flag) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -958,7 +1255,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -989,7 +_,7 @@
|
||||
BlockState blockState1 = level.getBlockState(blockPos.above());
|
||||
boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1);
|
||||
return isPossibleToRespawnInThis && isPossibleToRespawnInThis1
|
||||
@@ -624,7 +609,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
: Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -976,6 +1273,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1007,6 +_,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public ServerPlayer teleport(TeleportTransition teleportTransition) {
|
||||
@@ -632,10 +617,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -985,17 +1283,52 @@ public class ServerPlayer extends Player {
|
||||
@@ -1016,17 +_,52 @@
|
||||
|
||||
ServerLevel level = teleportTransition.newLevel();
|
||||
ServerLevel serverLevel = this.serverLevel();
|
||||
ServerLevel serverLevel = this.level();
|
||||
- ResourceKey<Level> resourceKey = serverLevel.dimension();
|
||||
+ // CraftBukkit start
|
||||
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> resourceKey = serverLevel.getTypeKey();
|
||||
@@ -688,7 +673,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.isChangingDimension = true;
|
||||
LevelData levelData = level.getLevelData();
|
||||
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);
|
||||
serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
@@ -721,12 +706,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.connection.resetPosition();
|
||||
level.addDuringTeleport(this);
|
||||
profilerFiller.pop();
|
||||
@@ -1027,11 +1374,40 @@ public class ServerPlayer extends Player {
|
||||
this.lastSentExp = -1;
|
||||
@@ -1059,10 +_,37 @@
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
+
|
||||
+
|
||||
this.teleportSpectators(teleportTransition, serverLevel);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent);
|
||||
@@ -740,7 +723,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public @Nullable org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent(
|
||||
@@ -758,11 +741,10 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
+ return new org.bukkit.craftbukkit.event.CraftPortalEvent(event);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public void forceSetRotation(float yRot, float xRot) {
|
||||
this.connection.send(new ClientboundPlayerRotationPacket(yRot, xRot));
|
||||
@@ -1040,12 +1416,26 @@ public class ServerPlayer extends Player {
|
||||
@@ -1072,12 +_,26 @@
|
||||
public void triggerDimensionChangeTriggers(ServerLevel level) {
|
||||
ResourceKey<Level> resourceKey = level.dimension();
|
||||
ResourceKey<Level> resourceKey1 = this.level().dimension();
|
||||
@@ -792,7 +774,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
}
|
||||
@@ -1061,19 +1451,18 @@ public class ServerPlayer extends Player {
|
||||
@@ -1093,19 +_,18 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -816,7 +798,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (this.level().isBrightOutside()) {
|
||||
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
|
||||
} 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);
|
||||
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1128,21 +1544,29 @@ public class ServerPlayer extends Player {
|
||||
@@ -1160,21 +_,29 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) {
|
||||
@@ -865,7 +847,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
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);
|
||||
@@ -885,8 +867,8 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1185,8 +1609,9 @@ public class ServerPlayer extends Player {
|
||||
this.connection.send(new ClientboundOpenSignEditorPacket(signEntity.getBlockPos(), isFrontText));
|
||||
@@ -1222,8 +_,9 @@
|
||||
this.connection.send(new ClientboundShowDialogPacket(dialog));
|
||||
}
|
||||
|
||||
- public void nextContainerCounter() {
|
||||
@@ -896,7 +878,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1194,12 +1619,39 @@ public class ServerPlayer extends Player {
|
||||
@@ -1231,12 +_,39 @@
|
||||
if (menu == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -937,7 +919,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (abstractContainerMenu == null) {
|
||||
if (this.isSpectator()) {
|
||||
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();
|
||||
} else {
|
||||
@@ -954,7 +936,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1223,14 +1679,25 @@ public class ServerPlayer extends Player {
|
||||
@@ -1260,14 +_,25 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(AbstractHorse horse, Container inventory) {
|
||||
@@ -983,7 +965,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1252,10 +1719,30 @@ public class ServerPlayer extends Player {
|
||||
@@ -1289,10 +_,30 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@@ -1014,7 +996,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
@Override
|
||||
public void doCloseContainer() {
|
||||
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);
|
||||
if (rounded > 0) {
|
||||
this.awardStat(Stats.SWIM_ONE_CM, rounded);
|
||||
@@ -1037,7 +1019,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (dy > 0.0) {
|
||||
@@ -1301,13 +1788,13 @@ public class ServerPlayer extends Player {
|
||||
@@ -1338,13 +_,13 @@
|
||||
if (rounded > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(Stats.SPRINT_ONE_CM, rounded);
|
||||
@@ -1054,7 +1036,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1347,13 +1834,13 @@ public class ServerPlayer extends Player {
|
||||
@@ -1386,13 +_,13 @@
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int amount) {
|
||||
this.stats.increment(this, stat, amount);
|
||||
@@ -1070,7 +1052,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1384,9 +1871,9 @@ public class ServerPlayer extends Player {
|
||||
@@ -1423,9 +_,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(Stats.JUMP);
|
||||
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() {
|
||||
this.disconnected = true;
|
||||
this.ejectPassengers();
|
||||
@@ -1096,7 +1078,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, false);
|
||||
}
|
||||
@@ -1410,6 +1904,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1449,6 +_,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -1104,7 +1086,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1444,12 +1939,12 @@ public class ServerPlayer extends Player {
|
||||
@@ -1483,12 +_,12 @@
|
||||
this.onUpdateAbilities();
|
||||
if (keepEverything) {
|
||||
this.getAttributes().assignBaseValues(that.getAttributes());
|
||||
@@ -1119,16 +1101,16 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
this.getInventory().replaceWith(that.getInventory());
|
||||
@@ -1460,7 +1955,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1499,7 +_,7 @@
|
||||
this.portalProcess = that.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(that.getAttributes());
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ // 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.experienceLevel = that.experienceLevel;
|
||||
@@ -1476,7 +1971,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1515,7 +_,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -1137,7 +1119,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.seenCredits = that.seenCredits;
|
||||
this.enteredNetherPosition = that.enteredNetherPosition;
|
||||
this.chunkTrackingView = that.chunkTrackingView;
|
||||
@@ -1529,7 +2024,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1568,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1146,7 +1128,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, true);
|
||||
}
|
||||
@@ -1538,7 +2033,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1577,7 +_,7 @@
|
||||
this.setCamera(this);
|
||||
}
|
||||
|
||||
@@ -1155,7 +1137,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (flag) {
|
||||
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) {
|
||||
@@ -1175,7 +1157,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
} else {
|
||||
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId()));
|
||||
if (gameMode == GameType.SPECTATOR) {
|
||||
@@ -1593,7 +2096,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -1633,7 +_,7 @@
|
||||
|
||||
this.onUpdateAbilities();
|
||||
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) {
|
||||
@@ -1199,7 +1181,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,7 +2169,42 @@ public class ServerPlayer extends Player {
|
||||
@@ -1701,7 +_,42 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientInformation) {
|
||||
@@ -1242,7 +1224,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
this.requestedViewDistance = clientInformation.viewDistance();
|
||||
this.chatVisibility = clientInformation.chatVisibility();
|
||||
this.canChatColor = clientInformation.chatColors();
|
||||
@@ -1747,8 +2290,23 @@ public class ServerPlayer extends Player {
|
||||
@@ -1787,8 +_,23 @@
|
||||
Entity camera = this.getCamera();
|
||||
this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate);
|
||||
if (camera != this.camera) {
|
||||
@@ -1267,7 +1249,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
if (entityToSpectate != null) {
|
||||
@@ -1782,11 +2340,11 @@ public class ServerPlayer extends Player {
|
||||
@@ -1822,11 +_,11 @@
|
||||
|
||||
@Nullable
|
||||
public Component getTabListDisplayName() {
|
||||
@@ -1281,7 +1263,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1817,11 +2375,56 @@ public class ServerPlayer extends Player {
|
||||
@@ -1857,11 +_,56 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) {
|
||||
@@ -1340,7 +1322,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
}
|
||||
|
||||
public SectionPos getLastSectionPos() {
|
||||
@@ -1851,16 +2454,23 @@ public class ServerPlayer extends Player {
|
||||
@@ -1891,16 +_,23 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1368,24 +1350,24 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
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
|
||||
+ 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()) {
|
||||
+ this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE);
|
||||
+ } else {
|
||||
+ this.gameMode.setGameModeForPlayer(readPlayerMode(tag,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType"));
|
||||
+ this.gameMode.setGameModeForPlayer(readPlayerMode(input,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType"));
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Expand PlayerGameModeChangeEvent
|
||||
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
|
||||
public void removeVehicle() {
|
||||
@@ -1401,7 +1383,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
if (vehicle instanceof LivingEntity livingEntity) {
|
||||
for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) {
|
||||
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) {
|
||||
@@ -1410,7 +1392,7 @@ index 62cd0d7f900130806c007ffba1bc95367725e991..57af8cd7629fa14176c6e7a29956617e
|
||||
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) {
|
||||
@@ -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);
|
||||
}
|
||||
}
|
@@ -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
|
||||
+++ 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;
|
||||
@Nullable
|
||||
public EntityReference<LivingEntity> owner;
|
||||
@@ -16,7 +8,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
|
||||
protected AbstractHorse(EntityType<? extends AbstractHorse> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -250,7 +251,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -252,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,7 +17,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
return !this.isVehicle();
|
||||
}
|
||||
|
||||
@@ -301,7 +302,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -303,7 +_,7 @@
|
||||
|
||||
public void createInventory() {
|
||||
SimpleContainer simpleContainer = this.inventory;
|
||||
@@ -34,7 +26,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
if (simpleContainer != null) {
|
||||
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() {
|
||||
@@ -43,7 +35,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -450,7 +451,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -456,7 +_,7 @@
|
||||
i1 = 5;
|
||||
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
|
||||
flag = true;
|
||||
@@ -52,7 +44,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
}
|
||||
} else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) {
|
||||
f = 10.0F;
|
||||
@@ -458,12 +459,12 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -464,12 +_,12 @@
|
||||
i1 = 10;
|
||||
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
|
||||
flag = true;
|
||||
@@ -67,7 +59,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -534,7 +535,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -540,7 +_,7 @@
|
||||
super.aiStep();
|
||||
if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) {
|
||||
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
|
||||
@@ -76,7 +68,7 @@ index 6688b21327cea13f1fc756a224e22a7fe7a07b71..7c473eea481f5e055cc70512027726f4
|
||||
}
|
||||
|
||||
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
|
||||
public InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||
if (this.isVehicle() || this.isBaby()) {
|
||||
@@ -674,6 +685,12 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
this.setFlag(16, eating);
|
||||
}
|
||||
|
||||
+ // 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");
|
||||
}
|
||||
@@ -788,6 +_,7 @@
|
||||
output.putInt("Temper", this.getTemper());
|
||||
output.putBoolean("Tame", this.isTamed());
|
||||
EntityReference.store(this.owner, output, "Owner");
|
||||
+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // Paper - max domestication
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -795,6 +813,7 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
this.setTemper(compound.getIntOr("Temper", 0));
|
||||
this.setTamed(compound.getBooleanOr("Tame", false));
|
||||
this.owner = EntityReference.readWithOldOwnerConversion(compound, "Owner", this.level());
|
||||
@@ -798,6 +_,7 @@
|
||||
this.setTemper(input.getIntOr("Temper", 0));
|
||||
this.setTamed(input.getBooleanOr("Tame", false));
|
||||
this.owner = EntityReference.readWithOldOwnerConversion(input, "Owner", this.level());
|
||||
+ this.maxDomestication = compound.getIntOr("Bukkit.MaxDomestication", this instanceof Llama ? 30 : 100); // Paper - max domestication
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -883,6 +902,17 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory
|
||||
@@ -886,6 +_,17 @@
|
||||
|
||||
@Override
|
||||
public void handleStartJump(int jumpPower) {
|
@@ -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
|
||||
+++ 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 long timeEntitySatOnShoulder;
|
||||
final Inventory inventory;
|
||||
@@ -17,7 +9,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
public final InventoryMenu inventoryMenu;
|
||||
public AbstractContainerMenu containerMenu;
|
||||
protected FoodData foodData = new FoodData();
|
||||
@@ -208,6 +208,18 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -217,6 +_,18 @@
|
||||
public Entity currentExplosionCause;
|
||||
private boolean ignoreFallDamageFromCurrentImpulse = false;
|
||||
private int currentImpulseContextResetGraceTime = 0;
|
||||
@@ -34,9 +26,9 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) {
|
||||
public Player(Level level, GameProfile gameProfile) {
|
||||
super(EntityType.PLAYER, level);
|
||||
@@ -276,6 +288,13 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -286,6 +_,13 @@
|
||||
|
||||
if (this.isSleeping()) {
|
||||
this.sleepCounter++;
|
||||
@@ -50,7 +42,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
if (this.sleepCounter > 100) {
|
||||
this.sleepCounter = 100;
|
||||
}
|
||||
@@ -293,7 +312,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -303,7 +_,7 @@
|
||||
this.updateIsUnderwater();
|
||||
super.tick();
|
||||
if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) {
|
||||
@@ -59,7 +51,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
|
||||
@@ -380,7 +399,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -390,7 +_,7 @@
|
||||
}
|
||||
|
||||
private void turtleHelmetTick() {
|
||||
@@ -68,7 +60,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
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() {
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
@@ -538,8 +569,14 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -548,8 +_,14 @@
|
||||
public void rideTick() {
|
||||
if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
|
||||
this.stopRiding();
|
||||
@@ -104,7 +96,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
super.rideTick();
|
||||
this.oBob = this.bob;
|
||||
this.bob = 0.0F;
|
||||
@@ -598,6 +635,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -608,6 +_,7 @@
|
||||
this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft());
|
||||
this.playShoulderEntityAmbientSound(this.getShoulderEntityRight());
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -841,10 +879,10 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -850,10 +_,10 @@
|
||||
if (this.isDeadOrDying()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -125,7 +117,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
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;
|
||||
float secondsToDisableBlocking = entity.getSecondsToDisableBlocking();
|
||||
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) {
|
||||
@@ -183,7 +175,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -894,7 +959,12 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -903,7 +_,12 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,7 +189,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
if (!this.isInvulnerableTo(level, damageSource)) {
|
||||
amount = this.getDamageAfterArmorAbsorb(damageSource, amount);
|
||||
amount = this.getDamageAfterMagicAbsorb(damageSource, amount);
|
||||
@@ -906,7 +976,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -915,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (var8 != 0.0F) {
|
||||
@@ -206,7 +198,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
this.getCombatTracker().recordDamage(damageSource, var8);
|
||||
this.setHealth(this.getHealth() - var8);
|
||||
if (var8 < 3.4028235E37F) {
|
||||
@@ -916,6 +986,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -925,6 +_,7 @@
|
||||
this.gameEvent(GameEvent.ENTITY_DAMAGE);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +206,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
public boolean isTextFilteringEnabled() {
|
||||
@@ -997,13 +1068,19 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1009,13 +_,19 @@
|
||||
|
||||
@Override
|
||||
public void removeVehicle() {
|
||||
@@ -236,7 +228,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1082,8 +1159,17 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1094,8 +_,17 @@
|
||||
}
|
||||
|
||||
public void attack(Entity target) {
|
||||
@@ -256,7 +248,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
|
||||
ItemStack weaponItem = this.getWeaponItem();
|
||||
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);
|
||||
f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F;
|
||||
f1 *= attackStrengthScale;
|
||||
@@ -289,7 +281,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
flag1 = true;
|
||||
} else {
|
||||
flag1 = false;
|
||||
@@ -1118,7 +1211,9 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1130,7 +_,9 @@
|
||||
&& !this.isPassenger()
|
||||
&& target instanceof LivingEntity
|
||||
&& !this.isSprinting();
|
||||
@@ -299,7 +291,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
f *= 1.5F;
|
||||
}
|
||||
|
||||
@@ -1145,17 +1240,23 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1157,17 +_,23 @@
|
||||
if (target instanceof LivingEntity livingEntity1) {
|
||||
livingEntity1.knockback(
|
||||
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) {
|
||||
@@ -1169,42 +1270,59 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1181,42 +_,59 @@
|
||||
&& !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker())
|
||||
&& this.distanceToSqr(livingEntity2) < 9.0) {
|
||||
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
|
||||
@@ -420,7 +412,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
this.inventoryMenu.removed(this);
|
||||
if (this.containerMenu != null && this.hasContainerOpen()) {
|
||||
this.doCloseContainer();
|
||||
@@ -1355,6 +1474,12 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1367,6 +_,12 @@
|
||||
}
|
||||
|
||||
public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos bedPos) {
|
||||
@@ -433,7 +425,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
this.startSleeping(bedPos);
|
||||
this.sleepCounter = 0;
|
||||
return Either.right(Unit.INSTANCE);
|
||||
@@ -1466,7 +1591,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1478,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) {
|
||||
@@ -442,7 +434,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
return false;
|
||||
} else {
|
||||
if (fallDistance >= 2.0) {
|
||||
@@ -1507,7 +1632,15 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1519,7 +_,15 @@
|
||||
}
|
||||
|
||||
public void startFallFlying() {
|
||||
@@ -459,7 +451,7 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1613,15 +1746,35 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1625,15 +_,35 @@
|
||||
public int getXpNeededForNextLevel() {
|
||||
if (this.experienceLevel >= 30) {
|
||||
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() {
|
||||
if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
|
||||
@@ -540,24 +532,32 @@ index 5418c07c58f12de53aabe75b43ff77848769c23d..2046c4d3ad5ea3254ad6bc83e6437e5c
|
||||
+ @Nullable
|
||||
+ private Entity respawnEntityOnShoulder0(CompoundTag entityCompound) { // CraftBukkit void->boolean
|
||||
+ // Paper end - release entity api - return entity - overload
|
||||
if (!this.level().isClientSide && !entityCompound.isEmpty()) {
|
||||
- EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).ifPresent(entity -> {
|
||||
+ return EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit
|
||||
if (this.level() instanceof ServerLevel serverLevel && !entityCompound.isEmpty()) {
|
||||
try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) {
|
||||
- EntityType.create(
|
||||
+ return EntityType.create(
|
||||
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());
|
||||
- ((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
|
||||
+ }).orElse(null); // CraftBukkit // Paper end - release entity api - return entity
|
||||
+ return serverLevel.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // Paper
|
||||
+ }).orElse(null); // Paper - release entity api - return entity
|
||||
}
|
||||
}
|
||||
+ return null; // Paper - return null
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1926,17 +2108,32 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1945,17 +_,32 @@
|
||||
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++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2027,12 +2225,20 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -2046,12 +_,20 @@
|
||||
}
|
||||
|
||||
public boolean hasClientLoaded() {
|
@@ -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
|
||||
+++ 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) {
|
||||
super(entityType, level);
|
||||
@@ -153,11 +164,19 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -152,11 +_,19 @@
|
||||
|
||||
@Override
|
||||
public boolean canCollideWith(Entity entity) {
|
||||
@@ -48,7 +40,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -258,6 +277,14 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -257,6 +_,14 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -63,7 +55,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
if (this.getHurtTime() > 0) {
|
||||
this.setHurtTime(this.getHurtTime() - 1);
|
||||
}
|
||||
@@ -267,8 +294,20 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -266,8 +_,20 @@
|
||||
}
|
||||
|
||||
this.checkBelowWorld();
|
||||
@@ -85,7 +77,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
this.updateInWaterStateAndDoFluidPushing();
|
||||
if (this.isInLava()) {
|
||||
this.lavaIgnite();
|
||||
@@ -350,12 +389,16 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -356,12 +_,16 @@
|
||||
Vec3 deltaMovement = this.getDeltaMovement();
|
||||
this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed));
|
||||
if (this.onGround()) {
|
||||
@@ -104,12 +96,12 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +500,15 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.setDisplayOffset(compound.getIntOr("DisplayOffset", this.getDefaultDisplayOffset()));
|
||||
this.flipped = compound.getBooleanOr("FlippedRotation", false);
|
||||
this.firstTick = compound.getBooleanOr("HasTicked", false);
|
||||
@@ -463,6 +_,15 @@
|
||||
this.setDisplayOffset(input.getIntOr("DisplayOffset", this.getDefaultDisplayOffset()));
|
||||
this.flipped = input.getBooleanOr("FlippedRotation", false);
|
||||
this.firstTick = input.getBooleanOr("HasTicked", false);
|
||||
+ // Paper start - Friction API
|
||||
+ compound.getString("Paper.FrictionState").ifPresent(frictionState -> {
|
||||
+ input.getString("Paper.FrictionState").ifPresent(frictionState -> {
|
||||
+ try {
|
||||
+ this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState);
|
||||
+ } catch (Exception ignored) {
|
||||
@@ -120,14 +112,13 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -472,13 +524,27 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -475,13 +_,26 @@
|
||||
|
||||
compound.putBoolean("FlippedRotation", this.flipped);
|
||||
compound.putBoolean("HasTicked", this.firstTick);
|
||||
+
|
||||
output.putBoolean("FlippedRotation", this.flipped);
|
||||
output.putBoolean("HasTicked", this.firstTick);
|
||||
+ // Paper start - Friction API
|
||||
+ 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
|
||||
}
|
||||
@@ -148,7 +139,7 @@ index 4b9090c9e2804f2e2340a392e71d434992125442..99617c08cbd989092ba357d8df928786
|
||||
double d = entity.getX() - this.getX();
|
||||
double d1 = entity.getZ() - this.getZ();
|
||||
double d2 = d * d + d1 * d1;
|
||||
@@ -587,4 +653,26 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
@@ -590,4 +_,26 @@
|
||||
public boolean isFurnace() {
|
||||
return false;
|
||||
}
|
@@ -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
|
||||
+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
@@ -60,12 +60,12 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
default void addChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) {
|
||||
@@ -60,12 +_,14 @@
|
||||
default void addChestVehicleSaveData(ValueOutput output) {
|
||||
if (this.getContainerLootTable() != null) {
|
||||
tag.putString("LootTable", this.getContainerLootTable().location().toString());
|
||||
+ this.lootableData().saveNbt(tag); // Paper
|
||||
output.putString("LootTable", this.getContainerLootTable().location().toString());
|
||||
+ this.lootableData().saveNbt(output); // Paper
|
||||
if (this.getContainerLootTableSeed() != 0L) {
|
||||
tag.putLong("LootTableSeed", this.getContainerLootTableSeed());
|
||||
output.putLong("LootTableSeed", this.getContainerLootTableSeed());
|
||||
}
|
||||
- } else {
|
||||
- ContainerHelper.saveAllItems(tag, this.getItemStacks(), levelRegistry);
|
||||
} else {
|
||||
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) {
|
||||
@@ -73,7 +73,12 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
ResourceKey<LootTable> resourceKey = tag.read("LootTable", LootTable.KEY_CODEC).orElse(null);
|
||||
default void readChestVehicleSaveData(ValueInput input) {
|
||||
@@ -73,7 +_,12 @@
|
||||
ResourceKey<LootTable> resourceKey = input.read("LootTable", LootTable.KEY_CODEC).orElse(null);
|
||||
this.setContainerLootTable(resourceKey);
|
||||
this.setContainerLootTableSeed(tag.getLongOr("LootTableSeed", 0L));
|
||||
this.setContainerLootTableSeed(input.getLongOr("LootTableSeed", 0L));
|
||||
- if (resourceKey == null) {
|
||||
+ // Paper start - LootTable API
|
||||
+ if (this.getContainerLootTable() != null) {
|
||||
+ this.lootableData().loadNbt(tag);
|
||||
+ this.lootableData().loadNbt(input);
|
||||
+ }
|
||||
+ // Paper end - LootTable API
|
||||
+ 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) {
|
||||
@@ -68,7 +60,7 @@ index 498e188a4b5fa22378fe146bba689fff595575af..feebd1610ebd3c26a337259c14f5c774
|
||||
LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position());
|
||||
if (player != null) {
|
||||
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) {
|
||||
return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0);
|
||||
}
|
@@ -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);
|
@@ -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
|
||||
+++ b/net/minecraft/world/level/GameRules.java
|
||||
@@ -34,6 +34,14 @@ import net.minecraft.world.flag.FeatureFlags;
|
||||
@@ -35,6 +_,14 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class GameRules {
|
||||
@@ -23,7 +15,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
public static final int DEFAULT_RANDOM_TICK_SPEED = 3;
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
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)
|
||||
);
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_REDUCEDDEBUGINFO = register(
|
||||
@@ -36,7 +28,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
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)
|
||||
);
|
||||
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));
|
||||
}
|
||||
})
|
||||
@@ -138,8 +146,8 @@ public class GameRules {
|
||||
@@ -139,8 +_,8 @@
|
||||
"doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true)
|
||||
);
|
||||
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));
|
||||
}
|
||||
})
|
||||
@@ -210,11 +218,11 @@ public class GameRules {
|
||||
@@ -211,11 +_,11 @@
|
||||
public static final GameRules.Key<GameRules.IntegerValue> RULE_MINECART_MAX_SPEED = register(
|
||||
"minecartMaxSpeed",
|
||||
GameRules.Category.MISC,
|
||||
@@ -73,7 +65,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
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 FeatureFlagSet enabledFeatures;
|
||||
@@ -81,7 +73,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
|
||||
public static <T extends GameRules.Value<T>> GameRules.Type<T> getType(GameRules.Key<T> 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) {
|
||||
this.rules = rules;
|
||||
this.enabledFeatures = enabledFeatures;
|
||||
@@ -104,7 +96,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Tried to access invalid game rule");
|
||||
} 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) {
|
||||
@@ -334,7 +354,7 @@ public class GameRules {
|
||||
public static class BooleanValue extends GameRules.Value<GameRules.BooleanValue> {
|
||||
@@ -346,7 +_,7 @@
|
||||
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<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<>(
|
||||
BoolArgumentType::bool,
|
||||
type -> new GameRules.BooleanValue(type, defaultValue),
|
||||
@@ -355,17 +375,21 @@ public class GameRules {
|
||||
@@ -379,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +158,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -394,9 +418,9 @@ public class GameRules {
|
||||
@@ -418,9 +_,9 @@
|
||||
}
|
||||
|
||||
@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> {
|
||||
private int value;
|
||||
|
||||
@@ -178,7 +179,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
return new GameRules.Type<>(
|
||||
IntegerArgumentType::integer,
|
||||
type -> new GameRules.IntegerValue(type, defaultValue),
|
||||
@@ -446,7 +470,7 @@ public class GameRules {
|
||||
@@ -470,7 +_,7 @@
|
||||
}
|
||||
|
||||
static GameRules.Type<GameRules.IntegerValue> create(
|
||||
@@ -187,7 +188,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
) {
|
||||
return new GameRules.Type<>(
|
||||
() -> IntegerArgumentType.integer(min, max),
|
||||
@@ -468,17 +492,21 @@ public class GameRules {
|
||||
@@ -492,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +214,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -529,13 +557,17 @@ public class GameRules {
|
||||
@@ -553,13 +_,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -233,7 +234,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
|
||||
@@ -575,7 +607,7 @@ public class GameRules {
|
||||
@@ -599,7 +_,7 @@
|
||||
public static class Type<T extends GameRules.Value<T>> {
|
||||
final Supplier<ArgumentType<?>> argument;
|
||||
private final Function<GameRules.Type<T>, T> constructor;
|
||||
@@ -242,7 +243,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
private final GameRules.VisitorCaller<T> visitorCaller;
|
||||
final Class<T> valueClass;
|
||||
final FeatureFlagSet requiredFeatures;
|
||||
@@ -583,7 +615,7 @@ public class GameRules {
|
||||
@@ -607,7 +_,7 @@
|
||||
Type(
|
||||
Supplier<ArgumentType<?>> argument,
|
||||
Function<GameRules.Type<T>, T> constructor,
|
||||
@@ -251,7 +252,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
GameRules.VisitorCaller<T> visitorCaller,
|
||||
Class<T> valueClass,
|
||||
FeatureFlagSet requiredFeatures
|
||||
@@ -611,6 +643,12 @@ public class GameRules {
|
||||
@@ -635,6 +_,12 @@
|
||||
public FeatureFlagSet requiredFeatures() {
|
||||
return this.requiredFeatures;
|
||||
}
|
||||
@@ -264,7 +265,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
}
|
||||
|
||||
public abstract static class Value<T extends GameRules.Value<T>> {
|
||||
@@ -620,16 +658,16 @@ public class GameRules {
|
||||
@@ -644,16 +_,16 @@
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -288,7 +289,7 @@ index cd6b2cd0bba4fd9be4b37745f4beabee8b87505f..02bc5d83b92a594ec519f0a02b0517fd
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,7 +686,7 @@ public class GameRules {
|
||||
@@ -672,7 +_,7 @@
|
||||
|
||||
protected abstract T copy();
|
||||
|
@@ -1,5 +1,7 @@
|
||||
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.type.DurationOrDisabled;
|
||||
import java.util.HashMap;
|
||||
@@ -14,6 +16,8 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.RandomizableContainer;
|
||||
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.checkerframework.checker.nullness.qual.NonNull;
|
||||
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 LOOTED_PLAYERS = "lootedPlayers";
|
||||
|
||||
public void loadNbt(final CompoundTag base) {
|
||||
final Optional<CompoundTag> compOpt = base.getCompound(ROOT);
|
||||
public void loadNbt(final ValueInput base) {
|
||||
final Optional<ValueInput> compOpt = base.child(ROOT);
|
||||
if (compOpt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
CompoundTag comp = compOpt.get();
|
||||
final ValueInput comp = compOpt.get();
|
||||
this.lastFill = comp.getLongOr(LAST_FILL, -1);
|
||||
this.nextRefill = comp.getLongOr(NEXT_REFILL, -1);
|
||||
this.numRefills = comp.getIntOr(NUM_REFILLS, 0);
|
||||
final ListTag list = comp.getListOrEmpty(LOOTED_PLAYERS);
|
||||
final int size = list.size();
|
||||
if (size > 0) {
|
||||
this.lootedPlayers = new HashMap<>(list.size());
|
||||
}
|
||||
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));
|
||||
});
|
||||
});
|
||||
final ValueInput.TypedInputList<SerializedLootedPlayerEntry> list = comp.listOrEmpty(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
|
||||
if (!list.isEmpty()) {
|
||||
this.lootedPlayers = new HashMap<>();
|
||||
list.forEach(serializedLootedPlayerEntry -> lootedPlayers.put(serializedLootedPlayerEntry.uuid, serializedLootedPlayerEntry.time));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveNbt(final CompoundTag base) {
|
||||
final CompoundTag comp = new CompoundTag();
|
||||
public void saveNbt(final ValueOutput base) {
|
||||
final ValueOutput comp = base.child(ROOT);
|
||||
if (this.nextRefill != -1) {
|
||||
comp.putLong(NEXT_REFILL, this.nextRefill);
|
||||
}
|
||||
@@ -199,18 +196,14 @@ public class PaperLootableInventoryData {
|
||||
comp.putInt(NUM_REFILLS, this.numRefills);
|
||||
}
|
||||
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()) {
|
||||
final CompoundTag cmp = new CompoundTag();
|
||||
cmp.store("UUID", UUIDUtil.CODEC, entry.getKey());
|
||||
cmp.putLong("Time", entry.getValue());
|
||||
list.add(cmp);
|
||||
list.add(new SerializedLootedPlayerEntry(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
comp.put(LOOTED_PLAYERS, list);
|
||||
}
|
||||
|
||||
if (!comp.isEmpty()) {
|
||||
base.put(ROOT, comp);
|
||||
if (comp.isEmpty()) {
|
||||
base.discard(ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,4 +235,14 @@ public class PaperLootableInventoryData {
|
||||
@Nullable Long getLastLooted(final UUID player) {
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -139,7 +139,11 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
|
||||
|
||||
@Override
|
||||
public void setRearing(boolean rearing) {
|
||||
this.getHandle().setForceStanding(rearing);
|
||||
if (rearing) {
|
||||
this.getHandle().setStanding(Integer.MAX_VALUE);
|
||||
} else {
|
||||
this.getHandle().clearStanding();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -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.MapId;
|
||||
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.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -2351,9 +2353,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
// Paper end - getLastPlayed replacement API
|
||||
|
||||
public void readExtraData(CompoundTag tag) {
|
||||
public void readExtraData(ValueInput tag) {
|
||||
this.hasPlayedBefore = true;
|
||||
tag.getCompound("bukkit").ifPresent(data -> {
|
||||
tag.child("bukkit").ifPresent(data -> {
|
||||
this.firstPlayed = data.getLongOr("firstPlayed", 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
|
||||
|
||||
if (!tag.contains("bukkit")) {
|
||||
tag.put("bukkit", new CompoundTag());
|
||||
}
|
||||
|
||||
CompoundTag data = tag.getCompoundOrEmpty("bukkit");
|
||||
ValueOutput data = tag.child("bukkit");
|
||||
ServerPlayer handle = this.getHandle();
|
||||
data.putInt("newExp", handle.newExp);
|
||||
data.putInt("newTotalExp", handle.newTotalExp);
|
||||
@@ -2385,11 +2383,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
data.putString("lastKnownName", handle.getScoreboardName());
|
||||
|
||||
// Paper start - persist for use in offline save data
|
||||
if (!tag.contains("Paper")) {
|
||||
tag.put("Paper", new CompoundTag());
|
||||
}
|
||||
|
||||
CompoundTag paper = tag.getCompoundOrEmpty("Paper");
|
||||
ValueOutput paper = tag.child("Paper");
|
||||
paper.putLong("LastLogin", handle.loginTime);
|
||||
paper.putLong("LastSeen", System.currentTimeMillis());
|
||||
// Paper end
|
||||
|
Reference in New Issue
Block a user