readd beacon effect cause

This commit is contained in:
Lulu13022002 2024-12-18 19:09:46 +01:00
parent dedc6b3394
commit 6126012369
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01
102 changed files with 443 additions and 488 deletions

View file

@ -28,7 +28,7 @@ and then catch exceptions and close if they fire.
Part of this commit was authored by: Spottedleaf, sandtechnology Part of this commit was authored by: Spottedleaf, sandtechnology
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc9924666634488044c666fd1 100644 index 18f25bc6ada79fd51eb7522a917236299616a371..1672bd0eeea8db44016bbbccf9a332c7f45fdb54 100644
--- a/net/minecraft/network/Connection.java --- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java
@@ -85,7 +85,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -85,7 +85,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -39,7 +39,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
+ private final Queue<WrappedConsumer> pendingActions = Queues.newConcurrentLinkedQueue(); // Paper - Optimize network + private final Queue<WrappedConsumer> pendingActions = Queues.newConcurrentLinkedQueue(); // Paper - Optimize network
public Channel channel; public Channel channel;
public SocketAddress address; public SocketAddress address;
// Spigot Start // Spigot start
@@ -145,6 +145,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -145,6 +145,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
// Paper end - packet limiter // Paper end - packet limiter
@ -51,7 +51,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
public Connection(PacketFlow receiving) { public Connection(PacketFlow receiving) {
this.receiving = receiving; this.receiving = receiving;
@@ -425,11 +429,38 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -423,11 +427,38 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
public void send(Packet<?> packet, @Nullable PacketSendListener listener, boolean flush) { public void send(Packet<?> packet, @Nullable PacketSendListener listener, boolean flush) {
@ -93,7 +93,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
} }
} }
@@ -438,7 +469,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -436,7 +467,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.flushQueue(); this.flushQueue();
action.accept(this); action.accept(this);
} else { } else {
@ -102,7 +102,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
} }
} }
@@ -452,6 +483,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -450,6 +481,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener sendListener, boolean flush) { private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener sendListener, boolean flush) {
@ -117,7 +117,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
ChannelFuture channelFuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); ChannelFuture channelFuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet);
if (sendListener != null) { if (sendListener != null) {
channelFuture.addListener(future -> { channelFuture.addListener(future -> {
@@ -467,14 +506,24 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -465,14 +504,24 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}); });
} }
@ -143,7 +143,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
} }
} }
@@ -486,16 +535,57 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -484,16 +533,57 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
} }
@ -206,15 +206,15 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world
private static int joinAttemptsThisTick; // Paper - Buffer joins to world private static int joinAttemptsThisTick; // Paper - Buffer joins to world
@@ -561,6 +651,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -557,6 +647,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
// Spigot Start
this.preparing = false; public void disconnect(DisconnectionDetails disconnectionDetails) {
// Spigot End this.preparing = false; // Spigot
+ this.clearPacketQueue(); // Paper - Optimize network + this.clearPacketQueue(); // Paper - Optimize network
if (this.channel == null) { if (this.channel == null) {
this.delayedDisconnect = disconnectionDetails; this.delayedDisconnect = disconnectionDetails;
} }
@@ -749,7 +840,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -745,7 +836,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void handleDisconnection() { public void handleDisconnection() {
if (this.channel != null && !this.channel.isOpen()) { if (this.channel != null && !this.channel.isOpen()) {
if (this.disconnectionHandled) { if (this.disconnectionHandled) {
@ -223,7 +223,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
} else { } else {
this.disconnectionHandled = true; this.disconnectionHandled = true;
PacketListener packetListener = this.getPacketListener(); PacketListener packetListener = this.getPacketListener();
@@ -760,7 +851,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -756,7 +847,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
); );
packetListener1.onDisconnect(disconnectionDetails); packetListener1.onDisconnect(disconnectionDetails);
} }
@ -232,7 +232,7 @@ index b624f001ba9d98c4dc68fcd66c0bc2de0a12308c..c4bb28857ee11dccc992466663448804
// Paper start - Add PlayerConnectionCloseEvent // Paper start - Add PlayerConnectionCloseEvent
if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) {
/* Player was logged in, either game listener or configuration listener */ /* Player was logged in, either game listener or configuration listener */
@@ -795,4 +886,93 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -791,4 +882,93 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void setBandwidthLogger(LocalSampleLogger bandwithLogger) { public void setBandwidthLogger(LocalSampleLogger bandwithLogger) {
this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwithLogger); this.bandwidthDebugMonitor = new BandwidthDebugMonitor(bandwithLogger);
} }

View file

@ -338,7 +338,7 @@ index 0000000000000000000000000000000000000000..bd888ef719b9bfc93bace0b1d0fb771a
+ } + }
+} +}
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 9bbcafa8e70f95d5ab6318211a0265acbfc76b1c..f8f145cd9614f7e38d6aa72501fe31837340a8bb 100644 index 8569f0670c13e3f635ef529f00e636bf7bca38b5..76e59a8b07ac58a38f368386e03aaa3d8586e21d 100644
--- a/net/minecraft/server/level/ChunkMap.java --- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java
@@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList; @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList;
@ -366,7 +366,7 @@ index 9bbcafa8e70f95d5ab6318211a0265acbfc76b1c..f8f145cd9614f7e38d6aa72501fe3183
import org.slf4j.Logger; import org.slf4j.Logger;
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index cce78d73e8adafd66d0f3ffb3fabb5e6c025c7df..a4b523ac1926895ccc87464892fa81753ae8f73c 100644 index 2e479c02794de1eb9753b6f1e59afc2d9d6981ba..7702004b68b7735043914f93b54b4413cd21ba41 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -551,6 +551,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -551,6 +551,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -472,10 +472,10 @@ index b4a1202a9f43525caf215d2f5c86ad92ea4f6de7..47db6ac3ef23fd0da127cfb5a4d3ba9e
public void tick() { public void tick() {
super.tick(); super.tick();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 020d05bb60abec10fa37e651c17f600c883af61d..2e5f1dc15ea6a20f8cbdef97ecbf00e5d56603cf 100644 index 61b779fc48d88a2ba0cb7c289e7c031877bac61b..32ca912230a5999ea244cdf1c5c54855844f571b 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -386,6 +386,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -380,6 +380,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean fixedPose = false; // Paper - Expand Pose API public boolean fixedPose = false; // Paper - Expand Pose API
private final int despawnTime; // Paper - entity despawn time limit private final int despawnTime; // Paper - entity despawn time limit
public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges
@ -491,7 +491,7 @@ index 020d05bb60abec10fa37e651c17f600c883af61d..2e5f1dc15ea6a20f8cbdef97ecbf00e5
public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) { public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) {
this.origin = location.toVector(); this.origin = location.toVector();
@@ -423,6 +432,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -417,6 +426,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.position = Vec3.ZERO; this.position = Vec3.ZERO;
this.blockPosition = BlockPos.ZERO; this.blockPosition = BlockPos.ZERO;
this.chunkPosition = ChunkPos.ZERO; this.chunkPosition = ChunkPos.ZERO;
@ -529,7 +529,7 @@ index 020d05bb60abec10fa37e651c17f600c883af61d..2e5f1dc15ea6a20f8cbdef97ecbf00e5
movement = this.maybeBackOffFromEdge(movement, type); movement = this.maybeBackOffFromEdge(movement, type);
Vec3 vec3 = this.collide(movement); Vec3 vec3 = this.collide(movement);
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 41ef8c24903e5efceead43796e647824a54193df..9de400977ec33e485e87cdf1cf145588527e1e10 100644 index fa67721bc0aa2d5b920d691f34d81d0a1feec202..c853c5ff5a9422b9a17be34102f80348ca89cad6 100644
--- a/net/minecraft/world/entity/LivingEntity.java --- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3089,6 +3089,14 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -3089,6 +3089,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
@ -647,7 +647,7 @@ index 789fea258d70e60d38271ebb31270562dc7eb3ab..d0ab3db7bbd2942db19f473474371b20
} }
} }
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
index 1c82a41acb8717b2c56498602fd1ecbe6aa58fe5..dcbd35d6bf81d7a0621020710114887b68a7dcc6 100644 index a9c7cf74174a2c998c182da149bdfeb87cca7b8d..e346edacf7705faf867430c9c44b8322a2bd9d72 100644
--- a/net/minecraft/world/entity/item/ItemEntity.java --- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -124,6 +124,29 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -124,6 +124,29 @@ public class ItemEntity extends Entity implements TraceableEntity {
@ -824,7 +824,7 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..dec705ec57e4f63ef2ccaa87c5400c11
+ +
} }
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 691fee2e2097244126f4fac0f5d00bf6916b9766..25fb8a91bd3012da383711d58cc25cbada510f56 100644 index b6342c7161c2539b316be53e72640d44ce576b79..13dbd0da80b2199519370ac6e993ace53f42c1ea 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -153,6 +153,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -153,6 +153,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray
diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java
index 0eba4fce940b90e67f3746480c040178ba9f5525..3bdbd3d566dee767204d898e0bb4f82f0060d9ca 100644 index 1e5d94cdcdffb4d2940f17bacdf0e6a488e84318..d3aebc7f833764351c8e5fe1fad1aa2f8718ca37 100644
--- a/io/papermc/paper/FeatureHooks.java --- a/io/papermc/paper/FeatureHooks.java
+++ b/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java
@@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.longs.LongSets; @@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.longs.LongSets;
@ -153,7 +153,7 @@ index 3a384175f8e7f204234bbaf3081bdc20c47a0d4b..5699bc15eba92e22433a20cb8326b59f
private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buffer) { private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buffer) {
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index a4b523ac1926895ccc87464892fa81753ae8f73c..ca9427a7eae9a66f4f1ccedda7b1def7ac2a88da 100644 index 7702004b68b7735043914f93b54b4413cd21ba41..4d20bda4cba578c47216d450c99389b744a59008 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -348,7 +348,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -348,7 +348,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -166,7 +166,7 @@ index a4b523ac1926895ccc87464892fa81753ae8f73c..ca9427a7eae9a66f4f1ccedda7b1def7
this.levelStorageAccess = levelStorageAccess; this.levelStorageAccess = levelStorageAccess;
this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()); this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile());
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
index 732a4f20bade67c57a4f85142849752b72e349ee..6176f0738aa1a18df5d7d4d49fd6961e3f2eb736 100644 index d7028ed8ebdecd647467b67f62f7431a6df59f76..9fdb825be2b04a5806bbb3d39948bad0863e7ae5 100644
--- a/net/minecraft/server/level/ServerPlayerGameMode.java --- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -312,6 +312,7 @@ public class ServerPlayerGameMode { @@ -312,6 +312,7 @@ public class ServerPlayerGameMode {
@ -196,7 +196,7 @@ index 342bc843c384761e883de861044f4f8930ae8763..14878690a88fd4de3e2c127086607e6c
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent(); new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent();
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 2580b249d9a024400e295ca5beab551b3571ceb3..d227714de0fe13544779fae6cf0e9ff6af5469c7 100644 index 8a93d1034eb0dab4b4010d52ddbb0caa5697416d..bafeeab3edbc73f6f86474e18ab4a3d96ce17157 100644
--- a/net/minecraft/server/players/PlayerList.java --- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java
@@ -404,7 +404,7 @@ public abstract class PlayerList { @@ -404,7 +404,7 @@ public abstract class PlayerList {
@ -209,7 +209,7 @@ index 2580b249d9a024400e295ca5beab551b3571ceb3..d227714de0fe13544779fae6cf0e9ff6
} }
// Paper end - Send empty chunk // Paper end - Send empty chunk
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 25fb8a91bd3012da383711d58cc25cbada510f56..872c3b8826f436b15f6ab0a3619692c5202eadc3 100644 index 13dbd0da80b2199519370ac6e993ace53f42c1ea..0e4ab448755632696c4326f1df9f3855cd38a64d 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -168,6 +168,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -168,6 +168,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -247,7 +247,7 @@ index 25fb8a91bd3012da383711d58cc25cbada510f56..872c3b8826f436b15f6ab0a3619692c5
if (blockState == null) { if (blockState == null) {
// CraftBukkit start - remove blockstate if failed (or the same) // CraftBukkit start - remove blockstate if failed (or the same)
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
index 12d9b532e466ec4e46920d409b5f1b3ae60b80f8..bc688ad1097ef4159dfc5f96d963a9fa63262e20 100644 index 809b3c37d3749c76c3c243cd91c593d03693e9b3..860d1c9729c4ee97ec6f40f7aa969829070b27c0 100644
--- a/net/minecraft/world/level/chunk/ChunkAccess.java --- a/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -114,14 +114,14 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @@ -114,14 +114,14 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
@ -256,7 +256,7 @@ index 12d9b532e466ec4e46920d409b5f1b3ae60b80f8..bc688ad1097ef4159dfc5f96d963a9fa
- replaceMissingSections(biomeRegistry, this.sections); - replaceMissingSections(biomeRegistry, this.sections);
+ this.replaceMissingSections(biomeRegistry, this.sections); // Paper - Anti-Xray - make it a non-static method + this.replaceMissingSections(biomeRegistry, this.sections); // Paper - Anti-Xray - make it a non-static method
this.biomeRegistry = biomeRegistry; // Craftbukkit this.biomeRegistry = biomeRegistry; // CraftBukkit
} }
- private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sections) { - private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sections) {
@ -269,7 +269,7 @@ index 12d9b532e466ec4e46920d409b5f1b3ae60b80f8..bc688ad1097ef4159dfc5f96d963a9fa
} }
} }
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index b3cc671f33b2c8c5f3131afffc6ee9d7b83dd3bc..d1d0dc13eecb0e0eb3a7839b570a5fe7f62f3fba 100644 index 2b5d99eb6860578cc1af8fbe2571c314846984dd..bc4260623dfb1d804f41593293a5c176c86df5a1 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java --- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -109,7 +109,7 @@ public class LevelChunk extends ChunkAccess { @@ -109,7 +109,7 @@ public class LevelChunk extends ChunkAccess {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Use Velocity compression and cipher natives
diff --git a/net/minecraft/network/CipherDecoder.java b/net/minecraft/network/CipherDecoder.java diff --git a/net/minecraft/network/CipherDecoder.java b/net/minecraft/network/CipherDecoder.java
index 429325ffb7db2b85ed271ddf3da64c6fdc593673..4a445cb0ab19c6eca94fdc2172e1b286d1947c63 100644 index 429325ffb7db2b85ed271ddf3da64c6fdc593673..d764552aea825af7bbf0f47c9d88af527d9dbe62 100644
--- a/net/minecraft/network/CipherDecoder.java --- a/net/minecraft/network/CipherDecoder.java
+++ b/net/minecraft/network/CipherDecoder.java +++ b/net/minecraft/network/CipherDecoder.java
@@ -7,14 +7,30 @@ import java.util.List; @@ -7,14 +7,30 @@ import java.util.List;
@ -17,8 +17,8 @@ index 429325ffb7db2b85ed271ddf3da64c6fdc593673..4a445cb0ab19c6eca94fdc2172e1b286
- public CipherDecoder(Cipher cipher) { - public CipherDecoder(Cipher cipher) {
- this.cipher = new CipherBase(cipher); - this.cipher = new CipherBase(cipher);
+ public CipherDecoder(com.velocitypowered.natives.encryption.VelocityCipher cipher) { // Paper - Use Velocity cipher + public CipherDecoder(com.velocitypowered.natives.encryption.VelocityCipher cipher) { // Paper - Use Velocity cipher
+ this.cipher = cipher; // Paper - Use Velocity cipher + this.cipher = cipher; // Paper - Use Velocity cipher
} }
@Override @Override
@ -38,13 +38,13 @@ index 429325ffb7db2b85ed271ddf3da64c6fdc593673..4a445cb0ab19c6eca94fdc2172e1b286
+ +
+ // Paper start - Use Velocity cipher + // Paper start - Use Velocity cipher
+ @Override + @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { + public void handlerRemoved(ChannelHandlerContext ctx) {
+ this.cipher.close(); + this.cipher.close();
+ } + }
+ // Paper end - Use Velocity cipher + // Paper end - Use Velocity cipher
} }
diff --git a/net/minecraft/network/CipherEncoder.java b/net/minecraft/network/CipherEncoder.java diff --git a/net/minecraft/network/CipherEncoder.java b/net/minecraft/network/CipherEncoder.java
index 992b9c7aed57ce29cdd2b4f66737d39db214f0cf..e087a35bcaf326c37a3e58f4d06165a61747c5a9 100644 index 992b9c7aed57ce29cdd2b4f66737d39db214f0cf..b927c85923147d2b346e892a3e4deee48b3d073e 100644
--- a/net/minecraft/network/CipherEncoder.java --- a/net/minecraft/network/CipherEncoder.java
+++ b/net/minecraft/network/CipherEncoder.java +++ b/net/minecraft/network/CipherEncoder.java
@@ -5,15 +5,31 @@ import io.netty.channel.ChannelHandlerContext; @@ -5,15 +5,31 @@ import io.netty.channel.ChannelHandlerContext;
@ -58,8 +58,8 @@ index 992b9c7aed57ce29cdd2b4f66737d39db214f0cf..e087a35bcaf326c37a3e58f4d06165a6
- public CipherEncoder(Cipher cipher) { - public CipherEncoder(Cipher cipher) {
- this.cipher = new CipherBase(cipher); - this.cipher = new CipherBase(cipher);
+ public CipherEncoder(com.velocitypowered.natives.encryption.VelocityCipher cipher) { // Paper - Use Velocity cipher + public CipherEncoder(com.velocitypowered.natives.encryption.VelocityCipher cipher) { // Paper - Use Velocity cipher
+ this.cipher = cipher; // Paper - Use Velocity cipher + this.cipher = cipher; // Paper - Use Velocity cipher
} }
+ // Paper start - Use Velocity cipher + // Paper start - Use Velocity cipher
@ -80,7 +80,7 @@ index 992b9c7aed57ce29cdd2b4f66737d39db214f0cf..e087a35bcaf326c37a3e58f4d06165a6
+ +
+ // Paper start - Use Velocity cipher + // Paper start - Use Velocity cipher
+ @Override + @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { + public void handlerRemoved(ChannelHandlerContext ctx) {
+ this.cipher.close(); + this.cipher.close();
+ } + }
+ // Paper end - Use Velocity cipher + // Paper end - Use Velocity cipher
@ -269,10 +269,10 @@ index bc674b08a41d5529fe06c6d3f077051cf4138f73..ea8a894158c44c2e7943dea43ecd8e1f
+ // Paper end - Use Velocity cipher + // Paper end - Use Velocity cipher
} }
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
index c4bb28857ee11dccc9924666634488044c666fd1..8fe485c5bf79804bb4d1f774f95a92b14a576e80 100644 index 1672bd0eeea8db44016bbbccf9a332c7f45fdb54..bfdc637a750602c00919422ca0e3943ba34db832 100644
--- a/net/minecraft/network/Connection.java --- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java
@@ -770,11 +770,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -766,11 +766,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
return connection; return connection;
} }
@ -299,7 +299,7 @@ index c4bb28857ee11dccc9924666634488044c666fd1..8fe485c5bf79804bb4d1f774f95a92b1
public boolean isEncrypted() { public boolean isEncrypted() {
return this.encrypted; return this.encrypted;
@@ -813,16 +824,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -809,16 +820,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
// Paper end - add proper async disconnect // Paper end - add proper async disconnect
public void setupCompression(int threshold, boolean validateDecompressed) { public void setupCompression(int threshold, boolean validateDecompressed) {
if (threshold >= 0) { if (threshold >= 0) {

View file

@ -8,7 +8,7 @@ Areas affected by lag comepnsation:
- Eating food items - Eating food items
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index fd6fdb6d7e15633bd01d4f930ee3b15c0dd2ca06..22dc6bec58702762e4a31415f9aed2df2b3ad0d6 100644 index 5649482a8b85056bc009b868e19ca11f21d59fbf..f4fba4e2d12c7ab4b4eb9858cd738a9678a2d203 100644
--- a/net/minecraft/server/MinecraftServer.java --- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java
@@ -301,6 +301,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -301,6 +301,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -19,7 +19,7 @@ index fd6fdb6d7e15633bd01d4f930ee3b15c0dd2ca06..22dc6bec58702762e4a31415f9aed2df
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) { public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
@@ -1566,6 +1567,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1561,6 +1562,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
for (ServerLevel serverLevel : this.getAllLevels()) { for (ServerLevel serverLevel : this.getAllLevels()) {
serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
@ -28,7 +28,7 @@ index fd6fdb6d7e15633bd01d4f930ee3b15c0dd2ca06..22dc6bec58702762e4a31415f9aed2df
/* Drop global time updates /* Drop global time updates
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index ca9427a7eae9a66f4f1ccedda7b1def7ac2a88da..efc18884358907661d1226409f11d19a394073b3 100644 index 4d20bda4cba578c47216d450c99389b744a59008..47b7d487467225505e3f20cea92e114331d660fd 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -2362,4 +2362,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -2362,4 +2362,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -49,20 +49,20 @@ index ca9427a7eae9a66f4f1ccedda7b1def7ac2a88da..efc18884358907661d1226409f11d19a
+ // Paper end - lag compensation + // Paper end - lag compensation
} }
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
index 6176f0738aa1a18df5d7d4d49fd6961e3f2eb736..d6da40d7188a55a9b2eeedb540c8e275359342e4 100644 index 9fdb825be2b04a5806bbb3d39948bad0863e7ae5..261445152f741b68f91cd8fc1eac17275ee52427 100644
--- a/net/minecraft/server/level/ServerPlayerGameMode.java --- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -111,7 +111,7 @@ public class ServerPlayerGameMode { @@ -111,7 +111,7 @@ public class ServerPlayerGameMode {
} }
public void tick() { public void tick() {
- this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit; - this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit
+ this.gameTicks = (int) this.level.getLagCompensationTick(); // Paper - lag compensation + this.gameTicks = (int) this.level.getLagCompensationTick(); // Paper - lag compensation
if (this.hasDelayedDestroy) { if (this.hasDelayedDestroy) {
BlockState blockState = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks BlockState blockState = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks
if (blockState == null || blockState.isAir()) { // Paper - Don't allow digging into unloaded chunks if (blockState == null || blockState.isAir()) { // Paper - Don't allow digging into unloaded chunks
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index c83aeaf4e50dd7290c608dfe260a3bd2404b6004..8439e1593c9973243383dc7091c587f7e72eb9e0 100644 index 228ceecd5ab9040dcc6710d1cdd0feda2f901016..884e1f8f72cc31520ba0c54af17be3879918a5d3 100644
--- a/net/minecraft/world/entity/LivingEntity.java --- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3831,6 +3831,10 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -3831,6 +3831,10 @@ public abstract class LivingEntity extends Entity implements Attackable {

View file

@ -2326,7 +2326,7 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9
+ } + }
+} +}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index efc18884358907661d1226409f11d19a394073b3..9cc47bda7197ca3f63b0ede9905c9a13931f84ed 100644 index 47b7d487467225505e3f20cea92e114331d660fd..c38eda42b33cfa4792625f40ebde6f30e591119b 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -2352,10 +2352,10 @@ index efc18884358907661d1226409f11d19a394073b3..9cc47bda7197ca3f63b0ede9905c9a13
@Override @Override
public void onCreated(Entity entity) { public void onCreated(Entity entity) {
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 872c3b8826f436b15f6ab0a3619692c5202eadc3..cb6ca60af3d3f90501e4693a78466b9f7462362d 100644 index 0e4ab448755632696c4326f1df9f3855cd38a64d..8abb17d30373fab80b466891abd16b31ab536f64 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -1401,6 +1401,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1396,6 +1396,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract FuelValues fuelValues(); public abstract FuelValues fuelValues();

View file

@ -204,7 +204,7 @@ index 6475509689439636275b06b9eac33f0922d8fcfd..6c398c91909f42e352e80d0781549df9
int i = this.inventory.findSlotMatchingCraftingIngredient(item, item1); int i = this.inventory.findSlotMatchingCraftingIngredient(item, item1);
if (i == -1) { if (i == -1) {
diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java
index e8522f5ccd69ff5513782a31a3b53219bc17b0e5..9a72651c5efefc6290ae14aa50ca79572d274562 100644 index e8522f5ccd69ff5513782a31a3b53219bc17b0e5..80fa9153bdce9b0728cc1ee8908fe5481e84a1f8 100644
--- a/net/minecraft/world/entity/player/Inventory.java --- a/net/minecraft/world/entity/player/Inventory.java
+++ b/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java
@@ -178,12 +178,12 @@ public class Inventory implements Container, Nameable { @@ -178,12 +178,12 @@ public class Inventory implements Container, Nameable {
@ -219,7 +219,7 @@ index e8522f5ccd69ff5513782a31a3b53219bc17b0e5..9a72651c5efefc6290ae14aa50ca7957
- && itemStack.is(item) - && itemStack.is(item)
- && isUsableForCrafting(itemStack) - && isUsableForCrafting(itemStack)
+ && item.matches(itemStack) // Paper - Improve exact choice recipe ingredients + && item.matches(itemStack) // Paper - Improve exact choice recipe ingredients
+ && (!(item instanceof io.papermc.paper.inventory.recipe.ItemOrExact.Item) || Inventory.isUsableForCrafting(itemStack)) // Paper - Improve exact choice recipe ingredients + && (!(item instanceof io.papermc.paper.inventory.recipe.ItemOrExact.Item) || Inventory.isUsableForCrafting(itemStack)) // Paper - Improve exact choice recipe ingredients
&& (stack.isEmpty() || ItemStack.isSameItemSameComponents(stack, itemStack))) { && (stack.isEmpty() || ItemStack.isSameItemSameComponents(stack, itemStack))) {
return i; return i;
} }

View file

@ -1,13 +1,5 @@
--- a/com/mojang/brigadier/CommandDispatcher.java --- a/com/mojang/brigadier/CommandDispatcher.java
+++ b/com/mojang/brigadier/CommandDispatcher.java +++ b/com/mojang/brigadier/CommandDispatcher.java
@@ -3,6 +_,7 @@
package com.mojang.brigadier;
+// CHECKSTYLE:OFF
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.CommandContextBuilder;
@@ -297,15 +_,21 @@ @@ -297,15 +_,21 @@
List<ParseResults<S>> potentials = null; List<ParseResults<S>> potentials = null;
final int cursor = originalReader.getCursor(); final int cursor = originalReader.getCursor();

View file

@ -100,8 +100,8 @@
MutableComponent mutableComponent = Component.literal(var12.getMessage() == null ? var12.getClass().getName() : var12.getMessage()); MutableComponent mutableComponent = Component.literal(var12.getMessage() == null ? var12.getClass().getName() : var12.getMessage());
- if (LOGGER.isDebugEnabled()) { - if (LOGGER.isDebugEnabled()) {
- LOGGER.error("Command exception: /{}", command, var12); - LOGGER.error("Command exception: /{}", command, var12);
+ Commands.LOGGER.error("Command exception: /{}", command, var12); // Paper - always show execution exception in console log + LOGGER.error("Command exception: /{}", command, var12); // Paper - always show execution exception in console log
+ if (commandSourceStack.getServer().isDebugging() || Commands.LOGGER.isDebugEnabled()) { // Paper - Debugging + if (commandSourceStack.getServer().isDebugging() || LOGGER.isDebugEnabled()) { // Paper - Debugging
StackTraceElement[] stackTrace = var12.getStackTrace(); StackTraceElement[] stackTrace = var12.getStackTrace();
for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { for (int i = 0; i < Math.min(stackTrace.length, 3); i++) {

View file

@ -4,7 +4,7 @@
private static byte[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException { private static byte[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(24L); accounter.accountBytes(24L);
int _int = input.readInt(); int _int = input.readInt();
+ com.google.common.base.Preconditions.checkArgument( _int < 1 << 24); // Spigot + com.google.common.base.Preconditions.checkArgument(_int < 1 << 24); // Spigot
accounter.accountBytes(1L, _int); accounter.accountBytes(1L, _int);
byte[] bytes = new byte[_int]; byte[] bytes = new byte[_int];
input.readFully(bytes); input.readFully(bytes);

View file

@ -4,7 +4,7 @@
private static int[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException { private static int[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(24L); accounter.accountBytes(24L);
int _int = input.readInt(); int _int = input.readInt();
+ com.google.common.base.Preconditions.checkArgument( _int < 1 << 24); // Spigot + com.google.common.base.Preconditions.checkArgument(_int < 1 << 24); // Spigot
accounter.accountBytes(4L, _int); accounter.accountBytes(4L, _int);
int[] ints = new int[_int]; int[] ints = new int[_int];

View file

@ -1,13 +1,12 @@
--- a/net/minecraft/nbt/NbtIo.java --- a/net/minecraft/nbt/NbtIo.java
+++ b/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java
@@ -118,6 +_,12 @@ @@ -118,6 +_,11 @@
} }
public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException { public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException {
+ // Spigot start + // Spigot start
+ if ( input instanceof io.netty.buffer.ByteBufInputStream ) + if (input instanceof io.netty.buffer.ByteBufInputStream byteBufInputStream) {
+ { + input = new DataInputStream(new org.spigotmc.LimitStream(byteBufInputStream, accounter));
+ input = new DataInputStream(new org.spigotmc.LimitStream((InputStream) input, accounter));
+ } + }
+ // Spigot end + // Spigot end
Tag unnamedTag = readUnnamedTag(input, accounter); Tag unnamedTag = readUnnamedTag(input, accounter);

View file

@ -21,11 +21,11 @@
private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue(); private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue();
public Channel channel; public Channel channel;
public SocketAddress address; public SocketAddress address;
+ // Spigot Start + // Spigot start
+ public java.util.UUID spoofedUUID; + public java.util.UUID spoofedUUID;
+ public com.mojang.authlib.properties.Property[] spoofedProfile; + public com.mojang.authlib.properties.Property[] spoofedProfile;
+ public boolean preparing = true; + public boolean preparing = true;
+ // Spigot End + // Spigot end
@Nullable @Nullable
private volatile PacketListener disconnectListener; private volatile PacketListener disconnectListener;
@Nullable @Nullable
@ -70,13 +70,11 @@
public Connection(PacketFlow receiving) { public Connection(PacketFlow receiving) {
this.receiving = receiving; this.receiving = receiving;
@@ -116,6 +_,9 @@ @@ -116,6 +_,7 @@
super.channelActive(context); super.channelActive(context);
this.channel = context.channel(); this.channel = context.channel();
this.address = this.channel.remoteAddress(); this.address = this.channel.remoteAddress();
+ // Spigot Start + this.preparing = false; // Spigot
+ this.preparing = false;
+ // Spigot End
if (this.delayedDisconnect != null) { if (this.delayedDisconnect != null) {
this.disconnect(this.delayedDisconnect); this.disconnect(this.delayedDisconnect);
} }
@ -228,13 +226,11 @@
} }
if (this.tickCount++ % 20 == 0) { if (this.tickCount++ % 20 == 0) {
@@ -432,12 +_,15 @@ @@ -432,12 +_,13 @@
} }
public void disconnect(DisconnectionDetails disconnectionDetails) { public void disconnect(DisconnectionDetails disconnectionDetails) {
+ // Spigot Start + this.preparing = false; // Spigot
+ this.preparing = false;
+ // Spigot End
if (this.channel == null) { if (this.channel == null) {
this.delayedDisconnect = disconnectionDetails; this.delayedDisconnect = disconnectionDetails;
} }

View file

@ -18,7 +18,7 @@
buffer.writeVarInt(this.entity); buffer.writeVarInt(this.entity);
int size = this.slots.size(); int size = this.slots.size();
+ try (io.papermc.paper.util.DataSanitizationUtil.DataSanitizer ignored = io.papermc.paper.util.DataSanitizationUtil.start(this.sanitize)) { // Paper - data sanitization + try (io.papermc.paper.util.DataSanitizationUtil.DataSanitizer ignored = io.papermc.paper.util.DataSanitizationUtil.start(this.sanitize)) { // Paper - data sanitization
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Pair<EquipmentSlot, ItemStack> pair = this.slots.get(i); Pair<EquipmentSlot, ItemStack> pair = this.slots.get(i);
EquipmentSlot equipmentSlot = pair.getFirst(); EquipmentSlot equipmentSlot = pair.getFirst();

View file

@ -17,7 +17,7 @@
buffer.writeByte(this.options); buffer.writeByte(this.options);
buffer.writeUtf(this.nametagVisibility); buffer.writeUtf(this.nametagVisibility);
- buffer.writeUtf(this.collisionRule); - buffer.writeUtf(this.collisionRule);
+ buffer.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? "never" : this.collisionRule); // Paper - Configurable player collision + buffer.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.NEVER.name : this.collisionRule); // Paper - Configurable player collision
buffer.writeEnum(this.color); buffer.writeEnum(this.color);
ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerPrefix); ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerPrefix);
ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerSuffix); ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerSuffix);

View file

@ -65,15 +65,15 @@
} }
- if (!eula.hasAgreedToEULA()) { - if (!eula.hasAgreedToEULA()) {
+ // Spigot Start + // Spigot start
+ boolean eulaAgreed = Boolean.getBoolean("com.mojang.eula.agree"); + boolean eulaAgreed = Boolean.getBoolean("com.mojang.eula.agree");
+ if (eulaAgreed) { + if (eulaAgreed) {
+ System.err.println("You have used the Spigot command line EULA agreement flag."); + LOGGER.error("You have used the Spigot command line EULA agreement flag.");
+ System.err.println("By using this setting you are indicating your agreement to Mojang's EULA (https://account.mojang.com/documents/minecraft_eula)."); + LOGGER.error("By using this setting you are indicating your agreement to Mojang's EULA (https://aka.ms/MinecraftEULA).");
+ System.err.println("If you do not agree to the above EULA please stop your server and remove this flag immediately."); + LOGGER.error("If you do not agree to the above EULA please stop your server and remove this flag immediately.");
+ } + }
+ // Spigot End + if (!eula.hasAgreedToEULA() && !eulaAgreed) {
+ if (!eula.hasAgreedToEULA() && !eulaAgreed) { // Spigot + // Spigot end
LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
return; return;
} }
@ -84,11 +84,11 @@
+ // Paper start - Detect headless JRE + // Paper start - Detect headless JRE
+ String awtException = io.papermc.paper.util.ServerEnvironment.awtDependencyCheck(); + String awtException = io.papermc.paper.util.ServerEnvironment.awtDependencyCheck();
+ if (awtException != null) { + if (awtException != null) {
+ Main.LOGGER.error("You are using a headless JRE distribution."); + LOGGER.error("You are using a headless JRE distribution.");
+ Main.LOGGER.error("This distribution is missing certain graphic libraries that the Minecraft server needs to function."); + LOGGER.error("This distribution is missing certain graphic libraries that the Minecraft server needs to function.");
+ Main.LOGGER.error("For instructions on how to install the non-headless JRE, see https://docs.papermc.io/misc/java-install"); + LOGGER.error("For instructions on how to install the non-headless JRE, see https://docs.papermc.io/misc/java-install");
+ Main.LOGGER.error(""); + LOGGER.error("");
+ Main.LOGGER.error(awtException); + LOGGER.error(awtException);
+ return; + return;
+ } + }
+ // Paper end - Detect headless JRE + // Paper end - Detect headless JRE
@ -195,7 +195,7 @@
thread1, thread1,
levelStorageAccess, levelStorageAccess,
packRepository, packRepository,
@@ -257,17 +_,29 @@ @@ -257,17 +_,34 @@
services, services,
LoggerChunkProgressListener::createFromGameruleRadius LoggerChunkProgressListener::createFromGameruleRadius
); );
@ -203,7 +203,12 @@
dedicatedServer1.setPort(optionSet.valueOf(optionSpec11)); dedicatedServer1.setPort(optionSet.valueOf(optionSpec11));
- dedicatedServer1.setDemo(optionSet.has(optionSpec2)); - dedicatedServer1.setDemo(optionSet.has(optionSpec2));
+ */ + */
+ dedicatedServer1.setDemo(optionSet.has("demo")); // Paper + // Paper start
+ if (optionSet.has("serverId")) {
+ dedicatedServer1.setId((String) optionSet.valueOf("serverId"));
+ }
+ dedicatedServer1.setDemo(optionSet.has("demo"));
+ // Paper end
+ /* + /*
dedicatedServer1.setId(optionSet.valueOf(optionSpec12)); dedicatedServer1.setId(optionSet.valueOf(optionSpec12));
- boolean flag = !optionSet.has(optionSpec) && !optionSet.valuesOf(optionSpec15).contains("nogui"); - boolean flag = !optionSet.has(optionSpec) && !optionSet.valuesOf(optionSpec15).contains("nogui");

View file

@ -61,7 +61,7 @@
+ public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS; + public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS;
+ private static final int SAMPLE_INTERVAL = 20; // Paper - improve server tick loop + private static final int SAMPLE_INTERVAL = 20; // Paper - improve server tick loop
+ @Deprecated(forRemoval = true) // Paper + @Deprecated(forRemoval = true) // Paper
+ public final double[] recentTps = new double[ 3 ]; + public final double[] recentTps = new double[3];
+ // Spigot end + // Spigot end
+ public volatile boolean hasFullyShutdown; // Paper - Improved watchdog support + public volatile boolean hasFullyShutdown; // Paper - Improved watchdog support
+ public volatile boolean abnormalExit; // Paper - Improved watchdog support + public volatile boolean abnormalExit; // Paper - Improved watchdog support
@ -623,16 +623,17 @@
} }
LOGGER.info("Saving worlds"); LOGGER.info("Saving worlds");
@@ -646,6 +_,15 @@ @@ -646,6 +_,16 @@
} catch (IOException var4) { } catch (IOException var4) {
LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4);
} }
+ // Spigot start + // Spigot start
+ io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.shutdown(); // Paper + io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.shutdown(); // Paper
+ try { io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.awaitTermination(30, java.util.concurrent.TimeUnit.SECONDS); // Paper + try {
+ io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR.awaitTermination(30, java.util.concurrent.TimeUnit.SECONDS); // Paper
+ } catch (java.lang.InterruptedException ignored) {} // Paper + } catch (java.lang.InterruptedException ignored) {} // Paper
+ if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { + if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
+ MinecraftServer.LOGGER.info("Saving usercache.json"); + LOGGER.info("Saving usercache.json");
+ this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving + this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
+ } + }
+ // Spigot end + // Spigot end
@ -654,15 +655,10 @@
this.running = false; this.running = false;
if (waitForServer) { if (waitForServer) {
try { try {
@@ -671,6 +_,63 @@ @@ -671,6 +_,57 @@
} }
} }
+ // Spigot Start
+ private static double calcTps(double avg, double exp, double tps) {
+ return (avg * exp) + (tps * (1 - exp));
+ }
+
+ // Paper start - Further improve server tick loop + // Paper start - Further improve server tick loop
+ private static final long SEC_IN_NANO = 1000000000; + private static final long SEC_IN_NANO = 1000000000;
+ private static final long MAX_CATCHUP_BUFFER = TICK_TIME * TPS * 60L; + private static final long MAX_CATCHUP_BUFFER = TICK_TIME * TPS * 60L;
@ -713,7 +709,6 @@
+ } + }
+ private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL)); + private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
+ // Paper end + // Paper end
+ // Spigot End
+ +
protected void runServer() { protected void runServer() {
try { try {
@ -725,7 +720,7 @@
+ this.server.spark.enableBeforePlugins(); // Paper - spark + this.server.spark.enableBeforePlugins(); // Paper - spark
+ // Spigot start + // Spigot start
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper + org.spigotmc.WatchdogThread.hasStarted = true; // Paper
+ Arrays.fill( this.recentTps, 20 ); + Arrays.fill(this.recentTps, 20);
+ // Paper start - further improve server tick loop + // Paper start - further improve server tick loop
+ long tickSection = Util.getNanos(); + long tickSection = Util.getNanos();
+ long currentTime; + long currentTime;
@ -1181,7 +1176,7 @@
if (this.isEnforceWhitelist()) { if (this.isEnforceWhitelist()) {
PlayerList playerList = commandSource.getServer().getPlayerList(); PlayerList playerList = commandSource.getServer().getPlayerList();
UserWhiteList whiteList = playerList.getWhiteList(); UserWhiteList whiteList = playerList.getWhiteList();
+ if (!((net.minecraft.server.dedicated.DedicatedServer) getServer()).getProperties().whiteList.get()) return; // Paper - whitelist not enabled + if (!((net.minecraft.server.dedicated.DedicatedServer) this).getProperties().whiteList.get()) return; // Paper - whitelist not enabled
for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) { for (ServerPlayer serverPlayer : Lists.newArrayList(playerList.getPlayers())) {
- if (!whiteList.isWhiteListed(serverPlayer.getGameProfile())) { - if (!whiteList.isWhiteListed(serverPlayer.getGameProfile())) {

View file

@ -4,12 +4,12 @@
} }
public boolean stopSprinting() { public boolean stopSprinting() {
+ // CraftBukkit start, add sendLog parameter + // CraftBukkit start - add sendLog parameter
+ return this.stopSprinting(true); + return this.stopSprinting(true);
+ } + }
+ +
+ public boolean stopSprinting(boolean sendLog) { + public boolean stopSprinting(boolean sendLog) {
+ // CraftBukkit end + // CraftBukkit end - add sendLog parameter
if (this.remainingSprintTicks > 0L) { if (this.remainingSprintTicks > 0L) {
- this.finishTickSprint(); - this.finishTickSprint();
+ this.finishTickSprint(sendLog); // CraftBukkit - add sendLog parameter + this.finishTickSprint(sendLog); // CraftBukkit - add sendLog parameter

View file

@ -1,10 +0,0 @@
--- a/net/minecraft/server/commands/LootCommand.java
+++ b/net/minecraft/server/commands/LootCommand.java
@@ -395,6 +_,7 @@
private static int dropInWorld(CommandSourceStack source, Vec3 pos, List<ItemStack> items, LootCommand.Callback callback) throws CommandSyntaxException {
ServerLevel level = source.getLevel();
+ items.removeIf(ItemStack::isEmpty); // CraftBukkit - SPIGOT-6959 Remove empty items for avoid throw an error in new EntityItem
items.forEach(itemStack -> {
ItemEntity itemEntity = new ItemEntity(level, pos.x, pos.y, pos.z, itemStack.copy());
itemEntity.setDefaultPickUpDelay();

View file

@ -123,11 +123,11 @@
+ // Paper start - detect running as root + // Paper start - detect running as root
+ if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { + if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) {
+ DedicatedServer.LOGGER.warn("****************************"); + LOGGER.warn("****************************");
+ DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); + LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED.");
+ DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); + LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS.");
+ DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); + LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/");
+ DedicatedServer.LOGGER.warn("****************************"); + LOGGER.warn("****************************");
+ } + }
+ // Paper end - detect running as root + // Paper end - detect running as root
+ +
@ -174,12 +174,12 @@
+ java.net.SocketAddress bindAddress; + java.net.SocketAddress bindAddress;
+ if (this.getLocalIp().startsWith("unix:")) { + if (this.getLocalIp().startsWith("unix:")) {
+ if (!io.netty.channel.epoll.Epoll.isAvailable()) { + if (!io.netty.channel.epoll.Epoll.isAvailable()) {
+ DedicatedServer.LOGGER.error("**** INVALID CONFIGURATION!"); + LOGGER.error("**** INVALID CONFIGURATION!");
+ DedicatedServer.LOGGER.error("You are trying to use a Unix domain socket but you're not on a supported OS."); + LOGGER.error("You are trying to use a Unix domain socket but you're not on a supported OS.");
+ return false; + return false;
+ } else if (!io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && !org.spigotmc.SpigotConfig.bungee) { + } else if (!io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && !org.spigotmc.SpigotConfig.bungee) {
+ DedicatedServer.LOGGER.error("**** INVALID CONFIGURATION!"); + LOGGER.error("**** INVALID CONFIGURATION!");
+ DedicatedServer.LOGGER.error("Unix domain sockets require IPs to be forwarded from a proxy."); + LOGGER.error("Unix domain sockets require IPs to be forwarded from a proxy.");
+ return false; + return false;
+ } + }
+ bindAddress = new io.netty.channel.unix.DomainSocketAddress(this.getLocalIp().substring("unix:".length())); + bindAddress = new io.netty.channel.unix.DomainSocketAddress(this.getLocalIp().substring("unix:".length()));
@ -229,11 +229,11 @@
+ // Spigot start + // Spigot start
+ // Paper start - Add Velocity IP Forwarding Support + // Paper start - Add Velocity IP Forwarding Support
+ if (usingProxy) { + if (usingProxy) {
+ DedicatedServer.LOGGER.warn("Whilst this makes it possible to use " + proxyFlavor + ", unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); + LOGGER.warn("Whilst this makes it possible to use {}, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.", proxyFlavor);
+ DedicatedServer.LOGGER.warn("Please see " + proxyLink + " for further information."); + LOGGER.warn("Please see {} for further information.", proxyLink);
+ // Paper end - Add Velocity IP Forwarding Support + // Paper end - Add Velocity IP Forwarding Support
+ } else { + } else {
+ DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
+ } + }
+ // Spigot end + // Spigot end
LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");

View file

@ -24,7 +24,7 @@
} }
public static Properties loadFromFile(Path path) { public static Properties loadFromFile(Path path) {
+ if (!path.toFile().exists()) return new Properties(); // CraftBukkit - SPIGOT-7465, MC-264979: Don't load if file doesn't exist + if (!Files.exists(path)) return new Properties(); // CraftBukkit - SPIGOT-7465, MC-264979: Don't load if file doesn't exist
try { try {
try { try {
Properties var13; Properties var13;

View file

@ -148,7 +148,7 @@
} }
- protected void setServerViewDistance(int viewDistance) { - protected void setServerViewDistance(int viewDistance) {
+ public void setServerViewDistance(int viewDistance) { // Paper - publi + public void setServerViewDistance(int viewDistance) { // Paper - public
int i = Mth.clamp(viewDistance, 2, 32); int i = Mth.clamp(viewDistance, 2, 32);
if (i != this.serverViewDistance) { if (i != this.serverViewDistance) {
this.serverViewDistance = i; this.serverViewDistance = i;
@ -274,7 +274,7 @@
+ return; + return;
+ } + }
+ // Paper end - ignore and warn about illegal addEntity calls instead of crashing server + // Paper end - ignore and warn about illegal addEntity calls instead of crashing server
+ if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Paper - Fire PlayerJoinEvent when Player is actually ready; Delayadding to tracker until after list packets + if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Paper - Fire PlayerJoinEvent when Player is actually ready; Delay adding to tracker until after list packets
if (!(entity instanceof EnderDragonPart)) { if (!(entity instanceof EnderDragonPart)) {
EntityType<?> type = entity.getType(); EntityType<?> type = entity.getType();
int i = type.clientTrackingRange() * 16; int i = type.clientTrackingRange() * 16;
@ -327,14 +327,14 @@
if (player != this.entity) { if (player != this.entity) {
- Vec3 vec3 = player.position().subtract(this.entity.position()); - Vec3 vec3 = player.position().subtract(this.entity.position());
+ // Paper start - remove allocation of Vec3D here + // Paper start - remove allocation of Vec3D here
+ // Vec3 vec3d = player.position().subtract(this.entity.position()); + // Vec3 vec3 = player.position().subtract(this.entity.position());
+ double vec3d_dx = player.getX() - this.entity.getX(); + double vec3_dx = player.getX() - this.entity.getX();
+ double vec3d_dz = player.getZ() - this.entity.getZ(); + double vec3_dz = player.getZ() - this.entity.getZ();
+ // Paper end - remove allocation of Vec3D here + // Paper end - remove allocation of Vec3D here
int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player); int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player);
double d = Math.min(this.getEffectiveRange(), playerViewDistance * 16); double d = Math.min(this.getEffectiveRange(), playerViewDistance * 16);
- double d1 = vec3.x * vec3.x + vec3.z * vec3.z; - double d1 = vec3.x * vec3.x + vec3.z * vec3.z;
+ double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper + double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
double d2 = d * d; double d2 = d * d;
- boolean flag = d1 <= d2 - boolean flag = d1 <= d2
- && this.entity.broadcastToPlayer(player) - && this.entity.broadcastToPlayer(player)
@ -344,8 +344,8 @@
+ if (flag && level.paperConfig().entities.trackingRangeY.enabled) { + if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
+ double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1); + double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
+ if (rangeY != -1) { + if (rangeY != -1) {
+ double vec3d_dy = player.getY() - this.entity.getY(); + double vec3_dy = player.getY() - this.entity.getY();
+ flag = vec3d_dy * vec3d_dy <= rangeY * rangeY; + flag = vec3_dy * vec3_dy <= rangeY * rangeY;
+ } + }
+ } + }
+ flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); + flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);

View file

@ -84,7 +84,7 @@
if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) { if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) {
ChunkAccess chunkAccess = this.lastChunk[i]; ChunkAccess chunkAccess = this.lastChunk[i];
- if (chunkAccess != null || !requireChunk) { - if (chunkAccess != null || !requireChunk) {
+ if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime + if (chunkAccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
return chunkAccess; return chunkAccess;
} }
} }
@ -178,7 +178,7 @@
this.lastSpawnState = spawnState; this.lastSpawnState = spawnState;
profiler.popPush("spawnAndTick"); profiler.popPush("spawnAndTick");
- boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); - boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
+ boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit; + boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
List<MobCategory> filteredSpawningCategories; List<MobCategory> filteredSpawningCategories;
if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) {

View file

@ -200,7 +200,7 @@
this.registryAccess(), this.registryAccess(),
server.getStructureManager(), server.getStructureManager(),
- dimension, - dimension,
+ getTypeKey(), // Paper - Fix missing CB diff + getTypeKey(), // Paper - Fix missing CB diff
chunkGenerator, chunkGenerator,
this.chunkSource.randomState(), this.chunkSource.randomState(),
this, this,
@ -302,7 +302,7 @@
DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos); DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos);
boolean flag = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) boolean flag = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)
- && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * 0.01 - && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * 0.01
+ && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01D) // Paper - Configurable spawn chances for skeleton horses + && this.random.nextDouble() < currentDifficultyAt.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01) // Paper - Configurable spawn chances for skeleton horses
&& !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD); && !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD);
if (flag) { if (flag) {
SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
@ -409,23 +409,23 @@
this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
+ */ + */
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (ServerPlayer player : this.players) {
+ if (((ServerPlayer) this.players.get(idx)).level() == this) { + if (player.level() == this) {
+ ((ServerPlayer) this.players.get(idx)).tickWeather(); + player.tickWeather();
+ } + }
+ } + }
+ +
+ if (isRaining != this.isRaining()) { + if (isRaining != this.isRaining()) {
+ // Only send weather packets to those affected + // Only send weather packets to those affected
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (ServerPlayer player : this.players) {
+ if (((ServerPlayer) this.players.get(idx)).level() == this) { + if (player.level() == this) {
+ ((ServerPlayer) this.players.get(idx)).setPlayerWeather((!isRaining ? org.bukkit.WeatherType.DOWNFALL : org.bukkit.WeatherType.CLEAR), false); + player.setPlayerWeather((!isRaining ? org.bukkit.WeatherType.DOWNFALL : org.bukkit.WeatherType.CLEAR), false);
+ } + }
+ } + }
+ } + }
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (ServerPlayer player : this.players) {
+ if (((ServerPlayer) this.players.get(idx)).level() == this) { + if (player.level() == this) {
+ ((ServerPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel); + player.updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel);
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -600,19 +600,19 @@
} }
public void unload(LevelChunk chunk) { public void unload(LevelChunk chunk) {
+ // Spigot Start + // Spigot start
+ for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) { + for (net.minecraft.world.level.block.entity.BlockEntity blockEntity : chunk.getBlockEntities().values()) {
+ if (tileentity instanceof net.minecraft.world.Container) { + if (blockEntity instanceof net.minecraft.world.Container) {
+ // Paper start - this area looks like it can load chunks, change the behavior + // Paper start - this area looks like it can load chunks, change the behavior
+ // chests for example can apply physics to the world + // chests for example can apply physics to the world
+ // so instead we just change the active container and call the event + // so instead we just change the active container and call the event
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { + for (org.bukkit.entity.HumanEntity human : Lists.newArrayList(((net.minecraft.world.Container) blockEntity).getViewers())) {
+ ((org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason + ((org.bukkit.craftbukkit.entity.CraftHumanEntity) human).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
+ } + }
+ // Paper end - this area looks like it can load chunks, change the behavior + // Paper end - this area looks like it can load chunks, change the behavior
+ } + }
+ } + }
+ // Spigot End + // Spigot end
chunk.clearAllBlockEntities(); chunk.clearAllBlockEntities();
chunk.unregisterTickContainerFromLevel(this); chunk.unregisterTickContainerFromLevel(this);
} }
@ -776,7 +776,7 @@
+ ParticleOptions smallExplosionParticles, + ParticleOptions smallExplosionParticles,
+ ParticleOptions largeExplosionParticles, + ParticleOptions largeExplosionParticles,
+ Holder<SoundEvent> explosionSound, + Holder<SoundEvent> explosionSound,
+ java.util.function.Consumer<ServerExplosion> configurator + @Nullable java.util.function.Consumer<ServerExplosion> configurator
+ ) { + ) {
+ // CraftBukkit end + // CraftBukkit end
Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) {
@ -865,7 +865,7 @@
- for (int i1 = 0; i1 < this.players.size(); i1++) { - for (int i1 = 0; i1 < this.players.size(); i1++) {
- ServerPlayer serverPlayer = this.players.get(i1); - ServerPlayer serverPlayer = this.players.get(i1);
+ for (int i1 = 0; i1 < receivers.size(); i1++) { // Paper - particle API + for (int i1 = 0; i1 < receivers.size(); i1++) { // Paper - particle API
+ ServerPlayer serverPlayer = receivers.get(i1); // Paper - particle API + ServerPlayer serverPlayer = receivers.get(i1); // Paper - particle API
+ if (sender != null && !serverPlayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit + if (sender != null && !serverPlayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) { if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) {
i++; i++;
@ -889,11 +889,11 @@
+ +
+ final Optional<net.minecraft.world.level.saveddata.SavedData> cacheEntry = storage.cache.get(mapId.key()); + final Optional<net.minecraft.world.level.saveddata.SavedData> cacheEntry = storage.cache.get(mapId.key());
+ if (cacheEntry == null) { // Cache did not contain, try to load and may init + if (cacheEntry == null) { // Cache did not contain, try to load and may init
+ final MapItemSavedData worldmap = storage.get(MapItemSavedData.factory(), mapId.key()); // get populates the cache + final MapItemSavedData mapData = storage.get(MapItemSavedData.factory(), mapId.key()); // get populates the cache
+ if (worldmap != null) { // map was read, init it and return + if (mapData != null) { // map was read, init it and return
+ worldmap.id = mapId; + mapData.id = mapId;
+ new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView).callEvent(); + new org.bukkit.event.server.MapInitializeEvent(mapData.mapView).callEvent();
+ return worldmap; + return mapData;
+ } + }
+ +
+ return null; // Map does not exist, reading failed. + return null; // Map does not exist, reading failed.
@ -1096,7 +1096,7 @@
+ } + }
+ } + }
+ // Spigot end + // Spigot end
+ // Spigot Start + // Spigot start
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message + if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
+ // Paper start - Fix merchant inventory not closing on entity removal + // Paper start - Fix merchant inventory not closing on entity removal
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { + if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
@ -1107,7 +1107,7 @@
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason + h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
+ } + }
+ } + }
+ // Spigot End + // Spigot end
ServerLevel.this.getChunkSource().removeEntity(entity); ServerLevel.this.getChunkSource().removeEntity(entity);
if (entity instanceof ServerPlayer serverPlayer) { if (entity instanceof ServerPlayer serverPlayer) {
ServerLevel.this.players.remove(serverPlayer); ServerLevel.this.players.remove(serverPlayer);

View file

@ -334,7 +334,7 @@
private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) {
- this.getScoreboard().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); - this.getScoreboard().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points));
- } - }
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); + this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); // CraftBukkit - Use our scores instead
+ } + }
+ +
+ // Paper start - PlayerDeathEvent#getItemsToKeep + // Paper start - PlayerDeathEvent#getItemsToKeep
@ -571,11 +571,11 @@
+ ); + );
+ // Paper end - respawn flags + // Paper end - respawn flags
+ this.level().getCraftServer().getPluginManager().callEvent(respawnEvent); + this.level().getCraftServer().getPluginManager().callEvent(respawnEvent);
+ // Spigot Start + // Spigot start
+ if (this.connection.isDisconnected()) { + if (this.connection.isDisconnected()) {
+ return null; + return null;
+ } + }
+ // Spigot End + // Spigot end
+ +
+ location = respawnEvent.getRespawnLocation(); + location = respawnEvent.getRespawnLocation();
+ +
@ -613,7 +613,7 @@
boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1);
return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 return isPossibleToRespawnInThis && isPossibleToRespawnInThis1
- ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle)) - ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle))
+ ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle, false, false)) // CraftBukkit + ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle, false, false)) // CraftBukkit
: Optional.empty(); : Optional.empty();
} }
} }
@ -1159,7 +1159,7 @@
} }
- boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera); - boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera);
+ boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, cause); // CraftBukkit + boolean flag = super.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, cause); // CraftBukkit
if (flag) { if (flag) {
this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw);
} }

