[ci skip] Add more identifying patch comments

This commit is contained in:
Nassim Jahnke 2024-01-18 15:56:25 +01:00
parent 3a0aff9ba9
commit 16f89b4fa7
29 changed files with 107 additions and 89 deletions

View File

@ -204,7 +204,8 @@ when making and submitting changes.
## Formatting ## Formatting
All modifications to non-Paper files should be marked. All modifications to non-Paper files should be marked. The one exception to this is
when modifying javadoc comments, which should not have these markers.
- You need to add a comment with a short and identifiable description of the patch: - You need to add a comment with a short and identifiable description of the patch:
`// Paper start - <COMMIT DESCRIPTION>` `// Paper start - <COMMIT DESCRIPTION>`

View File

@ -65,9 +65,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityitem.setDefaultPickUpDelay(); entityitem.setDefaultPickUpDelay();
- this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null); - this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null);
+ this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null, result.getExperience()); // Paper - Add EntityFertilizeEggEvent event + this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null, result.getExperience()); // Paper - Add EntityFertilizeEggEvent event
if (this.spawnAtLocation(entityitem) != null) { // Paper - call EntityDropItemEvent if (this.spawnAtLocation(entityitem) != null) { // Paper - Call EntityDropItemEvent
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F); this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
} // Paper } // Paper - Call EntityDropItemEvent
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java

View File

@ -12,13 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
this.level().getProfiler().push("portal"); this.level().getProfiler().push("portal");
this.portalTime = i; this.portalTime = i;
+ // Paper start + // Paper start - Add EntityPortalReadyEvent
+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER); + io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER);
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ this.portalTime = 0; + this.portalTime = 0;
+ } else { + } else {
+ worldserver1 = event.getTargetWorld() == null ? null : ((CraftWorld) event.getTargetWorld()).getHandle(); + worldserver1 = event.getTargetWorld() == null ? null : ((CraftWorld) event.getTargetWorld()).getHandle();
+ // Paper end + // Paper end - Add EntityPortalReadyEvent
this.setPortalCooldown(); this.setPortalCooldown();
// CraftBukkit start // CraftBukkit start
if (this instanceof ServerPlayer) { if (this instanceof ServerPlayer) {
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else { } else {
this.changeDimension(worldserver1); this.changeDimension(worldserver1);
} }
+ } // Paper + } // Paper - Add EntityPortalReadyEvent
// CraftBukkit end // CraftBukkit end
this.level().getProfiler().pop(); this.level().getProfiler().pop();
} }

View File

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
+ // Paper start + // Paper start - Add PlayerInventorySlotChangeEvent
+ @Override + @Override
+ public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) { + public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
+ Slot slot = handler.getSlot(slotId); + Slot slot = handler.getSlot(slotId);
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ } + }
+ } + }
+ // Paper end + // Paper end - Add PlayerInventorySlotChangeEvent
@Override @Override
public void dataChanged(AbstractContainerMenu handler, int property, int value) {} public void dataChanged(AbstractContainerMenu handler, int property, int value) {}
@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ContainerListener icrafting = (ContainerListener) iterator.next(); ContainerListener icrafting = (ContainerListener) iterator.next();
- icrafting.slotChanged(this, slot, itemstack2); - icrafting.slotChanged(this, slot, itemstack2);
+ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper + icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent
} }
} }
@ -55,11 +55,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public interface ContainerListener { public interface ContainerListener {
void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack); void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack);
+ // Paper start + // Paper start - Add PlayerInventorySlotChangeEvent
+ default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) { + default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) {
+ slotChanged(handler, slotId, stack); + slotChanged(handler, slotId, stack);
+ } + }
+ // Paper end + // Paper end - Add PlayerInventorySlotChangeEvent
+ +
void dataChanged(AbstractContainerMenu handler, int property, int value); void dataChanged(AbstractContainerMenu handler, int property, int value);
} }

View File

