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

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:
63c208dd Remove no longer used import
70be76c7 PR-958: Further clarify deprecation of TAG_CONTAINER_ARRAY
ae21f4ac PR-955: Add methods to place structures with block/entity transformers
e3d960f2 SPIGOT-7547: Remark that Damageable#setAbsorptionAmount() is capped to a specific value
b125516c Fix typo in RecipeChoice.ExactChoice docs
309497c1 Add EntityMountEvent and EntityDismount Event
2fd45ae3 Improve ItemFactory#enchantItem consistency
2b198268 PR-933: Define native persistent data types for lists

CraftBukkit Changes:
771182f70 PR-1327: Add methods to place structures with block/entity transformers
e41ad4c82 SPIGOT-7567: SpawnReason for SNOWMAN is reported as BUILD_IRONGOLEM
76931e8bd Add EntityMountEvent and EntityDismount Event
9b29b21c7 PR-1183: Better handle lambda expression and renaming of classes in Commodore
1462ebe85 Reformat Commodore.java
9fde4c037 PR-1324: Improve ItemFactory#enchantItem consistency
4e419c774 PR-1295: Define native persistent data types for lists
dd8cca388 SPIGOT-7562: Fix Score#getScore and Score#isScoreSet
690278200 Only fetch an online UUID in online mode
1da8d9a53 Fire PreLogin events even in offline mode
2e88514ad PR-1325: Use CraftBlockType and CraftItemType instead of CraftMagicNumbers to convert between minecraft and bukkit block / item representation

Spigot Changes:
864e4acc Restore accidentally removed package-info.java
f91a10d5 Remove obsolete EntityMountEvent and EntityDismountEvent
828f0593 SPIGOT-7558: Deprecate silenceable lightning API as sound is now client-side and cannot be removed
cdc4e035 Remove obsolete patch fetching correct mode UUIDs
49e36b8e Merge related BungeeCord patches
6e87b9ab Remove obsolete firing of PreLogin events in offline mode
5c76b183 Remove redundant patch dealing with exceptions in the crash reporter
3a2219d1 Remove redundant patch logging cause of unexpected exception
This commit is contained in:
Jake Potrebic 2024-01-14 01:46:04 -08:00
parent 734d812b3d
commit fa7d1b668f
46 changed files with 332 additions and 389 deletions

View file

@ -0,0 +1,29 @@
--- /dev/null 2024-01-13 10:03:30.400485704 -0800
+++ CraftBukkit-Patches/9999-re-add-asm-dependency.patch 2024-01-13 21:41:27.650692678 -0800
@@ -0,0 +0,0 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <jake.m.potrebic@gmail.com>
+Date: Sat, 13 Jan 2024 21:41:02 -0800
+Subject: [PATCH] re add asm dependency
+
+
+diff --git a/pom.xml b/pom.xml
+index 266853a682..d18fdadf92 100644
+--- a/pom.xml
++++ b/pom.xml
+@@ -0,0 +0,0 @@
+ <version>2.19.0</version>
+ <scope>compile</scope>
+ </dependency>
++ <dependency>
++ <groupId>org.ow2.asm</groupId>
++ <artifactId>asm</artifactId>
++ <version>9.5</version>
++ <scope>compile</scope>
++ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-commons</artifactId>
+--
+2.43.0
+

View file

