Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9088)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
5efeb7bd Also update compiler version
c13b867a Update some Maven plugin versions
deb28d9f PR-837: Add more bell API
e938d62a PR-819: Allow Player#sendBlockDamage() to specify a source entity
0e75532c PR-818: Add more Guardian API, particularly for its laser
a10155aa PR-839: Add BlockData#rotate and BlockData#mirror
77e690b4 PR-836: Add missing API for explosive minecarts
60722059 PR-832: Allow getting chunks without generating them and optimize chunk data request for ungenerated chunks
0a2c4b4b PR-834: Add Player#sendHurtAnimation()

CraftBukkit Changes:
be8682aa8 Also update compiler version
08e305f5b Update some Maven plugin versions
187bdd463 PR-1160: Add more bell API
2f8e5bc7c PR-1145: Allow Player#sendBlockDamage() to specify a source entity
bcbb61b36 PR-1144: Add more Guardian API, particularly for its laser
722ddff6d PR-1162: Add BlockData#rotate and BlockData#mirror
80998277c PR-1159: Add missing API for explosive minecarts
1fddefce1 PR-1155: Allow getting chunks without generating them and optimize chunk data request for ungenerated chunks
20e8a486f PR-1157: Add Player#sendHurtAnimation()

Spigot Changes:
b31949f2 Rebuild patches
This commit is contained in:
Jake Potrebic 2023-04-07 11:39:13 -07:00
parent 771aa3ec89
commit a37ccc7532
30 changed files with 112 additions and 326 deletions

View file

@ -39,4 +39,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
/**
* Checks if the chunk is loaded.
* Checks if the chunk is fully generated.

View file

@ -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();
+

View file

@ -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);
+ }
+}

View file

@ -1,38 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TheFruxz <cedricspitzer@outlook.de>
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.

View file

@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
@@ -0,0 +0,0 @@ tasks.withType<Javadoc> {
"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/",

View file

@ -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
+ /**

View file

@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
testImplementation("org.hamcrest:hamcrest-library:1.3")
@@ -0,0 +0,0 @@ tasks.withType<Javadoc> {
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

View file

@ -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
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.10.1</version>
- <version>3.11.0</version>
- <configuration>
- <!-- we use the Eclipse compiler as it doesn't need a JDK -->
- <compilerId>eclipse</compilerId>
- <!-- default changed with version 3.11.0 -->
- <showWarnings>false</showWarnings>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-eclipse</artifactId>
- <version>2.12.0</version>
- <version>2.13.0</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.2.2</version>
- <version>3.3.0</version>
- <configuration>
- <archive>
- <manifest>
@ -309,11 +311,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>3.4.0</version>
- <version>3.5.0</version>
- <configuration>
- <links>
- <link>https://guava.dev/releases/31.0.1-jre/api/docs/</link>
- <link>https://javadoc.io/doc/org.yaml/snakeyaml/1.30/</link>
- <link>https://guava.dev/releases/31.1-jre/api/docs/</link>
- <link>https://javadoc.io/doc/org.yaml/snakeyaml/1.33/</link>
- <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/</link>
- <link>https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/</link>
- </links>
@ -333,7 +335,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>3.1.2</version>
- <version>3.2.1</version>
- <executions>
- <execution>
- <phase>process-classes</phase>
@ -358,7 +360,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.21</version>
- <version>1.23</version>
- <executions>
- <execution>
- <phase>process-classes</phase>

View file

@ -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.

View file

@ -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

View file

@ -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<Location, BlockData> blockChanges) {
+ sendMultiBlockChange(blockChanges, false);
+ default void sendMultiBlockChange(@NotNull Map<? extends io.papermc.paper.math.Position, BlockData> 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<Location, BlockData> blockChanges, boolean suppressLightUpdates);
+ void sendMultiBlockChange(@NotNull Map<? extends io.papermc.paper.math.Position, BlockData> 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

View file

@ -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<BlockState> getTileEntities(Predicate<Block> 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<BlockState> entities = new ArrayList<>();
+ java.util.List<BlockState> 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));
+ }

View file

@ -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<LivingEntity> 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<LivingEntity> 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);
}

View file

@ -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();
}

View file

@ -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));
});
});

View file

@ -1,32 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TheFruxz <cedricspitzer@outlook.de>
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);
}

View file

@ -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

View file

@ -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 {
}

View file

@ -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();

View file

@ -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

View file

@ -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<ChunkHolder> 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<ChunkHolder> 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));
+ });
+ });
+

View file

@ -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

View file

@ -34,17 +34,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start
+ @Override
+ public void sendMultiBlockChange(Map<Location, BlockData> blockChanges, boolean suppressLightUpdates) {
+ public void sendMultiBlockChange(final Map<? extends io.papermc.paper.math.Position, BlockData> blockChanges, final boolean suppressLightUpdates) {
+ if (this.getHandle().connection == null) return;
+
+ Map<SectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState>> sectionMap = new HashMap<>();
+
+ for (Map.Entry<Location, BlockData> entry : blockChanges.entrySet()) {
+ Location location = entry.getKey();
+ if (!location.getWorld().equals(this.getWorld())) continue;
+
+ for (Map.Entry<? extends io.papermc.paper.math.Position, BlockData> 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<net.minecraft.world.level.block.state.BlockState> sectionData = sectionMap.computeIfAbsent(sectionPos, key -> new it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap<>());

View file

@ -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();

View file

@ -505,7 +505,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.2.2</version>
- <version>3.3.0</version>
- <configuration>
- <archive>
- <manifest>
@ -623,7 +623,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>3.3.0</version>
- <version>3.5.0</version>
- <executions>
- <execution>
- <phase>package</phase>
@ -650,23 +650,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.10.1</version>
- <version>3.11.0</version>
- <configuration>
- <!-- we use the Eclipse compiler as it doesn't need a JDK -->
- <compilerId>eclipse</compilerId>
- <!-- default changed with version 3.11.0 -->
- <showWarnings>false</showWarnings>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-eclipse</artifactId>
- <version>2.12.0</version>
- <version>2.13.0</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.12.4</version>
- <version>3.0.0</version>
- <configuration>
- <workingDirectory>${basedir}/target/test-server</workingDirectory>
- <excludes>
@ -695,7 +697,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>3.1.2</version>
- <version>3.2.1</version>
- <executions>
- <execution>
- <phase>test-compile</phase>

View file

@ -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
}
}

View file

@ -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

@ -1 +1 @@
Subproject commit 9153f77e75057c0d0be267de6e0dca89e487625f
Subproject commit 5efeb7bdbfa459cd0a59aa6a8941ff962662617f

@ -1 +1 @@
Subproject commit e142fb9fd3784080c43e025c32d8306881fee4ca
Subproject commit be8682aa824764ebf811107c5eb928ffad6c1af5

@ -1 +1 @@
Subproject commit 6ad4b93c2ab4d981910821bd43be6a085177bed9
Subproject commit b31949f2f33ef94ed07dbe37fb00939cf049a989