@ -37,6 +37,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.entity.player.ProfilePublicKey; +import net.minecraft.world.entity.player.ProfilePublicKey;
+ +
+/**
+ * While Velocity supports BungeeCord-style IP forwarding, it is not secure. Users
+ * have a lot of problems setting up firewalls or setting up plugins like IPWhitelist.
+ * Further, the BungeeCord IP forwarding protocol still retains essentially its original
+ * form, when there is brand-new support for custom login plugin messages in 1.13.
+ * <p>
+ * Velocity's modern IP forwarding uses an HMAC-SHA256 code to ensure authenticity
+ * of messages, is packed into a binary format that is smaller than BungeeCord's
+ * forwarding, and is integrated into the Minecraft login process by using the 1.13
+ * login plugin message packet.
+ */
+public class VelocityProxy { +public class VelocityProxy {
+ private static final int SUPPORTED_FORWARDING_VERSION = 1; + private static final int SUPPORTED_FORWARDING_VERSION = 1;
+ public static final int MODERN_FORWARDING_WITH_KEY = 2; + public static final int MODERN_FORWARDING_WITH_KEY = 2;
@ -102,11 +113,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
// CraftBukkit end // CraftBukkit end
+ // Paper start + // Paper start - Add Velocity IP Forwarding Support
+ boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled; + boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled;
+ String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; + String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
+ String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; + String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
+ // Paper end + // Paper end - Add Velocity IP Forwarding Support
if (!this.usesAuthentication()) { if (!this.usesAuthentication()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@ -114,11 +125,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (org.spigotmc.SpigotConfig.bungee) { - if (org.spigotmc.SpigotConfig.bungee) {
- DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); - DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.");
- DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information."); - DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
+ // Paper start + // 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."); + 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.");
+ DedicatedServer.LOGGER.warn("Please see " + proxyLink + " for further information."); + DedicatedServer.LOGGER.warn("Please see " + proxyLink + " for further information.");
+ // Paper end + // 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."); 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.");
} }
@ -130,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private final String serverId; private final String serverId;
private ServerPlayer player; // CraftBukkit private ServerPlayer player; // CraftBukkit
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
+ private int velocityLoginMessageId = -1; // Paper - Velocity support + private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) { public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
this.state = ServerLoginPacketListenerImpl.State.HELLO; this.state = ServerLoginPacketListenerImpl.State.HELLO;
@ -138,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.state = ServerLoginPacketListenerImpl.State.KEY; this.state = ServerLoginPacketListenerImpl.State.KEY;
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge)); this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge));
} else { } else {
+ // Paper start - Velocity support + // Paper start - Add Velocity IP Forwarding Support
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
+ this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt(); + this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt();
+ net.minecraft.network.FriendlyByteBuf buf = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()); + net.minecraft.network.FriendlyByteBuf buf = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.buffer());
@ -147,7 +158,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.connection.send(packet1); + this.connection.send(packet1);
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Add Velocity IP Forwarding Support
// CraftBukkit start // CraftBukkit start
// Paper start - Cache authenticator threads // Paper start - Cache authenticator threads
authenticatorPool.execute(new Runnable() { authenticatorPool.execute(new Runnable() {
@ -155,12 +166,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent
+ // Paper start - Velocity support + // Paper start - Add Velocity IP Forwarding Support
+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { + if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
+ disconnect("This server requires you to connect with Velocity."); + disconnect("This server requires you to connect with Velocity.");
+ return gameprofile; + return gameprofile;
+ } + }
+ // Paper end - Velocity support + // Paper end - Add Velocity IP Forwarding Support
String playerName = gameprofile.getName(); String playerName = gameprofile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
java.util.UUID uniqueId = gameprofile.getId(); java.util.UUID uniqueId = gameprofile.getId();
@ -168,7 +179,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket packet) { public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket packet) {
+ // Paper start - Velocity support + // Paper start - Add Velocity IP Forwarding Support
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && packet.transactionId() == this.velocityLoginMessageId) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && packet.transactionId() == this.velocityLoginMessageId) {
+ ServerboundCustomQueryAnswerPacket.QueryAnswerPayload payload = (ServerboundCustomQueryAnswerPacket.QueryAnswerPayload)packet.payload(); + ServerboundCustomQueryAnswerPacket.QueryAnswerPayload payload = (ServerboundCustomQueryAnswerPacket.QueryAnswerPayload)packet.payload();
+ if (payload == null) { + if (payload == null) {
@ -212,7 +223,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }); + });
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Add Velocity IP Forwarding Support
this.disconnect(ServerLoginPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY); this.disconnect(ServerLoginPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
} }
@ -225,7 +236,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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) { - if (org.spigotmc.SpigotConfig.bungee) {
+ if (org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { // Paper - Velocity 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");

View File

@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Call BlockFadeEvent
this.destroyBlock(world, pos); this.destroyBlock(world, pos);
world.playSound((Player)null, pos, SoundEvents.FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F); world.playSound((Player)null, pos, SoundEvents.FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F);
this.spawnTadpoles(world, pos, random); this.spawnTadpoles(world, pos, random);
@ -46,13 +46,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return this.getHatchLevel(state) == 2; return this.getHatchLevel(state) == 2;
} }
+ // Paper start + // Paper start - Call BlockFadeEvent
+ private void rescheduleTick(ServerLevel world, BlockPos pos) { + private void rescheduleTick(ServerLevel world, BlockPos pos) {
+ int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS; + int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS;
+ world.scheduleTick(pos, this, (baseDelay / 3) + world.random.nextInt(RANDOM_HATCH_OFFSET_TICKS)); + world.scheduleTick(pos, this, (baseDelay / 3) + world.random.nextInt(RANDOM_HATCH_OFFSET_TICKS));
+ // reschedule to avoid being stuck here and behave like the other calls (see #onPlace) + // reschedule to avoid being stuck here and behave like the other calls (see #onPlace)
+ } + }
+ // Paper end + // Paper end - Call BlockFadeEvent
+ +
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ rescheduleTick(world, pos); + rescheduleTick(world, pos);
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Call BlockFadeEvent
world.playSound((Player)null, pos, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); world.playSound((Player)null, pos, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
world.destroyBlock(pos, false); world.destroyBlock(pos, false);
Sniffer sniffer = EntityType.SNIFFER.create(world); Sniffer sniffer = EntityType.SNIFFER.create(world);

View File

@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) {
return false; return false;
- } else if (this.dimension.isPresent() && this.dimension.get() != world.dimension()) { - } else if (this.dimension.isPresent() && this.dimension.get() != world.dimension()) {
+ } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? world.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(world))) { // Paper + } else if (this.dimension.isPresent() && this.dimension.get() != (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck ? world.dimension() : org.bukkit.craftbukkit.util.CraftDimensionUtil.getMainDimensionKey(world))) { // Paper - Add option for strict advancement dimension checks
return false; return false;
} else { } else {
BlockPos blockPos = BlockPos.containing(x, y, z); BlockPos blockPos = BlockPos.containing(x, y, z);
@ -31,12 +31,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ResourceKey<Level> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(origin); ResourceKey<Level> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(origin);
ResourceKey<Level> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level()); ResourceKey<Level> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level());
+ // Paper start - config for strict advancement checks for dimensions + // Paper start - Add option for strict advancement dimension checks
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.strictAdvancementDimensionCheck) {
+ maindimensionkey = resourcekey; + maindimensionkey = resourcekey;
+ maindimensionkey1 = resourcekey1; + maindimensionkey1 = resourcekey1;
+ } + }
+ // Paper end + // Paper end - Add option for strict advancement dimension checks
CriteriaTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1); CriteriaTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1);
if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) { if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) {
CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); CriteriaTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);