@ -93,6 +93,8 @@ paperweight {
mappingsPatch = layout.projectDirectory.file("build-data/mappings-patch.tiny")
reobfMappingsPatch = layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny")
spigotServerPatchPatchesDir = layout.projectDirectory.dir("build-data/spigot-server-patches")
reobfPackagesToFix.addAll(
"co.aikar.timings",
"com.destroystokyo.paper",

View file

@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
@@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
/**
* Represents a choice that will be valid only one of the stacks is exactly
* matched (aside from stack size).
* Represents a choice that will be valid only if one of the stacks is
* exactly matched (aside from stack size).
- * <br>
- * <b>Only valid for shaped recipes</b>
*/

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public interface ItemFactory {
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allows treasure enchants, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be enchanted directly
* @return a new ItemStack containing the result of the Enchantment
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
+ * designed and was originally broken.
*/
@ -23,9 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
@@ -0,0 +0,0 @@ public interface ItemFactory {
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allow the treasure enchants, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be
* enchanted directly
* @return a new ItemStack containing the result of the Enchantment
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
+ * designed and was originally broken.
*/
@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
@@ -0,0 +0,0 @@ public interface ItemFactory {
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allow treasure enchantments, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be
* enchanted directly
* @return a new ItemStack containing the result of the Enchantment
+ * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly
+ * designed and was originally broken.
*/

View file

@ -623,30 +623,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param loc The location to strike lightning
* @param isSilent Whether this strike makes no sound
* @return The lightning entity.
+ * @deprecated The lightning strike sound has been moved into the client and
+ * this doesn't prevent the sound being played. Use the regular (non spigot) methods instead
+ * for a consistent behavior.
*/
@NotNull
+ @Deprecated // Paper
public LightningStrike strikeLightning(@NotNull Location loc, boolean isSilent) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param loc The location to strike lightning
* @param isSilent Whether this strike makes no sound
* @return The lightning entity.
+ * @deprecated The lightning strike sound has been moved into the client and
+ * this doesn't prevent the sound being played. Use the regular (non spigot) methods instead
+ * for a consistent behavior.
*/
@NotNull
+ @Deprecated // Paper
public LightningStrike strikeLightningEffect(@NotNull Location loc, boolean isSilent) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@ -815,17 +791,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper
public class Spigot extends Entity.Spigot {
- /*
+ /**
* Returns whether the strike is silent.
*
* @return whether the strike is silent.
+ * @deprecated The lightning strike sound has been moved into the client and
+ * this can't predict if the sound will be played or not accurately.
*/
+ @Deprecated // Paper
public boolean isSilent() {
throw new UnsupportedOperationException("Not supported yet.");
/**
@@ -0,0 +0,0 @@ public interface LightningStrike extends Entity {
}
}

View file

@ -20,6 +20,48 @@ this is going to be the best soultion all around.
Improvements/suggestions welcome!
diff --git a/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java b/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java
@@ -0,0 +0,0 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Entity dismounted;
+ private final boolean isCancellable; // Paper
public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted) {
+ // Paper start
+ this(what, dismounted, true);
+ }
+
+ public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable) {
+ // Paper end
super(what);
this.dismounted = dismounted;
+ this.isCancellable = isCancellable; // Paper
}
/**
@@ -0,0 +0,0 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
@Override
public void setCancelled(boolean cancel) {
+ // Paper start
+ if (cancel && !this.isCancellable) {
+ return;
+ }
this.cancelled = cancel;
}
+ public boolean isCancellable() {
+ return this.isCancellable;
+ // Paper end
+ }
+
@NotNull
@Override
public HandlerList getHandlers() {
diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java

View file

@ -32,11 +32,10 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
return;
@@ -0,0 +0,0 @@ public class Commodore {
}
// Paper end
+
+ // Paper start - ItemFactory#getSpawnEgg (paper had original method that returned ItemStack, upstream added identical but returned Material)
+ if (owner.equals("org/bukkit/inventory/ItemFactory") && name.equals("getSpawnEgg") && desc.equals("(Lorg/bukkit/entity/EntityType;)Lorg/bukkit/inventory/ItemStack;")) {
+ super.visitInsn(Opcodes.SWAP); // has 1 param, this moves the owner instance to the top for the checkcast
@ -46,6 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return;
+ }
+ // Paper end - ItemFactory#getSpawnEgg
if ( modern )
{
if ( owner.equals( "org/bukkit/Material" ) )
if (modern) {
if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) {
switch (name) {

View file

@ -148,13 +148,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return;
+ }
+ // Paper end
// Spigot start
// CraftBukkit start
// Paper start - Cache authenticator threads
authenticatorPool.execute(new Runnable() {
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
public class LoginHandler {
public void fireEvents(GameProfile gameprofile) throws Exception {
// CraftBukkit start
private void callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception {
+ // Paper start - Velocity support
+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
+ disconnect("This server requires you to connect with Velocity.");
@ -162,8 +162,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
String playerName = gameprofile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.channel.remoteAddress()).getAddress(); // Paper
java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); // Paper
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@Override
@ -202,7 +202,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Proceed with login
+ authenticatorPool.execute(() -> {
+ try {
+ new LoginHandler().fireEvents(this.authenticatedProfile);
+ this.callPlayerPreLoginEvents(this.authenticatedProfile);
+ } catch (Exception ex) {
+ disconnect("Failed to verify username!");
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + this.authenticatedProfile.getName(), ex);

View file

@ -55,10 +55,11 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
@@ -0,0 +0,0 @@ public class Commodore {
desc = getOriginalOrRewrite(desc);
}
// Paper end
+
+ // Paper start - DisplaySlot
+ if (owner.equals("org/bukkit/scoreboard/DisplaySlot")) {
+ if (name.startsWith("SIDEBAR_") && !name.startsWith("SIDEBAR_TEAM_")) {
@ -67,9 +68,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+ // Paper end - DisplaySlot
if ( owner.equals( "org/bukkit/block/Biome" ) )
{
if (owner.equals("org/bukkit/block/Biome")) {
switch (name) {
case "NETHER":
diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

View file

@ -167,15 +167,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
) );
@@ -0,0 +0,0 @@ public class Commodore {
);
// Paper start - Plugin rewrites
+ private static final String CB_PACKAGE = org.bukkit.Bukkit.getServer().getClass().getPackageName().replace('.', '/');
private static final Map<String, String> SEARCH_AND_REMOVE = initReplacementsMap();
private static Map<String, String> initReplacementsMap()
{
@@ -0,0 +0,0 @@ public class Commodore
private static Map<String, String> initReplacementsMap() {
Map<String, String> getAndRemove = new HashMap<>();
@@ -0,0 +0,0 @@ public class Commodore {
super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
return;
}
@ -185,8 +185,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return;
+ }
// Paper end
if ( modern )
{
if (modern) {
diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000

View file

@ -9,10 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
public void fireEvents(GameProfile gameprofile) throws Exception {
private void callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception {
String playerName = gameprofile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
+ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.channel.remoteAddress()).getAddress(); // Paper
java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
+ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); // Paper
java.util.UUID uniqueId = gameprofile.getId();
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;

View file

@ -47,11 +47,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
// Spigot Start
if (result == null) {
GameProfile profile = null;
// Only fetch an online UUID in online mode
- if ( this.getOnlineMode() || org.spigotmc.SpigotConfig.bungee )
+ if ( this.getOnlineMode() || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ) // Paper - Handle via setting
{
- if (this.getOnlineMode() || org.spigotmc.SpigotConfig.bungee) { // Spigot: bungee = online mode, for now.
+ if (this.getOnlineMode() || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) { // Paper - Handle via setting
// This is potentially blocking :(
profile = this.console.getProfileCache().get(name).orElse(null);
}

View file

@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol
// Paper end
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5")
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java

View file

@ -3024,14 +3024,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable);
if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
- ServerLoginPacketListenerImpl.this.disconnect(event.getKickMessage());
+ ServerLoginPacketListenerImpl.this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure
- this.disconnect(event.getKickMessage());
+ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure
return;
}
} else {
if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
- ServerLoginPacketListenerImpl.this.disconnect(asyncEvent.getKickMessage());
+ ServerLoginPacketListenerImpl.this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure
- this.disconnect(asyncEvent.getKickMessage());
+ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure
return;
}
}
@ -4818,8 +4818,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory {
EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures);
return craft;
CraftItemStack craft = (CraftItemStack) itemStack;
return CraftItemStack.asCraftMirror(EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures));
}
+
+ // Paper start - Adventure

View file

@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
break;
@@ -0,0 +0,0 @@ public class CraftEffect {
Preconditions.checkArgument(data == Material.AIR || ((Material) data).isRecord(), "Invalid record type for Material %s!", data);
datavalue = Item.getId(CraftMagicNumbers.getItem((Material) data));
datavalue = Item.getId(CraftItemType.bukkitToMinecraft((Material) data));
break;
+ // Paper start - handle shoot white smoke event
+ case SHOOT_WHITE_SMOKE:
@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
case STEP_SOUND:
+ if (data instanceof Material) { // Paper - support BlockData
Preconditions.checkArgument(((Material) data).isBlock(), "Material %s is not a block!", data);
datavalue = Block.getId(CraftMagicNumbers.getBlock((Material) data).defaultBlockState());
datavalue = Block.getId(CraftBlockType.bukkitToMinecraft((Material) data).defaultBlockState());
+ // Paper start - support BlockData
+ break;
+ }

View file

@ -20,11 +20,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- exclude(group = "org.apache.logging.log4j", module = "log4j-api")
- }
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
+ implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
implementation("org.ow2.asm:asm-commons:9.5")
implementation("commons-lang:commons-lang:2.6")
runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1")
runtimeOnly("com.mysql:mysql-connector-j:8.2.0")
@@ -0,0 +0,0 @@ tasks.jar {
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""

View file

@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - cache block data strings
+ if (material != null) {
+ Block block = CraftMagicNumbers.getBlock(material);
+ Block block = CraftBlockType.bukkitToMinecraft(material);
+ if (block != null) {
+ net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block);
+ data = data == null ? key.toString() : key + data;
@ -67,5 +67,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private static CraftBlockData createNewData(Material material, String data) {
+ // Paper end - cache block data strings
net.minecraft.world.level.block.state.BlockState blockData;
Block block = CraftMagicNumbers.getBlock(material);
Block block = CraftBlockType.bukkitToMinecraft(material);
Map<Property<?>, Comparable<?>> parsed = null;

View file

@ -19,22 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge));
} else {
// Spigot start
- new Thread("User Authenticator #" + ServerLoginPacketListenerImpl.UNIQUE_THREAD_ID.incrementAndGet()) {
-
// CraftBukkit start
- Thread thread = new Thread("User Authenticator #" + ServerLoginPacketListenerImpl.UNIQUE_THREAD_ID.incrementAndGet()) {
+ // Paper start - Cache authenticator threads
+ authenticatorPool.execute(new Runnable() {
@Override
public void run() {
try {
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
ServerLoginPacketListenerImpl.this.server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + ServerLoginPacketListenerImpl.this.requestedUsername, ex);
}
}
- }.start();
- };
-
- thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(ServerLoginPacketListenerImpl.LOGGER));
- thread.start();
+ });
+ // Paper end
// Spigot end
// CraftBukkit end
}
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@ -59,4 +61,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
// Spigot start
// CraftBukkit start

View file

@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies {
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
implementation("org.ow2.asm:asm-commons:9.5")
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
implementation("commons-lang:commons-lang:2.6")
+ implementation("net.fabricmc:mapping-io:0.5.0") // Paper - needed to read mappings for stacktrace deobfuscation

View file

@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Map<Class, TagAdapter> adapters = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - Replace HashMap with ConcurrentHashMap to avoid CME
/**
* Creates a suitable adapter instance for the primitive class type
* Creates a suitable adapter instance for the primitive class type.

View file

@ -18,9 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Preconditions.checkArgument(material != null, "Material cannot be null");
Preconditions.checkArgument(material.isBlock(), "Material.%s must be a block", material);
- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM);
- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftBlockType.bukkitToMinecraft(material).defaultBlockState(), SpawnReason.CUSTOM);
+ // Paper start - restore API behavior for spawning falling blocks
+ FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); // Paper
+ FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftBlockType.bukkitToMinecraft(material).defaultBlockState()); // Paper
+ entity.time = 1;
+
+ this.world.addFreshEntity(entity, SpawnReason.CUSTOM);

View file

@ -1,36 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 16 Dec 2023 13:06:20 -0800
Subject: [PATCH] Fix scoreboard entries
1.20.3/4 introduced ScoreHolder which broke a lot of existing
logic that just assumed score entries were strings.
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
@@ -0,0 +0,0 @@ final class CraftScore implements Score {
public int getScore() {
Scoreboard board = this.objective.checkState().board;
- if (board.getTrackedPlayers().contains(this.entry)) { // Lazy
+ // if (board.getTrackedPlayers().contains(this.entry)) { // Lazy // Paper - just use the null check
ReadOnlyScoreInfo score = board.getPlayerScoreInfo(this.entry, this.objective.getHandle());
if (score != null) { // Lazy
return score.value();
}
- }
+ // } // Paper - just use the null check above
return 0; // Lazy
}
@@ -0,0 +0,0 @@ final class CraftScore implements Score {
public boolean isScoreSet() {
Scoreboard board = this.objective.checkState().board;
- return board.getTrackedPlayers().contains(this.entry) && board.getPlayerScoreInfo(this.entry, this.objective.getHandle()) != null;
+ return /*board.getTrackedPlayers().contains(this.entry) && */board.getPlayerScoreInfo(this.entry, this.objective.getHandle()) != null; // Paper - just check if the player score info exists
}
@Override

View file

@ -13,7 +13,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private ServerPlayer cause;
private final Set<Entity> hitEntities = Sets.newHashSet();
private int blocksSetOnFire;
- public boolean isSilent = false; // Spigot
+ public boolean isEffect; // Paper - Properly handle lightning effects api
public LightningBolt(EntityType<? extends LightningBolt> type, Level world) {
@ -22,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void tick() {
super.tick();
- if (!this.isSilent && this.life == 2) { // Spigot
+ if (!this.isEffect && this.life == 2) { // Spigot // Paper - Properly handle lightning effects api
- if (this.life == 2) {
+ if (!this.isEffect && this.life == 2) { // Paper - Properly handle lightning effects api
if (this.level().isClientSide()) {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false);
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false);
@ -58,24 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM);
return (LightningStrike) lightning.getBukkitEntity();
}
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
{
LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world );
lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );
- lightning.isSilent = isSilent;
CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM );
return (LightningStrike) lightning.getBukkitEntity();
}
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
{
LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world );
lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );
- lightning.visualOnly = true;
- lightning.isSilent = isSilent;
+ lightning.isEffect = true; // Paper - Properly handle lightning effects api
CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM );
return (LightningStrike) lightning.getBukkitEntity();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
@ -89,12 +70,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
public int getFlashes() {
@@ -0,0 +0,0 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
@Override
public boolean isSilent()
{
- return CraftLightningStrike.this.getHandle().isSilent;
+ return false; // Paper - Properly handle lightning effects api; the concept of isSilent doesn't exist as sound is controlled by the client
}
};

View file

@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return new CraftBlockEntityState<>(world, tileEntity);
- }
+ // Paper - revert upstream's revert of the block state changes. Block entities that have already had the block type set to AIR are still valid, upstream decided to ignore them
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftBlockType.minecraftToBukkit(blockData.getBlock()));
return new CraftBlockState(world, blockPosition, blockData);
}
};
@ -367,7 +367,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start
+ BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType::create);
+ for (net.minecraft.world.level.block.Block block : blockEntityType.validBlocks) {
+ CraftBlockStates.register(CraftMagicNumbers.getMaterial(block), factory);
+ CraftBlockStates.register(CraftBlockType.minecraftToBukkit(block), factory);
}
+ CraftBlockStates.register(blockEntityType, factory);
+ // Paper end
@ -423,8 +423,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.entity.BlockEntityType;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.support.AbstractTestingBase;
import org.junit.jupiter.api.Test;
@@ -0,0 +0,0 @@ public class BlockStateTest extends AbstractTestingBase {
}
}