View file

@ -59,7 +59,7 @@
public void tick() { public void tick() {
- this.gameTicks++; - this.gameTicks++;
+ this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit; + this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit
if (this.hasDelayedDestroy) { if (this.hasDelayedDestroy) {
- BlockState blockState = this.level.getBlockState(this.delayedDestroyPos); - BlockState blockState = this.level.getBlockState(this.delayedDestroyPos);
- if (blockState.isAir()) { - if (blockState.isAir()) {
@ -102,7 +102,7 @@
- return; - return;
- } - }
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ // CraftBukkit end + // CraftBukkit end
+ return; + return;
+ } + }
@ -113,7 +113,7 @@
+ // Let the client know the block still exists + // Let the client know the block still exists
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks + // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -207,7 +207,7 @@
} }
} }
} }
@@ -235,36 +_,125 @@ @@ -235,36 +_,127 @@
public boolean destroyBlock(BlockPos pos) { public boolean destroyBlock(BlockPos pos) {
BlockState blockState = this.level.getBlockState(pos); BlockState blockState = this.level.getBlockState(pos);
@ -258,12 +258,14 @@
+ // Paper end - Don't resync blocks + // Paper end - Don't resync blocks
+ +
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction + if (!this.captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
+ BlockEntity tileentity = this.level.getBlockEntity(pos); + BlockEntity blockEntity = this.level.getBlockEntity(pos);
+ if (tileentity != null) { + if (blockEntity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket()); + this.player.connection.send(blockEntity.getUpdatePacket());
+ } + }
+ } else {capturedBlockEntity = true;} // Paper - Send block entities after destroy prediction + } else {
+ this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ }
+ return false; + return false;
+ } + }
+ } + }