View File

@ -12,14 +12,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe
entityitem.setDefaultPickUpDelay(); entityitem.setDefaultPickUpDelay();
+ // Paper start + // Paper start - Call EntityDropItemEvent
+ return this.spawnAtLocation(entityitem); + return this.spawnAtLocation(entityitem);
+ } + }
+ } + }
+ @Nullable + @Nullable
+ public ItemEntity spawnAtLocation(ItemEntity entityitem) { + public ItemEntity spawnAtLocation(ItemEntity entityitem) {
+ { + {
+ // Paper end + // Paper end - Call EntityDropItemEvent
// CraftBukkit start // CraftBukkit start
EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityitem.setDeltaMovement((double) (0.3F * -Mth.sin(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.cos(f1) * f2), (double) (0.3F * Mth.sin(Dolphin.this.getXRot() * 0.017453292F) * 1.5F), (double) (0.3F * Mth.cos(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.sin(f1) * f2)); entityitem.setDeltaMovement((double) (0.3F * -Mth.sin(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.cos(f1) * f2), (double) (0.3F * Mth.sin(Dolphin.this.getXRot() * 0.017453292F) * 1.5F), (double) (0.3F * Mth.cos(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.sin(f1) * f2));
- Dolphin.this.level().addFreshEntity(entityitem); - Dolphin.this.level().addFreshEntity(entityitem);
+ Dolphin.this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent + Dolphin.this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent
} }
} }
} }
@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityitem.setThrower(this); entityitem.setThrower(this);
this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F);
- this.level().addFreshEntity(entityitem); - this.level().addFreshEntity(entityitem);
+ this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent + this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent
} }
} }
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), stack); ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), stack);
- this.level().addFreshEntity(entityitem); - this.level().addFreshEntity(entityitem);
+ this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent + this.spawnAtLocation(entityitem); // Paper - Call EntityDropItemEvent
} }
@Override @Override
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.level().addFreshEntity(entityitem); - this.level().addFreshEntity(entityitem);
- return true; - return true;
+ return this.spawnAtLocation(entityitem) != null; // Paper - call EntityDropItemEvent by calling spawnAtLocation. + return this.spawnAtLocation(entityitem) != null; // Paper - Call EntityDropItemEvent
} }
} }
@ -79,10 +79,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityitem.setDefaultPickUpDelay(); entityitem.setDefaultPickUpDelay();
this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null); this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null);
+ if (this.spawnAtLocation(entityitem) != null) { // Paper - call EntityDropItemEvent + if (this.spawnAtLocation(entityitem) != null) { // Paper - Call EntityDropItemEvent
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F); this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
- world.addFreshEntity(entityitem); - world.addFreshEntity(entityitem);
+ } // Paper + } // Paper - Call EntityDropItemEvent
} }
@Override @Override

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
BlockPos blockPos = this.sourcePos.relative(NeighborUpdater.UPDATE_ORDER[this.idx++]); BlockPos blockPos = this.sourcePos.relative(NeighborUpdater.UPDATE_ORDER[this.idx++]);
BlockState blockState = world.getBlockState(blockPos); BlockState blockState = world.getBlockState(blockPos);
- NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false); - NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false);
+ // Paper start + // Paper start - Call BlockPhysicsEvent
+ try { + try {
+ boolean cancelled = false; + boolean cancelled = false;
+ org.bukkit.craftbukkit.CraftWorld cworld = world.getWorld(); + org.bukkit.craftbukkit.CraftWorld cworld = world.getWorld();
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } catch (StackOverflowError ex) { + } catch (StackOverflowError ex) {
+ world.lastPhysicsProblem = new BlockPos(blockPos); + world.lastPhysicsProblem = new BlockPos(blockPos);
+ } + }
+ // Paper end + // Paper end - Call BlockPhysicsEvent
if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) { if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) {
++this.idx; ++this.idx;
} }

