diff --git a/patches/api/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch b/patches/api/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch index 00ee9d4176..82790c9b61 100644 --- a/patches/api/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch +++ b/patches/api/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch @@ -39,4 +39,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end /** - * Checks if the chunk is loaded. + * Checks if the chunk is fully generated. diff --git a/patches/api/Add-BellRevealRaiderEvent.patch b/patches/api/Add-BellRevealRaiderEvent.patch index 1470462de4..aaed3f322b 100644 --- a/patches/api/Add-BellRevealRaiderEvent.patch +++ b/patches/api/Add-BellRevealRaiderEvent.patch @@ -22,7 +22,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +/** + * Called when a {@link org.bukkit.entity.Raider} is revealed by a bell. ++ * @deprecated use {@link org.bukkit.event.block.BellResonateEvent} + */ ++@Deprecated +public class BellRevealRaiderEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + diff --git a/patches/api/Add-BellRingEvent.patch b/patches/api/Add-BellRingEvent.patch index 43284724b8..62f1c01811 100644 --- a/patches/api/Add-BellRingEvent.patch +++ b/patches/api/Add-BellRingEvent.patch @@ -15,55 +15,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package io.papermc.paper.event.block; + +import org.bukkit.block.Block; ++import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; -+import org.bukkit.event.HandlerList; -+import org.bukkit.event.block.BlockEvent; -+import org.bukkit.potion.PotionEffect; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when a bell is rung. ++ * @deprecated use {@link org.bukkit.event.block.BellRingEvent} + */ -+public class BellRingEvent extends BlockEvent implements Cancellable { -+ private static final HandlerList handlers = new HandlerList(); -+ private boolean cancelled; -+ private final Entity entity; ++@Deprecated ++public class BellRingEvent extends org.bukkit.event.block.BellRingEvent implements Cancellable { + -+ public BellRingEvent(@NotNull Block block, @Nullable Entity entity) { -+ super(block); -+ this.entity = entity; -+ } -+ -+ @Override -+ public boolean isCancelled() { -+ return cancelled; -+ } -+ -+ @Override -+ public void setCancelled(boolean cancelled) { -+ this.cancelled = cancelled; -+ } -+ -+ /** -+ * Gets the entity that rang the bell. -+ * -+ * @return the ringer or null if none -+ */ -+ @Nullable -+ public Entity getEntity() { -+ return entity; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; ++ public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) { ++ super(block, direction, entity); + } +} diff --git a/patches/api/Add-custom-destroyerIdentity-to-sendBlockDamage.patch b/patches/api/Add-custom-destroyerIdentity-to-sendBlockDamage.patch deleted file mode 100644 index b7b02bc86c..0000000000 --- a/patches/api/Add-custom-destroyerIdentity-to-sendBlockDamage.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: TheFruxz -Date: Sat, 2 Apr 2022 13:03:39 +0200 -Subject: [PATCH] Add custom destroyerIdentity to sendBlockDamage - - -diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/entity/Player.java -+++ b/src/main/java/org/bukkit/entity/Player.java -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - /** - * Send block damage. This fakes block break progress for a user at a - * certain location. This will not actually change the block's break -- * progress in any way. -+ * progress in any way. The destroying entity will be this player. - * - * @param loc the location of the damaged block - * @param progress the progress from 0.0 - 1.0 where 0 is no damage and -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - public void sendBlockDamage(@NotNull Location loc, float progress); - - // Paper start -+ -+ /** -+ * Send block damage. This fakes block break progress for a user at a certain location. -+ * This will not actually change the block's break progress in any way. -+ * The destroying entity is defined via the destroyerIdentity parameter. -+ * -+ * @param loc the location of the damaged block -+ * @param progress the progress from 0.0 - 1.0 where 0 is no damage and 1.0 is the most damaged -+ * @param destroyerIdentity the entity id of the destroyer -+ */ -+ public void sendBlockDamage(@NotNull Location loc, float progress, int destroyerIdentity); -+ - /** - * Send multiple block changes. This fakes a multi block change packet for each - * chunk section that a block change occurs. This will not actually change the world in any way. diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index c373eebbb9..9562e21cdc 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 compileOnly("org.apache.maven:maven-resolver-provider:3.8.5") @@ -0,0 +0,0 @@ tasks.withType { - "https://guava.dev/releases/31.0.1-jre/api/docs/", + "https://guava.dev/releases/31.1-jre/api/docs/", "https://javadoc.io/doc/org.yaml/snakeyaml/1.33/", "https://javadoc.io/doc/org.jetbrains/annotations/23.0.0/", // Paper - we don't want Java 5 annotations - "https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/", diff --git a/patches/api/Block-Ticking-API.patch b/patches/api/Block-Ticking-API.patch index 6b18f16a5b..8f8e6b6612 100644 --- a/patches/api/Block-Ticking-API.patch +++ b/patches/api/Block-Ticking-API.patch @@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/block/data/BlockData.java +++ b/src/main/java/org/bukkit/block/data/BlockData.java @@ -0,0 +0,0 @@ public interface BlockData extends Cloneable { + * @param mirror the mirror */ - @NotNull - Material getPlacementMaterial(); + void mirror(@NotNull Mirror mirror); + + // Paper start - Tick API + /** diff --git a/patches/api/Build-system-changes.patch b/patches/api/Build-system-changes.patch index 0a8309e9e0..c4b2dd9dc6 100644 --- a/patches/api/Build-system-changes.patch +++ b/patches/api/Build-system-changes.patch @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 testImplementation("org.hamcrest:hamcrest-library:1.3") @@ -0,0 +0,0 @@ tasks.withType { options.links( - "https://guava.dev/releases/31.0.1-jre/api/docs/", + "https://guava.dev/releases/31.1-jre/api/docs/", "https://javadoc.io/doc/org.yaml/snakeyaml/1.33/", - "https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/", + "https://javadoc.io/doc/org.jetbrains/annotations/23.0.0/", // Paper - we don't want Java 5 annotations diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch index 4801f18139..7096d7421f 100644 --- a/patches/api/Convert-project-to-Gradle.patch +++ b/patches/api/Convert-project-to-Gradle.patch @@ -96,7 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + options.use() + options.isDocFilesSubDirs = true + options.links( -+ "https://guava.dev/releases/31.0.1-jre/api/docs/", ++ "https://guava.dev/releases/31.1-jre/api/docs/", + "https://javadoc.io/doc/org.yaml/snakeyaml/1.33/", + "https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/", + "https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/", @@ -251,23 +251,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-compiler-plugin -- 3.10.1 +- 3.11.0 - - - eclipse +- +- false - - - - org.codehaus.plexus - plexus-compiler-eclipse -- 2.12.0 +- 2.13.0 - - - - - org.apache.maven.plugins - maven-jar-plugin -- 3.2.2 +- 3.3.0 - - - @@ -309,11 +311,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-javadoc-plugin -- 3.4.0 +- 3.5.0 - - -- https://guava.dev/releases/31.0.1-jre/api/docs/ -- https://javadoc.io/doc/org.yaml/snakeyaml/1.30/ +- https://guava.dev/releases/31.1-jre/api/docs/ +- https://javadoc.io/doc/org.yaml/snakeyaml/1.33/ - https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/ - https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/ - @@ -333,7 +335,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-checkstyle-plugin -- 3.1.2 +- 3.2.1 - - - process-classes @@ -358,7 +360,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.codehaus.mojo - animal-sniffer-maven-plugin -- 1.21 +- 1.23 - - - process-classes diff --git a/patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch b/patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch index 337afe052a..053efda2ed 100644 --- a/patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch +++ b/patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch @@ -120,5 +120,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + /** - * Add custom chat completion suggestions shown to the player while typing a - * message. + * Send a hurt animation. This fakes incoming damage towards the player from + * the given yaw relative to the player's direction. diff --git a/patches/api/Missing-Entity-Behavior-API.patch b/patches/api/Missing-Entity-Behavior-API.patch index ff58445a1a..a0d2e41f70 100644 --- a/patches/api/Missing-Entity-Behavior-API.patch +++ b/patches/api/Missing-Entity-Behavior-API.patch @@ -1176,55 +1176,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + void setConversionTime(int time, boolean broadcastEntityEvent); + // Paper stop - missing entity behaviour api - converting without entity event } -diff --git a/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java b/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java -+++ b/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java -@@ -0,0 +0,0 @@ import org.bukkit.entity.Minecart; - * Represents a Minecart with TNT inside it that can explode when triggered. - */ - public interface ExplosiveMinecart extends Minecart { -+ // Paper start - Entity API -+ /** -+ * Set the number of ticks until the Minecart explodes after being primed. -+ * -+ * @param fuseTicks fuse ticks or -1 if the fuse isn't primed -+ */ -+ void setFuseTicks(int fuseTicks); -+ -+ /** -+ * Retrieve the number of ticks until the explosive Minecart explodes. -+ * -+ * @return number of ticks or -1 if the fuse isn't primed -+ */ -+ int getFuseTicks(); -+ -+ /** -+ * Checks whether this explosive Minecart is ignited (its fuse is primed). -+ * -+ * @return whether the Minecart is ignited -+ */ -+ boolean isIgnited(); -+ -+ /** -+ * Ignites this explosive Minecart, beginning its fuse. -+ */ -+ void ignite(); -+ -+ /** -+ * Immediately explodes the Minecart. -+ * Power will depend on the Minecart's horizontal speed. -+ */ -+ void explode(); -+ -+ /** -+ * Immediately explodes the Minecart with the specified power. -+ * -+ * @param power explosion power -+ */ -+ void explode(double power); -+ // Paper end - Entity API - } diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java diff --git a/patches/api/Multi-Block-Change-API.patch b/patches/api/Multi-Block-Change-API.patch index 0a4716c374..8489c2f8cd 100644 --- a/patches/api/Multi-Block-Change-API.patch +++ b/patches/api/Multi-Block-Change-API.patch @@ -17,22 +17,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Send multiple block changes. This fakes a multi block change packet for each + * chunk section that a block change occurs. This will not actually change the world in any way. + * -+ * @param blockChanges A map of the locations you want to change to their new block data ++ * @param blockChanges A map of the positions you want to change to their new block data + */ -+ public default void sendMultiBlockChange(@NotNull java.util.Map blockChanges) { -+ sendMultiBlockChange(blockChanges, false); ++ default void sendMultiBlockChange(@NotNull Map blockChanges) { ++ this.sendMultiBlockChange(blockChanges, false); + } + + /** + * Send multiple block changes. This fakes a multi block change packet for each + * chunk section that a block change occurs. This will not actually change the world in any way. + * -+ * @param blockChanges A map of the locations you want to change to their new block data ++ * @param blockChanges A map of the positions you want to change to their new block data + * @param suppressLightUpdates Whether to suppress light updates or not + */ -+ public void sendMultiBlockChange(@NotNull java.util.Map blockChanges, boolean suppressLightUpdates); ++ void sendMultiBlockChange(@NotNull Map blockChanges, boolean suppressLightUpdates); + // Paper end + /** - * Send an equipment change for the target entity. This will not - * actually change the entity's equipment in any way. + * Send block damage. This fakes block break progress at a certain location + * sourced by the provided entity. This will not actually change the block's diff --git a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch index 4b52bc1cf9..f9962bc501 100644 --- a/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch +++ b/patches/server/Ability-to-get-Tile-Entities-from-a-chunk-without-sn.patch @@ -8,17 +8,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java -@@ -0,0 +0,0 @@ import com.google.common.base.Preconditions; - import com.google.common.base.Predicates; - import com.mojang.serialization.Codec; - import java.lang.ref.WeakReference; -+import java.util.ArrayList; - import java.util.Arrays; - import java.util.Collection; -+import java.util.List; - import java.util.Objects; - import java.util.concurrent.locks.LockSupport; - import java.util.function.BooleanSupplier; @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { @Override @@ -34,9 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.getWorld().getChunkAt(x, z); // Transient load for this tick } @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { - } + BlockState[] entities = new BlockState[chunk.blockEntities.size()]; - BlockPos position = (BlockPos) obj; + for (BlockPos position : chunk.blockEntities.keySet()) { - entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(); + // Paper start + entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(useSnapshot); @@ -48,15 +37,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public Collection getTileEntities(Predicate blockPredicate, boolean useSnapshot) { + Preconditions.checkNotNull(blockPredicate, "blockPredicate"); -+ if (!isLoaded()) { -+ getWorld().getChunkAt(x, z); // Transient load for this tick ++ if (!this.isLoaded()) { ++ this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick + } -+ net.minecraft.world.level.chunk.LevelChunk chunk = getHandle(); ++ ChunkAccess chunk = this.getHandle(ChunkStatus.FULL); + -+ List entities = new ArrayList<>(); ++ java.util.List entities = new java.util.ArrayList<>(); + + for (BlockPos position : chunk.blockEntities.keySet()) { -+ Block block = worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); ++ Block block = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); + if (blockPredicate.test(block)) { + entities.add(block.getState(useSnapshot)); + } diff --git a/patches/server/Add-BellRevealRaiderEvent.patch b/patches/server/Add-BellRevealRaiderEvent.patch index 40dcabe4a7..3bea43f9b8 100644 --- a/patches/server/Add-BellRevealRaiderEvent.patch +++ b/patches/server/Add-BellRevealRaiderEvent.patch @@ -9,14 +9,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java @@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity { - private static void makeRaidersGlow(Level world, BlockPos pos, List hearingEntities) { - hearingEntities.stream().filter((entity) -> { - return isRaiderWithinRange(pos, entity); -- }).forEach(BellBlockEntity::glow); -+ }).forEach(entity -> glow(entity, pos)); // Paper - pass BlockPos + return BellBlockEntity.isRaiderWithinRange(pos, entityliving); + }).map((entity) -> (org.bukkit.entity.LivingEntity) entity.getBukkitEntity()).collect(java.util.stream.Collectors.toCollection(java.util.ArrayList::new)); // CraftBukkit + +- org.bukkit.craftbukkit.event.CraftEventFactory.handleBellResonateEvent(world, pos, entities).forEach(BellBlockEntity::glow); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBellResonateEvent(world, pos, entities).forEach(entity -> glow(entity, pos)); // Paper - pass BlockPos + // CraftBukkit end } - private static void showBellParticles(Level world, BlockPos pos, List hearingEntities) { @@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity { return entity.isAlive() && !entity.isRemoved() && pos.closerToCenterThan(entity.position(), 48.0D) && entity.getType().is(EntityTypeTags.RAIDERS); } diff --git a/patches/server/Add-BellRingEvent.patch b/patches/server/Add-BellRingEvent.patch index 39e0a65831..16260d2009 100644 --- a/patches/server/Add-BellRingEvent.patch +++ b/patches/server/Add-BellRingEvent.patch @@ -6,23 +6,20 @@ Subject: [PATCH] Add BellRingEvent Add a new event, BellRingEvent, to trigger whenever a player rings a village bell. Passes along the bell block and the player who rang it. -diff --git a/src/main/java/net/minecraft/world/level/block/BellBlock.java b/src/main/java/net/minecraft/world/level/block/BellBlock.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 ---- a/src/main/java/net/minecraft/world/level/block/BellBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/BellBlock.java -@@ -0,0 +0,0 @@ package net.minecraft.world.level.block; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; -+import io.papermc.paper.util.MCUtil; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.stats.Stats; -@@ -0,0 +0,0 @@ public class BellBlock extends BaseEntityBlock { - direction = world.getBlockState(pos).getValue(FACING); - } +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -0,0 +0,0 @@ public class CraftEventFactory { + return tradeSelectEvent; + } -+ if (!new io.papermc.paper.event.block.BellRingEvent(world.getWorld().getBlockAt(MCUtil.toLocation(world, pos)), entity == null ? null : entity.getBukkitEntity()).callEvent()) return false; // Paper - BellRingEvent - ((BellBlockEntity)blockEntity).onHit(direction); - world.playSound((Player)null, pos, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F); - world.gameEvent(entity, GameEvent.BLOCK_CHANGE, pos); ++ @SuppressWarnings("deprecation") // Paper use deprecated event to maintain compat (it extends modern event) + public static boolean handleBellRingEvent(Level world, BlockPos position, Direction direction, Entity entity) { + Block block = CraftBlock.at(world, position); + BlockFace bukkitDirection = CraftBlock.notchToBlockFace(direction); +- BellRingEvent event = new BellRingEvent(block, bukkitDirection, (entity != null) ? entity.getBukkitEntity() : null); ++ BellRingEvent event = new io.papermc.paper.event.block.BellRingEvent(block, bukkitDirection, (entity != null) ? entity.getBukkitEntity() : null); // Paper - deprecated BellRingEvent + Bukkit.getPluginManager().callEvent(event); + return !event.isCancelled(); + } diff --git a/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch index cbb6022325..a7e21e3944 100644 --- a/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch +++ b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch @@ -51,25 +51,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Chunk getChunkAt(int x, int z) { -- return this.world.getChunkSource().getChunk(x, z, true).bukkitChunk; +- net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) this.world.getChunk(x, z, ChunkStatus.FULL, true); + // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it -+ net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); ++ net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); + if (chunk == null) { -+ addTicket(x, z); ++ this.addTicket(x, z); + chunk = this.world.getChunkSource().getChunk(x, z, true); + } -+ return chunk.bukkitChunk; + // Paper end -+ } -+ + return new CraftChunk(chunk); + } + +@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { + return new CraftChunk(this.getHandle(), x, z); + } + + // Paper start + private void addTicket(int x, int z) { -+ io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper - } ++ io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> this.world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper ++ } + // Paper end - ++ @Override public Chunk getChunkAt(Block block) { + Preconditions.checkArgument(block != null, "null block"); @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { public boolean unloadChunkRequest(int x, int z) { org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot @@ -115,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> { net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c; -+ if (chunk != null) addTicket(x, z); // Paper - ret.complete(chunk == null ? null : chunk.getBukkitChunk()); ++ if (chunk != null) this.addTicket(x, z); // Paper + ret.complete(chunk == null ? null : new CraftChunk(chunk)); }); }); diff --git a/patches/server/Add-custom-destroyerIdentity-to-sendBlockDamage.patch b/patches/server/Add-custom-destroyerIdentity-to-sendBlockDamage.patch deleted file mode 100644 index 73467e4749..0000000000 --- a/patches/server/Add-custom-destroyerIdentity-to-sendBlockDamage.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: TheFruxz -Date: Sat, 26 Mar 2022 18:41:36 +0100 -Subject: [PATCH] Add custom destroyerIdentity to sendBlockDamage - - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - - @Override - public void sendBlockDamage(Location loc, float progress) { -+ // Paper start - customBlockDamage identity -+ sendBlockDamage(loc, progress, this.getHandle().getId()); -+ } -+ -+ @Override -+ public void sendBlockDamage(Location loc, float progress, int destroyerIdentity) { -+ // Paper end - customBlockDamage identity - Preconditions.checkArgument(loc != null, "loc must not be null"); - Preconditions.checkArgument(progress >= 0.0 && progress <= 1.0, "progress must be between 0.0 and 1.0 (inclusive)"); - - if (this.getHandle().connection == null) return; - - int stage = (int) (9 * progress); // There are 0 - 9 damage states -- ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(this.getHandle().getId(), new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); -+ ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(destroyerIdentity, new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); // Paper - customBlockDamage identity - this.getHandle().connection.send(packet); - } - diff --git a/patches/server/Block-Ticking-API.patch b/patches/server/Block-Ticking-API.patch index 56d00ff1d2..980f95a177 100644 --- a/patches/server/Block-Ticking-API.patch +++ b/patches/server/Block-Ticking-API.patch @@ -35,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -0,0 +0,0 @@ public class CraftBlockData implements BlockData { - public Material getPlacementMaterial() { - return CraftMagicNumbers.getMaterial(this.state.getBlock().asItem()); + public void mirror(Mirror mirror) { + this.state = this.state.mirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name())); } + + // Paper start - Block tick API diff --git a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch index f5a2793375..3d34078340 100644 --- a/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch +++ b/patches/server/Fix-ChunkSnapshot-isSectionEmpty-int-and-optimize-Pa.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - LevelLightEngine lightengine = chunk.level.getLightEngine(); + LevelLightEngine lightengine = this.worldServer.getLightEngine(); DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(x, i, z)); @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { } diff --git a/patches/server/Implement-regenerateChunk.patch b/patches/server/Implement-regenerateChunk.patch index 0e3c7e2c5f..f2d8cad7f1 100644 --- a/patches/server/Implement-regenerateChunk.patch +++ b/patches/server/Implement-regenerateChunk.patch @@ -9,7 +9,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ import org.bukkit.util.Vector; +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; public class CraftWorld extends CraftRegionAccessor implements World { public static final int CUSTOM_DIMENSION_OFFSET = 10; private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); diff --git a/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch index 3e92efb9eb..6e7863e254 100644 --- a/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch @@ -109,18 +109,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + default Level getNMSWorld() { -+ return getTileEntity().getLevel(); ++ return this.getTileEntity().getLevel(); + } + + default Block getBlock() { -+ final BlockPos position = getTileEntity().getBlockPos(); -+ final Chunk bukkitChunk = getTileEntity().getLevel().getChunkAt(position).bukkitChunk; ++ final BlockPos position = this.getTileEntity().getBlockPos(); ++ final Chunk bukkitChunk = this.getBukkitWorld().getChunkAt(org.bukkit.craftbukkit.block.CraftBlock.at(this.getNMSWorld(), position)); + return bukkitChunk.getBlock(position.getX(), position.getY(), position.getZ()); + } + + @Override + default PaperLootableInventoryData getLootableData() { -+ return getTileEntity().lootableData; ++ return this.getTileEntity().lootableData; + } +} diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableEntityInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableEntityInventory.java diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 53b32292e3..e13c463ab2 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -7071,7 +7071,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.Entity; @@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { - + public boolean needsDecoration; // CraftBukkit end + // Paper start @@ -7311,9 +7311,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Chunk[] getLoadedChunks() { - Long2ObjectLinkedOpenHashMap chunks = this.world.getChunkSource().chunkMap.visibleChunkMap; -- return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); +- return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(CraftChunk::new).toArray(Chunk[]::new); + List chunks = io.papermc.paper.chunk.system.ChunkSystem.getVisibleChunkHolders(this.world); // Paper -+ return chunks.stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new); ++ return chunks.stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(CraftChunk::new).toArray(Chunk[]::new); } @Override @@ -7335,7 +7335,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (Bukkit.isPrimaryThread()) { + net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); + if (immediate != null) { -+ return java.util.concurrent.CompletableFuture.completedFuture(immediate.getBukkitChunk()); ++ return java.util.concurrent.CompletableFuture.completedFuture(new CraftChunk(immediate)); + } + } + @@ -7351,7 +7351,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> { + net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { + net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c; -+ ret.complete(chunk == null ? null : chunk.getBukkitChunk()); ++ ret.complete(chunk == null ? null : new CraftChunk(chunk)); + }); + }); + diff --git a/patches/server/Missing-Entity-Behavior-API.patch b/patches/server/Missing-Entity-Behavior-API.patch index e3c7890e25..b044c1b25e 100644 --- a/patches/server/Missing-Entity-Behavior-API.patch +++ b/patches/server/Missing-Entity-Behavior-API.patch @@ -786,61 +786,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setPickupCooldown(int cooldown) { + throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns"); + } -+ // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.CraftServer; - import org.bukkit.entity.EntityType; - import org.bukkit.entity.minecart.ExplosiveMinecart; - --final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart { -+public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart { // Paper - getHandle -> make public - CraftMinecartTNT(CraftServer server, MinecartTNT entity) { - super(server, entity); - } -@@ -0,0 +0,0 @@ final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart - public EntityType getType() { - return EntityType.MINECART_TNT; - } -+ // Paper start -+ @Override -+ public net.minecraft.world.entity.vehicle.MinecartTNT getHandle() { -+ return (net.minecraft.world.entity.vehicle.MinecartTNT) entity; -+ } -+ -+ @Override -+ public void setFuseTicks(int fuseTicks) { -+ this.getHandle().fuse = fuseTicks; -+ } -+ -+ @Override -+ public int getFuseTicks() { -+ return this.getHandle().getFuse(); -+ } -+ -+ @Override -+ public boolean isIgnited() { -+ return this.getHandle().isPrimed(); -+ } -+ -+ @Override -+ public void ignite() { -+ this.getHandle().primeFuse(); -+ } -+ -+ @Override -+ public void explode() { -+ explode(this.getHandle().getDeltaMovement().horizontalDistanceSqr()); -+ } -+ -+ @Override -+ public void explode(double power) { -+ com.google.common.base.Preconditions.checkArgument(power >= 0 && Double.isFinite(power), "Explosion power must be a finite non-negative number"); -+ this.getHandle().explode(power); -+ } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java diff --git a/patches/server/Multi-Block-Change-API-Implementation.patch b/patches/server/Multi-Block-Change-API-Implementation.patch index 580cffc2d5..a0f028b8e7 100644 --- a/patches/server/Multi-Block-Change-API-Implementation.patch +++ b/patches/server/Multi-Block-Change-API-Implementation.patch @@ -34,17 +34,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override -+ public void sendMultiBlockChange(Map blockChanges, boolean suppressLightUpdates) { ++ public void sendMultiBlockChange(final Map blockChanges, final boolean suppressLightUpdates) { + if (this.getHandle().connection == null) return; + + Map> sectionMap = new HashMap<>(); + -+ for (Map.Entry entry : blockChanges.entrySet()) { -+ Location location = entry.getKey(); -+ if (!location.getWorld().equals(this.getWorld())) continue; -+ ++ for (Map.Entry entry : blockChanges.entrySet()) { + BlockData blockData = entry.getValue(); -+ BlockPos blockPos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()); ++ BlockPos blockPos = io.papermc.paper.util.MCUtil.toBlockPos(entry.getKey()); + SectionPos sectionPos = SectionPos.of(blockPos); + + it.unimi.dsi.fastutil.shorts.Short2ObjectMap sectionData = sectionMap.computeIfAbsent(sectionPos, key -> new it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap<>()); diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index c502969c88..35b2dc4f96 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -16832,9 +16832,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /* * If it's a new world, the first few chunks are generated inside @@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { - * no way of creating a CraftWorld/CraftServer at that point. */ - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); + org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration)); + this.chunkHolder.getEntityChunk().callEntitiesLoadEvent(); // Paper - rewrite chunk system if (this.needsDecoration) { @@ -16845,9 +16845,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void unloadCallback() { + if (!this.loadedTicketLevel) { LOGGER.error("Double calling chunk unload!", new Throwable()); } // Paper org.bukkit.Server server = this.level.getCraftServer(); -- org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isUnsaved()); + this.chunkHolder.getEntityChunk().callEntitiesUnloadEvent(); // Paper - rewrite chunk system -+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, true); // Paper - rewrite chunk system - force save to true so that mustNotSave is correctly set below + org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); +- org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(bukkitChunk, this.isUnsaved()); ++ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(bukkitChunk, true); // Paper - rewrite chunk system - force save to true so that mustNotSave is correctly set below server.getPluginManager().callEvent(unloadEvent); // note: saving can be prevented, but not forced if no saving is actually required this.mustNotSave = !unloadEvent.isSaveChunk(); diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index 5576a2d144..62053dff33 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -505,7 +505,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-jar-plugin -- 3.2.2 +- 3.3.0 - - - @@ -623,7 +623,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-assembly-plugin -- 3.3.0 +- 3.5.0 - - - package @@ -650,23 +650,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-compiler-plugin -- 3.10.1 +- 3.11.0 - - - eclipse +- +- false - - - - org.codehaus.plexus - plexus-compiler-eclipse -- 2.12.0 +- 2.13.0 - - - - - org.apache.maven.plugins - maven-surefire-plugin -- 2.12.4 +- 3.0.0 - - ${basedir}/target/test-server - @@ -695,7 +697,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - org.apache.maven.plugins - maven-checkstyle-plugin -- 3.1.2 +- 3.2.1 - - - test-compile diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch index 851bd832e1..8cf9dbc4d6 100644 --- a/patches/server/Timings-v2.patch +++ b/patches/server/Timings-v2.patch @@ -1590,7 +1590,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration)); if (this.needsDecoration) { + try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper @@ -1600,7 +1600,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { } } - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(this.bukkitChunk)); + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); + } // Paper } } diff --git a/patches/server/Warn-on-plugins-accessing-faraway-chunks.patch b/patches/server/Warn-on-plugins-accessing-faraway-chunks.patch index 1a6ec1921d..365de1d3e2 100644 --- a/patches/server/Warn-on-plugins-accessing-faraway-chunks.patch +++ b/patches/server/Warn-on-plugins-accessing-faraway-chunks.patch @@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Chunk getChunkAt(int x, int z) { + warnUnsafeChunk("getting a faraway chunk", x, z); // Paper // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it - net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); + net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); if (chunk == null) { @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override diff --git a/work/Bukkit b/work/Bukkit index 9153f77e75..5efeb7bdbf 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 9153f77e75057c0d0be267de6e0dca89e487625f +Subproject commit 5efeb7bdbfa459cd0a59aa6a8941ff962662617f diff --git a/work/CraftBukkit b/work/CraftBukkit index e142fb9fd3..be8682aa82 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit e142fb9fd3784080c43e025c32d8306881fee4ca +Subproject commit be8682aa824764ebf811107c5eb928ffad6c1af5 diff --git a/work/Spigot b/work/Spigot index 6ad4b93c2a..b31949f2f3 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 6ad4b93c2ab4d981910821bd43be6a085177bed9 +Subproject commit b31949f2f33ef94ed07dbe37fb00939cf049a989