View file

@ -1785,21 +1785,20 @@
} }
public void sendDisguisedChatMessage(Component message, ChatType.Bound boundType) { public void sendDisguisedChatMessage(Component message, ChatType.Bound boundType) {
@@ -1579,6 +_,18 @@ @@ -1579,6 +_,17 @@
return this.connection.getRemoteAddress(); return this.connection.getRemoteAddress();
} }
+ // Spigot Start + // Spigot start
+ public SocketAddress getRawAddress() + public SocketAddress getRawAddress() {
+ {
+ // Paper start - Unix domain socket support; this can be nullable in the case of a Unix domain socket, so if it is, fake something + // Paper start - Unix domain socket support; this can be nullable in the case of a Unix domain socket, so if it is, fake something
+ if (connection.channel.remoteAddress() == null) { + if (this.connection.channel.remoteAddress() == null) {
+ return new java.net.InetSocketAddress(java.net.InetAddress.getLoopbackAddress(), 0); + return new java.net.InetSocketAddress(java.net.InetAddress.getLoopbackAddress(), 0);
+ } + }
+ // Paper end - Unix domain socket support + // Paper end - Unix domain socket support
+ return this.connection.channel.remoteAddress(); + return this.connection.channel.remoteAddress();
+ } + }
+ // Spigot End + // Spigot end
+ +
public void switchToConfig() { public void switchToConfig() {
this.waitingForSwitchToConfig = true; this.waitingForSwitchToConfig = true;
@ -1812,12 +1811,12 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
final ServerLevel serverLevel = this.player.serverLevel(); final ServerLevel serverLevel = this.player.serverLevel();
final Entity target = packet.getTarget(serverLevel); final Entity target = packet.getTarget(serverLevel);
+ // Spigot Start + // Spigot start
+ if (target == this.player && !this.player.isSpectator()) { + if (target == this.player && !this.player.isSpectator()) {
+ this.disconnect(Component.literal("Cannot interact with self!"), org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION); // Paper - kick event cause + this.disconnect(Component.literal("Cannot interact with self!"), org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION); // Paper - kick event cause
+ return; + return;
+ } + }
+ // Spigot End + // Spigot end
this.player.resetLastActionTime(); this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
if (target != null) { if (target != null) {

View file

@ -107,9 +107,9 @@
+ if (event.callEvent()) { + if (event.callEvent()) {
+ // If we've failed somehow, let the client know so and go no further. + // If we've failed somehow, let the client know so and go no further.
+ if (event.isFailed()) { + if (event.isFailed()) {
+ Component component = io.papermc.paper.adventure.PaperAdventure.asVanilla(event.failMessage()); + Component message = io.papermc.paper.adventure.PaperAdventure.asVanilla(event.failMessage());
+ this.connection.send(new ClientboundLoginDisconnectPacket(component)); + this.connection.send(new ClientboundLoginDisconnectPacket(message));
+ this.connection.disconnect(component); + this.connection.disconnect(message);
+ return; + return;
+ } + }
+ +
@ -129,7 +129,7 @@
+ } + }
+ } + }
+ // Paper end + // Paper end
+ // Spigot Start + // Spigot start
+ String[] split = packet.hostName().split("\00"); + String[] split = packet.hostName().split("\00");
+ if (!handledByEvent && proxyLogicEnabled) { // Paper + if (!handledByEvent && proxyLogicEnabled) { // Paper
+ // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! + // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
@ -141,20 +141,20 @@
+ // Paper end - Unix domain socket support + // Paper end - Unix domain socket support
+ this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] ); + this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] );
+ } else { + } else {
+ Component chatmessage = Component.literal("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!"); + Component message = Component.literal("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
+ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); + this.connection.send(new ClientboundLoginDisconnectPacket(message));
+ this.connection.disconnect(chatmessage); + this.connection.disconnect(message);
+ return; + return;
+ } + }
+ if (split.length == 4) { + if (split.length == 4) {
+ this.connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class); + this.connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class);
+ } + }
+ } else if ((split.length == 3 || split.length == 4) && (ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher(split[1]).matches())) { + } else if ((split.length == 3 || split.length == 4) && (ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher(split[1]).matches())) {
+ Component chatmessage = Component.literal("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?"); + Component message = Component.literal("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?");
+ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); + this.connection.send(new ClientboundLoginDisconnectPacket(message));
+ this.connection.disconnect(chatmessage); + this.connection.disconnect(message);
+ } + }
+ // Spigot End + // Spigot end
} }
} }