View File

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
@@ -0,0 +0,0 @@ public class SnifferEggBlock extends Block { @@ -0,0 +0,0 @@ public class SnifferEggBlock extends Block {
// Paper start // Paper start - Call BlockFadeEvent
private void rescheduleTick(ServerLevel world, BlockPos pos) { private void rescheduleTick(ServerLevel world, BlockPos pos) {
- int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS; - int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS;
+ int baseDelay = hatchBoost(world, pos) ? world.paperConfig().entities.sniffer.boostedHatchTime.or(BOOSTED_HATCH_TIME_TICKS) : world.paperConfig().entities.sniffer.hatchTime.or(REGULAR_HATCH_TIME_TICKS); // Paper - Configure sniffer egg hatch time + int baseDelay = hatchBoost(world, pos) ? world.paperConfig().entities.sniffer.boostedHatchTime.or(BOOSTED_HATCH_TIME_TICKS) : world.paperConfig().entities.sniffer.hatchTime.or(REGULAR_HATCH_TIME_TICKS); // Paper - Configure sniffer egg hatch time

View File

@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation()); - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation());
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, cancelledItem, hand, hitResult.getLocation()); // Paper + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, cancelledItem, hand, hitResult.getLocation()); // Paper - correctly handle items on cooldown
this.firedInteract = true; this.firedInteract = true;
this.interactResult = event.useItemInHand() == Event.Result.DENY; this.interactResult = event.useItemInHand() == Event.Result.DENY;
this.interactPosition = blockposition.immutable(); this.interactPosition = blockposition.immutable();

View File

@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return; return;
} }
+ // Paper start - Warn on headless + // 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."); + Main.LOGGER.error("You are using a headless JRE distribution.");
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Main.LOGGER.error(awtException); + Main.LOGGER.error(awtException);
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Detect headless JRE
+ +
org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init
// Paper start - fix SPIGOT-5824 // Paper start - fix SPIGOT-5824

View File