View file

@ -33,29 +33,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else areaEffectCloud.discard(); // Paper
this.discard();
}
diff --git a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
@@ -0,0 +0,0 @@ public class CarvedPumpkinBlock extends HorizontalDirectionalBlock {
// clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down
entity.moveTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.05D, (double) pos.getZ() + 0.5D, 0.0F, 0.0F);
// CraftBukkit start
- if (!world.addFreshEntity(entity, SpawnReason.BUILD_IRONGOLEM)) {
+ // Paper start - correct spawn reason
+ final SpawnReason spawnReason;
+ if (entity.getType() == EntityType.SNOW_GOLEM) {
+ spawnReason = SpawnReason.BUILD_SNOWMAN;
+ } else if (entity.getType() == EntityType.IRON_GOLEM) {
+ spawnReason = SpawnReason.BUILD_IRONGOLEM;
+ } else {
+ spawnReason = SpawnReason.DEFAULT;
+ }
+ if (!world.addFreshEntity(entity, spawnReason)) {
+ // Paper end
return;
}
CarvedPumpkinBlock.clearPatternBlocks(world, patternResult); // CraftBukkit - from above
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java

View file

@ -18,10 +18,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.Map;
@@ -0,0 +0,0 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
+import javax.annotation.Nonnull;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
@@ -0,0 +0,0 @@ import org.bukkit.plugin.AuthorNagException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@ -32,20 +37,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
+import javax.annotation.Nonnull;
+
/**
* This file is imported from Commodore.
*
@@ -0,0 +0,0 @@ public class Commodore
"org/bukkit/inventory/ItemStack (I)V setTypeId"
) );
@@ -0,0 +0,0 @@ public class Commodore {
"org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent"
);
+ // Paper start - Plugin rewrites
+ private static final Map<String, String> SEARCH_AND_REMOVE = initReplacementsMap();
+ private static Map<String, String> initReplacementsMap()
+ {
+ private static Map<String, String> initReplacementsMap() {
+ Map<String, String> getAndRemove = new HashMap<>();
+ // Be wary of maven shade's relocations
+
@ -75,15 +73,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ return rewrite != null ? rewrite : original;
+ }
+ // Paper end
+ // Paper end - Plugin rewrites
+
public static void main(String[] args)
{
public static void main(String[] args) {
OptionParser parser = new OptionParser();
@@ -0,0 +0,0 @@ public class Commodore
OptionSpec<File> inputFlag = parser.acceptsAll(Arrays.asList("i", "input")).withRequiredArg().ofType(File.class).required();
@@ -0,0 +0,0 @@ public class Commodore {
ClassWriter cw = new ClassWriter(cr, 0);
cr.accept( new ClassVisitor( Opcodes.ASM9, cw )
{
cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) {
+
+ // Paper start - Rewrite plugins
+ @Override
+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
@ -98,14 +97,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
+
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
{
return new MethodVisitor( this.api, super.visitMethod( access, name, desc, signature, exceptions ) )
{
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return new MethodVisitor(this.api, super.visitMethod(access, name, desc, signature, exceptions)) {
+ // Paper start - Plugin rewrites
+ @Override
+ public void visitTypeInsn(int opcode, String type)
+ {
+ public void visitTypeInsn(int opcode, String type) {
+ type = getOriginalOrRewrite(type);
+
+ super.visitTypeInsn(opcode, type);
@ -131,44 +128,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ @Override
+ public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index)
+ {
+ public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) {
+ descriptor = getOriginalOrRewrite(descriptor);
+
+ super.visitLocalVariable(name, descriptor, signature, start, end, index);
+ }
+ // Paper end
+
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc)
{
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
+ // Paper start - Rewrite plugins
+ owner = getOriginalOrRewrite(owner);
+ if ( desc != null )
+ {
+ if (desc != null) {
+ desc = getOriginalOrRewrite(desc);
+ }
+ // Paper end
+
if ( owner.equals( "org/bukkit/block/Biome" ) )
{
switch ( name )
@@ -0,0 +0,0 @@ public class Commodore
if (owner.equals("org/bukkit/block/Biome")) {
switch (name) {
case "NETHER":
@@ -0,0 +0,0 @@ public class Commodore {
}
// Paper start - Rewrite plugins
+ owner = getOriginalOrRewrite(owner) ;
+ if (desc != null)
+ {
+ if (desc != null) {
+ desc = getOriginalOrRewrite(desc);
+ }
if ((owner.equals("org/bukkit/OfflinePlayer") || owner.equals("org/bukkit/entity/Player")) && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) {
super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
return;
@@ -0,0 +0,0 @@ public class Commodore
@@ -0,0 +0,0 @@ public class Commodore {
@Override
public void visitLdcInsn(Object value)
{
public void visitLdcInsn(Object value) {
+ // Paper start
+ if (value instanceof Type type) {
+ if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
@ -176,20 +168,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+ // Paper end
if ( value instanceof String && ( (String) value ).equals( "com.mysql.jdbc.Driver" ) )
{
if (value instanceof String && ((String) value).equals("com.mysql.jdbc.Driver")) {
super.visitLdcInsn("com.mysql.cj.jdbc.Driver");
@@ -0,0 +0,0 @@ public class Commodore
return;
@@ -0,0 +0,0 @@ public class Commodore {
@Override
public void visitInvokeDynamicInsn( String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments )
{
public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) {
+ // Paper start - Rewrite plugins
+ name = getOriginalOrRewrite(name);
+ if ( descriptor != null )
+ {
+ if (descriptor != null) {
+ descriptor = getOriginalOrRewrite(descriptor);
+ }
+ final String fName = name;
+ final String fDescriptor = descriptor;
+ // Paper end - Rewrite plugins
if (bootstrapMethodHandle.getOwner().equals("java/lang/invoke/LambdaMetafactory")
&& bootstrapMethodHandle.getName().equals( "metafactory" ) && bootstrapMethodArguments.length == 3 )
{
&& bootstrapMethodHandle.getName().equals("metafactory") && bootstrapMethodArguments.length == 3) {
Type samMethodType = (Type) bootstrapMethodArguments[0];
@@ -0,0 +0,0 @@ public class Commodore {
methodArgs.add(new Handle(newOpcode, newOwner, newName, newDescription, newItf));
methodArgs.add(newInstantiated);
- super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new));
+ super.visitInvokeDynamicInsn(fName, fDescriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new)); // Paper - use final local vars
}, implMethod.getTag(), implMethod.getOwner(), implMethod.getName(), implMethod.getDesc(), implMethod.isInterface(), samMethodType, instantiatedMethodType);
return;
}

View file

@ -8,16 +8,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory {
}
CraftItemStack craft = (CraftItemStack) itemStack;
- EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures);
- return craft;
+ return EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures).asBukkitCopy(); // Paper - fix broken implementation
}
// Paper start - Adventure
@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory {
return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror();
}

View file

@ -180,8 +180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
MinecraftServer.LOGGER.error("Encountered an unexpected exception", throwable);
// Spigot Start
if ( throwable.getCause() != null )
CrashReport crashreport = MinecraftServer.constructOrExtractCrashReport(throwable);
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.services.profileCache().clearExecutor();
}
@ -213,14 +213,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return new TickTask(this.tickCount, runnable);
}
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
try {
crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
} catch (Throwable t) {
+ if (throwable instanceof ThreadDeath) { throw (ThreadDeath)throwable; } // Paper
throw new RuntimeException("Error generating crash report", t);
}
// Spigot End
@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.worldData.setDataConfiguration(worlddataconfiguration);

View file

@ -6100,7 +6100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
worldserver.timings.doTick.stopTiming(); // Spigot
} catch (Throwable throwable) {
// Spigot Start
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java

View file

@ -10,7 +10,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
@@ -0,0 +0,0 @@ public class Commodore {
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CB_PACKAGE + "/advancement/CraftAdvancement", "getDisplay0", desc, false);
return;
}

View file

@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @Override
+ public Collection<org.bukkit.Material> getInfiniburn() {
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(net.minecraft.core.registries.BuiltInRegistries.BLOCK.getTagOrEmpty(this.getHandle().dimensionType().infiniburn()).iterator(), blockHolder -> CraftMagicNumbers.getMaterial(blockHolder.value())));
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(net.minecraft.core.registries.BuiltInRegistries.BLOCK.getTagOrEmpty(this.getHandle().dimensionType().infiniburn()).iterator(), blockHolder -> CraftBlockType.minecraftToBukkit(blockHolder.value())));
+ }
+
+ @Override

View file

@ -18,9 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ public final org.bukkit.Material getBukkitMaterial() {
+ if (this.cachedMaterial == null) {
+ this.cachedMaterial = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this.getBlock());
+ this.cachedMaterial = org.bukkit.craftbukkit.block.CraftBlockType.minecraftToBukkit(this.getBlock());
+ }
+
+ return this.cachedMaterial;
+ }
+ // Paper end - optimise getType calls
@ -35,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public Material getBlockType(int x, int y, int z) {
this.validateChunkCoordinates(x, y, z);
- return CraftMagicNumbers.getMaterial(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
- return CraftBlockType.minecraftToBukkit(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
+ return this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise getType calls
}
@ -48,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public Material getType() {
- return CraftMagicNumbers.getMaterial(this.world.getBlockState(this.position).getBlock());
- return CraftBlockType.minecraftToBukkit(this.world.getBlockState(this.position).getBlock());
+ return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls
}
@ -61,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public Material getType() {
- return CraftMagicNumbers.getMaterial(this.data.getBlock());
- return CraftBlockType.minecraftToBukkit(this.data.getBlock());
+ return this.data.getBukkitMaterial(); // Paper - optimise getType calls
}
@ -74,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public Material getMaterial() {
- return CraftMagicNumbers.getMaterial(this.state.getBlock());
- return CraftBlockType.minecraftToBukkit(this.state.getBlock());
+ return this.state.getBukkitMaterial(); // Paper - optimise getType calls
}
@ -87,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public Material getType(int x, int y, int z) {
- return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z).getBlock());
- return CraftBlockType.minecraftToBukkit(this.getTypeId(x, y, z).getBlock());
+ return this.getTypeId(x, y, z).getBukkitMaterial(); // Paper - optimise getType calls
}

View file

@ -19,9 +19,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies {
implementation("jline:jline:2.12.1")
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
implementation("org.ow2.asm:asm-commons:9.5")
+ implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
implementation("commons-lang:commons-lang:2.6")
runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1")

View file

@ -223,7 +223,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
@@ -0,0 +0,0 @@ public class Commodore {
return;
}
@ -233,6 +233,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return;
+ }
+ // Paper end
if ( modern )
{
if ( owner.equals( "org/bukkit/Material" ) )
+
if (modern) {
if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) {
switch (name) {

View file

@ -99,7 +99,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.entity.Piglin;
import org.bukkit.inventory.Inventory;

View file

@ -184,7 +184,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<org.bukkit.inventory.ItemStack> drops, Runnable lootCheck) {
+ private static java.util.function.Function<org.bukkit.inventory.ItemStack, Entity.DefaultDrop> FROM_FUNCTION = stack -> {
+ if (stack == null) return null;
+ return new Entity.DefaultDrop(CraftMagicNumbers.getItem(stack.getType()), stack, null);
+ return new Entity.DefaultDrop(CraftItemType.bukkitToMinecraft(stack.getType()), stack, null);
+ };
+ public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<Entity.DefaultDrop> drops, Runnable lootCheck) { // Paper
// Paper end

View file

@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") {
+ exclude(group = "org.apache.logging.log4j", module = "log4j-api")
+ }
+ implementation("org.ow2.asm:asm:9.5")
+ implementation("org.ow2.asm:asm-commons:9.5")
+ implementation("commons-lang:commons-lang:2.6")
+ runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1")
+ runtimeOnly("com.mysql:mysql-connector-j:8.2.0")
@ -244,6 +244,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- <version>9.5</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm-commons</artifactId>
- <version>9.5</version>
- <scope>compile</scope>
- </dependency>
- <!-- Mojang depends -->
- <dependency>
- <groupId>com.github.oshi</groupId>

View file

@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
this.getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks);
this.getHandle().getCooldowns().addCooldown(CraftItemType.bukkitToMinecraft(material), ticks);
}
+ // Paper start

View file

@ -58,8 +58,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ alsoShade(log4jPlugins.output)
+ // Paper end
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
implementation("org.ow2.asm:asm:9.5")
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
implementation("org.ow2.asm:asm-commons:9.5")
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
@@ -0,0 +0,0 @@ relocation {
}

View file

@ -58,11 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void testEntityTagMeta() {
+ for (final Item item : BuiltInRegistries.ITEM) {
+ if (item instanceof net.minecraft.world.item.HangingEntityItem || item instanceof net.minecraft.world.item.MobBucketItem) {
+ ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(item));
+ ItemStack stack = new ItemStack(CraftItemType.minecraftToBukkit(item));
+ assertTrue(ENTITY_TAG_METAS.contains(stack.getItemMeta().getClass()), "missing entity tag meta handling for " + item);
+ stack = CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.STONE);
+ stack.editMeta(meta -> meta.displayName(net.kyori.adventure.text.Component.text("hello")));
+ stack.setType(CraftMagicNumbers.getMaterial(item));
+ stack.setType(CraftItemType.minecraftToBukkit(item));
+ assertTrue(ENTITY_TAG_METAS.contains(stack.getItemMeta().getClass()), "missing entity tag meta handling for " + item);
+ }
+ }

View file

@ -64,10 +64,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.valid) {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
// CraftBukkit end
// Spigot start
- org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity());
+ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper
}
- EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity());
+ EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper
// Suppress during worldgen
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);

@ -1 +1 @@
Subproject commit 0c7aedbceabcf05dde0a483001acd3d957e06c03
Subproject commit 63c208dd3f16a0874b5e21348c35ce9e5c829d03

@ -1 +1 @@
Subproject commit 53ebb05e3951a1a05e4efb8a739d9bf31d21385e
Subproject commit 771182f70cd789f3d220cfef80876845a48ebec5

@ -1 +1 @@
Subproject commit e7ce55a3b93404a86c248a3d749e5219adda4ca0
Subproject commit 864e4acc0db6ad9899f269740823a23d082d18d0