View file

@ -47,7 +47,7 @@
GameProfileCache.GameProfileInfo gameProfileInfo = new GameProfileCache.GameProfileInfo(gameProfile, time); GameProfileCache.GameProfileInfo gameProfileInfo = new GameProfileCache.GameProfileInfo(gameProfile, time);
this.safeAdd(gameProfileInfo); this.safeAdd(gameProfileInfo);
- this.save(); - this.save();
+ if(!org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) this.save(true); // Spigot - skip saving if disabled // Paper - Perf: Async GameProfileCache saving + if (!org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) this.save(true); // Spigot - skip saving if disabled // Paper - Perf: Async GameProfileCache saving
} }
private long getNextOperation() { private long getNextOperation() {
@ -130,11 +130,11 @@
return (List<GameProfileCache.GameProfileInfo>)var9; return (List<GameProfileCache.GameProfileInfo>)var9;
} catch (FileNotFoundException var7) { } catch (FileNotFoundException var7) {
+ // Spigot Start + // Spigot start
+ } catch (com.google.gson.JsonSyntaxException | NullPointerException ex) { + } catch (com.google.gson.JsonSyntaxException | NullPointerException ex) {
+ GameProfileCache.LOGGER.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." ); + LOGGER.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." );
+ this.file.delete(); + this.file.delete();
+ // Spigot End + // Spigot end
} catch (JsonParseException | IOException var8) { } catch (JsonParseException | IOException var8) {
LOGGER.warn("Failed to load profile cache {}", this.file, var8); LOGGER.warn("Failed to load profile cache {}", this.file, var8);
} }

View file

@ -671,11 +671,11 @@
+ } else { + } else {
+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING);
+ } + }
+ // Spigot Start + // Spigot start
+ if (teleportTransition == null) { // Paper - Add PlayerPostRespawnEvent - diff on change - spigot early returns if respawn pos is null, that is how they handle disconnected player in respawn event + if (teleportTransition == null) { // Paper - Add PlayerPostRespawnEvent - diff on change - spigot early returns if respawn pos is null, that is how they handle disconnected player in respawn event
+ return player; + return player;
+ } + }
+ // Spigot End + // Spigot end
+ ServerLevel level = teleportTransition.newLevel(); + ServerLevel level = teleportTransition.newLevel();
+ serverPlayer.spawnIn(level); + serverPlayer.spawnIn(level);
+ serverPlayer.unsetRemoved(); + serverPlayer.unsetRemoved();

View file

@ -68,14 +68,14 @@
this.map.put(this.getKeyForUser(storedUserEntry.getUser()), (V)storedUserEntry); this.map.put(this.getKeyForUser(storedUserEntry.getUser()), (V)storedUserEntry);
} }
} }
+ // Spigot Start + // Spigot start
+ } catch (com.google.gson.JsonParseException | NullPointerException ex) { + } catch (com.google.gson.JsonParseException | NullPointerException ex) {
+ org.bukkit.Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Unable to read file " + this.file + ", backing it up to {0}.backup and creating new copy.", ex); + LOGGER.warn("Unable to read file {}, backing it up to {0}.backup and creating new copy.", this.file, ex);
+ File backup = new File(this.file + ".backup"); + File backup = new File(this.file + ".backup");
+ this.file.renameTo(backup); + this.file.renameTo(backup);
+ this.file.delete(); + this.file.delete();
} }
+ // Spigot End + // Spigot end
} }
} }
} }

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/UserBanListEntry.java --- a/net/minecraft/server/players/UserBanListEntry.java
+++ b/net/minecraft/server/players/UserBanListEntry.java +++ b/net/minecraft/server/players/UserBanListEntry.java
@@ -37,19 +_,29 @@ @@ -37,19 +_,27 @@
@Nullable @Nullable
private static GameProfile createGameProfile(JsonObject json) { private static GameProfile createGameProfile(JsonObject json) {
@ -21,16 +21,14 @@
- return new GameProfile(uuid, json.get("name").getAsString()); - return new GameProfile(uuid, json.get("name").getAsString());
+ } + }
+ if ( json.has("name")) + if (json.has("name")) {
+ {
+ name = json.get("name").getAsString(); + name = json.get("name").getAsString();
+ } + }
+ if ( uuid != null || name != null ) + if (uuid != null || name != null) {
+ { + return new GameProfile(uuid, name);
+ return new GameProfile( uuid, name );
} else { } else {
return null; return null;
} }
+ // Spigot End + // Spigot end
} }
} }

View file