@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) { private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) {
if (sectionPos != null) { if (sectionPos != null) {
- ChunkAccess chunkAccess = world.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false); - ChunkAccess chunkAccess = world.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false);
+ ChunkAccess chunkAccess = world.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - can cause sync loads while completing a chunk, resulting in deadlock + ChunkAccess chunkAccess = world.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - Perf: can cause sync loads while completing a chunk, resulting in deadlock
if (chunkAccess != null) { if (chunkAccess != null) {
dispatcherConsumer.accept(chunkAccess.getListenerRegistry(sectionPos.y())); dispatcherConsumer.accept(chunkAccess.getListenerRegistry(sectionPos.y()));
} }

View File

@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void sendSystemMessage(Component message) { public void sendSystemMessage(Component message) {
if (this.trackOutput) { if (this.trackOutput) {
+ org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper + org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks
SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT; SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT;
Date date = new Date(); Date date = new Date();
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Set<CommandSender> recipients = new HashSet<>(); Set<CommandSender> recipients = new HashSet<>();
for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) { for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) {
- if (permissible instanceof CommandSender && permissible.hasPermission(permission)) { - if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
+ if (permissible instanceof CommandSender && !(permissible instanceof org.bukkit.command.BlockCommandSender) && permissible.hasPermission(permission)) { // Paper - don't broadcast to BlockCommandSender (specifically Command Blocks) + if (permissible instanceof CommandSender && !(permissible instanceof org.bukkit.command.BlockCommandSender) && permissible.hasPermission(permission)) { // Paper - Don't broadcast messages to command blocks
recipients.add((CommandSender) permissible); recipients.add((CommandSender) permissible);
} }
} }

View File

@ -17,12 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public ItemEntity(Level world, double x, double y, double z, ItemStack stack) { public ItemEntity(Level world, double x, double y, double z, ItemStack stack) {
- this(world, x, y, z, stack, world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D); - this(world, x, y, z, stack, world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D);
+ // Paper start - don't use world random in entity constructor + // Paper start - Don't use level random in entity constructors (to make them thread-safe)
+ this(EntityType.ITEM, world); + this(EntityType.ITEM, world);
+ this.setPos(x, y, z); + this.setPos(x, y, z);
+ this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D); + this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D);
+ this.setItem(stack); + this.setItem(stack);
+ // Paper end + // Paper end - Don't use level random in entity constructors
} }
public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) { public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) {
@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this(EntityType.TNT, world); this(EntityType.TNT, world);
this.setPos(x, y, z); this.setPos(x, y, z);
- double d3 = world.random.nextDouble() * 6.2831854820251465D; - double d3 = world.random.nextDouble() * 6.2831854820251465D;
+ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - don't use world random in entity constructor + double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - Don't use level random in entity constructors
this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
this.setFuse(80); this.setFuse(80);

View File

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); - this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
+ // 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 entity after predicting capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
return; return;
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode { @@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
// Spigot start - handle debug stick left click for non-creative // Spigot start - handle debug stick left click for non-creative
@ -102,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // 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 - Toggle this location for capturing as this is used for api if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode { @@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
if (event.useInteractedBlock() == Event.Result.DENY) { if (event.useInteractedBlock() == Event.Result.DENY) {
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.

View File

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
protected void pickUpItem(ItemEntity item) { protected void pickUpItem(ItemEntity item) {
- this.onItemPickup(item); - this.onItemPickup(item);
+ // this.onItemPickup(item); // Paper - call in PiglinAi#pickUpItem after EntityPickupItemEvent is fired + // this.onItemPickup(item); // Paper - EntityPickupItemEvent fixes; call in PiglinAi#pickUpItem after EntityPickupItemEvent is fired
PiglinAi.pickUpItem(this, item); PiglinAi.pickUpItem(this, item);
} }
@ -33,16 +33,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
- if (drop.getItem().is(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled()) { - if (drop.getItem().is(Items.GOLD_NUGGET) && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled()) {
+ // Paper start - fix event firing twice + // Paper start - EntityPickupItemEvent fixes; fix event firing twice
+ if (drop.getItem().is(Items.GOLD_NUGGET) /* && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled() */) { + if (drop.getItem().is(Items.GOLD_NUGGET) /* && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled() */) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled()) return; + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, 0, false).isCancelled()) return;
+ piglin.onItemPickup(drop); // Paper - moved from Piglin#pickUpItem - call prior to item entity modification + piglin.onItemPickup(drop); // Paper - moved from Piglin#pickUpItem - call prior to item entity modification
+ // Paper end + // Paper end - EntityPickupItemEvent fixes
piglin.take(drop, drop.getItem().getCount()); piglin.take(drop, drop.getItem().getCount());
itemstack = drop.getItem(); itemstack = drop.getItem();
drop.discard(); drop.discard();
} else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, drop.getItem().getCount() - 1, false).isCancelled()) { } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, drop.getItem().getCount() - 1, false).isCancelled()) {
+ piglin.onItemPickup(drop); // Paper - moved from Piglin#pickUpItem - call prior to item entity modification + piglin.onItemPickup(drop); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification
piglin.take(drop, 1); piglin.take(drop, 1);
itemstack = PiglinAi.removeOneItemFromItemEntity(drop); itemstack = PiglinAi.removeOneItemFromItemEntity(drop);
} else { } else {
@ -54,11 +54,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null; boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) { if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) {
+ // Paper start + // Paper start - EntityPickupItemEvent fixes
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) {
+ return; + return;
+ } + }
+ // Paper end + // Paper end - EntityPickupItemEvent fixes
EquipmentSlot enumitemslot = EquipmentSlot.HEAD; EquipmentSlot enumitemslot = EquipmentSlot.HEAD;
ItemStack itemstack1 = this.getItemBySlot(enumitemslot); ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
double d0 = (double) this.getEquipmentDropChance(enumitemslot); double d0 = (double) this.getEquipmentDropChance(enumitemslot);

