tons of patches (#5835)

This commit is contained in:
Jake Potrebic 2021-06-14 19:59:31 -07:00 committed by GitHub
parent 38e4dc3050
commit d3424f4a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
276 changed files with 1441 additions and 2130 deletions

View File

@ -4,3 +4,15 @@
# This line would make the field public and remove the final modifier
#public-f net.minecraft.network.protocol.game.ClientboundChatPacket sender
# Leave out the member and it will apply to the class itself
# Item Rarity API
public net.minecraft.world.item.Item rarity
# More Enchantment API
public net.minecraft.world.item.enchantment.Enchantment slots;
# Fix and optimise world force upgrading
public net.minecraft.util.worldupdate.WorldUpgrader REGEX;
# More Lidded Block API
public net.minecraft.world.level.block.entity.EnderChestBlockEntity openersCounter

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 68a03821a5f06308a9c51fdf107d3924c44886c8..34b51466ffb281b05f531b3f7deda245ae7fd96a 100644
index 9c7960f56733ff18b949cffe15f082c4cde28317..38003de85a8098fc78fc947dd975990d478ee908 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1,6 +1,7 @@
@ -16,7 +16,7 @@ index 68a03821a5f06308a9c51fdf107d3924c44886c8..34b51466ffb281b05f531b3f7deda245
import java.util.UUID;
import com.destroystokyo.paper.ClientOption; // Paper
import com.destroystokyo.paper.Title; // Paper
@@ -1942,6 +1943,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@@ -1969,6 +1970,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
void sendOpLevel(byte level);
// Paper end

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Cache the result of Material#isBlock
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 69c85c3a1f45476f7de0a9399852d82eeb4f9c86..0f081835c0484e15fca4fadaa27e90cadd394276 100644
index 1efc97d88c38863bcd6cd4c11c8b88a18ee06b25..5ff032f73d88dd91163ff3e6c89dcd0d1507228c 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -3935,6 +3935,7 @@ public enum Material implements Keyed {
@@ -3936,6 +3936,7 @@ public enum Material implements Keyed {
public final Class<?> data;
private final boolean legacy;
private final NamespacedKey key;
@ -16,7 +16,7 @@ index 69c85c3a1f45476f7de0a9399852d82eeb4f9c86..0f081835c0484e15fca4fadaa27e90ca
private Material(final int id) {
this(id, 64);
@@ -4132,6 +4133,11 @@ public enum Material implements Keyed {
@@ -4133,6 +4134,11 @@ public enum Material implements Keyed {
* @return true if this material is a block
*/
public boolean isBlock() {
@ -28,7 +28,7 @@ index 69c85c3a1f45476f7de0a9399852d82eeb4f9c86..0f081835c0484e15fca4fadaa27e90ca
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isBlock">
case ACACIA_BUTTON:
@@ -5213,6 +5219,7 @@ public enum Material implements Keyed {
@@ -5214,6 +5220,7 @@ public enum Material implements Keyed {
static {
for (Material material : values()) {
BY_NAME.put(material.name(), material);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add Block#isValidTool
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 181658c679d306ffc4ad45259494571ee224ef47..08e6f1741685f54506c8a4ff29bbd30f62cf8e45 100644
index b3c127a3d4c554c08e500497a54755e626342dd3..ca488173a20bcf3427906f0a6548f06a97c9dc36 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -218,6 +218,15 @@ public interface Block extends Metadatable {
@@ -219,6 +219,15 @@ public interface Block extends Metadatable {
public static int getBlockKeyZ(long packed) {
return (int) ((packed << 10) >> 37);
}

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Implement Keyed on World
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 68101a322ffab8ec28843386b79b8079576fa720..5f7208196684d9c8373df28b7cfb5f9e21baa41e 100644
index bad4593447ca390b3e2f3bc71b4ea9f4dd673445..142050887ac02e36ae20e73a43ec698b6bab1947 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -639,6 +639,18 @@ public final class Bukkit {
@ -28,7 +28,7 @@ index 68101a322ffab8ec28843386b79b8079576fa720..5f7208196684d9c8373df28b7cfb5f9e
/**
* Gets the map from the given item ID.
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index a79fa08b9e6fb924b2da933eb6e4b365d14d938d..f3e27d2d02a9407bb1b091b8c1125ad5abf99e55 100644
index 48c6434a6a5b1659d4cc8ddf8fe23806628c3b7e..0b3de184f7267543d693c45379bf5989303cf56a 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -541,6 +541,17 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@ -50,7 +50,7 @@ index a79fa08b9e6fb924b2da933eb6e4b365d14d938d..f3e27d2d02a9407bb1b091b8c1125ad5
* Gets the map from the given item ID.
*
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index ced33fc6de6bfa2767123131d532e7ae9ef3a5be..98512bddbb0c8bd6a3f487c60b1ec77b274b991e 100644
index 27d97cde0fb5f6d727656c291e34dc468200f0c0..178a0853bd8136c6a7408f5d49604ceb2479f138 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -43,7 +43,7 @@ import org.jetbrains.annotations.Nullable;
@ -62,7 +62,7 @@ index ced33fc6de6bfa2767123131d532e7ae9ef3a5be..98512bddbb0c8bd6a3f487c60b1ec77b
// Paper start
/**
@@ -829,6 +829,15 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad
@@ -1534,6 +1534,15 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad
@NotNull
java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent);

View File

@ -39,10 +39,10 @@ index 0000000000000000000000000000000000000000..74ef8395cc040ce488c2acaa416db202
+ }
+}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 0f081835c0484e15fca4fadaa27e90cadd394276..07b8b913434bb575df8670230d693b2d4cec2571 100644
index 5ff032f73d88dd91163ff3e6c89dcd0d1507228c..a9bcb123526da0881728070d36aea37612db8cf2 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4002,6 +4002,17 @@ public enum Material implements Keyed {
@@ -4003,6 +4003,17 @@ public enum Material implements Keyed {
public String getTranslationKey() {
return Bukkit.getUnsafe().getTranslationKey(this);
}

View File

@ -5,7 +5,7 @@ Subject: [PATCH] add isDeeplySleeping to HumanEntity
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
index f0e0710fef5a3e0b722ece7ccf89c3d0f88f8f0f..2ce774c81a93260a1464183d435b4c418ed61648 100644
index 112c891e54e8f30ac10e6865efc2a8ee8d172188..0ad7a3d4d40d58eb950e34668f9554bb73f934fb 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -319,6 +319,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder

View File

@ -5,7 +5,7 @@ Subject: [PATCH] More World API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 98512bddbb0c8bd6a3f487c60b1ec77b274b991e..a1496fe00a2d5ba6c1af054d4327f868b2cd7344 100644
index 178a0853bd8136c6a7408f5d49604ceb2479f138..244bb359492ae486f0610f5aea6b75997dbc4bdc 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -3482,6 +3482,120 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad

View File

@ -30,10 +30,10 @@ index ed4d417c2deefb78807cb61b01df5afcd334d754..a40b045f08b85e22e75459b547e7e7c0
// Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Skeleton.java b/src/main/java/org/bukkit/entity/Skeleton.java
index 1c367f78eadf24850061a84ce63b950b79d3c435..684477b894e52ff33f9fce2edf76e58c292dd75e 100644
index b7e424ea8a282f45fb8b91c919e4e4526c00be8b..2ca7c040270fa1b0fe623a0a779879783201a2f1 100644
--- a/src/main/java/org/bukkit/entity/Skeleton.java
+++ b/src/main/java/org/bukkit/entity/Skeleton.java
@@ -46,4 +46,19 @@ public interface Skeleton extends Monster, RangedEntity { // Paper
@@ -64,4 +64,19 @@ public interface Skeleton extends AbstractSkeleton, com.destroystokyo.paper.enti
*/
STRAY;
}

View File

@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..58f78d5e91beacaf710f62461cf869f7
+
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 050ee6a6fd0b74d9bfdd9dfe88cd4cd3d17da868..a8b6cc350e85d4f1a31f30dee42feafd0edb6009 100644
index 142050887ac02e36ae20e73a43ec698b6bab1947..e8414592b3afeb1e5db2b817b8fb7c13e073b9aa 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1949,6 +1949,14 @@ public final class Bukkit {
@ -89,7 +89,7 @@ index 050ee6a6fd0b74d9bfdd9dfe88cd4cd3d17da868..a8b6cc350e85d4f1a31f30dee42feafd
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index eb7f604600839618eaf27e0e5444b4830716eb07..2b400079559abd6b847782ae8480f2ae1948e22a 100644
index 0b3de184f7267543d693c45379bf5989303cf56a..e88b47a838dc472ad64271a518ee1789f7be19fa 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1709,5 +1709,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View File

@ -26,7 +26,7 @@ index 6dbd520182b1e7713a68baad09b7f613424ef619..e504567cf755557be8511f2c93c17157
* Returns the server's protocol version.
*
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index fccfae41f53a175e1a6a670c793e464456de6b60..0f8c593ae9bca46081f0b22c2d763a2699175398 100644
index f72d3d62d61755bbaf1950ebcb228ce95d1faf58..1bd9f7582bb907ff178fd110fdc92834885d1d78 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -873,5 +873,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor

View File

@ -7,7 +7,7 @@ Subject: [PATCH] Add command line option to load extra plugin jars not in the
ex: java -jar paperclip.jar nogui -add-plugin=/path/to/plugin.jar -add-plugin=/path/to/another/plugin_jar.jar
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 26685f59b235ea5b4c4fb7ae21acb5149edaa2b3..ca866876f2f35a1c41eb009064412423fa09e441 100644
index 49e5d49eb09bb966e47d6a03ac08a527c963b43d..f988705a3cd3943b2f6f952b4f8b5ec014722978 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -60,6 +60,7 @@ public final class SimplePluginManager implements PluginManager {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] List all missing hard depends not just first
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index ca866876f2f35a1c41eb009064412423fa09e441..d1c35e4cf778070f8d18bbe0af8d423334c6dfbf 100644
index f988705a3cd3943b2f6f952b4f8b5ec014722978..0e25119564dfa9cb12f3c5dc5f653d7f2c147a9d 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -264,6 +264,7 @@ public final class SimplePluginManager implements PluginManager {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Attributes API for item defaults
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 07b8b913434bb575df8670230d693b2d4cec2571..397591da25fbb0e4d3012431df70d661d9bc9188 100644
index a9bcb123526da0881728070d36aea37612db8cf2..d635c4fb85d3eeea3853037b2da5881c4853b193 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -4013,6 +4013,19 @@ public enum Material implements Keyed {
@@ -4014,6 +4014,19 @@ public enum Material implements Keyed {
public io.papermc.paper.inventory.ItemRarity getItemRarity() {
return Bukkit.getUnsafe().getItemRarity(this);
}

View File

@ -5,6 +5,8 @@ Subject: [PATCH] Clear SyncLoadInfo
This patch merely adds the extra argument "clear" after /paper syncloadinfo to clear currently stored syncload info.
Relies on other not-applied patches
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 6fad9329213e4e8a3ef9ce7fb568ad22484a11f3..a6b2b69a5a79fb8cea81e55018ee7f57c8820e56 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java

View File

@ -5,6 +5,8 @@ Subject: [PATCH] Make sure to remove correct TE during TE tick
This looks like it can cause premature TE removal.
1.17: doesnt apply anymore?
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index b89cefc8890774dbc64fd6bddeb038d2ee36d485..4523bc1f49e7be248a47eeb599fa7b6550dbb08d 100644
--- a/src/main/java/net/minecraft/world/level/Level.java

View File

@ -34,6 +34,8 @@ This should fix some problems converting old data, as the
changes here are going to prevent the chunk from being regenerated
incorrectly.
SPOTTEDLEAF!!!!!!!!!!!
diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
index 16f6aa39385e2d278d4883a32c11ddd119d0d85d..3d262dcf6db0e395d2fa457f7197f24013037ac1 100644
--- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java

View File

@ -3,6 +3,7 @@ From: SamB440 <sam@islandearth.net>
Date: Fri, 21 May 2021 00:22:09 +0100
Subject: [PATCH] Fix MC-148809: Increase structure block data length to 128
Fixed in 1.17
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetStructureBlockPacket.java
index 4c797dd82bb1989861e350a7e628eb847b58bbd8..4792aafd8d992cd64d05f8bbef5cbf30988949ed 100644

View File

@ -3,6 +3,7 @@ From: lukas81298 <lukas81298@gmail.com>
Date: Sun, 13 Dec 2020 13:42:55 +0100
Subject: [PATCH] do not create unnecessary copies of passenger list
1.17: Mojang removed the copy of the passenger list from getPassengers, no longer needed
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPassengersPacket.java
index a6ecb82d14ccab5d8229689a2a6cb67c579b1f71..cded79352dff0978e0d633eae9d9020b4dec1d4b 100644

View File

@ -3,6 +3,7 @@ From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 20 Apr 2021 01:15:04 +0100
Subject: [PATCH] don't throw when loading invalid TEs
1.17: Mojang catches the exception
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 05fa76c02ce61e26891ad995fe89e925ea086557..b7ebb213efd759253f0042f77e11f2a8102ea6ca 100644

View File

@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 26 Feb 2021 16:24:25 -0600
Subject: [PATCH] Expose Tracked Players
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 87c719caf796f54296ff7e412548062e02af270e..ec30f886585d407fbd122e05107ebca44895c585 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -170,7 +170,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;
- ChunkMap.TrackedEntity tracker; // Paper
+ public ChunkMap.TrackedEntity tracker; // Paper package private -> public
public boolean collisionLoadChunks = false; // Paper
public Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index d2d179cdef8129653983b01d94928ba83f64f644..ec8c7499662c0a810f1337ebc0fa24d2f3ca79e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -16,6 +16,7 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections; // Paper
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -2305,6 +2306,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Paper start
+ @Override
+ public Set<Player> getTrackedPlayers() {
+ if (entity.tracker == null) {
+ return Collections.emptySet();
+ }
+
+ Set<Player> set = new HashSet<>(entity.tracker.seenBy.size());
+ for (ServerPlayer entityPlayer : entity.tracker.seenBy) {
+ set.add(entityPlayer.getBukkitEntity().getPlayer());
+ }
+ return set;
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{

View File

@ -1,120 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <lynxplay101@gmail.com>
Date: Wed, 3 Mar 2021 12:48:48 +0100
Subject: [PATCH] Remove streams from SensorNearest
The behavioural nearby sensors are validated every tick on the entities
that registered the respective sensors and are therefore a good subject
to performance improvements.
More specifically this commit replaces the Stream#filter usage with
ArrayList#removeIf as the removeIf method on an array list is heavily
optimized towards a single internal array re-allocation without any
further overhead on the removeIf call.
The only negative of this change is the rather agressive diff these
patches introduce as the methods are basically being reimplemented
compared to the previous stream-based implementation.
See: https://nipafx.dev/java-stream-performance/
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
index 91295b8501b1e9d60bf9a7e954ea7fbce9cdea7f..0cd5a19beeb6103dec454b9071cc2e40adf2d006 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
@@ -27,18 +27,16 @@ public class NearestItemSensor extends Sensor<Mob> {
List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(8.0D, 4.0D, 8.0D), (entityitem) -> {
return true;
});
-
- entity.getClass();
+ // Paper start - remove streams in favour of lists
list.sort(Comparator.comparingDouble(entity::distanceToSqr));
- Stream stream = list.stream().filter((entityitem) -> {
- return entity.wantsToPickUp(entityitem.getItem());
- }).filter((entityitem) -> {
- return entityitem.closerThan((Entity) entity, 9.0D);
- });
-
- entity.getClass();
- Optional<ItemEntity> optional = stream.filter(entity::hasLineOfSight).findFirst();
-
- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional);
+ ItemEntity nearest = null;
+ for (ItemEntity entityItem : list) {
+ if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 9.0D) && entity.canSee(entityItem)) {
+ nearest = entityItem;
+ break;
+ }
+ }
+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, Optional.ofNullable(nearest));
+ // Paper end
}
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
index bf38e8b465ae0f50e34b94e0d7830dfdc1be1d59..fa827377ef0ef7cb280d1d54e156e45579899e6c 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
@@ -26,10 +26,12 @@ public class NearestLivingEntitySensor extends Sensor<LivingEntity> {
list.sort(Comparator.comparingDouble(entity::distanceToSqr));
Brain<?> behaviorcontroller = entity.getBrain();
- behaviorcontroller.setMemory(MemoryModuleType.MOBS, (Object) list);
- behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_MOBS, list.stream().filter((entityliving1) -> {
- return doTick(entity, entityliving1);
- }).collect(Collectors.toList()));
+ behaviorcontroller.setMemory(MemoryModuleType.MOBS, list); // Paper - decompile error
+ // Paper start - remove streams in favour of lists
+ List<LivingEntity> visibleMobs = new java.util.ArrayList<>(list);
+ visibleMobs.removeIf(otherEntityLiving -> !Sensor.a(entity, otherEntityLiving));
+ behaviorcontroller.setMemory(MemoryModuleType.VISIBLE_MOBS, visibleMobs);
+ // Paper end
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
index 41a9db2cc4af26baa7072b3c4cebc5357ff43301..fe7414293f144656a938de42524841592c9f40d4 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
@@ -26,22 +26,26 @@ public class PlayerSensor extends Sensor<LivingEntity> {
@Override
protected void doTick(ServerLevel world, LivingEntity entity) {
- Stream stream = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((entityplayer) -> {
- return entity.closerThan((Entity) entityplayer, 16.0D);
- });
+ // Paper start - remove streams in favour of lists
+ List<Player> players = new java.util.ArrayList<>(world.players());
+ players.removeIf(player -> !EntitySelector.notSpectator().test(player) || !entity.closerThan(player, 16.0D)); // Paper - removeIf only re-allocates once compared to iterator
+ players.sort(Comparator.comparingDouble(entity::distanceToSqr));
- entity.getClass();
- List<Player> list = (List) stream.sorted(Comparator.comparingDouble(entity::h)).collect(Collectors.toList());
Brain<?> behaviorcontroller = entity.getBrain();
-
- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_PLAYERS, (Object) list);
- List<Player> list1 = (List) list.stream().filter((entityhuman) -> {
- return doTick(entity, (LivingEntity) entityhuman);
- }).collect(Collectors.toList());
-
- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, (Object) (list1.isEmpty() ? null : (Player) list1.get(0)));
- Optional<Player> optional = list1.stream().filter(EntitySelector.ATTACK_ALLOWED).findFirst();
-
- behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, optional);
+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_PLAYERS, players);
+
+ Player nearest = null, nearestTargetable = null;
+ for (Player player : players) {
+ if (Sensor.a(entity, player)) {
+ if (nearest == null) nearest = player;
+ if (EntitySelector.canAITarget().test(player)) {
+ nearestTargetable = player;
+ break; // Both variables are assigned, no reason to loop further
+ }
+ }
+ }
+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, nearest);
+ behaviorcontroller.setMemory(MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, nearestTargetable);
+ // Paper end
}
}

View File

@ -1,110 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 6 Jan 2021 00:34:04 -0800
Subject: [PATCH] Implement Keyed on World
diff --git a/src/main/java/net/minecraft/core/Registry.java b/src/main/java/net/minecraft/core/Registry.java
index 5a98bc1522c2035487ce0a048c236903dbfa816e..4924d8cd3004a6e1ce76cd5cf7520556c23fe20a 100644
--- a/src/main/java/net/minecraft/core/Registry.java
+++ b/src/main/java/net/minecraft/core/Registry.java
@@ -130,7 +130,7 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
public static final ResourceKey<Registry<LootItemFunctionType>> LOOT_FUNCTION_REGISTRY = createRegistryKey("loot_function_type");
public static final ResourceKey<Registry<LootItemConditionType>> LOOT_ITEM_REGISTRY = createRegistryKey("loot_condition_type");
public static final ResourceKey<Registry<DimensionType>> DIMENSION_TYPE_REGISTRY = createRegistryKey("dimension_type");
- public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension");
+ public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension"); public static final ResourceKey<Registry<Level>> getWorldRegistry() { return DIMENSION_REGISTRY; } // Paper - OBFHELPER
public static final ResourceKey<Registry<LevelStem>> LEVEL_STEM_REGISTRY = createRegistryKey("dimension");
public static final Registry<SoundEvent> SOUND_EVENT = registerSimple(Registry.SOUND_EVENT_REGISTRY, () -> {
return SoundEvents.ITEM_PICKUP;
@@ -339,9 +339,9 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
ResourceLocation minecraftkey = resourcekey.location();
Registry.LOADERS.put(minecraftkey, defaultEntry);
- WritableRegistry<R> iregistrywritable = Registry.WRITABLE_REGISTRY;
+ WritableRegistry iregistrywritable = Registry.WRITABLE_REGISTRY; // Paper - decompile fix
- return (WritableRegistry) iregistrywritable.register(resourcekey, (Object) registry, lifecycle);
+ return (R) iregistrywritable.register(resourcekey, (Object) registry, lifecycle); // Paper - decompile fix
}
protected Registry(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle) {
@@ -428,11 +428,11 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
}
public static <V, T extends V> T register(Registry<V> registry, ResourceLocation id, T entry) {
- return ((WritableRegistry) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable());
+ return ((WritableRegistry<V>) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable()); // Paper - decompile fix
}
public static <V, T extends V> T registerMapping(Registry<V> registry, int rawId, String id, T entry) {
- return ((WritableRegistry) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable());
+ return ((WritableRegistry<V>) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable()); // Paper - decompile fix
}
static {
diff --git a/src/main/java/net/minecraft/resources/ResourceKey.java b/src/main/java/net/minecraft/resources/ResourceKey.java
index 2f39438ee9b23706efb2fd877fe223777b6968c7..3085ec1f20f4c945242697b809188a8c828cfb75 100644
--- a/src/main/java/net/minecraft/resources/ResourceKey.java
+++ b/src/main/java/net/minecraft/resources/ResourceKey.java
@@ -12,6 +12,7 @@ public class ResourceKey<T> {
private final ResourceLocation registryName;
private final ResourceLocation location;
+ public static <T> ResourceKey<T> newResourceKey(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation minecraftKey) { return create(registryKey, minecraftKey); } // Paper - OBFHELPER
public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registry, ResourceLocation value) {
return create(registry.location, value);
}
@@ -41,6 +42,7 @@ public class ResourceKey<T> {
return this.registryName.equals(registry.location());
}
+ public ResourceLocation getLocation() { return location(); } // Paper - OBFHELPER
public ResourceLocation location() {
return this.location;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 794b894ed24636aec60de9a28ba7613d7a917324..6905256147d9bd79e5f52bf86bdb21c89b8411a7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1156,7 +1156,7 @@ public final class CraftServer implements Server {
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.Level.END;
} else {
- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH)));
+ worldKey = ResourceKey.newResourceKey(Registry.getWorldRegistry(), new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
}
ServerLevel internal = (ServerLevel) new ServerLevel(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11),
@@ -1246,6 +1246,15 @@ public final class CraftServer implements Server {
return null;
}
+ // Paper start
+ @Override
+ public World getWorld(NamespacedKey worldKey) {
+ ServerLevel worldServer = console.getLevel(ResourceKey.newResourceKey(Registry.getWorldRegistry(), CraftNamespacedKey.toMinecraft(worldKey)));
+ if (worldServer == null) return null;
+ return worldServer.getWorld();
+ }
+ // Paper end
+
public void addWorld(World world) {
// Check if a World already exists with the UID.
if (getWorld(world.getUID()) != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index f497b9e11a075a84ff0a2117eb79d0532e4a326f..b0212b2043ee5fd77c8876ef0b51ef91488712f0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2566,6 +2566,11 @@ public class CraftWorld implements World {
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
}, net.minecraft.server.MinecraftServer.getServer());
}
+
+ @Override
+ public org.bukkit.NamespacedKey getKey() {
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().getLocation());
+ }
// Paper end
// Spigot start

View File

@ -1,52 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 12 Mar 2021 17:09:42 -0800
Subject: [PATCH] Item Rarity API
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
index 58400e84830c93675b0a1fe632be5e217c19a932..cb079bfd5339b96ad372b0a3b483d02cd0636bfd 100644
--- a/src/main/java/net/minecraft/world/item/Item.java
+++ b/src/main/java/net/minecraft/world/item/Item.java
@@ -45,7 +45,7 @@ public class Item implements ItemLike {
protected static final UUID BASE_ATTACK_SPEED_UUID = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
protected static final Random random = new Random();
protected final CreativeModeTab category;
- private final Rarity rarity;
+ private final Rarity rarity; public final Rarity getItemRarity() { return rarity; } // Paper - OBFHELPER
private final int maxStackSize;
private final int maxDamage;
private final boolean isFireResistant;
@@ -209,6 +209,7 @@ public class Item implements ItemLike {
return stack.isEnchanted();
}
+ public Rarity getItemStackRarity(ItemStack itemStack) { return getRarity(itemStack); } // Paper - OBFHELPER
public Rarity getRarity(ItemStack stack) {
if (!stack.isEnchanted()) {
return this.rarity;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 25a29d997f163ce2b11330d66a691601f514a9cb..472b0615dcdc3c0c52bd377fd69752716f354262 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -470,6 +470,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
public int nextEntityId() {
return net.minecraft.world.entity.Entity.nextEntityId();
}
+
+ @Override
+ public io.papermc.paper.inventory.ItemRarity getItemRarity(org.bukkit.Material material) {
+ Item item = getItem(material);
+ if (item == null) {
+ throw new IllegalArgumentException(material + " is not an item, and rarity does not apply to blocks");
+ }
+ return io.papermc.paper.inventory.ItemRarity.values()[item.getItemRarity().ordinal()];
+ }
+
+ @Override
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
+ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
+ }
// Paper end
/**

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Mon, 5 Apr 2021 18:35:15 -0700
Subject: [PATCH] Don't ignore result of PlayerEditBookEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 1add53082ab9382cb2e90dc8305b8c71ef1c6a46..65afc23f4791aca19bff78ed86b3b0d31fa81977 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1144,7 +1144,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
list.stream().map(StringTag::valueOf).forEach(nbttaglist::add);
ItemStack old = itemstack.copy(); // CraftBukkit
itemstack.addTagElement("pages", (Tag) nbttaglist);
- CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit
+ this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
}
}

View File

@ -1,59 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Sat, 27 Mar 2021 11:13:30 +0100
Subject: [PATCH] fix cancelling block falling causing client desync
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 2ba81e7179c7f9e2e1add1ad6bd6b96ee12c5da1..718e20f83a9b510c095d7e12241616cdce33d2d6 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -13,6 +13,7 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.Tag;
@@ -41,6 +42,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class FallingBlockEntity extends Entity {
@@ -114,8 +116,18 @@ public class FallingBlockEntity extends Entity {
if (this.time++ == 0) {
blockposition = this.blockPosition();
- if (this.level.getBlockState(blockposition).is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
- this.level.removeBlock(blockposition, false);
+ // Paper start - fix cancelling block falling causing client desync
+ if (this.level.getBlockState(blockposition).isSameInstance(block)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (this.level.getBlockState(blockposition).isSameInstance(block)) { //if listener didn't update the block
+ ((ServerLevel) level).getChunkSource().blockChanged(blockposition);
+ }
+ this.remove();
+ return;
+ } else {
+ this.level.setAir(blockposition, false);
+ }
+ // Paper end - fix cancelling block falling causing client desync
} else if (!this.level.isClientSide) {
this.remove();
return;
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 17baae6b11f191f4738a107c7e62ea5bdac17a3c..32cda8c2e14cf8b218cb006a9b25330f0dab849a 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -682,6 +682,7 @@ public abstract class BlockBehaviour {
return this.getBlock().is(tag) && predicate.test(this);
}
+ public final boolean isSameInstance(Block block) { return is(block); } // Paper - OBFHELPER
public boolean is(Block block) {
return this.getBlock().is(block);
}

View File

@ -1,113 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alphaesia <creepashadowz@gmail.com>
Date: Fri, 23 Apr 2021 09:57:56 +1200
Subject: [PATCH] Fix duplicating /give items on item drop cancel
Fixes SPIGOT-2942 (Give command fires PlayerDropItemEvent, cancelling it causes item duplication).
For every stack of items to give, /give puts the item stack straight
into the player's inventory. However, it also summons a "fake item"
at the player's location. When the PlayerDropItemEvent for this fake
item is cancelled, the server attempts to put the item back into the
player's inventory. The result is that the fake item, which is never
meant to be obtained, is combined with the real items injected directly
into the player's inventory. This means more items than the amount
specified in /give are given to the player - one for every stack of
items given. (e.g. /give @s dirt 1 gives you 2 dirt).
While this isn't a big issue for general building usage, it can affect
e.g. adventure maps where the number of items the player receives is
important (and you want to restrict the player from throwing items).
If there are any overflow items that didn't make it into the inventory
(insufficient space), those items are dropped as a real item instead
of a fake one. While cancelling this drop would also result in the
server attempting to put those items into the inventory, since it is
full this has no effect.
Just ignoring cancellation of the PlayerDropItemEvent seems like the
cleanest and least intrusive way to fix it.
diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java
index a6259e9160f291cf527a4ea5533a2e5530471874..3b8a7b9bdd2445afa93e4f2dc971a1d252c1463a 100644
--- a/src/main/java/net/minecraft/server/commands/GiveCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java
@@ -49,7 +49,7 @@ public class GiveCommand {
if (flag && itemstack.isEmpty()) {
itemstack.setCount(1);
- entityitem = entityplayer.drop(itemstack, false);
+ entityitem = entityplayer.drop(itemstack, false, false, true); // Paper - Fix duplicating /give items on item drop cancel
if (entityitem != null) {
entityitem.makeFakeItem();
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 4817b8ab259d348b48bc325d34ba9351ffe951df..cfb9bd6b9863a0f6f0f50181b7553adce90cfebe 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -639,7 +639,14 @@ public abstract class Player extends LivingEntity {
@Nullable
public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) {
- if (stack.isEmpty()) {
+ // Paper start - Fix duplicating /give items on item drop cancel
+ return this.drop(stack, throwRandomly, retainOwnership, false);
+ }
+
+ @Nullable
+ public ItemEntity drop(ItemStack itemstack, boolean flag, boolean flag1, boolean alwaysSucceed) {
+ // Paper end
+ if (itemstack.isEmpty()) {
return null;
} else {
if (this.level.isClientSide) {
@@ -647,17 +654,17 @@ public abstract class Player extends LivingEntity {
}
double d0 = this.getEyeY() - 0.30000001192092896D;
- ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), stack);
+ ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), itemstack);
entityitem.setPickUpDelay(40);
- if (retainOwnership) {
+ if (flag1) {
entityitem.setThrower(this.getUUID());
}
float f;
float f1;
- if (throwRandomly) {
+ if (flag) {
f = this.random.nextFloat() * 0.5F;
f1 = this.random.nextFloat() * 6.2831855F;
entityitem.setDeltaMovement((double) (-Mth.sin(f1) * f), 0.20000000298023224D, (double) (Mth.cos(f1) * f));
@@ -680,12 +687,12 @@ public abstract class Player extends LivingEntity {
PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
this.level.getCraftServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
+ if (event.isCancelled() && !alwaysSucceed) { // Paper - Fix duplicating /give items on item drop cancel
org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
- if (retainOwnership && (cur == null || cur.getAmount() == 0)) {
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
// The complete stack was dropped
player.getInventory().setItemInHand(drop.getItemStack());
- } else if (retainOwnership && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
// Only one item is dropped
cur.setAmount(cur.getAmount() + 1);
player.getInventory().setItemInHand(cur);
@@ -697,9 +704,9 @@ public abstract class Player extends LivingEntity {
}
// CraftBukkit end
// Paper start - remove player from map on drop
- if (stack.getItem() == Items.FILLED_MAP) {
- MapItemSavedData worldmap = MapItem.getOrCreateSavedData(stack, this.level);
- worldmap.updateSeenPlayers(this, stack);
+ if (itemstack.getItem() == Items.FILLED_MAP) {
+ MapItemSavedData worldmap = MapItem.getOrCreateSavedData(itemstack, this.level);
+ worldmap.updateSeenPlayers(this, itemstack);
}
// Paper end

View File

@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Thu, 22 Apr 2021 19:02:07 -0700
Subject: [PATCH] fix PlayerItemHeldEvent firing twice
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
index 68026536cfc26f07ca99ee9e76fd74b4ed4a995c..848fb02988b0fb319655f790112274ac2a437d25 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
@@ -24,6 +24,7 @@ public class ServerboundSetCarriedItemPacket implements Packet<ServerGamePacketL
listener.handleSetCarriedItem(this);
}
+ public int getItemInHandIndex() { return getSlot(); } // Paper - OBFHELPER
public int getSlot() {
return this.slot;
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 67defaf71752ed29fde483e8232aa358ffa53675..5b0eb8744dba5df6f16bafd6d907cd1efd508fe6 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1907,6 +1907,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.player.isImmobile()) return; // CraftBukkit
if (packet.getSlot() >= 0 && packet.getSlot() < Inventory.getSelectionSize()) {
+ if (packet.getItemInHandIndex() == this.player.inventory.selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.selected, packet.getSlot());
this.craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@ -1,146 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 7 Jul 2020 10:52:34 -0700
Subject: [PATCH] More World API
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a7553a856b9c99bee8f75d514b97cfab952bfd33..511e6a941d441c55a4b38660f0f7f8c47fa689dd 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1863,6 +1863,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
return !this.worldDataServer.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, feature, pos, radius, skipExistingChunks); // CraftBukkit
}
+ public BlockPos getNearestBiome(Biome biomeBase, BlockPos blockPosition, int radius, int step) { return this.findNearestBiome(biomeBase, blockPosition, radius, step); } // Paper - OBFHELPER
@Nullable
public BlockPos findNearestBiome(Biome biome, BlockPos pos, int radius, int j) {
return this.getChunkSource().getGenerator().getBiomeSource().findBiomeHorizontal(pos.getX(), pos.getY(), pos.getZ(), radius, j, (biomebase1) -> {
@@ -1885,6 +1886,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
return this.noSave;
}
+ public RegistryAccess getWorldCustomRegistry() { return registryAccess(); } // Paper - OBFHELPER
@Override
public RegistryAccess registryAccess() {
return this.server.registryAccess();
diff --git a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
index 7dead90a0d77e936816c2a54fe70c87d92dc8e5b..fb2bdfbeb44de6ce967af2deb4738972b44dcf44 100644
--- a/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
+++ b/src/main/java/net/minecraft/world/level/dimension/DimensionType.java
@@ -142,10 +142,10 @@ public class DimensionType {
public static RegistryAccess.RegistryHolder registerBuiltin(RegistryAccess.RegistryHolder registryManager) {
WritableRegistry<DimensionType> iregistrywritable = registryManager.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
- iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable());
- iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, (Object) DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable());
- iregistrywritable.register(DimensionType.NETHER_LOCATION, (Object) DimensionType.DEFAULT_NETHER, Lifecycle.stable());
- iregistrywritable.register(DimensionType.END_LOCATION, (Object) DimensionType.DEFAULT_END, Lifecycle.stable());
+ iregistrywritable.register(DimensionType.OVERWORLD_LOCATION, DimensionType.DEFAULT_OVERWORLD, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.OVERWORLD_CAVES_LOCATION, DimensionType.DEFAULT_OVERWORLD_CAVES, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.NETHER_LOCATION, DimensionType.DEFAULT_NETHER, Lifecycle.stable()); // Paper - decompile fix
+ iregistrywritable.register(DimensionType.END_LOCATION, DimensionType.DEFAULT_END, Lifecycle.stable()); // Paper - decompile fix
return registryManager;
}
@@ -164,10 +164,10 @@ public class DimensionType {
public static MappedRegistry<LevelStem> defaultDimensions(Registry<DimensionType> dimensionRegistry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> chunkGeneratorSettingsRegistry, long seed) {
MappedRegistry<LevelStem> registrymaterials = new MappedRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.experimental());
- registrymaterials.register(LevelStem.NETHER, (Object) (new LevelStem(() -> {
+ registrymaterials.register(LevelStem.NETHER, (new LevelStem(() -> { // Paper - decompile fix
return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.NETHER_LOCATION);
}, defaultNetherGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable());
- registrymaterials.register(LevelStem.END, (Object) (new LevelStem(() -> {
+ registrymaterials.register(LevelStem.END, (new LevelStem(() -> { // Paper - decompile fix
return (DimensionType) dimensionRegistry.getOrThrow(DimensionType.END_LOCATION);
}, defaultEndGenerator(biomeRegistry, chunkGeneratorSettingsRegistry, seed))), Lifecycle.stable());
return registrymaterials;
@@ -256,6 +256,7 @@ public class DimensionType {
return this.brightnessRamp[i];
}
+ public Tag<Block> getInfiniburnTag() { return infiniburn(); } // Paper - OBFHELPER
public Tag<Block> infiniburn() {
Tag<Block> tag = BlockTags.getAllTags().getTag(this.infiniburn);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index b44e83d93bba579e439b93e5093350675137b070..a1fa2d5e00bd125abd38a00e0bc3936f2fb8186f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2515,6 +2515,75 @@ public class CraftWorld implements World {
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}
+ // Paper start
+ @Override
+ public Location locateNearestBiome(Location origin, Biome biome, int radius) {
+ return this.locateNearestBiome(origin, biome, radius, 8);
+ }
+
+ @Override
+ public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) {
+ BlockPos originPos = new BlockPos(origin.getX(), origin.getY(), origin.getZ());
+ BlockPos nearest = getHandle().getNearestBiome(CraftBlock.biomeToBiomeBase(getHandle().getWorldCustomRegistry().registryOrThrow(Registry.BIOME_REGISTRY), biome), originPos, radius, step);
+ return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
+ }
+
+ @Override
+ public boolean isUltrawarm() {
+ return getHandle().dimensionType().ultraWarm();
+ }
+
+ @Override
+ public boolean isNatural() {
+ return getHandle().dimensionType().natural();
+ }
+
+ @Override
+ public double getCoordinateScale() {
+ return getHandle().dimensionType().coordinateScale();
+ }
+
+ @Override
+ public boolean hasSkylight() {
+ return getHandle().dimensionType().hasSkyLight();
+ }
+
+ @Override
+ public boolean hasBedrockCeiling() {
+ return getHandle().dimensionType().hasSkyLight();
+ }
+
+ @Override
+ public boolean isPiglinSafe() {
+ return getHandle().dimensionType().piglinSafe();
+ }
+
+ @Override
+ public boolean doesBedWork() {
+ return getHandle().dimensionType().bedWorks();
+ }
+
+ @Override
+ public boolean doesRespawnAnchorWork() {
+ return getHandle().dimensionType().respawnAnchorWorks();
+ }
+
+ @Override
+ public boolean hasRaids() {
+ return getHandle().dimensionType().hasRaids();
+ }
+
+ @Override
+ public boolean isFixedTime() {
+ return getHandle().dimensionType().hasFixedTime();
+ }
+
+ @Override
+ public Collection<org.bukkit.Material> getInfiniburn() {
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().getInfiniburnTag().getTagged().iterator(), CraftMagicNumbers::getMaterial));
+ }
+ // Paper end
+
@Override
public Raid locateNearestRaid(Location location, int radius) {
Validate.notNull(location, "Location cannot be null");

View File

@ -1,89 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com>
Date: Fri, 8 Jan 2021 20:31:13 +0100
Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent
diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java
index 9d27b658d32297337fb367bae628a1cc3a78712a..4abbe45237667c08753c040ef1281af1b2f34f88 100644
--- a/src/main/java/net/minecraft/advancements/Advancement.java
+++ b/src/main/java/net/minecraft/advancements/Advancement.java
@@ -76,6 +76,7 @@ public class Advancement {
return this.parent;
}
+ public final @Nullable DisplayInfo getAdvancementDisplay() { return this.getDisplay(); } // Paper - OBFHELPER
@Nullable
public DisplayInfo getDisplay() {
return this.display;
@@ -125,6 +126,7 @@ public class Advancement {
return this.requirements;
}
+ public final Component getChatComponent() { return this.getChatComponent(); } // Paper - OBFHELPER
public Component getChatComponent() {
return this.chatComponent;
}
diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
index 2bcf14826ec1c6a1654246844d03184ceae55d79..1b41578fed1da6d15a806a7200e53954f608b625 100644
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
@@ -54,10 +54,12 @@ public class DisplayInfo {
return this.description;
}
+ public final FrameType getFrameType() { return this.getFrame(); } // Paper - OBFHELPER
public FrameType getFrame() {
return this.frame;
}
+ public final boolean shouldAnnounceToChat() { return this.shouldAnnounceChat(); } // Paper - OBFHELPER
public boolean shouldAnnounceChat() {
return this.announceChat;
}
diff --git a/src/main/java/net/minecraft/advancements/FrameType.java b/src/main/java/net/minecraft/advancements/FrameType.java
index 0ccac480a760259412b525e66c43de3a209543f5..f6d4b876bdd25942763780f17c8bb69ac3d56031 100644
--- a/src/main/java/net/minecraft/advancements/FrameType.java
+++ b/src/main/java/net/minecraft/advancements/FrameType.java
@@ -20,6 +20,7 @@ public enum FrameType {
this.displayName = new TranslatableComponent("advancements.toast." + s);
}
+ public final String getId() { return this.getName(); } // Paper - OBFHELPER
public String getName() {
return this.name;
}
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index b8d3f2c59199e245e2035d6205dd1a042aa93f77..fcb59f6538e66fa43d11d4998e6eeac2e33b0393 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -51,6 +51,7 @@ import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.level.GameRules;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import io.papermc.paper.adventure.PaperAdventure; // Paper
public class PlayerAdvancements {
@@ -313,10 +314,18 @@ public class PlayerAdvancements {
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
- this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ boolean announceToChat = advancement.getAdvancementDisplay() != null && advancement.getAdvancementDisplay().shouldAnnounceToChat();
+ net.kyori.adventure.text.Component message = announceToChat ? PaperAdventure.asAdventure(new TranslatableComponent("chat.type.advancement." + advancement.getAdvancementDisplay().getFrameType().getId(), this.player.getDisplayName(), advancement.getChatComponent())) : null;
+ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message);
+ this.player.level.getCraftServer().getPluginManager().callEvent(event);
+ message = event.message();
+ // Paper end
advancement.getRewards().a(this.player);
- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
- this.playerList.broadcastMessage(new TranslatableComponent("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatType.SYSTEM, Util.NIL_UUID);
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+ this.playerList.broadcastMessage(PaperAdventure.asVanilla(message), ChatType.SYSTEM, Util.getNullUUID());
+ // Paper end
}
}
}

View File

@ -1,174 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Connor Linfoot <connorlinfoot@me.com>
Date: Sun, 16 May 2021 15:07:34 +0100
Subject: [PATCH] Add basic Datapack API
diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapack.java b/src/main/java/io/papermc/paper/datapack/PaperDatapack.java
new file mode 100644
index 0000000000000000000000000000000000000000..66debefcd474e4dcc2a8889a82af6c1809c93f46
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/PaperDatapack.java
@@ -0,0 +1,51 @@
+package io.papermc.paper.datapack;
+
+import Compatibility;
+import io.papermc.paper.event.server.ServerResourcesReloadedEvent;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.packs.repository.Pack;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class PaperDatapack implements Datapack {
+ private final String name;
+ private final Compatibility compatibility;
+ private final boolean enabled;
+
+ PaperDatapack(Pack loader, boolean enabled) {
+ this.name = loader.getName();
+ this.compatibility = Compatibility.valueOf(loader.getVersion().name());
+ this.enabled = enabled;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Compatibility getCompatibility() {
+ return compatibility;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ if (enabled == this.enabled) {
+ return;
+ }
+
+ MinecraftServer server = MinecraftServer.getServer();
+ List<String> enabledKeys = server.getPackRepository().getEnabledPacks().stream().map(Pack::getName).collect(Collectors.toList());
+ if (enabled) {
+ enabledKeys.add(this.name);
+ } else {
+ enabledKeys.remove(this.name);
+ }
+ server.reloadServerResources(enabledKeys, ServerResourcesReloadedEvent.Cause.PLUGIN);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java b/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..ec221183bef1065bda0a37e1025958df0d1f6318
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/PaperDatapackManager.java
@@ -0,0 +1,25 @@
+package io.papermc.paper.datapack;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+import net.minecraft.server.packs.repository.Pack;
+import net.minecraft.server.packs.repository.PackRepository;
+
+public class PaperDatapackManager implements DatapackManager {
+ private final PackRepository repository;
+
+ public PaperDatapackManager(PackRepository repository) {
+ this.repository = repository;
+ }
+
+ @Override
+ public Collection<Datapack> getPacks() {
+ Collection<Pack> enabledPacks = repository.getEnabledPacks();
+ return repository.getPacks().stream().map(loader -> new PaperDatapack(loader, enabledPacks.contains(loader))).collect(Collectors.toList());
+ }
+
+ @Override
+ public Collection<Datapack> getEnabledPacks() {
+ return repository.getEnabledPacks().stream().map(loader -> new PaperDatapack(loader, true)).collect(Collectors.toList());
+ }
+}
diff --git a/src/main/java/net/minecraft/server/packs/repository/Pack.java b/src/main/java/net/minecraft/server/packs/repository/Pack.java
index df5d258b80e37077fa236e4190ad934853c88619..4120326e0d047347e5d7ab9521babe7bb6b6a7db 100644
--- a/src/main/java/net/minecraft/server/packs/repository/Pack.java
+++ b/src/main/java/net/minecraft/server/packs/repository/Pack.java
@@ -101,6 +101,7 @@ public class Pack implements AutoCloseable {
});
}
+ public final PackCompatibility getVersion() { return this.getCompatibility(); } // Paper - OBFHELPER
public PackCompatibility getCompatibility() {
return this.compatibility;
}
@@ -109,6 +110,7 @@ public class Pack implements AutoCloseable {
return (PackResources) this.supplier.get();
}
+ public final String getName() { return this.getId(); } // Paper - OBFHELPER
public String getId() {
return this.id;
}
diff --git a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
index bce2fd67048bd1fd53865eef81bac262dbda2865..8d0ef3bdf9fa283f54628800768717181df28aa5 100644
--- a/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
+++ b/src/main/java/net/minecraft/server/packs/repository/PackRepository.java
@@ -88,6 +88,7 @@ public class PackRepository implements AutoCloseable {
return this.available.keySet();
}
+ public final Collection<Pack> getPacks() { return this.getAvailablePacks(); } // Paper - OBFHELPER
public Collection<Pack> getAvailablePacks() {
return this.available.values();
}
@@ -96,6 +97,7 @@ public class PackRepository implements AutoCloseable {
return (Collection) this.selected.stream().map(Pack::getId).collect(ImmutableSet.toImmutableSet());
}
+ public final Collection<Pack> getEnabledPacks() { return this.getSelectedPacks(); } // Paper - OBFHELPER
public Collection<Pack> getSelectedPacks() {
return this.selected;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6905256147d9bd79e5f52bf86bdb21c89b8411a7..63639923f7875d76f569b8c6e958782c6462d906 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -18,6 +18,7 @@ import com.mojang.serialization.Lifecycle;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
+import io.papermc.paper.datapack.PaperDatapackManager; // Paper
import io.papermc.paper.util.TraceUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import java.awt.image.BufferedImage;
@@ -264,6 +265,7 @@ public final class CraftServer implements Server {
public boolean ignoreVanillaPermissions = false;
private final List<CraftPlayer> playerView;
public int reloadCount;
+ private final PaperDatapackManager datapackManager; // Paper
public static Exception excessiveVelEx; // Paper - Velocity warnings
static {
@@ -346,6 +348,7 @@ public final class CraftServer implements Server {
TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
minimumAPI = configuration.getString("settings.minimum-api");
loadIcon();
+ datapackManager = new PaperDatapackManager(console.getPackRepository()); // Paper
}
public boolean getCommandBlockOverride(String command) {
@@ -2496,5 +2499,11 @@ public final class CraftServer implements Server {
public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return mobGoals;
}
+
+ @Override
+ public PaperDatapackManager getDatapackManager() {
+ return datapackManager;
+ }
+
// Paper end
}

View File

@ -1,138 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 15 May 2021 10:04:43 -0700
Subject: [PATCH] additions to PlayerGameModeChangeEvent
diff --git a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
index c0098a8f8a9fa2671ff66cbcf50ac74b057d1446..ebbd6f2b0e7236b33d136ab2218c8eca4c5df03e 100644
--- a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
+++ b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java
@@ -43,7 +43,13 @@ public class DefaultGameModeCommands {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (entityplayer.gameMode.getGameModeForPlayer() != defaultGameMode) {
- entityplayer.setGameMode(defaultGameMode);
+ // Paper start - handle event cancelling the change
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(defaultGameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED));
+ if (event != null && event.isCancelled()) {
+ source.sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
+ continue;
+ }
+ // Paper end
++i;
}
}
diff --git a/src/main/java/net/minecraft/server/commands/GameModeCommand.java b/src/main/java/net/minecraft/server/commands/GameModeCommand.java
index 3e999090fb3b03b996a9790c53e5b4618c8891f7..3b17c81167f8e011e7f9c09bf42eb632f5a3c2f2 100644
--- a/src/main/java/net/minecraft/server/commands/GameModeCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GameModeCommand.java
@@ -62,13 +62,13 @@ public class GameModeCommand {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) {
- entityplayer.setGameMode(gameMode);
- // CraftBukkit start - handle event cancelling the change
- if (entityplayer.gameMode.getGameModeForPlayer() != gameMode) {
- context.getSource().sendFailure(new net.minecraft.network.chat.TextComponent("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'"));
+ // Paper start - handle event cancelling the change
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = entityplayer.setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.COMMAND, net.kyori.adventure.text.Component.text("Failed to set the gamemode of '" + entityplayer.getScoreboardName() + "'", net.kyori.adventure.text.format.NamedTextColor.RED));
+ if (event != null && event.isCancelled()) {
+ context.getSource().sendSuccess(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.cancelMessage()), false);
continue;
}
- // CraftBukkit end
+ // Paper end
logGamemodeChange((CommandSourceStack) context.getSource(), entityplayer, gameMode);
++i;
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 5d710a1f4e0c61d4be6efe8cebd9b80789868338..779b926921fd435620cbbc69ed6f9931a422b652 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -393,7 +393,16 @@ public class ServerPlayer extends Player implements ContainerListener {
if (this.getY() > 300) this.setPosRaw(getX(), 257, getZ()); // Paper - bring down to a saner Y level if out of world
if (tag.contains("playerGameType", 99)) {
if (this.getServer().getForceGameType()) {
+ // Paper start - call PlayerGameModeChangeEvent on join for players that do not have the correct gamemode
+ if (this.getServer().getDefaultGameType() != GameType.byId(tag.getInt("playerGameType"))) {
+ if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.getServer().getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
this.gameMode.setGameModeForPlayer(this.getServer().getDefaultGameType(), GameType.NOT_SET);
+ } else {
+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if cancelled, set gamemode normally
+ }
+ } else {
+ this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET); // copied from below; if no change needed, set gamemode normally
+ } // Paper end
} else {
this.gameMode.setGameModeForPlayer(GameType.byId(tag.getInt("playerGameType")), tag.contains("previousPlayerGameType", 3) ? GameType.byId(tag.getInt("previousPlayerGameType")) : GameType.NOT_SET);
}
@@ -1789,21 +1798,27 @@ public class ServerPlayer extends Player implements ContainerListener {
@Override
public void setGameMode(GameType gameMode) {
+ // Paper start - Add cause and nullable message to event
+ setGamemode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
+ }
+
+ public PlayerGameModeChangeEvent setGamemode(GameType enumgamemode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) {
+ // Paper end
// CraftBukkit start
- if (gameMode == this.gameMode.getGameModeForPlayer()) {
- return;
+ if (enumgamemode == this.gameMode.getGameModeForPlayer()) {
+ return null; // Paper
}
- PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(gameMode.getId()));
+ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId()), cause, message); // Paper
level.getCraftServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- return;
+ return event; // Paper
}
// CraftBukkit end
- this.gameMode.setGameModeForPlayer(gameMode);
- this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
- if (gameMode == GameType.SPECTATOR) {
+ this.gameMode.setGameModeForPlayer(enumgamemode);
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) enumgamemode.getId()));
+ if (enumgamemode == GameType.SPECTATOR) {
this.removeEntitiesOnShoulder();
this.stopRiding();
} else {
@@ -1812,6 +1827,7 @@ public class ServerPlayer extends Player implements ContainerListener {
this.onUpdateAbilities();
this.updateEffectVisibility();
+ return event; // Paper
}
@Override
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a0e69cac7699ddc318057c8016e329850d3baa26..c454908f23a436f66f8e64fc346186f113b6eefb 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2449,7 +2449,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
this.player = this.server.getPlayerList().respawn(this.player, false);
if (this.server.isHardcore()) {
- this.player.setGameMode(GameType.SPECTATOR);
+ this.player.setGamemode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper
((GameRules.BooleanValue) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index ec8c7499662c0a810f1337ebc0fa24d2f3ca79e7..3dbe94d9b9647f5cc1e27335b36042e50c652cea 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1189,7 +1189,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new IllegalArgumentException("Mode cannot be null");
}
- getHandle().setGameMode(GameType.byId(mode.getValue()));
+ getHandle().setGamemode(GameType.byId(mode.getValue()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.PLUGIN, null); // Paper
}
@Override

View File

@ -1,127 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 14 May 2021 13:42:17 -0500
Subject: [PATCH] Add Mob#lookAt API
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index ea34306858116e5626383af408529091836c2752..5692b497875ba2ee455859bc8a88d7888afd86fc 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -850,14 +850,17 @@ public abstract class Mob extends LivingEntity {
protected void customServerAiStep() {}
+ public int getMaxHeadXRot() { return getMaxHeadXRot(); } // Paper - OBFHELPER
public int getMaxHeadXRot() {
return 40;
}
+ public int getMaxHeadYRot() { return getMaxHeadYRot(); } // Paper - OBFHELPER
public int getMaxHeadYRot() {
return 75;
}
+ public int getHeadRotSpeed() { return getHeadRotSpeed(); } // Paper - OBFHELPER
public int getHeadRotSpeed() {
return 10;
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
index faba4a95883bb0fcfd4f65c3f62bd6f476ded249..3fe159c4bdc3ad3e95354e18e2921305af121725 100644
--- a/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
+++ b/src/main/java/net/minecraft/world/entity/ai/control/LookControl.java
@@ -20,18 +20,28 @@ public class LookControl {
this.mob = entity;
}
+ public void lookAt(Vec3 vec3d) { setLookAt(vec3d); } // Paper - OBFHELPER
public void setLookAt(Vec3 direction) {
this.setLookAt(direction.x, direction.y, direction.z);
}
+ // Paper start
+ public void lookAt(Entity entity) {
+ this.lookAt(entity.getX(), getWantedY(entity), entity.getZ());
+ }
+ // Paper end
+
+ public void lookAt(Entity entity, float f, float f1) { setLookAt(entity, f, f1); } // Paper - OBFHELPER
public void setLookAt(Entity entity, float yawSpeed, float pitchSpeed) {
this.setLookAt(entity.getX(), getWantedY(entity), entity.getZ(), yawSpeed, pitchSpeed);
}
+ public void lookAt(double d0, double d1, double d2) { setLookAt(d0, d1, d2); } // Paper - OBFHELPER
public void setLookAt(double x, double y, double z) {
this.setLookAt(x, y, z, (float) this.mob.getHeadRotSpeed(), (float) this.mob.getMaxHeadXRot());
}
+ public void lookAt(double d0, double d1, double d2, float f, float f1) { setLookAt(d0, d1, d2, f, f1); } // Paper - OBFHELPER
public void setLookAt(double x, double y, double z, float yawSpeed, float pitchSpeed) {
this.wantedX = x;
this.wantedY = y;
@@ -103,6 +113,7 @@ public class LookControl {
return from + f4;
}
+ public static double getWantedY(Entity entity) { return getWantedY(entity); } // Paper - OBFHELPER
private static double getWantedY(Entity entity) {
return entity instanceof LivingEntity ? entity.getEyeY() : (entity.getBoundingBox().minY + entity.getBoundingBox().maxY) / 2.0D;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 1e3a0851c75d8067d2699f00bb3f6621d1d739d8..f597cf70779fde265cc45868aba3ae9db898fb6e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -83,5 +83,53 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
public boolean isInDaylight() {
return getHandle().isInDaylight();
}
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
+ getHandle().getLookControl().lookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle());
+ }
+
+ @Override
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) {
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
+ getHandle().getLookControl().lookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z) {
+ getHandle().getLookControl().lookAt(x, y, z);
+ }
+
+ @Override
+ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) {
+ getHandle().getLookControl().lookAt(x, y, z, headRotationSpeed, maxHeadPitch);
+ }
+
+ @Override
+ public int getHeadRotationSpeed() {
+ return getHandle().getHeadRotSpeed();
+ }
+
+ @Override
+ public int getMaxHeadPitch() {
+ return getHandle().getMaxHeadXRot();
+ }
// Paper end
}

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Spawn player in correct world on login
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 7eb3088d47ff78198e01a3a12b0ce6abe9d6ca6b..66735bbc2528c5812c9df14ef7cd91cb69d903b2 100644
index 9c13479d2a508728c10803dee719ed7ad097e019..56b33bcd93cd4e8b448271edee497b7c3c9b246a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -193,7 +193,18 @@ public abstract class PlayerList {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Move range check for block placing up
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 39777c2b1bbb12ce3e5be3724235ea0a8072cef8..99a16a2f0c2dc227dd45db1964c2d47ffdcda73e 100644
index 2b8a9d16add3ac81ede029a909a40feaa07c51d3..afd5f5efdd6b47811fdbc23adeacace594602046 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1693,17 +1693,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -1694,17 +1694,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
Direction enumdirection = movingobjectpositionblock.getDirection();

View File

@ -10,7 +10,7 @@ This fixes that by checking if the modified spawn location is
still at a respawn anchor.
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 66735bbc2528c5812c9df14ef7cd91cb69d903b2..9c594c0f142ca10b7c1df50faf45ccb3f7468ba9 100644
index 56b33bcd93cd4e8b448271edee497b7c3c9b246a..0528099611eca136722507cacbd8ba6a668778b8 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -77,6 +77,7 @@ import net.minecraft.world.level.GameRules;
@ -21,7 +21,7 @@ index 66735bbc2528c5812c9df14ef7cd91cb69d903b2..9c594c0f142ca10b7c1df50faf45ccb3
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.border.BorderChangeListener;
import net.minecraft.world.level.border.WorldBorder;
@@ -821,6 +822,7 @@ public abstract class PlayerList {
@@ -822,6 +823,7 @@ public abstract class PlayerList {
// Paper start
boolean isBedSpawn = false;
boolean isRespawn = false;
@ -29,7 +29,7 @@ index 66735bbc2528c5812c9df14ef7cd91cb69d903b2..9c594c0f142ca10b7c1df50faf45ccb3
// Paper end
// CraftBukkit start - fire PlayerRespawnEvent
@@ -831,7 +833,7 @@ public abstract class PlayerList {
@@ -832,7 +834,7 @@ public abstract class PlayerList {
Optional optional;
if (blockposition != null) {
@ -38,7 +38,7 @@ index 66735bbc2528c5812c9df14ef7cd91cb69d903b2..9c594c0f142ca10b7c1df50faf45ccb3
} else {
optional = Optional.empty();
}
@@ -874,7 +876,12 @@ public abstract class PlayerList {
@@ -875,7 +877,12 @@ public abstract class PlayerList {
}
// Spigot End
@ -52,7 +52,7 @@ index 66735bbc2528c5812c9df14ef7cd91cb69d903b2..9c594c0f142ca10b7c1df50faf45ccb3
if (!flag) entityplayer.reset(); // SPIGOT-4785
isRespawn = true; // Paper
} else {
@@ -911,8 +918,12 @@ public abstract class PlayerList {
@@ -913,8 +920,12 @@ public abstract class PlayerList {
}
// entityplayer1.syncInventory();
entityplayer1.setHealth(entityplayer1.getHealth());

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Add missing strikeLighting call to
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index f72471ac82907a0d5112598b3289689495285944..d79a711d4080ad8acb2c240870be9d99a0b84cea 100644
index 29b2f5d3e6fd4859fbe94ad1cd5c355be7f9d4f3..babe877022156adc224643c3d487793bfa43d5ff 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2623,6 +2623,7 @@ public class CraftWorld implements World {
@@ -2627,6 +2627,7 @@ public class CraftWorld implements World {
lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );
lightning.visualOnly = true;
lightning.isSilent = isSilent;

View File

@ -55,7 +55,7 @@ index 1feda8b44364c748497174944b26abc4f058f354..1889de77a5e3d9371005b6bd451e2c0e
} // Paper start
for (ServerLevel level : this.getAllLevels()) {
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index cd34b5aa61c78d8138500a93f0a9714bedd7ed86..b49fa995973f860a95d937c98e2821435262ce25 100644
index b106a972a76e856d6cdab78dec5daef77b135f98..de50d3de98490b5620a085c1af7fb100b8b8ad99 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -169,6 +169,7 @@ public class ServerPlayer extends Player {
@ -67,7 +67,7 @@ index cd34b5aa61c78d8138500a93f0a9714bedd7ed86..b49fa995973f860a95d937c98e282143
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10;
public ServerGamePacketListenerImpl connection;
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 9c594c0f142ca10b7c1df50faf45ccb3f7468ba9..8c62367888af566dd9be4bb5cd301c26e0248e46 100644
index 0528099611eca136722507cacbd8ba6a668778b8..554da65376a1513af64fee6a958ceaa63c88b552 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -561,6 +561,7 @@ public abstract class PlayerList {
@ -78,7 +78,7 @@ index 9c594c0f142ca10b7c1df50faf45ccb3f7468ba9..8c62367888af566dd9be4bb5cd301c26
this.playerIo.save(player);
ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit
@@ -1198,10 +1199,21 @@ public abstract class PlayerList {
@@ -1200,10 +1201,21 @@ public abstract class PlayerList {
}
public void saveAll() {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Brand support
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 99a16a2f0c2dc227dd45db1964c2d47ffdcda73e..0176b85a031b33cb2a12bb75079f5e3111f4f2b7 100644
index afd5f5efdd6b47811fdbc23adeacace594602046..30cdacbefb07c7b3e7d64cbb78ff821a5f6c7567 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
@ -33,7 +33,7 @@ index 99a16a2f0c2dc227dd45db1964c2d47ffdcda73e..0176b85a031b33cb2a12bb75079f5e31
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
this.server = server;
this.connection = connection;
@@ -3000,6 +3004,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -3001,6 +3005,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
@ -42,7 +42,7 @@ index 99a16a2f0c2dc227dd45db1964c2d47ffdcda73e..0176b85a031b33cb2a12bb75079f5e31
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
@@ -3027,6 +3033,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -3028,6 +3034,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
try {
byte[] data = new byte[packet.data.readableBytes()];
packet.data.readBytes(data);
@ -58,7 +58,7 @@ index 99a16a2f0c2dc227dd45db1964c2d47ffdcda73e..0176b85a031b33cb2a12bb75079f5e31
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
@@ -3036,6 +3051,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -3037,6 +3052,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}
@ -72,10 +72,10 @@ index 99a16a2f0c2dc227dd45db1964c2d47ffdcda73e..0176b85a031b33cb2a12bb75079f5e31
return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0a6d6ea67eaf8b2a59ec45fb3ffb85096f509997..b277c87c0834ddcefcfaebd85c9e69d8d389b59e 100644
index e4386cf8bc6170f0c144560905ab285e44ebd5bb..a574848e34a391650efd09e5a5ec010ea5eb769e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2386,6 +2386,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2393,6 +2393,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end
};

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add #setMaxPlayers API
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 8c62367888af566dd9be4bb5cd301c26e0248e46..2f73f1f770e5e1fa422bec9c27e5bd10e86b7538 100644
index 554da65376a1513af64fee6a958ceaa63c88b552..c61a4e8e03996487ed3f7f39187d96a866191a41 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -142,7 +142,7 @@ public abstract class PlayerList {
@ -18,7 +18,7 @@ index 8c62367888af566dd9be4bb5cd301c26e0248e46..2f73f1f770e5e1fa422bec9c27e5bd10
private boolean allowCheatsForAllPlayers;
private static final boolean ALLOW_LOGOUTIVATOR = false;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index df2c41d18377d8519d5537186d529ecc1901f58a..74de169828d7e1e55d15546eb637a87268610700 100644
index beb8b7d06ef47c80ede95c884598fedcc7126d67..7795735e5acc3b7b6b71b4e61bdc4bdcb722a7b3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -616,6 +616,13 @@ public final class CraftServer implements Server {

View File

@ -24,7 +24,7 @@ index bdabcdb60dbfb803ead13c42c8dd5e100b37dc00..4ae56444d258cdf44a02256315d6aae8
// if this keepSpawnInMemory is false a plugin has already removed our tickets, do not re-add
this.removeTicketsForSpawn(this.paperConfig.keepLoadedRange, prevSpawn);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d79a711d4080ad8acb2c240870be9d99a0b84cea..4ca674fac0e1ed354a0c49284c21ca2b117dd852 100644
index babe877022156adc224643c3d487793bfa43d5ff..b24395160c1ea84ed44a1db07b4f024a540ca80b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -386,11 +386,13 @@ public class CraftWorld implements World {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add moon phase API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4ca674fac0e1ed354a0c49284c21ca2b117dd852..d0b2de0f0a37554eb812aa8c7c20f1067807dc40 100644
index b24395160c1ea84ed44a1db07b4f024a540ca80b..b373e72237cc33a628648de515b163d8ce2980fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -325,6 +325,11 @@ public class CraftWorld implements World {

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