@ -5,7 +5,7 @@
for (RecipeHolder<?> recipeHolder : recipes) { for (RecipeHolder<?> recipeHolder : recipes) {
ResourceKey<Recipe<?>> resourceKey = recipeHolder.id(); ResourceKey<Recipe<?>> resourceKey = recipeHolder.id();
- if (!this.known.contains(resourceKey) && !recipeHolder.value().isSpecial()) { - if (!this.known.contains(resourceKey) && !recipeHolder.value().isSpecial()) {
+ if (!this.known.contains(resourceKey) && !recipeHolder.value().isSpecial() && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerRecipeListUpdateEvent(player, resourceKey.location())) { // CraftBukkit{ + if (!this.known.contains(resourceKey) && !recipeHolder.value().isSpecial() && org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerRecipeListUpdateEvent(player, resourceKey.location())) { // CraftBukkit
this.add(resourceKey); this.add(resourceKey);
this.addHighlight(resourceKey); this.addHighlight(resourceKey);
this.displayResolver this.displayResolver

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/stats/ServerStatsCounter.java --- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -51,9 +_,22 @@ @@ -51,9 +_,21 @@
LOGGER.error("Couldn't parse statistics file {}", file, var5); LOGGER.error("Couldn't parse statistics file {}", file, var5);
} }
} }
@ -9,17 +9,16 @@
+ // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving) + // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving)
+ // Fixes stat initialization to not cause a NullPointerException + // Fixes stat initialization to not cause a NullPointerException
+ // Spigot start + // Spigot start
+ for ( Map.Entry<ResourceLocation, Integer> entry : org.spigotmc.SpigotConfig.forcedStats.entrySet() ) + for (Map.Entry<ResourceLocation, Integer> entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) {
+ {
+ Stat<ResourceLocation> wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats + Stat<ResourceLocation> wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats
+ this.stats.put( wrapper, entry.getValue().intValue() ); + this.stats.put(wrapper, entry.getValue().intValue());
+ } + }
+ // Spigot end + // Spigot end
+ // Paper end - Moved after stat fetching for player state file + // Paper end - Moved after stat fetching for player state file
} }
public void save() { public void save() {
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot
try { try {
FileUtils.writeStringToFile(this.file, this.toJson()); FileUtils.writeStringToFile(this.file, this.toJson());
} catch (IOException var2) { } catch (IOException var2) {
@ -27,7 +26,7 @@
@Override @Override
public void setValue(Player player, Stat<?> stat, int i) { public void setValue(Player player, Stat<?> stat, int i) {
+ if ( org.spigotmc.SpigotConfig.disableStatSaving ) return; // Spigot + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot
+ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final ResourceLocation resourceLocation && org.spigotmc.SpigotConfig.forcedStats.get(resourceLocation) != null) return; // Paper - disable saving forced stats + if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final ResourceLocation resourceLocation && org.spigotmc.SpigotConfig.forcedStats.get(resourceLocation) != null) return; // Paper - disable saving forced stats
super.setValue(player, stat, i); super.setValue(player, stat, i);
this.dirty.add(stat); this.dirty.add(stat);

View file

@ -5,7 +5,7 @@
public final Container container2; public final Container container2;
+ // Paper start - add fields and methods + // Paper start - add fields and methods
+ public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<org.bukkit.entity.HumanEntity>(); + public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
+ +
+ public java.util.List<ItemStack> getContents() { + public java.util.List<ItemStack> getContents() {
+ java.util.List<ItemStack> result = new java.util.ArrayList<>(this.getContainerSize()); + java.util.List<ItemStack> result = new java.util.ArrayList<>(this.getContainerSize());

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -136,6 +_,114 @@ @@ -136,6 +_,108 @@
import org.slf4j.Logger; import org.slf4j.Logger;
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
@ -105,12 +105,6 @@
+ return this.bukkitEntity; + return this.bukkitEntity;
+ } + }
+ // Paper end + // Paper end
+
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return Entity.TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
+ +
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id"; public static final String ID_TAG = "id";
@ -205,6 +199,19 @@
} }
public boolean isColliding(BlockPos pos, BlockState state) { public boolean isColliding(BlockPos pos, BlockState state) {
@@ -284,6 +_,12 @@
return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215;
}
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return Entity.TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
+
public boolean isSpectator() {
return false;
}
@@ -324,7 +_,7 @@ @@ -324,7 +_,7 @@
} }

View file

@ -44,7 +44,7 @@
if (!(this.level() instanceof ServerLevel)) { if (!(this.level() instanceof ServerLevel)) {
this.level().setSkyFlashTime(2); this.level().setSkyFlashTime(2);
- } else if (!this.visualOnly) { - } else if (!this.visualOnly) {
+ } else if (!this.visualOnly && !this.isEffect) { // Paper - Properly handle lightning effects api + } else if (!this.visualOnly && !this.isEffect) { // Paper - Properly handle lightning effects api
List<Entity> entities = this.level() List<Entity> entities = this.level()
.getEntities( .getEntities(
this, this,

View file

@ -66,7 +66,7 @@
- this.setHealth(this.getMaxHealth()); - this.setHealth(this.getMaxHealth());
+ this.craftAttributes = new CraftAttributeMap(this.attributes); // CraftBukkit + this.craftAttributes = new CraftAttributeMap(this.attributes); // CraftBukkit
+ // CraftBukkit - this.setHealth(this.getMaxHealth()) inlined and simplified to skip the instanceof check for Player, as getBukkitEntity() is not initialized in constructor + // CraftBukkit - this.setHealth(this.getMaxHealth()) inlined and simplified to skip the instanceof check for Player, as getBukkitEntity() is not initialized in constructor
+ this.entityData.set(LivingEntity.DATA_HEALTH_ID, (float) this.getAttribute(Attributes.MAX_HEALTH).getValue()); + this.entityData.set(LivingEntity.DATA_HEALTH_ID, this.getMaxHealth());
this.blocksBuilding = true; this.blocksBuilding = true;
this.rotA = (float)((Math.random() + 1.0) * 0.01F); this.rotA = (float)((Math.random() + 1.0) * 0.01F);
this.reapplyPosition(); this.reapplyPosition();

View file

@ -4,7 +4,7 @@
public FloatGoal(Mob mob) { public FloatGoal(Mob mob) {
this.mob = mob; this.mob = mob;
+ if (mob.getCommandSenderWorld().paperConfig().entities.behavior.spawnerNerfedMobsShouldJump) mob.goalFloat = this; // Paper - Allow nerfed mobs to jump and float + if (mob.level().paperConfig().entities.behavior.spawnerNerfedMobsShouldJump) mob.goalFloat = this; // Paper - Allow nerfed mobs to jump and float
this.setFlags(EnumSet.of(Goal.Flag.JUMP)); this.setFlags(EnumSet.of(Goal.Flag.JUMP));
mob.getNavigation().setCanFloat(true); mob.getNavigation().setCanFloat(true);
} }

View file

@ -50,7 +50,7 @@
+ // Paper start - EntityPathfindEvent + // Paper start - EntityPathfindEvent
+ boolean copiedSet = false; + boolean copiedSet = false;
+ for (BlockPos possibleTarget : targets) { + for (BlockPos possibleTarget : targets) {
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border + if (!this.mob.level().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { + io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
+ if (!copiedSet) { + if (!copiedSet) {
+ copiedSet = true; + copiedSet = true;

View file

@ -4,7 +4,7 @@
} }
public void stopFollowing() { public void stopFollowing() {
+ if (this.leader == null) return; // Avoid NPE, plugins can now set the leader and certain fish goals might cause this method to be called + if (this.leader == null) return; // Paper - Avoid NPE, plugins can now set the leader and certain fish goals might cause this method to be called
this.leader.removeFollower(); this.leader.removeFollower();
this.leader = null; this.leader = null;
} }

View file

@ -14,8 +14,8 @@
@Override @Override
- protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) { - protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) {
+ // CraftBukkit start - void -> boolean + // CraftBukkit start - void -> boolean
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, org.bukkit.event.entity.EntityDamageEvent event) { + public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event); + boolean damageResult = super.actuallyHurt(level, damageSource, amount, event);
+ if (!damageResult) return false; + if (!damageResult) return false;
this.resetLove(); this.resetLove();
- super.actuallyHurt(level, damageSource, amount); - super.actuallyHurt(level, damageSource, amount);

View file

@ -1,6 +1,10 @@
--- a/net/minecraft/world/entity/animal/Bee.java --- a/net/minecraft/world/entity/animal/Bee.java
+++ b/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java
@@ -144,7 +_,22 @@ @@ -141,10 +_,26 @@
Bee.BeeGoToHiveGoal goToHiveGoal;
private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal;
private int underWaterTicks;
+ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override
public Bee(EntityType<? extends Bee> entityType, Level level) { public Bee(EntityType<? extends Bee> entityType, Level level) {
super(entityType, level); super(entityType, level);
@ -65,24 +69,18 @@
- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); - return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ // Paper start - move over logic to accommodate isTooFarAway with chunk load check + // Paper start - move over logic to accommodate isTooFarAway with chunk load check
+ if (this.hivePos != null && !this.isTooFarAway(this.hivePos) && this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) != null) { + if (this.hivePos != null && !this.isTooFarAway(this.hivePos) && this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) != null) {
+ return (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); + return this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
} }
+ return null; + return null;
+ // Paper end + // Paper end
} }
boolean isHiveValid() { boolean isHiveValid() {
@@ -520,11 +_,13 @@ @@ -525,6 +_,7 @@
this.setFlag(4, hasStung);
}
+ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override
public boolean isRolling() {
return this.getFlag(2);
} }
public void setRolling(boolean isRolling) { public void setRolling(boolean isRolling) {
+ isRolling = rollingOverride.toBooleanOrElse(isRolling); // Paper - Rolling override + isRolling = this.rollingOverride.toBooleanOrElse(isRolling); // Paper - Rolling override
this.setFlag(2, isRolling); this.setFlag(2, isRolling);
} }

View file

@ -1,18 +1,19 @@
--- a/net/minecraft/world/entity/animal/Dolphin.java --- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java
@@ -63,6 +_,12 @@ @@ -96,6 +_,13 @@
import net.minecraft.world.phys.Vec3; return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING);
}
public class Dolphin extends AgeableWaterCreature {
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ @Override + @Override
+ public int getDefaultMaxAirSupply() { + public int getDefaultMaxAirSupply() {
+ return TOTAL_AIR_SUPPLY; + return TOTAL_AIR_SUPPLY;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
private static final EntityDataAccessor<BlockPos> TREASURE_POS = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BLOCK_POS); +
private static final EntityDataAccessor<Boolean> GOT_FISH = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BOOLEAN); @Override
private static final EntityDataAccessor<Integer> MOISTNESS_LEVEL = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.INT); public float getAgeScale() {
return this.isBaby() ? 0.65F : 1.0F;
@@ -196,7 +_,7 @@ @@ -196,7 +_,7 @@
@Override @Override

View file

@ -22,9 +22,9 @@
} }
@Override @Override
@@ -620,4 +_,11 @@ @@ -521,6 +_,13 @@
return Util.getRandom(variants, random); ) {
} return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON);
} }
+ +
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
@ -33,4 +33,6 @@
+ return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY; + return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
}
public static enum AnimationState {
PLAYING_DEAD,

View file

@ -34,10 +34,11 @@
} }
} }
@@ -381,4 +_,14 @@ @@ -381,4 +_,15 @@
) { ) {
return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos);
} }
+
+ // Paper start - Goat ram API + // Paper start - Goat ram API
+ public void ram(net.minecraft.world.entity.LivingEntity entity) { + public void ram(net.minecraft.world.entity.LivingEntity entity) {
+ Brain<Goat> brain = this.getBrain(); + Brain<Goat> brain = this.getBrain();

View file

@ -1,12 +1,13 @@
--- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java --- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@@ -69,9 +_,16 @@ @@ -69,9 +_,17 @@
super.dropEquipment(level); super.dropEquipment(level);
if (this.hasChest()) { if (this.hasChest()) {
this.spawnAtLocation(level, Blocks.CHEST); this.spawnAtLocation(level, Blocks.CHEST);
+ //this.setChest(false); // Paper - moved to post death logic + //this.setChest(false); // Paper - moved to post death logic
+ } + }
+ } + }
+
+ // Paper start + // Paper start
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
+ if (this.hasChest() && (event == null || !event.isCancelled())) { + if (this.hasChest() && (event == null || !event.isCancelled())) {

View file

@ -24,7 +24,7 @@
} }
+ +
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + public final List<HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK; + private int maxStack = MAX_STACK;
+ +
+ @Override + @Override
@ -132,7 +132,7 @@
} }
if (this.canEatGrass()) { if (this.canEatGrass()) {
@@ -690,6 +_,15 @@ @@ -690,6 +_,16 @@
} }
} }
@ -140,6 +140,7 @@
+ public void setMouthOpen(boolean open) { + public void setMouthOpen(boolean open) {
+ this.setFlag(FLAG_OPEN_MOUTH, open); + this.setFlag(FLAG_OPEN_MOUTH, open);
+ } + }
+
+ public boolean isMouthOpen() { + public boolean isMouthOpen() {
+ return this.getFlag(FLAG_OPEN_MOUTH); + return this.getFlag(FLAG_OPEN_MOUTH);
+ } + }
@ -148,7 +149,7 @@
@Override @Override
public InteractionResult mobInteract(Player player, InteractionHand hand) { public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (this.isVehicle() || this.isBaby()) { if (this.isVehicle() || this.isBaby()) {
@@ -727,6 +_,11 @@ @@ -727,6 +_,12 @@
this.setFlag(16, eating); this.setFlag(16, eating);
} }
@ -157,6 +158,7 @@
+ this.setFlag(FLAG_STANDING, standing); + this.setFlag(FLAG_STANDING, standing);
+ } + }
+ // Paper end - Horse API + // Paper end - Horse API
+
public void setStanding(boolean standing) { public void setStanding(boolean standing) {
if (standing) { if (standing) {
this.setEating(false); this.setEating(false);

View file

@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java --- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -266,6 +_,13 @@ @@ -267,6 +_,13 @@
BlockPos headBlock = this.getHeadBlock();
this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.SNIFFER_DIGGING, (serverLevel1, itemStack) -> { this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.SNIFFER_DIGGING, (serverLevel1, itemStack) -> {
ItemEntity itemEntity = new ItemEntity(this.level(), headBlock.getX(), headBlock.getY(), headBlock.getZ(), itemStack); ItemEntity itemEntity = new ItemEntity(this.level(), headBlock.getX(), headBlock.getY(), headBlock.getZ(), itemStack);
itemEntity.setDefaultPickUpDelay();
+ // CraftBukkit start - handle EntityDropItemEvent + // CraftBukkit start - handle EntityDropItemEvent
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event); + org.bukkit.Bukkit.getPluginManager().callEvent(event);
@ -11,9 +11,9 @@
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
itemEntity.setDefaultPickUpDelay();
serverLevel1.addFreshEntity(itemEntity); serverLevel1.addFreshEntity(itemEntity);
}); });
this.playSound(SoundEvents.SNIFFER_DROP_SEED, 1.0F, 1.0F);
@@ -325,12 +_,17 @@ @@ -325,12 +_,17 @@
@Override @Override

View file

@ -48,16 +48,14 @@
double d = flyTargetLocation.x - this.getX(); double d = flyTargetLocation.x - this.getX();
double d1 = flyTargetLocation.y - this.getY(); double d1 = flyTargetLocation.y - this.getY();
double d2 = flyTargetLocation.z - this.getZ(); double d2 = flyTargetLocation.z - this.getZ();
@@ -369,7 +_,14 @@ @@ -369,7 +_,12 @@
if (this.nearestCrystal.isRemoved()) { if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null; this.nearestCrystal = null;
} else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
- this.setHealth(this.getHealth() + 1.0F); - this.setHealth(this.getHealth() + 1.0F);
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.event.entity.EntityRegainHealthEvent event = new org.bukkit.event.entity.EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); + org.bukkit.event.entity.EntityRegainHealthEvent event = new org.bukkit.event.entity.EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
+ this.level().getCraftServer().getPluginManager().callEvent(event); + if (event.callEvent()) {
+
+ if (!event.isCancelled()) {
+ this.setHealth((float) (this.getHealth() + event.getAmount())); + this.setHealth((float) (this.getHealth() + event.getAmount()));
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -94,7 +92,7 @@
} else { } else {
flag = true; flag = true;
} }
@@ -450,6 +_,54 @@ @@ -450,6 +_,58 @@
} }
} }
@ -116,32 +114,36 @@
+ } + }
+ } else { + } else {
+ for (org.bukkit.block.Block block : event.blockList()) { + for (org.bukkit.block.Block block : event.blockList()) {
+ org.bukkit.Material blockId = block.getType(); + org.bukkit.Material blockType = block.getType();
+ if (blockId.isAir()) { + if (blockType.isAir()) {
+ continue; + continue;
+ } + }
+ +
+ org.bukkit.craftbukkit.block.CraftBlock craftBlock = ((org.bukkit.craftbukkit.block.CraftBlock) block); + org.bukkit.craftbukkit.block.CraftBlock craftBlock = ((org.bukkit.craftbukkit.block.CraftBlock) block);
+ BlockPos blockposition = craftBlock.getPosition(); + BlockPos pos = craftBlock.getPosition();
+ +
+ net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().getBlock(); + net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().getBlock();
+ if (nmsBlock.dropFromExplosion(this.explosionSource)) { + if (nmsBlock.dropFromExplosion(this.explosionSource)) {
+ net.minecraft.world.level.block.entity.BlockEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(blockposition) : null; + net.minecraft.world.level.block.entity.BlockEntity blockEntity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(pos) : null;
+ net.minecraft.world.level.storage.loot.LootParams.Builder loottableinfo_builder = (new net.minecraft.world.level.storage.loot.LootParams.Builder((ServerLevel) this.level())).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, Vec3.atCenterOf(blockposition)).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.TOOL, net.minecraft.world.item.ItemStack.EMPTY).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.BLOCK_ENTITY, tileentity); + net.minecraft.world.level.storage.loot.LootParams.Builder builder = new net.minecraft.world.level.storage.loot.LootParams.Builder((ServerLevel) this.level())
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.TOOL, net.minecraft.world.item.ItemStack.EMPTY)
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.EXPLOSION_RADIUS, 1.0F / event.getYield())
+ .withOptionalParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.BLOCK_ENTITY, blockEntity);
+ +
+ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> { + craftBlock.getNMS().getDrops(builder).forEach((stack) -> {
+ net.minecraft.world.level.block.Block.popResource(this.level(), blockposition, itemstack); + net.minecraft.world.level.block.Block.popResource(this.level(), pos, stack);
+ }); + });
+ craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, net.minecraft.world.item.ItemStack.EMPTY, false); + craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), pos, net.minecraft.world.item.ItemStack.EMPTY, false);
+ } + }
+ // Paper start - TNTPrimeEvent + // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level(), blockposition); + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level(), pos);
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent()) + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent())
+ continue; + continue;
+ // Paper end - TNTPrimeEvent + // Paper end - TNTPrimeEvent
+ nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource); + nmsBlock.wasExploded((ServerLevel) this.level(), pos, this.explosionSource);
+ +
+ this.level().removeBlock(blockposition, false); + this.level().removeBlock(pos, false);
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end

View file

@ -6,7 +6,7 @@
DragonFireball dragonFireball = new DragonFireball(level, this.dragon, vec32.normalize()); DragonFireball dragonFireball = new DragonFireball(level, this.dragon, vec32.normalize());
+ dragonFireball.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported + dragonFireball.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported
dragonFireball.moveTo(d2, d3, d4, 0.0F, 0.0F); dragonFireball.moveTo(d2, d3, d4, 0.0F, 0.0F);
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events + if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events
level.addFreshEntity(dragonFireball); level.addFreshEntity(dragonFireball);
+ else dragonFireball.discard(null); // Paper - EnderDragon Events + else dragonFireball.discard(null); // Paper - EnderDragon Events
this.fireballCharge = 0; this.fireballCharge = 0;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java --- a/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java
+++ b/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java
@@ -23,6 +_,19 @@ @@ -23,6 +_,18 @@
this.currentPhase.end(); this.currentPhase.end();
} }
@ -10,8 +10,7 @@
+ (this.currentPhase == null) ? null : org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()), + (this.currentPhase == null) ? null : org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()),
+ org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(phase) + org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(phase)
+ ); + );
+ this.dragon.level().getCraftServer().getPluginManager().callEvent(event); + if (!event.callEvent()) {
+ if (event.isCancelled()) {
+ return; + return;
+ } + }
+ phase = org.bukkit.craftbukkit.entity.CraftEnderDragon.getMinecraftPhase(event.getNewPhase()); + phase = org.bukkit.craftbukkit.entity.CraftEnderDragon.getMinecraftPhase(event.getNewPhase());

View file