View File

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.powerLightningRod(); this.powerLightningRod();
- LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition()); - LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition());
+ LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition(), this); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent + LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition(), this); // Paper - Call EntityChangeBlockEvent
this.gameEvent(GameEvent.LIGHTNING_STRIKE); this.gameEvent(GameEvent.LIGHTNING_STRIKE);
} }
} }
@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- private static void clearCopperOnLightningStrike(Level world, BlockPos pos) { - private static void clearCopperOnLightningStrike(Level world, BlockPos pos) {
+ private static void clearCopperOnLightningStrike(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent + private static void clearCopperOnLightningStrike(Level world, BlockPos pos, Entity lightning) { // Paper - Call EntityChangeBlockEvent
BlockState iblockdata = world.getBlockState(pos); BlockState iblockdata = world.getBlockState(pos);
BlockPos blockposition1; BlockPos blockposition1;
BlockState iblockdata1; BlockState iblockdata1;
@ -32,12 +32,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (iblockdata1.getBlock() instanceof WeatheringCopper) { if (iblockdata1.getBlock() instanceof WeatheringCopper) {
- world.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(world.getBlockState(blockposition1))); - world.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(world.getBlockState(blockposition1)));
+ // Paper start - call EntityChangeBlockEvent + // Paper start - Call EntityChangeBlockEvent
+ BlockState newBlock = WeatheringCopper.getFirst(world.getBlockState(blockposition1)); + BlockState newBlock = WeatheringCopper.getFirst(world.getBlockState(blockposition1));
+ if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1, newBlock)) { + if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1, newBlock)) {
+ world.setBlockAndUpdate(blockposition1, newBlock); + world.setBlockAndUpdate(blockposition1, newBlock);
+ } + }
+ // Paper end + // Paper end - Call EntityChangeBlockEvent
BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
int i = world.random.nextInt(3) + 3; int i = world.random.nextInt(3) + 3;

View File

@ -64,6 +64,12 @@ https://bugs.mojang.com/browse/MC-153086
https://bugs.mojang.com/browse/MC-200092 https://bugs.mojang.com/browse/MC-200092
Fix yaw being ignored for a player's first spawn pos Fix yaw being ignored for a player's first spawn pos
https://bugs.mojang.com/browse/MC-158900
Fix error when joining after tempban expired
https://bugs.mojang.com/browse/MC-259571
Fix last gamemode not being saved on death or reload
== AT == == AT ==
public net/minecraft/world/entity/Mob leashInfoTag public net/minecraft/world/entity/Mob leashInfoTag

View File

@ -56,11 +56,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static boolean useJline = true; public static boolean useJline = true;
public static boolean useConsole = true; public static boolean useConsole = true;
+ // Paper start - Hijack log manager to ensure logging on shutdown + // Paper start - Reset loggers after shutdown
+ static { + static {
+ System.setProperty("java.util.logging.manager", "io.papermc.paper.log.CustomLogManager"); + System.setProperty("java.util.logging.manager", "io.papermc.paper.log.CustomLogManager");
+ } + }
+ // Paper end + // Paper end - Reset loggers after shutdown
+ +
public static void main(String[] args) { public static void main(String[] args) {
// Paper start // Paper start

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) { if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
this.usePlayerItem(player, hand, itemstack); this.usePlayerItem(player, hand, itemstack);
- this.heal((float) item.getFoodProperties().getNutrition()); - this.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper + this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
return InteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
boolean bl = this.getHealth() < this.getMaxHealth(); boolean bl = this.getHealth() < this.getMaxHealth();
if (bl) { if (bl) {
- this.heal(2.0F); - this.heal(2.0F);
+ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper + this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
} }
boolean bl2 = this.isTamed() && this.getAge() == 0 && this.canFallInLove(); boolean bl2 = this.isTamed() && this.getAge() == 0 && this.canFallInLove();
@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f); - this.heal(f);
+ this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper + this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
flag = true; flag = true;
} }

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- player.removeEffect(MobEffects.DIG_SLOWDOWN); - player.removeEffect(MobEffects.DIG_SLOWDOWN);
+ player.removeEffect(MobEffects.DIG_SLOWDOWN, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper + player.removeEffect(MobEffects.DIG_SLOWDOWN, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper - Add missing effect cause
} }
@Override @Override
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!world.isClientSide) { if (!world.isClientSide) {
- user.removeEffect(MobEffects.POISON); - user.removeEffect(MobEffects.POISON);
+ user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper + user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause
} }
if (stack.isEmpty()) { if (stack.isEmpty()) {
@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ItemStack itemStack = super.finishUsingItem(stack, world, user); ItemStack itemStack = super.finishUsingItem(stack, world, user);
listPotionEffects(itemStack, (effect) -> { listPotionEffects(itemStack, (effect) -> {
- user.addEffect(effect.createEffectInstance()); - user.addEffect(effect.createEffectInstance());
+ user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper + user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause
}); });
return user instanceof Player && ((Player)user).getAbilities().instabuild ? itemStack : new ItemStack(Items.BOWL); return user instanceof Player && ((Player)user).getAbilities().instabuild ? itemStack : new ItemStack(Items.BOWL);
} }

View File

@ -19,12 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ relativeFlags.add(org.bukkit.craftbukkit.entity.CraftPlayer.toApiRelativeFlag(relativeArgument)); + relativeFlags.add(org.bukkit.craftbukkit.entity.CraftPlayer.toApiRelativeFlag(relativeArgument));
+ } + }
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags)); + PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags));
+ // Paper end + // Paper end - Teleport API
this.cserver.getPluginManager().callEvent(event); this.cserver.getPluginManager().callEvent(event);
if (event.isCancelled() || !to.equals(event.getTo())) { if (event.isCancelled() || !to.equals(event.getTo())) {
- set.clear(); // Can't relative teleport - set.clear(); // Can't relative teleport
+ // set.clear(); // Can't relative teleport // Paper - Teleport API: Now you can! + // set.clear(); // Can't relative teleport // Paper - Teleport API; Now you can!
to = event.isCancelled() ? event.getFrom() : event.getTo(); to = event.isCancelled() ? event.getFrom() : event.getTo();
d0 = to.getX(); d0 = to.getX();
d1 = to.getY(); d1 = to.getY();

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Mob entityinsentient = (Mob) entity; Mob entityinsentient = (Mob) entity;
- if (ServerLevel.this.isUpdatingNavigations) { - if (ServerLevel.this.isUpdatingNavigations) {
+ if (false && ServerLevel.this.isUpdatingNavigations) { // Paper + if (false && ServerLevel.this.isUpdatingNavigations) { // Paper - Remove unnecessary onTrackingStart during navigation warning
String s = "onTrackingStart called during navigation iteration"; String s = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Mob entityinsentient = (Mob) entity; Mob entityinsentient = (Mob) entity;
- if (ServerLevel.this.isUpdatingNavigations) { - if (ServerLevel.this.isUpdatingNavigations) {
+ if (false && ServerLevel.this.isUpdatingNavigations) { // Paper + if (false && ServerLevel.this.isUpdatingNavigations) { // Paper - Remove unnecessary onTrackingStart during navigation warning
String s = "onTrackingStart called during navigation iteration"; String s = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));

View File

@ -100,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entityitem.setDefaultPickUpDelay(); - entityitem.setDefaultPickUpDelay();
+ entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) + entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer)
// Paper start // Paper start - Call EntityDropItemEvent
return this.spawnAtLocation(entityitem); return this.spawnAtLocation(entityitem);
} }
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java

View File

@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private BlockPos delayedDestroyPos; private BlockPos delayedDestroyPos;
private int delayedTickStart; private int delayedTickStart;
private int lastSentState; private int lastSentState;
+ public boolean captureSentBlockEntities = false; // Paper + public boolean captureSentBlockEntities = false; // Paper - Send block entities after destroy prediction
+ public boolean capturedBlockEntity = false; // Paper + public boolean capturedBlockEntity = false; // Paper - Send block entities after destroy prediction
public ServerPlayerGameMode(ServerPlayer player) { public ServerPlayerGameMode(ServerPlayer player) {
this.gameModeForPlayer = GameType.DEFAULT_MODE; this.gameModeForPlayer = GameType.DEFAULT_MODE;
@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (tileentity != null) { - if (tileentity != null) {
- this.player.connection.send(tileentity.getUpdatePacket()); - this.player.connection.send(tileentity.getUpdatePacket());
- } - }
+ capturedBlockEntity = true; // Paper - send block entity after predicting + capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
// CraftBukkit end // CraftBukkit end
return; return;
} }
@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (tileentity != null) { - if (tileentity != null) {
- this.player.connection.send(tileentity.getUpdatePacket()); - this.player.connection.send(tileentity.getUpdatePacket());
- } - }
+ capturedBlockEntity = true; // Paper - send block entity after predicting + capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
return; return;
} }
// CraftBukkit end // CraftBukkit end
@ -47,12 +47,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Update any tile entity data for this block // Update any tile entity data for this block
+ if (!captureSentBlockEntities) { // Paper - Toggle this location for capturing as this is used for api + if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction
BlockEntity tileentity = this.level.getBlockEntity(pos); BlockEntity tileentity = this.level.getBlockEntity(pos);
if (tileentity != null) { if (tileentity != null) {
this.player.connection.send(tileentity.getUpdatePacket()); this.player.connection.send(tileentity.getUpdatePacket());
} }
+ } else {capturedBlockEntity = true;} // Paper end + } else {capturedBlockEntity = true;} // Paper - Send block entities after destroy prediction
return false; return false;
} }
} }
@ -64,13 +64,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return; return;
} }
// Paper end - Don't allow digging in unloaded chunks // Paper end - Don't allow digging in unloaded chunks
+ // Paper start - send block entities after prediction + // Paper start - Send block entities after destroy prediction
+ this.player.gameMode.capturedBlockEntity = false; + this.player.gameMode.capturedBlockEntity = false;
+ this.player.gameMode.captureSentBlockEntities = true; + this.player.gameMode.captureSentBlockEntities = true;
+ // Paper end - send block entities after prediction + // Paper end - Send block entities after destroy prediction
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxBuildHeight(), packet.getSequence()); this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxBuildHeight(), packet.getSequence());
this.player.connection.ackBlockChangesUpTo(packet.getSequence()); this.player.connection.ackBlockChangesUpTo(packet.getSequence());
+ // Paper start - send block entities after prediction + // Paper start - Send block entities after destroy prediction
+ this.player.gameMode.captureSentBlockEntities = false; + this.player.gameMode.captureSentBlockEntities = false;
+ // If a block entity was modified speedup the block change ack to avoid the block entity + // If a block entity was modified speedup the block change ack to avoid the block entity
+ // being overriden. + // being overriden.
@ -85,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.player.connection.send(tileentity.getUpdatePacket()); + this.player.connection.send(tileentity.getUpdatePacket());
+ } + }
+ } + }
+ // Paper end - send block entities after prediction + // Paper end - Send block entities after destroy prediction
return; return;
default: default:
throw new IllegalArgumentException("Invalid player action"); throw new IllegalArgumentException("Invalid player action");