@ -1,18 +1,13 @@
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -77,6 +_,12 @@ @@ -69,6 +_,7 @@
&& entity.attackable(); private final int[] nextHeadUpdate = new int[2];
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0).selector(LIVING_ENTITY_SELECTOR); private final int[] idleHeadUpdates = new int[2];
private int destroyBlocksTick;
+ // Paper start + private boolean canPortal = false; // Paper
+ private boolean canPortal = false; public final ServerBossEvent bossEvent = (ServerBossEvent)new ServerBossEvent(
+ this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS
+ public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; } )
+ // Paper end
+
public WitherBoss(EntityType<? extends WitherBoss> entityType, Level level) {
super(entityType, level);
this.moveControl = new FlyingMoveControl(this, 10, false);
@@ -260,15 +_,40 @@ @@ -260,15 +_,40 @@
int i = this.getInvulnerableTicks() - 1; int i = this.getInvulnerableTicks() - 1;
this.bossEvent.setProgress(1.0F - i / 220.0F); this.bossEvent.setProgress(1.0F - i / 220.0F);
@ -106,13 +101,20 @@
} else { } else {
this.noActionTime = 0; this.noActionTime = 0;
} }
@@ -547,12 +_,12 @@ @@ -547,12 +_,18 @@
@Override @Override
public boolean canUsePortal(boolean allowPassengers) { public boolean canUsePortal(boolean allowPassengers) {
- return false; - return false;
- }
+ return this.canPortal; // Paper + return this.canPortal; // Paper
} + }
+
+ // Paper start
+ public void setCanTravelThroughPortals(boolean canPortal) {
+ this.canPortal = canPortal;
+ }
+ // Paper end
@Override @Override
public boolean canBeAffected(MobEffectInstance potioneffect) { public boolean canBeAffected(MobEffectInstance potioneffect) {

View file

@ -155,7 +155,7 @@
+ // CraftBukkit end + // CraftBukkit end
+ // Paper start - avoid duplicate event call + // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource); + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource);
+ if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit + if (!event.isCancelled()) this.kill(level, damageSource, false); // CraftBukkit
+ // Paper end + // Paper end
return false; return false;
} else if (damageSource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { } else if (damageSource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
@ -204,7 +204,7 @@
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(level, damageSource); // Paper + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(level, damageSource); // Paper
this.showBreakingParticles(); this.showBreakingParticles();
- this.kill(level); - this.kill(level);
+ if (!event.isCancelled()) this.kill(damageSource, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...) + if (!event.isCancelled()) this.kill(level, damageSource, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
} }
return true; return true;
@ -215,7 +215,7 @@
- this.kill(level); - this.kill(level);
+ // Paper start - avoid duplicate event call + // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource); + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource);
+ if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit + if (!event.isCancelled()) this.kill(level, damageSource, false); // CraftBukkit
+ // Paper end + // Paper end
} else { } else {
this.setHealth(health); this.setHealth(health);
@ -289,7 +289,7 @@
Rotations rotations = this.entityData.get(DATA_HEAD_POSE); Rotations rotations = this.entityData.get(DATA_HEAD_POSE);
if (!this.headPose.equals(rotations)) { if (!this.headPose.equals(rotations)) {
this.setHeadPose(rotations); this.setHeadPose(rotations);
@@ -587,9 +_,31 @@ @@ -587,9 +_,32 @@
return this.isSmall(); return this.isSmall();
} }
@ -309,9 +309,10 @@
+ +
+ public void kill(ServerLevel level, @Nullable DamageSource damageSource) { + public void kill(ServerLevel level, @Nullable DamageSource damageSource) {
+ // Paper start - make cancellable + // Paper start - make cancellable
+ this.kill(damageSource, true); + this.kill(level, damageSource, true);
+ } + }
+ public void kill(@Nullable DamageSource damageSource, boolean callEvent) { +
+ public void kill(ServerLevel level, @Nullable DamageSource damageSource, boolean callEvent) {
+ if (callEvent) { + if (callEvent) {
+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event + org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event
+ if (event.isCancelled()) return; + if (event.isCancelled()) return;

View file

@ -4,7 +4,7 @@
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.slf4j.Logger; import org.slf4j.Logger;
+// CraftBukkit start; +// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end +// CraftBukkit end
@ -20,28 +20,14 @@
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) { public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level); super(entityType, level);
@@ -80,6 +_,10 @@ @@ -89,6 +_,7 @@
}
public static FallingBlockEntity fall(Level level, BlockPos pos, BlockState blockState) {
+ // CraftBukkit start
+ return FallingBlockEntity.fall(level, pos, blockState, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+ public static FallingBlockEntity fall(Level level, BlockPos pos, BlockState blockState, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) {
FallingBlockEntity fallingBlockEntity = new FallingBlockEntity(
level,
pos.getX() + 0.5,
@@ -89,8 +_,9 @@
? blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)) ? blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false))
: blockState : blockState
); );
+ if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit + if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3); level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3);
- level.addFreshEntity(fallingBlockEntity); level.addFreshEntity(fallingBlockEntity);
+ level.addFreshEntity(fallingBlockEntity, creatureSpawnReason); // CraftBukkit
return fallingBlockEntity; return fallingBlockEntity;
}
@@ -139,13 +_,22 @@ @@ -139,13 +_,22 @@
@Override @Override
public void tick() { public void tick() {
@ -147,9 +133,9 @@
} }
+ +
+ // Paper start - Expand FallingBlock API + // Paper start - Expand FallingBlock API
+ if (compound.contains("Paper.AutoExpire")) { + if (compound.contains("Paper.AutoExpire")) {
+ this.autoExpire = compound.getBoolean("Paper.AutoExpire"); + this.autoExpire = compound.getBoolean("Paper.AutoExpire");
+ } + }
+ // Paper end - Expand FallingBlock API + // Paper end - Expand FallingBlock API
} }

View file

@ -142,18 +142,18 @@
} }
return true; return true;
@@ -308,6 +_,11 @@ @@ -322,6 +_,11 @@
if (!this.getItem().isEmpty()) {
@Override compound.put("Item", this.getItem().save(this.registryAccess()));
public void addAdditionalSaveData(CompoundTag compound) { }
+ // Paper start - Friction API + // Paper start - Friction API
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) { + if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
+ compound.putString("Paper.FrictionState", this.frictionState.toString()); + compound.putString("Paper.FrictionState", this.frictionState.toString());
+ } + }
+ // Paper end - Friction API + // Paper end - Friction API
compound.putShort("Health", (short)this.health); }
compound.putShort("Age", (short)this.age);
compound.putShort("PickupDelay", (short)this.pickupDelay); @Override
@@ -347,9 +_,19 @@ @@ -347,9 +_,19 @@
} else { } else {
this.setItem(ItemStack.EMPTY); this.setItem(ItemStack.EMPTY);
@ -164,7 +164,7 @@
+ try { + try {
+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs); + frictionState = net.kyori.adventure.util.TriState.valueOf(fs);
+ } catch (Exception ignored) { + } catch (Exception ignored) {
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state " + fs + " for " + this); + com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", fs, this);
+ } + }
+ } + }
+ // Paper end - Friction API + // Paper end - Friction API

View file

@ -4,7 +4,7 @@
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.level.portal.TeleportTransition;
+// CraftBukkit start; +// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent;
@ -95,7 +95,7 @@
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ // Craftbukkit end + // CraftBukkit end
this.level() this.level()
.explode( .explode(
this, this,
@ -118,7 +118,7 @@
+ // Paper start - Option to prevent TNT from moving in water + // Paper start - Option to prevent TNT from moving in water
+ @Override + @Override
+ public boolean isPushedByFluid() { + public boolean isPushedByFluid() {
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid(); + return !this.level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
+ } + }
+ // Paper end - Option to prevent TNT from moving in water + // Paper end - Option to prevent TNT from moving in water
} }

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/Bogged.java --- a/net/minecraft/world/entity/monster/Bogged.java
+++ b/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java
@@ -72,7 +_,20 @@ @@ -72,7 +_,19 @@
ItemStack itemInHand = player.getItemInHand(hand); ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
@ -11,18 +11,17 @@
+ org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemInHand, hand, drops); + org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemInHand, hand, drops);
+ if (event != null) { + if (event != null) {
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients // Paper - no longer needed
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ } + }
+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); + drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops());
+ // Paper end - custom shear drops + // Paper end - custom shear drops
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ this.shear(serverLevel, SoundSource.PLAYERS, itemInHand, drops); // Paper - custom shear drops + this.shear(serverLevel, SoundSource.PLAYERS, itemInHand, drops); // Paper - custom shear drops
this.gameEvent(GameEvent.SHEAR, player); this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
} }
@@ -125,15 +_,34 @@ @@ -125,15 +_,33 @@
@Override @Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) { public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
@ -53,10 +52,9 @@
- level, BuiltInLootTables.BOGGED_SHEAR, stack, (serverLevel, itemStack) -> this.spawnAtLocation(serverLevel, itemStack, this.getBbHeight()) - level, BuiltInLootTables.BOGGED_SHEAR, stack, (serverLevel, itemStack) -> this.spawnAtLocation(serverLevel, itemStack, this.getBbHeight())
- ); - );
+ // Paper start - custom shear drops + // Paper start - custom shear drops
+ private void spawnShearedMushrooms(ServerLevel world, ItemStack shears, java.util.List<ItemStack> drops) { + private void spawnShearedMushrooms(ServerLevel level, ItemStack stack, java.util.List<ItemStack> drops) {
+ final ServerLevel worldserver1 = world; // Named for lambda consumption
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles + this.forceDrops = true; // Paper - Add missing forceDrop toggles
+ drops.forEach(itemstack1 -> this.spawnAtLocation(world, shears, this.getBbHeight())); + drops.forEach(itemstack1 -> this.spawnAtLocation(level, stack, this.getBbHeight()));
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles + this.forceDrops = false; // Paper - Add missing forceDrop toggles
+ // Paper end - custom shear drops + // Paper end - custom shear drops
} }

View file

@ -13,7 +13,7 @@
if (compound.getBoolean("ignited")) { if (compound.getBoolean("ignited")) {
- this.ignite(); - this.ignite();
+ this.entityData.set(Creeper.DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event + this.entityData.set(DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event
} }
} }
@ -66,7 +66,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ } else { + } else {
+ this.swell = 0; + this.swell = 0;
+ this.entityData.set(DATA_IS_IGNITED, Boolean.valueOf(false)); // Paper + this.entityData.set(DATA_IS_IGNITED, false); // Paper
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
@ -81,7 +81,7 @@
areaEffectCloud.setRadius(2.5F); areaEffectCloud.setRadius(2.5F);
areaEffectCloud.setRadiusOnUse(-0.5F); areaEffectCloud.setRadiusOnUse(-0.5F);
areaEffectCloud.setWaitTime(10); areaEffectCloud.setWaitTime(10);
@@ -254,16 +_,26 @@ @@ -254,16 +_,27 @@
areaEffectCloud.addEffect(new MobEffectInstance(mobEffectInstance)); areaEffectCloud.addEffect(new MobEffectInstance(mobEffectInstance));
} }
@ -91,12 +91,13 @@
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit + this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
+ } + }
+ } + }
+
+ // Paper start - CreeperIgniteEvent + // Paper start - CreeperIgniteEvent
+ public void setIgnited(boolean ignited) { + public void setIgnited(boolean ignited) {
+ if (isIgnited() != ignited) { + if (isIgnited() != ignited) {
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited); + com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited);
+ if (event.callEvent()) { + if (event.callEvent()) {
+ this.entityData.set(Creeper.DATA_IS_IGNITED, event.isIgnited()); + this.entityData.set(DATA_IS_IGNITED, event.isIgnited());
+ } + }
+ } + }
+ } + }

View file

@ -71,22 +71,23 @@
return flag1; return flag1;
} }
@@ -400,6 +_,15 @@ @@ -401,6 +_,16 @@
public void setBeingStaredAt() {
this.entityData.set(DATA_STARED_AT, true); this.entityData.set(DATA_STARED_AT, true);
} }
+ // Paper start + // Paper start
+ public void setCreepy(boolean creepy) { + public void setCreepy(boolean creepy) {
+ this.entityData.set(EnderMan.DATA_CREEPY, creepy); + this.entityData.set(DATA_CREEPY, creepy);
+ } + }
+ +
+ public void setHasBeenStaredAt(boolean hasBeenStaredAt) { + public void setHasBeenStaredAt(boolean hasBeenStaredAt) {
+ this.entityData.set(EnderMan.DATA_STARED_AT, hasBeenStaredAt); + this.entityData.set(DATA_STARED_AT, hasBeenStaredAt);
+ } + }
+ // Paper end + // Paper end
+
@Override @Override
public boolean requiresCustomPersistence() { public boolean requiresCustomPersistence() {
return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
@@ -460,16 +_,19 @@ @@ -460,16 +_,19 @@
int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0);
int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0);

View file

@ -17,7 +17,7 @@
} }
LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower()); LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower());
+ largeFireball.bukkitYield = largeFireball.explosionPower = this.ghast.getExplosionPower(); // CraftBukkit - set bukkitYield when setting explosionpower + largeFireball.bukkitYield = largeFireball.explosionPower = this.ghast.getExplosionPower(); // CraftBukkit - set bukkitYield when setting explosionPower
largeFireball.setPos(this.ghast.getX() + viewVector.x * 4.0, this.ghast.getY(0.5) + 0.5, largeFireball.getZ() + viewVector.z * 4.0); largeFireball.setPos(this.ghast.getX() + viewVector.x * 4.0, this.ghast.getY(0.5) + 0.5, largeFireball.getZ() + viewVector.z * 4.0);
level.addFreshEntity(largeFireball); level.addFreshEntity(largeFireball);
this.chargeTime = -40; this.chargeTime = -40;

View file

@ -1,5 +1,17 @@
--- a/net/minecraft/world/entity/monster/Phantom.java --- a/net/minecraft/world/entity/monster/Phantom.java
+++ b/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java
@@ -47,6 +_,11 @@
Vec3 moveTargetPoint = Vec3.ZERO;
public BlockPos anchorPoint = BlockPos.ZERO;
Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE;
+ // Paper start
+ @Nullable
+ public java.util.UUID spawningEntity;
+ public boolean shouldBurnInDay = true;
+ // Paper end
public Phantom(EntityType<? extends Phantom> entityType, Level level) {
super(entityType, level);
@@ -141,7 +_,7 @@ @@ -141,7 +_,7 @@
@Override @Override
@ -9,10 +21,11 @@
this.igniteForSeconds(8.0F); this.igniteForSeconds(8.0F);
} }
@@ -165,6 +_,14 @@ @@ -165,6 +_,15 @@
} }
this.setPhantomSize(compound.getInt("Size")); this.setPhantomSize(compound.getInt("Size"));
+
+ // Paper start + // Paper start
+ if (compound.hasUUID("Paper.SpawningEntity")) { + if (compound.hasUUID("Paper.SpawningEntity")) {
+ this.spawningEntity = compound.getUUID("Paper.SpawningEntity"); + this.spawningEntity = compound.getUUID("Paper.SpawningEntity");
@ -32,31 +45,11 @@
+ if (this.spawningEntity != null) { + if (this.spawningEntity != null) {
+ compound.putUUID("Paper.SpawningEntity", this.spawningEntity); + compound.putUUID("Paper.SpawningEntity", this.spawningEntity);
+ } + }
+ compound.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); + compound.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
+ // Paper end + // Paper end
} }
@Override @Override
@@ -222,6 +_,19 @@
return targetingConditions.test(level, this, entity);
}
+ // Paper start
+ @Nullable
+ java.util.UUID spawningEntity;
+
+ @Nullable
+ public java.util.UUID getSpawningEntity() {
+ return this.spawningEntity;
+ }
+ public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
+ private boolean shouldBurnInDay = true;
+ public boolean shouldBurnInDay() { return shouldBurnInDay; }
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
+ // Paper end
static enum AttackPhase {
CIRCLE,
SWOOP;
@@ -247,7 +_,8 @@ @@ -247,7 +_,8 @@
for (Player player : nearbyPlayers) { for (Player player : nearbyPlayers) {

View file

@ -175,10 +175,11 @@
} }
@Override @Override
@@ -398,6 +_,12 @@ @@ -398,6 +_,13 @@
slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage());
} }
} }
+
+ // Paper start - Slime pathfinder events; clear timer and target when goal resets + // Paper start - Slime pathfinder events; clear timer and target when goal resets
+ public void stop() { + public void stop() {
+ this.growTiredTimer = 0; + this.growTiredTimer = 0;

View file

@ -30,7 +30,7 @@
PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY),
SoundEvents.WANDERING_TRADER_DISAPPEARED, SoundEvents.WANDERING_TRADER_DISAPPEARED,
- wanderingTrader -> this.level().isNight() && !wanderingTrader.isInvisible() - wanderingTrader -> this.level().isNight() && !wanderingTrader.isInvisible()
+ wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API + wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
) )
); );
this.goalSelector this.goalSelector

View file

@ -106,7 +106,7 @@
+ org.bukkit.inventory.InventoryView view = this.getBukkitView(); + org.bukkit.inventory.InventoryView view = this.getBukkitView();
+ org.bukkit.inventory.ItemStack newcursor = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack); + org.bukkit.inventory.ItemStack newcursor = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack);
+ newcursor.setAmount(count); + newcursor.setAmount(count);
+ java.util.Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new java.util.HashMap<Integer, org.bukkit.inventory.ItemStack>(); + java.util.Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new java.util.HashMap<>();
+ for (java.util.Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) { + for (java.util.Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) {
+ eventmap.put(ditem.getKey(), org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(ditem.getValue())); + eventmap.put(ditem.getKey(), org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(ditem.getValue()));
+ } + }
@ -147,12 +147,11 @@
if (!this.getCarried().isEmpty()) { if (!this.getCarried().isEmpty()) {
if (clickAction == ClickAction.PRIMARY) { if (clickAction == ClickAction.PRIMARY) {
- player.drop(this.getCarried(), true); - player.drop(this.getCarried(), true);
- this.setCarried(ItemStack.EMPTY); + // CraftBukkit start
+ // CraftBukkit start + ItemStack carried = this.getCarried();
+ ItemStack carried = this.getCarried(); this.setCarried(ItemStack.EMPTY);
+ this.setCarried(ItemStack.EMPTY); + player.drop(carried, true);
+ player.drop(carried, true); + // CraftBukkit end
+ // CraftBukkit start
} else { } else {
player.drop(this.getCarried().split(1), true); player.drop(this.getCarried().split(1), true);
} }

View file

@ -18,7 +18,8 @@
super(MenuType.BREWING_STAND, containerId); super(MenuType.BREWING_STAND, containerId);
+ this.player = playerInventory; // CraftBukkit + this.player = playerInventory; // CraftBukkit
checkContainerSize(brewingStandContainer, 5); checkContainerSize(brewingStandContainer, 5);
checkContainerDataCount(brewingStandData, 2); - checkContainerDataCount(brewingStandData, 2);
+ checkContainerDataCount(brewingStandData, 3); // Paper - Add recipeBrewTime
this.brewingStand = brewingStandContainer; this.brewingStand = brewingStandContainer;
this.brewingStandData = brewingStandData; this.brewingStandData = brewingStandData;
PotionBrewing potionBrewing = playerInventory.player.level().potionBrewing(); PotionBrewing potionBrewing = playerInventory.player.level().potionBrewing();
@ -61,7 +62,7 @@
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
- } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack)) { - } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack)) {
+ } else if (PotionSlot.mayPlaceItem(itemStack, this.player.player.level().potionBrewing())) { // Paper - custom potion mixes + } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack, this.player.player.level().potionBrewing())) { // Paper - custom potion mixes
if (!this.moveItemStackTo(item, 0, 3, false)) { if (!this.moveItemStackTo(item, 0, 3, false)) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }

View file

@ -49,7 +49,7 @@
public CartographyTableMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) { public CartographyTableMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) {
super(MenuType.CARTOGRAPHY_TABLE, containerId); super(MenuType.CARTOGRAPHY_TABLE, containerId);
+ // Paper Start - Add missing InventoryHolders - move down + // Paper start - Add missing InventoryHolders - move down
+ this.container = new SimpleContainer(this.createBlockHolder(access), 2) { // Paper - Add missing InventoryHolders + this.container = new SimpleContainer(this.createBlockHolder(access), 2) { // Paper - Add missing InventoryHolders
+ @Override + @Override
+ public void setChanged() { + public void setChanged() {
@ -66,7 +66,7 @@
+ this.resultContainer = new ResultContainer(this.createBlockHolder(access)) { // Paper - Add missing InventoryHolders + this.resultContainer = new ResultContainer(this.createBlockHolder(access)) { // Paper - Add missing InventoryHolders
+ @Override + @Override
+ public void setChanged() { + public void setChanged() {
+ CartographyTableMenu.this.slotsChanged(this); + // CartographyTableMenu.this.slotsChanged(this); // Paper - Add CartographyItemEvent - do not recompute results if the result slot changes - allows to set the result slot via api
+ super.setChanged(); + super.setChanged();
+ } + }
+ // CraftBukkit start + // CraftBukkit start
@ -76,7 +76,7 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ }; + };
+ // Paper Start - Add missing InventoryHolders - move down + // Paper end - Add missing InventoryHolders - move down
this.access = access; this.access = access;
this.addSlot(new Slot(this.container, 0, 15, 15) { this.addSlot(new Slot(this.container, 0, 15, 15) {
@Override @Override

View file

@ -20,7 +20,7 @@
public final int[] levelClue = new int[]{-1, -1, -1}; public final int[] levelClue = new int[]{-1, -1, -1};
+ // CraftBukkit start + // CraftBukkit start
+ private org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView bukkitEntity = null; + private org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView bukkitEntity = null;
+ private org.bukkit.entity.Player player; + private final org.bukkit.entity.Player player;
+ // CraftBukkit end + // CraftBukkit end
public EnchantmentMenu(int containerId, Inventory playerInventory) { public EnchantmentMenu(int containerId, Inventory playerInventory) {
@ -48,13 +48,11 @@
this.access = access; this.access = access;
this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) { this.addSlot(new Slot(this.enchantSlots, 0, 15, 47) {
@Override @Override
@@ -80,13 +_,16 @@ @@ -80,13 +_,14 @@
this.addDataSlot(DataSlot.shared(this.levelClue, 0)); this.addDataSlot(DataSlot.shared(this.levelClue, 0));
this.addDataSlot(DataSlot.shared(this.levelClue, 1)); this.addDataSlot(DataSlot.shared(this.levelClue, 1));
this.addDataSlot(DataSlot.shared(this.levelClue, 2)); this.addDataSlot(DataSlot.shared(this.levelClue, 2));
+ // CraftBukkit start + this.player = (org.bukkit.entity.Player) playerInventory.player.getBukkitEntity(); // CraftBukkit
+ this.player = (org.bukkit.entity.Player) playerInventory.player.getBukkitEntity();
+ // CraftBukkit end
} }
@Override @Override
@ -180,10 +178,11 @@
return stillValid(this.access, player, Blocks.ENCHANTING_TABLE); return stillValid(this.access, player, Blocks.ENCHANTING_TABLE);
} }
@@ -261,4 +_,22 @@ @@ -261,4 +_,23 @@
return itemStack; return itemStack;
} }
+
+ // CraftBukkit start + // CraftBukkit start
+ @Override + @Override
+ public org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView getBukkitView() { + public org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView getBukkitView() {

View file

@ -26,13 +26,13 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ // CraftBukkit start - add player + // CraftBukkit start - add player inventory
+ public LecternMenu(int containerId, net.minecraft.world.entity.player.Inventory playerinventory) { + public LecternMenu(int containerId, net.minecraft.world.entity.player.Inventory playerinventory) {
+ this(containerId, new SimpleContainer(1), new SimpleContainerData(1), playerinventory); + this(containerId, new SimpleContainer(1), new SimpleContainerData(1), playerinventory);
+ // CraftBukkit end - add player
+ } + }
+ +
+ public LecternMenu(int containerId, Container lectern, ContainerData lecternData, net.minecraft.world.entity.player.Inventory playerinventory) { + public LecternMenu(int containerId, Container lectern, ContainerData lecternData, net.minecraft.world.entity.player.Inventory playerinventory) {
+ // CraftBukkit end - add player inventory
super(MenuType.LECTERN, containerId); super(MenuType.LECTERN, containerId);
checkContainerSize(lectern, 1); checkContainerSize(lectern, 1);
checkContainerDataCount(lecternData, 1); checkContainerDataCount(lecternData, 1);

View file

@ -5,7 +5,7 @@
public int selectionHint; public int selectionHint;
private int futureXp; private int futureXp;
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
+ public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<org.bukkit.entity.HumanEntity>(); + public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK; + private int maxStack = MAX_STACK;
+ +
+ public java.util.List<ItemStack> getContents() { + public java.util.List<ItemStack> getContents() {
@ -18,7 +18,7 @@
+ +
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.remove(player); + this.transaction.remove(player);
+ this.merchant.setTradingPlayer((Player) null); // SPIGOT-4860 + this.merchant.setTradingPlayer(null); // SPIGOT-4860
+ } + }
+ +
+ public java.util.List<org.bukkit.entity.HumanEntity> getViewers() { + public java.util.List<org.bukkit.entity.HumanEntity> getViewers() {
@ -35,12 +35,12 @@
+ } + }
+ +
+ public org.bukkit.inventory.InventoryHolder getOwner() { + public org.bukkit.inventory.InventoryHolder getOwner() {
+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) ((net.minecraft.world.entity.npc.AbstractVillager) this.merchant).getBukkitEntity() : null; + return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null;
+ } + }
+ +
+ @Override + @Override
+ public org.bukkit.Location getLocation() { + public org.bukkit.Location getLocation() {
+ return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager) ? ((net.minecraft.world.entity.npc.AbstractVillager) this.merchant).getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations + return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations
+ } + }
+ // CraftBukkit end + // CraftBukkit end

View file

@ -23,7 +23,7 @@
+ final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down + final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down
+ // CraftBukkit start + // CraftBukkit start
+ private org.bukkit.craftbukkit.inventory.view.CraftStonecutterView bukkitEntity = null; + private org.bukkit.craftbukkit.inventory.view.CraftStonecutterView bukkitEntity = null;
+ private org.bukkit.entity.Player player; + private final org.bukkit.entity.Player player;
+ +
+ @Override + @Override
+ public org.bukkit.craftbukkit.inventory.view.CraftStonecutterView getBukkitView() { + public org.bukkit.craftbukkit.inventory.view.CraftStonecutterView getBukkitView() {

View file

@ -14,7 +14,7 @@
), ),
serverLevel, serverLevel,
- itemInHand - itemInHand
+ itemInHand, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid + itemInHand, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid
); );
- itemInHand.shrink(1); - itemInHand.shrink(1);
+ // Paper start - PlayerLaunchProjectileEvent + // Paper start - PlayerLaunchProjectileEvent

View file

@ -38,7 +38,7 @@
} }
} }
}; };
@@ -365,10 +_,178 @@ @@ -365,10 +_,171 @@
return InteractionResult.PASS; return InteractionResult.PASS;
} else { } else {
Item item = this.getItem(); Item item = this.getItem();
@ -127,13 +127,6 @@
+ serverLevel.isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent + serverLevel.isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
+ serverLevel.preventPoiUpdated = false; + serverLevel.preventPoiUpdated = false;
+ +
+ // Brute force all possible updates
+ // Paper start - Don't resync blocks
+ // BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ // for (Direction dir : Direction.values()) {
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
+ // }
+ // Paper end - Don't resync blocks
+ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return + SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
+ } else { + } else {
+ // Change the stack to its new contents if it hasn't been tampered with. + // Change the stack to its new contents if it hasn't been tampered with.
@ -179,9 +172,9 @@
+ // SPIGOT-4678 + // SPIGOT-4678
+ if (this.item instanceof SignItem && SignItem.openSign != null) { + if (this.item instanceof SignItem && SignItem.openSign != null) {
+ try { + try {
+ if (serverLevel.getBlockEntity(SignItem.openSign) instanceof net.minecraft.world.level.block.entity.SignBlockEntity tileentitysign) { + if (serverLevel.getBlockEntity(SignItem.openSign) instanceof net.minecraft.world.level.block.entity.SignBlockEntity blockEntity) {
+ if (serverLevel.getBlockState(SignItem.openSign).getBlock() instanceof net.minecraft.world.level.block.SignBlock blocksign) { + if (serverLevel.getBlockState(SignItem.openSign).getBlock() instanceof net.minecraft.world.level.block.SignBlock signBlock) {
+ blocksign.openTextEdit(player, tileentitysign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // Craftbukkit // Paper - Add PlayerOpenSignEvent + signBlock.openTextEdit(player, blockEntity, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // CraftBukkit // Paper - Add PlayerOpenSignEvent
+ } + }
+ } + }
+ } finally { + } finally {
@ -229,7 +222,7 @@
+ // Paper start - add force boolean overload + // Paper start - add force boolean overload
+ this.hurtAndBreak(damage, level, player, onBreak, false); + this.hurtAndBreak(damage, level, player, onBreak, false);
+ } + }
+ public void hurtAndBreak(int damage, ServerLevel level, @Nullable LivingEntity player, Consumer<Item> onBreak, boolean force) { // Paper - Add EntityDamageItemEvent + public void hurtAndBreak(int damage, ServerLevel level, @Nullable LivingEntity player, Consumer<Item> onBreak, boolean force) { // Paper - Add EntityDamageItemEvent
+ // Paper end + // Paper end
+ final int originalDamage = damage; // Paper - Expand PlayerItemDamageEvent + final int originalDamage = damage; // Paper - Expand PlayerItemDamageEvent
+ int i = this.processDurabilityChange(damage, level, player, force); // Paper + int i = this.processDurabilityChange(damage, level, player, force); // Paper

View file

@ -73,11 +73,11 @@
} }
nextSpawnData.getEquipment().ifPresent(mob::equip); nextSpawnData.getEquipment().ifPresent(mob::equip);
+ // Spigot Start + // Spigot start
+ if (mob.level().spigotConfig.nerfSpawnerMobs) { + if (mob.level().spigotConfig.nerfSpawnerMobs) {
+ mob.aware = false; + mob.aware = false;
+ } + }
+ // Spigot End + // Spigot end
} }
- if (!serverLevel.tryAddFreshEntityWithPassengers(entity)) { - if (!serverLevel.tryAddFreshEntityWithPassengers(entity)) {

View file

@ -140,7 +140,7 @@
} }
- public void set(boolean value, @Nullable MinecraftServer server) { - public void set(boolean value, @Nullable MinecraftServer server) {
+ public void set(boolean value, @Nullable ServerLevel level) { // CraftBukkit - per-world + public void set(boolean value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value; this.value = value;
- this.onChanged(server); - this.onChanged(server);
+ this.onChanged(level); // CraftBukkit - per-world + this.onChanged(level); // CraftBukkit - per-world
@ -161,7 +161,7 @@
@Override @Override
- public void setFrom(GameRules.BooleanValue value, @Nullable MinecraftServer server) { - public void setFrom(GameRules.BooleanValue value, @Nullable MinecraftServer server) {
+ public void setFrom(GameRules.BooleanValue value, @Nullable ServerLevel level) { // CraftBukkit - per-world + public void setFrom(GameRules.BooleanValue value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value.value; this.value = value.value;
- this.onChanged(server); - this.onChanged(server);
+ this.onChanged(level); // CraftBukkit - per-world + this.onChanged(level); // CraftBukkit - per-world
@ -208,7 +208,7 @@
+ public void set(int value, @Nullable ServerLevel level) { // CraftBukkit - per-world + public void set(int value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value; this.value = value;
- this.onChanged(server); - this.onChanged(server);
+ this.onChanged(level) ;// CraftBukkit - per-world + this.onChanged(level); // CraftBukkit - per-world
} }
@Override @Override

View file

@ -530,30 +530,25 @@
return chunk.getBlockState(pos); return chunk.getBlockState(pos);
} }
} }
@@ -454,32 +_,54 @@ @@ -454,32 +_,49 @@
this.pendingBlockEntityTickers.clear(); this.pendingBlockEntityTickers.clear();
} }
- Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator(); - Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
+ // Spigot start + // Spigot start
+ // Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
boolean runsNormally = this.tickRateManager().runsNormally(); boolean runsNormally = this.tickRateManager().runsNormally();
- while (iterator.hasNext()) { - while (iterator.hasNext()) {
- TickingBlockEntity tickingBlockEntity = iterator.next(); - TickingBlockEntity tickingBlockEntity = iterator.next();
+ int tilesThisCycle = 0;
+ var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll + var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
+ toRemove.add(null); // Paper - Fix MC-117075 + toRemove.add(null); // Paper - Fix MC-117075
+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters + for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
+ this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; + this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
+ TickingBlockEntity tickingBlockEntity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); + TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
+ // Spigot end + // Spigot end
if (tickingBlockEntity.isRemoved()) { if (tickingBlockEntity.isRemoved()) {
- iterator.remove(); - iterator.remove();
+ // Spigot start + toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
+ tilesThisCycle--;
+ toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
+ // Spigot end
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
tickingBlockEntity.tick(); tickingBlockEntity.tick();
} }

View file

@ -107,7 +107,7 @@
if (nearestPlayer != null) { if (nearestPlayer != null) {
double d2 = nearestPlayer.distanceToSqr(d, y, d1); double d2 = nearestPlayer.distanceToSqr(d, y, d1);
- if (isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { - if (isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) {
+ if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn + if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn
if (spawnerData == null) { if (spawnerData == null) {
Optional<MobSpawnSettings.SpawnerData> randomSpawnMobAt = getRandomSpawnMobAt( Optional<MobSpawnSettings.SpawnerData> randomSpawnMobAt = getRandomSpawnMobAt(
level, structureManager, generator, category, level.random, mutableBlockPos level, structureManager, generator, category, level.random, mutableBlockPos

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -33,6 +_,18 @@ @@ -33,6 +_,17 @@
import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@ -8,7 +8,6 @@
+import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.EnderDragonPart;
+import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
+import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.state.BlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftLocation; +import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityExplodeEvent;
@ -61,7 +60,7 @@
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) { if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) {
set.add(blockPos); set.add(blockPos);
+ // Paper start - prevent headless pistons from forming + // Paper start - prevent headless pistons from forming
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.getBlock() == Blocks.MOVING_PISTON) { + if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(Blocks.MOVING_PISTON)) {
+ net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos); + net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos);
+ if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { + if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) {
+ net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); + net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
@ -78,7 +77,7 @@
int floor5 = Mth.floor(this.center.z + f + 1.0); int floor5 = Mth.floor(this.center.z + f + 1.0);
- -
- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { - for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) {
+ List <Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source + List <Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ for (Entity entity : list) { // Paper - used in loop + for (Entity entity : list) { // Paper - used in loop
if (!entity.ignoreExplosion(this)) { if (!entity.ignoreExplosion(this)) {
double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
@ -95,10 +94,10 @@
+ +
+ // Special case ender dragon only give knockback if no damage is cancelled + // Special case ender dragon only give knockback if no damage is cancelled
+ // Thinks to note: + // Thinks to note:
+ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed) + // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed)
+ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon + // - Damaging EnderDragonPart while forward the damage to EnderDragon
+ // - Damaging EntityEnderDragon does nothing + // - Damaging EntityEnderDragon does nothing
+ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present + // - EnderDragon hitbock always covers the other parts and is therefore always present
+ if (entity instanceof EnderDragonPart) { + if (entity instanceof EnderDragonPart) {
+ continue; + continue;
+ } + }
@ -106,10 +105,10 @@
+ entity.lastDamageCancelled = false; + entity.lastDamageCancelled = false;
+ +
+ if (entity instanceof EnderDragon) { + if (entity instanceof EnderDragon) {
+ for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { + for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) {
+ // Calculate damage separately for each EntityComplexPart + // Calculate damage separately for each EntityComplexPart
+ if (list.contains(entityComplexPart)) { + if (list.contains(dragonPart)) {
+ entityComplexPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); + dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1));
+ } + }
+ } + }
+ } else { + } else {

View file

@ -128,7 +128,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ //this.popExperience(level, pos, i); + //this.popExperience(level, pos, i);
+ return i; + return i;
+ // Craftbukkit end + // CraftBukkit end
+ } + }
+ return 0; // CraftBukkit + return 0; // CraftBukkit
+ } + }

View file

@ -5,6 +5,6 @@
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); - return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking + return null; // CraftBukkit - remove unnecessary sign ticking
} }
} }