View File

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static boolean isInWorldBoundsHorizontal(BlockPos pos) { private static boolean isInWorldBoundsHorizontal(BlockPos pos) {
- return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; - return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000;
+ return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Dif on change + return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Diff on change warnUnsafeChunk()
} }
private static boolean isOutsideSpawnableHeight(int y) { private static boolean isOutsideSpawnableHeight(int y) {

View File

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (holder == null) { + if (holder == null) {
+ return; + return;
+ } + }
+ // Paper end + // Paper end - Replace getHolderOrThrow with a null check
JigsawPlacement.generateJigsaw(world, holder, this.target, maxDepth, blockPos, keepJigsaws); JigsawPlacement.generateJigsaw(world, holder, this.target, maxDepth, blockPos, keepJigsaws);
} }

View File

@ -13,13 +13,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
BlockState iblockdata1 = Blocks.CLAY.defaultBlockState(); BlockState iblockdata1 = Blocks.CLAY.defaultBlockState();
- world.setBlockAndUpdate(((PointedDripstoneBlock.FluidInfo) optional.get()).pos, iblockdata1); - world.setBlockAndUpdate(((PointedDripstoneBlock.FluidInfo) optional.get()).pos, iblockdata1);
+ // Paper start + // Paper start - Call BlockFormEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, iblockdata1)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, iblockdata1)) {
Block.pushEntitiesUp(((PointedDripstoneBlock.FluidInfo) optional.get()).sourceState, iblockdata1, world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos); Block.pushEntitiesUp(((PointedDripstoneBlock.FluidInfo) optional.get()).sourceState, iblockdata1, world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos);
world.gameEvent(GameEvent.BLOCK_CHANGE, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, GameEvent.Context.of(iblockdata1)); world.gameEvent(GameEvent.BLOCK_CHANGE, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, GameEvent.Context.of(iblockdata1));
world.levelEvent(1504, blockposition1, 0); world.levelEvent(1504, blockposition1, 0);
+ } + }
+ //Paper end + // Paper end - Call BlockFormEvent
} else { } else {
BlockPos blockposition2 = PointedDripstoneBlock.findFillableCauldronBelowStalactiteTip(world, blockposition1, fluidtype); BlockPos blockposition2 = PointedDripstoneBlock.findFillableCauldronBelowStalactiteTip(world, blockposition1, fluidtype);