View file

@ -7,7 +7,7 @@
- if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) { - if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) {
- level.setBlock(pos, this.getStateForAge(age + 1), 2); - level.setBlock(pos, this.getStateForAge(age + 1), 2);
+ // Spigot start + // Spigot start
+ int modifier; + int modifier = 100;
+ if (this == Blocks.BEETROOTS) { + if (this == Blocks.BEETROOTS) {
+ modifier = level.spigotConfig.beetrootModifier; + modifier = level.spigotConfig.beetrootModifier;
+ } else if (this == Blocks.CARROTS) { + } else if (this == Blocks.CARROTS) {
@ -18,7 +18,7 @@
+ } else if (this == Blocks.TORCHFLOWER_CROP) { + } else if (this == Blocks.TORCHFLOWER_CROP) {
+ modifier = level.spigotConfig.torchFlowerModifier; + modifier = level.spigotConfig.torchFlowerModifier;
+ // Paper end - Fix Spigot growth modifiers + // Paper end - Fix Spigot growth modifiers
+ } else { + } else if (this == Blocks.WHEAT) {
+ modifier = level.spigotConfig.wheatModifier; + modifier = level.spigotConfig.wheatModifier;
+ } + }
+ +

View file

@ -5,7 +5,7 @@
if (enderChestInventory != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChestBlockEntity) { if (enderChestInventory != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChestBlockEntity) {
BlockPos blockPos = pos.above(); BlockPos blockPos = pos.above();
- if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) { - if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) {
+ if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic + if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {
- if (level instanceof ServerLevel serverLevel) { - if (level instanceof ServerLevel serverLevel) {

View file

@ -1,23 +1,23 @@
--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java --- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
+++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
@@ -44,14 +_,31 @@ @@ -44,13 +_,31 @@
@Override @Override
protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
- if (state.getValue(AGE) < 25 && random.nextDouble() < this.growPerTickProbability) { - if (state.getValue(AGE) < 25 && random.nextDouble() < this.growPerTickProbability) {
+ // Spigot start + // Spigot start
+ int modifier; + int modifier = 100;
+ if (this == Blocks.KELP) { + if (this == Blocks.KELP) {
+ modifier = level.spigotConfig.kelpModifier; + modifier = level.spigotConfig.kelpModifier;
+ } else if (this == Blocks.TWISTING_VINES) { + } else if (this == Blocks.TWISTING_VINES) {
+ modifier = level.spigotConfig.twistingVinesModifier; + modifier = level.spigotConfig.twistingVinesModifier;
+ } else if (this == Blocks.WEEPING_VINES) { + } else if (this == Blocks.WEEPING_VINES) {
+ modifier = level.spigotConfig.weepingVinesModifier; + modifier = level.spigotConfig.weepingVinesModifier;
+ } else { + } else if (this == Blocks.CAVE_VINES) {
+ modifier = level.spigotConfig.caveVinesModifier; + modifier = level.spigotConfig.caveVinesModifier;
+ } + }
+ if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution + if (state.getValue(AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
+ // Spigot end + // Spigot end
BlockPos blockPos = pos.relative(this.growthDirection); BlockPos blockPos = pos.relative(this.growthDirection);
if (this.canGrowInto(level.getBlockState(blockPos))) { if (this.canGrowInto(level.getBlockState(blockPos))) {
- level.setBlockAndUpdate(blockPos, this.getGrowIntoState(state, level.random)); - level.setBlockAndUpdate(blockPos, this.getGrowIntoState(state, level.random));
@ -25,12 +25,12 @@
} }
} }
} }
+
+ // Paper start - Fix Spigot growth modifiers + // Paper start - Fix Spigot growth modifiers
+ protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) { + protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) {
+ return this.getGrowIntoState(state, random); + return this.getGrowIntoState(state, random);
+ } + }
+ // Paper end - Fix Spigot growth modifiers + // Paper end - Fix Spigot growth modifiers
protected BlockState getGrowIntoState(BlockState state, RandomSource random) { protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
return state.cycle(AGE); return state.cycle(AGE);
}

View file

@ -86,7 +86,7 @@
- private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder) { - private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder) {
- Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder); - Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder);
+ private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit + private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit
+ Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, searchRadius); // Craftbukkit + Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, searchRadius); // CraftBukkit
BlockUtil.FoundRectangle largestRectangleAround; BlockUtil.FoundRectangle largestRectangleAround;
TeleportTransition.PostTeleportTransition postTeleportTransition; TeleportTransition.PostTeleportTransition postTeleportTransition;
if (optional.isPresent()) { if (optional.isPresent()) {

View file

@ -7,7 +7,7 @@
- && canOpen(state, level, pos, shulkerBoxBlockEntity)) { - && canOpen(state, level, pos, shulkerBoxBlockEntity)) {
- player.openMenu(shulkerBoxBlockEntity); - player.openMenu(shulkerBoxBlockEntity);
+ && canOpen(state, level, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check + && canOpen(state, level, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_SHULKER_BOX); player.awardStat(Stats.OPEN_SHULKER_BOX);
PiglinAi.angerNearbyPiglins(serverLevel, player, true); PiglinAi.angerNearbyPiglins(serverLevel, player, true);
} }

View file

@ -48,6 +48,6 @@
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.SIGN, SignBlockEntity::tick); - return createTickerHelper(blockEntityType, BlockEntityType.SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking + return null; // CraftBukkit - remove unnecessary sign ticking
} }
} }

View file

@ -5,6 +5,6 @@
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick); - return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking + return null; // CraftBukkit - remove unnecessary sign ticking
} }
} }

View file

@ -83,7 +83,7 @@
if (blockEntity.lastCheckY >= height) { if (blockEntity.lastCheckY >= height) {
blockEntity.lastCheckY = level.getMinY() - 1; blockEntity.lastCheckY = level.getMinY() - 1;
@@ -224,36 +_,99 @@ @@ -224,35 +_,99 @@
@Override @Override
public void setRemoved() { public void setRemoved() {
@ -177,7 +177,6 @@
} }
} }
- } - }
-
+ return list; + return list;
+ } + }
+ +
@ -195,13 +194,13 @@
+ apiBlock, apiEffect, (org.bukkit.entity.Player) player.getBukkitEntity(), isPrimary + apiBlock, apiEffect, (org.bukkit.entity.Player) player.getBukkitEntity(), isPrimary
+ ); + );
+ if (!event.callEvent()) continue; + if (!event.callEvent()) continue;
+ player.addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(event.getEffect())); + player.addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(event.getEffect()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ } + }
+ } + }
+ // Paper end - BeaconEffectEvent + // Paper end - BeaconEffectEvent
public static void playSound(Level level, BlockPos pos, SoundEvent sound) { public static void playSound(Level level, BlockPos pos, SoundEvent sound) {
level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F); level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F);
}
@@ -282,7 +_,7 @@ @@ -282,7 +_,7 @@
private static Holder<MobEffect> loadEffect(CompoundTag tag, String key) { private static Holder<MobEffect> loadEffect(CompoundTag tag, String key) {
if (tag.contains(key, 8)) { if (tag.contains(key, 8)) {

View file

@ -208,7 +208,7 @@
boolean flag = false; boolean flag = false;
boolean isEmpty = destination.isEmpty(); boolean isEmpty = destination.isEmpty();
if (item.isEmpty()) { if (item.isEmpty()) {
+ // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem + // Spigot start - SPIGOT-6693, SimpleContainer#setItem
+ ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size + ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size
+ if (!stack.isEmpty() && stack.getCount() > destination.getMaxStackSize()) { + if (!stack.isEmpty() && stack.getCount() > destination.getMaxStackSize()) {
+ leftover = stack; // Paper - Make hoppers respect inventory max stack size + leftover = stack; // Paper - Make hoppers respect inventory max stack size

View file

@ -35,7 +35,7 @@
} }
replaceMissingSections(biomeRegistry, this.sections); replaceMissingSections(biomeRegistry, this.sections);
+ this.biomeRegistry = biomeRegistry; // Craftbukkit + this.biomeRegistry = biomeRegistry; // CraftBukkit
} }
private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sections) { private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sections) {

View file

@ -106,7 +106,7 @@
public FluidState getFluidState(int x, int y, int z) { public FluidState getFluidState(int x, int y, int z) {
- try { - try {
+ // try { // Paper start - Perf: Optimise Chunk#getFluid + // try { // Paper start - Perf: Optimise Chunk#getFluid
int sectionIndex = this.getSectionIndex(y); int sectionIndex = this.getSectionIndex(y);
if (sectionIndex >= 0 && sectionIndex < this.sections.length) { if (sectionIndex >= 0 && sectionIndex < this.sections.length) {
LevelChunkSection levelChunkSection = this.sections[sectionIndex]; LevelChunkSection levelChunkSection = this.sections[sectionIndex];

View file

@ -57,7 +57,7 @@
+ } else { + } else {
+ long days; + long days;
+ if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { + if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) {
+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_ONE_MINUTE is actually counting in ticks, a misnomer by Mojang + days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks
+ } else { + } else {
+ days = level.getDayTime() / 24000L; + days = level.getDayTime() / 24000L;
+ } + }

View file

@ -55,7 +55,7 @@
+ // Paper end - PhantomPreSpawnEvent + // Paper end - PhantomPreSpawnEvent
Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL); Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL);
if (phantom != null) { if (phantom != null) {
+ phantom.setSpawningEntity(serverPlayer.getUUID()); // Paper - PhantomPreSpawnEvent + phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent
phantom.moveTo(blockPos1, 0.0F, 0.0F); phantom.moveTo(blockPos1, 0.0F, 0.0F);
spawnGroupData = phantom.finalizeSpawn( spawnGroupData = phantom.finalizeSpawn(
level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData

View file

@ -41,7 +41,7 @@
for (Direction direction : Direction.Plane.HORIZONTAL) { for (Direction direction : Direction.Plane.HORIZONTAL) {
BlockPos blockPos = mutableBlockPos.setWithOffset(pos, direction); BlockPos blockPos = mutableBlockPos.setWithOffset(pos, direction);
- BlockState blockState = level.getBlockState(blockPos); - BlockState blockState = level.getBlockState(blockPos);
+ BlockState blockState = level.getBlockStateIfLoaded(mutableBlockPos); // Paper - Prevent chunk loading from fluid flowing + BlockState blockState = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing
+ if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing + if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluidState = blockState.getFluidState(); FluidState fluidState = blockState.getFluidState();
if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, blockPos, blockState)) { if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, blockPos, blockState)) {

View file

@ -23,10 +23,10 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston); state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
+ // Spigot Start + // Spigot start
+ } catch (StackOverflowError ex) { + } catch (StackOverflowError ex) {
+ level.lastPhysicsProblem = new BlockPos(pos); + level.lastPhysicsProblem = new BlockPos(pos);
+ // Spigot End + // Spigot end
} catch (Throwable var9) { } catch (Throwable var9) {
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours"); CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated"); CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");

View file

@ -49,26 +49,26 @@
- File file = new File(this.playerDir, player.getStringUUID() + suffix); - File file = new File(this.playerDir, player.getStringUUID() + suffix);
+ private Optional<CompoundTag> load(String name, String stringUuid, String suffix) { // CraftBukkit + private Optional<CompoundTag> load(String name, String stringUuid, String suffix) { // CraftBukkit
+ File file = new File(this.playerDir, stringUuid + suffix); // CraftBukkit + File file = new File(this.playerDir, stringUuid + suffix); // CraftBukkit
+ // Spigot Start + // Spigot start
+ boolean usingWrongFile = false; + boolean usingWrongFile = false;
+ if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first + if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first
+ file = new File(file, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(java.nio.charset.StandardCharsets.UTF_8)).toString() + suffix); + file = new File(file, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(java.nio.charset.StandardCharsets.UTF_8)).toString() + suffix);
+ if (file.exists()) { + if (file.exists()) {
+ usingWrongFile = true; + usingWrongFile = true;
+ org.bukkit.Bukkit.getServer().getLogger().warning("Using offline mode UUID file for player " + name + " as it is the only copy we can find."); + LOGGER.warn("Using offline mode UUID file for player {} as it is the only copy we can find.", name);
+ } + }
+ } + }
+ // Spigot End + // Spigot end
if (file.exists() && file.isFile()) { if (file.exists() && file.isFile()) {
try { try {
- return Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap())); - return Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
+ // Spigot Start + // Spigot start
+ Optional<CompoundTag> optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap())); + Optional<CompoundTag> optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
+ if (usingWrongFile) { + if (usingWrongFile) {
+ file.renameTo(new File(file.getPath() + ".offline-read")); + file.renameTo(new File(file.getPath() + ".offline-read"));
+ } + }
+ return optional; + return optional;
+ // Spigot End + // Spigot end
} catch (Exception var5) { } catch (Exception var5) {
- LOGGER.warn("Failed to load player data for {}", player.getName().getString()); - LOGGER.warn("Failed to load player data for {}", player.getName().getString());
+ LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit + LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit

View file

@ -904,13 +904,13 @@ public final class CraftServer implements Server {
@Override @Override
public long getConnectionThrottle() { public long getConnectionThrottle() {
// Spigot Start - Automatically set connection throttle for bungee configurations // Spigot start - Automatically set connection throttle for bungee configurations
if (org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { // Paper - Add Velocity IP Forwarding Support if (org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { // Paper - Add Velocity IP Forwarding Support
return -1; return -1;
} else { } else {
return this.configuration.getInt("settings.connection-throttle"); return this.configuration.getInt("settings.connection-throttle");
} }
// Spigot End // Spigot end
} }
@Override @Override
@ -2131,7 +2131,7 @@ public final class CraftServer implements Server {
if (result == null) { if (result == null) {
GameProfile profile = null; GameProfile profile = null;
// Only fetch an online UUID in online mode // Only fetch an online UUID in online mode
if (this.getOnlineMode() || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) { // Paper - Add setting for proxy online mode status if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) { // Paper - Add setting for proxy online mode status
// This is potentially blocking :( // This is potentially blocking :(
profile = this.console.getProfileCache().get(name).orElse(null); profile = this.console.getProfileCache().get(name).orElse(null);
} }
@ -2585,12 +2585,11 @@ public final class CraftServer implements Server {
} }
public List<String> tabCompleteCommand(Player player, String message, ServerLevel world, Vec3 pos) { public List<String> tabCompleteCommand(Player player, String message, ServerLevel world, Vec3 pos) {
// Spigot Start // Spigot start
if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) ) if ((org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains(" ")) {
{
return ImmutableList.of(); return ImmutableList.of();
} }
// Spigot End // Spigot end
List<String> completions = null; List<String> completions = null;
try { try {

View file

@ -149,13 +149,13 @@ public class Main {
this.acceptsAll(Main.asList("initSettings"), "Only create configuration files and then exit"); // SPIGOT-5761: Add initSettings option this.acceptsAll(Main.asList("initSettings"), "Only create configuration files and then exit"); // SPIGOT-5761: Add initSettings option
// Spigot Start // Spigot start
this.acceptsAll(Main.asList("S", "spigot-settings"), "File for spigot settings") this.acceptsAll(Main.asList("S", "spigot-settings"), "File for spigot settings")
.withRequiredArg() .withRequiredArg()
.ofType(File.class) .ofType(File.class)
.defaultsTo(new File("spigot.yml")) .defaultsTo(new File("spigot.yml"))
.describedAs("Yml file"); .describedAs("Yml file");
// Spigot End // Spigot end
// Paper start // Paper start
acceptsAll(asList("paper-dir", "paper-settings-directory"), "Directory for Paper settings") acceptsAll(asList("paper-dir", "paper-settings-directory"), "Directory for Paper settings")

View file

@ -23,7 +23,7 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
public Set<ComplexEntityPart> getParts() { public Set<ComplexEntityPart> getParts() {
Builder<ComplexEntityPart> builder = ImmutableSet.builder(); Builder<ComplexEntityPart> builder = ImmutableSet.builder();
for (EnderDragonPart part : this.getHandle().subEntities) { for (EnderDragonPart part : this.getHandle().getSubEntities()) {
builder.add((ComplexEntityPart) part.getBukkitEntity()); builder.add((ComplexEntityPart) part.getBukkitEntity());
} }

View file

@ -32,17 +32,17 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
// Paper start // Paper start
@Override @Override
public java.util.UUID getSpawningEntity() { public java.util.UUID getSpawningEntity() {
return getHandle().getSpawningEntity(); return this.getHandle().spawningEntity;
} }
@Override @Override
public boolean shouldBurnInDay() { public boolean shouldBurnInDay() {
return getHandle().shouldBurnInDay(); return this.getHandle().shouldBurnInDay;
} }
@Override @Override
public void setShouldBurnInDay(boolean shouldBurnInDay) { public void setShouldBurnInDay(boolean shouldBurnInDay) {
getHandle().setShouldBurnInDay(shouldBurnInDay); this.getHandle().shouldBurnInDay = shouldBurnInDay;
} }
@Override @Override

Some files were not shown because too many files have changed in this diff Show more