13
0
geforkt von Mirrors/Paper

chore: cleanup annotations in api adventure patch

Dieser Commit ist enthalten in:
Riley Park 2023-03-23 09:49:24 -07:00
Ursprung c4351787c6
Commit 39255145b6
64 geänderte Dateien mit 1308 neuen und 1246 gelöschten Zeilen

Datei anzeigen

@ -18,21 +18,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void resetPlayerWeather(); public void resetPlayerWeather();
+ // Paper start + // Paper start
+ /**
+ * Gives the player the amount of experience specified.
+ *
+ * @param amount Exp amount to give
+ */
+ public default void giveExp(int amount) {
+ giveExp(amount, false);
+ }
/** /**
* Gives the player the amount of experience specified. * Gives the player the amount of experience specified.
* *
* @param amount Exp amount to give * @param amount Exp amount to give
+ * @param applyMending Mend players items with mending, with same behavior as picking up orbs. calls {@link #applyMending(int)}
*/ */
- public void giveExp(int amount); - public void giveExp(int amount);
+ public default void giveExp(int amount) {
+ giveExp(amount, false);
+ }
+ /**
+ * Gives the player the amount of experience specified.
+ *
+ * @param amount Exp amount to give
+ * @param applyMending Mend players items with mending, with same behavior as picking up orbs. calls {@link #applyMending(int)}
+ */
+ public void giveExp(int amount, boolean applyMending); + public void giveExp(int amount, boolean applyMending);
+ +
+ /** + /**

Datei anzeigen

@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param message kick message * @param message kick message
*/ */
void kick(final @Nullable net.kyori.adventure.text.Component message); void kick(final net.kyori.adventure.text.@Nullable Component message);
+ +
+ /** + /**
+ * Kicks player with custom kick message and cause. + * Kicks player with custom kick message and cause.
@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param message kick message + * @param message kick message
+ * @param cause kick cause + * @param cause kick cause
+ */ + */
+ void kick(final @Nullable net.kyori.adventure.text.Component message, @NotNull org.bukkit.event.player.PlayerKickEvent.Cause cause); + void kick(final net.kyori.adventure.text.@Nullable Component message, org.bukkit.event.player.PlayerKickEvent.@NotNull Cause cause);
// Paper end // Paper end
/** /**

Datei anzeigen

@ -32,8 +32,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.damager = damager; this.damager = damager;
+ // Paper start - add critical damage API + // Paper start - add critical damage API
+ this.critical = critical; + this.critical = critical;
+ } }
+
+ /** + /**
+ * Shows this damage instance was critical. + * Shows this damage instance was critical.
+ * The damage instance can be critical if the attacking player met the respective conditions. + * The damage instance can be critical if the attacking player met the respective conditions.
@ -44,8 +44,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ public boolean isCritical() { + public boolean isCritical() {
+ return this.critical; + return this.critical;
} + }
+ // Paper end + // Paper end
+
/** /**
* Returns the entity that damaged the defender. * Returns the entity that damaged the defender.
*

Datei anzeigen

@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/inventory/ItemStack.java --- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat @@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
public @NotNull net.kyori.adventure.text.Component displayName() { public net.kyori.adventure.text.@NotNull Component displayName() {
return Bukkit.getServer().getItemFactory().displayName(this); return Bukkit.getServer().getItemFactory().displayName(this);
} }
+ +

Datei anzeigen

@ -194,8 +194,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * recipes. + * recipes.
* *
- * This includes it's name, description and other visible tags. - * This includes it's name, description and other visible tags.
- *
- * @return a AdvancementDisplay object, or null if not set.
+ * @return the display info + * @return the display info
+ */ */
- @Nullable
- AdvancementDisplay getDisplay();
+ @org.jetbrains.annotations.Nullable + @org.jetbrains.annotations.Nullable
+ io.papermc.paper.advancement.AdvancementDisplay getDisplay(); + io.papermc.paper.advancement.AdvancementDisplay getDisplay();
+ +
@ -205,13 +209,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * completes the advancement. Will return the same as + * completes the advancement. Will return the same as
+ * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an + * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an
+ * {@link io.papermc.paper.advancement.AdvancementDisplay} is present. + * {@link io.papermc.paper.advancement.AdvancementDisplay} is present.
* + *
- * @return a AdvancementDisplay object, or null if not set.
+ * @return the display name + * @return the display name
+ * @see io.papermc.paper.advancement.AdvancementDisplay#displayName() + * @see io.papermc.paper.advancement.AdvancementDisplay#displayName()
*/ + */
- @Nullable
- AdvancementDisplay getDisplay();
+ @NotNull net.kyori.adventure.text.Component displayName(); + @NotNull net.kyori.adventure.text.Component displayName();
+ +
+ /** + /**

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.amount = amount; this.amount = amount;
this.regainReason = regainReason; this.regainReason = regainReason;
+ this.isFastRegen = isFastRegen; // Paper + this.isFastRegen = isFastRegen; // Paper
+ } }
+
+ // Paper start - Add getter for isFastRegen + // Paper start - Add getter for isFastRegen
+ /** + /**
+ * Is this event a result of the fast regeneration mechanic + * Is this event a result of the fast regeneration mechanic
@ -35,8 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ public boolean isFastRegen() { + public boolean isFastRegen() {
+ return isFastRegen; + return isFastRegen;
} + }
+ // Paper end + // Paper end
+
/** /**
* Gets the amount of regained health * Gets the amount of regained health
*

Datei anzeigen

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void setConsumeArrow(boolean consumeArrow) { + public void setConsumeArrow(boolean consumeArrow) {
+ this.setConsumeItem(consumeArrow); + this.setConsumeItem(consumeArrow);
+ } + }
+
+ @Deprecated + @Deprecated
+ public boolean getConsumeArrow() { + public boolean getConsumeArrow() {
+ return this.shouldConsumeItem(); + return this.shouldConsumeItem();
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) { + public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) {
+ this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force); + this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force);
+ } + }
+
+ @Deprecated + @Deprecated
+ public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Entity projectile, final float force) { + public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Entity projectile, final float force) {
+ this(shooter, bow, arrowItem, projectile, EquipmentSlot.HAND, force, true); + this(shooter, bow, arrowItem, projectile, EquipmentSlot.HAND, force, true);

Datei anzeigen

@ -110,10 +110,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public WorldCreator(@NotNull String name) { public WorldCreator(@NotNull String name) {
- if (name == null) { - if (name == null) {
- throw new IllegalArgumentException("World name cannot be null"); - throw new IllegalArgumentException("World name cannot be null");
- }
-
- this.name = name;
- this.seed = (new Random()).nextLong();
+ // Paper start + // Paper start
+ this(name, getWorldKey(name)); + this(name, getWorldKey(name));
+ } }
+
+ private static NamespacedKey getWorldKey(String name) { + private static NamespacedKey getWorldKey(String name) {
+ final String mainLevelName = Bukkit.getUnsafe().getMainLevelName(); + final String mainLevelName = Bukkit.getUnsafe().getMainLevelName();
+ if (name.equals(mainLevelName)) { + if (name.equals(mainLevelName)) {
@ -124,10 +128,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return NamespacedKey.minecraft("the_end"); + return NamespacedKey.minecraft("the_end");
+ } else { + } else {
+ return NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_")); + return NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_"));
} + }
+ } + }
+
- this.name = name;
+ /** + /**
+ * Creates an empty WorldCreator for the given world name and key + * Creates an empty WorldCreator for the given world name and key
+ * + *
@ -139,7 +142,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ throw new IllegalArgumentException("World name and key cannot be null"); + throw new IllegalArgumentException("World name and key cannot be null");
+ } + }
+ this.name = levelName; + this.name = levelName;
this.seed = (new Random()).nextLong(); + this.seed = (new Random()).nextLong();
+ this.key = worldKey; + this.key = worldKey;
+ } + }
+ +
@ -183,8 +186,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull + @NotNull
+ public static WorldCreator ofKey(@NotNull NamespacedKey worldKey) { + public static WorldCreator ofKey(@NotNull NamespacedKey worldKey) {
+ return new WorldCreator(worldKey); + return new WorldCreator(worldKey);
} + }
+ // Paper end + // Paper end
+
/** /**
* Copies the options from the specified world * Copies the options from the specified world
*

Datei anzeigen

@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(entity, from, to); super(entity, from, to);
this.searchRadius = searchRadius; this.searchRadius = searchRadius;
+ this.type = org.bukkit.PortalType.CUSTOM; // Paper + this.type = org.bukkit.PortalType.CUSTOM; // Paper
+ } }
+
+ // Paper start + // Paper start
+ public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, final @NotNull org.bukkit.PortalType portalType) { + public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, final @NotNull org.bukkit.PortalType portalType) {
+ super(entity, from, to); + super(entity, from, to);
@ -63,11 +63,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Override + @Override
+ public void setTo(@Nullable final Location to) { + public void setTo(@Nullable final Location to) {
+ super.setTo(to); + super.setTo(to);
} + }
+ // Paper end + // Paper end
+
/** /**
* Set the Block radius to search in for available portals. * Set the Block radius to search in for available portals.
*
diff --git a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java

Datei anzeigen

@ -16,25 +16,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Removes the given ItemStacks from the storage contents of the inventory. + * Removes the given ItemStacks from the storage contents of the inventory.
+ * For removing ItemStacks from the inventories that have other content groups, + * For removing ItemStacks from the inventories that have other content groups,
+ * like Player inventories, see {@link #removeItemAnySlot(ItemStack...)}. + * like Player inventories, see {@link #removeItemAnySlot(ItemStack...)}.
* <p>
* It will try to remove 'as much as possible' from the types and amounts
* you give as arguments.
@@ -0,0 +0,0 @@ public interface Inventory extends Iterable<ItemStack> {
* @param items The ItemStacks to remove
* @return A HashMap containing items that couldn't be removed.
* @throws IllegalArgumentException if items is null
+ * @see #removeItemAnySlot(ItemStack...)
*/
@NotNull
public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+ // Paper start
+ /**
+ * Searches all possible inventory slots in order to remove the given ItemStacks.
+ * <p>
+ * Similar to {@link Inventory#removeItem(ItemStack...)} in behavior, except this
+ * method will check all possible slots in the inventory, rather than just the main
+ * storage contents.
+ * <p> + * <p>
+ * It will try to remove 'as much as possible' from the types and amounts + * It will try to remove 'as much as possible' from the types and amounts
+ * you give as arguments. + * you give as arguments.
@ -51,11 +32,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param items The ItemStacks to remove + * @param items The ItemStacks to remove
+ * @return A HashMap containing items that couldn't be removed. + * @return A HashMap containing items that couldn't be removed.
+ * @throws IllegalArgumentException if items is null + * @throws IllegalArgumentException if items is null
+ * @see #removeItemAnySlot(ItemStack...)
+ */ + */
+ @NotNull + @NotNull
+ public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+
+ // Paper start
+ /**
+ * Searches all possible inventory slots in order to remove the given ItemStacks.
+ * <p>
+ * Similar to {@link Inventory#removeItem(ItemStack...)} in behavior, except this
+ * method will check all possible slots in the inventory, rather than just the main
+ * storage contents.
* <p>
* It will try to remove 'as much as possible' from the types and amounts
* you give as arguments.
@@ -0,0 +0,0 @@ public interface Inventory extends Iterable<ItemStack> {
* @throws IllegalArgumentException if items is null
*/
@NotNull
- public HashMap<Integer, ItemStack> removeItem(@NotNull ItemStack... items) throws IllegalArgumentException;
+ public HashMap<Integer, ItemStack> removeItemAnySlot(@NotNull ItemStack... items) throws IllegalArgumentException; + public HashMap<Integer, ItemStack> removeItemAnySlot(@NotNull ItemStack... items) throws IllegalArgumentException;
+ // Paper end + // Paper end
+
/** /**
* Returns all ItemStacks from the inventory * Returns all ItemStacks from the inventory
*

Datei anzeigen

@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat @@ -0,0 +0,0 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat
* @return the name of the enchantment with {@code level} applied * @return the name of the enchantment with {@code level} applied
*/ */
public abstract @NotNull net.kyori.adventure.text.Component displayName(int level); public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
+ +
+ /** + /**
+ * Checks if this enchantment can be found in villager trades. + * Checks if this enchantment can be found in villager trades.

Datei anzeigen

@ -2194,7 +2194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- javaPlugin.init(loader, loader.server, description, dataFolder, file, this); - javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
+ javaPlugin.init(null, org.bukkit.Bukkit.getServer(), description, dataFolder, file, this); // Paper + javaPlugin.init(null, org.bukkit.Bukkit.getServer(), description, dataFolder, file, this); // Paper
+ } }
+ +
+ // Paper start + // Paper start
+ @Override + @Override
@ -2219,7 +2219,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Class<? extends org.bukkit.configuration.serialization.ConfigurationSerializable> serializable = clazz.asSubclass(org.bukkit.configuration.serialization.ConfigurationSerializable.class); + Class<? extends org.bukkit.configuration.serialization.ConfigurationSerializable> serializable = clazz.asSubclass(org.bukkit.configuration.serialization.ConfigurationSerializable.class);
+ org.bukkit.configuration.serialization.ConfigurationSerialization.unregisterClass(serializable); + org.bukkit.configuration.serialization.ConfigurationSerialization.unregisterClass(serializable);
+ } + }
} + }
+ +
+ @Override + @Override
+ public @Nullable io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup getGroup() { + public @Nullable io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup getGroup() {

Datei anzeigen

@ -8,6 +8,7 @@ Subject: [PATCH] Test changes
- Ignore package-private methods for nullability annotations - Ignore package-private methods for nullability annotations
- Add excludes for classes which don't pass - Add excludes for classes which don't pass
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
@ -146,6 +147,21 @@ diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bu
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java --- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java +++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -0,0 +0,0 @@ public class AnnotationTest {
"Lorg/jetbrains/annotations/Nullable;",
"Lorg/jetbrains/annotations/NotNull;",
"Lorg/jetbrains/annotations/Contract;",
- "Lorg/bukkit/UndefinedNullability;"
+ "Lorg/bukkit/UndefinedNullability;",
+ // Paper start
+ "Lorg/checkerframework/checker/nullness/qual/MonotonicNonNull;",
+ "Lorg/checkerframework/checker/nullness/qual/NonNull;",
+ "Lorg/checkerframework/checker/nullness/qual/Nullable;",
+ "Lorg/checkerframework/checker/nullness/qual/PolyNull;",
+ // Paper end
};
private static final String[] EXCLUDED_CLASSES = {
@@ -0,0 +0,0 @@ public class AnnotationTest { @@ -0,0 +0,0 @@ public class AnnotationTest {
"org/bukkit/util/io/Wrapper", "org/bukkit/util/io/Wrapper",
"org/bukkit/plugin/java/PluginClassLoader", "org/bukkit/plugin/java/PluginClassLoader",
@ -176,7 +192,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else if (method.invisibleTypeAnnotations != null) { + } else if (method.invisibleTypeAnnotations != null) {
+ dance: for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) { + dance: for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef); + final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_RETURN && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) { + if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_RETURN && java.util.Arrays.asList(ACCEPTED_ANNOTATIONS).contains(invisibleTypeAnnotation.desc)) {
+ warn = false; + warn = false;
+ break dance; // cha cha real smooth + break dance; // cha cha real smooth
+ } + }
@ -197,7 +213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (method.invisibleTypeAnnotations != null) { + if (method.invisibleTypeAnnotations != null) {
+ for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) { + for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef); + final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) { + if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.asList(ACCEPTED_ANNOTATIONS).contains(invisibleTypeAnnotation.desc)) {
+ continue dancing; + continue dancing;
+ } + }
+ } + }
@ -272,12 +288,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return true; + return true;
+ } + }
+ } + }
+
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
+ return false; + return false;
+ } + }
+ // Paper end + // Paper end
+
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
+ private static boolean isWellAnnotated(@Nullable List<? extends AnnotationNode> annotations) { // Paper + private static boolean isWellAnnotated(@Nullable List<? extends AnnotationNode> annotations) { // Paper
if (annotations == null) { if (annotations == null) {
return false; return false;

Datei anzeigen

@ -3400,12 +3400,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable java.util.UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable java.util.UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
+ +
+ } }
+ +
+ // Paper start + // Paper start
+ public int getPing() { + public int getPing() {
+ throw new UnsupportedOperationException( "Not supported yet." ); + throw new UnsupportedOperationException( "Not supported yet." );
} + }
+ // Paper end + // Paper end
} }
@ -3611,7 +3611,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public CustomTimingsHandler(@NotNull String name) { public CustomTimingsHandler(@NotNull String name) {
- this(name, null); - this(name, null);
- } - }
- + Timing timing;
- public CustomTimingsHandler(@NotNull String name, @Nullable CustomTimingsHandler parent) { - public CustomTimingsHandler(@NotNull String name, @Nullable CustomTimingsHandler parent) {
- this.name = name; - this.name = name;
- this.parent = parent; - this.parent = parent;
@ -3634,7 +3635,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- long avg = time / count; - long avg = time / count;
- -
- printStream.println(" " + timings.name + " Time: " + time + " Count: " + count + " Avg: " + avg + " Violations: " + timings.violations); - printStream.println(" " + timings.name + " Time: " + time + " Count: " + count + " Avg: " + avg + " Violations: " + timings.violations);
- } + new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace();
+ try {
+ final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class);
+ ofSafe.setAccessible(true);
+ timing = (Timing) ofSafe.invoke(null,"Minecraft", "(Deprecated API) " + name, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Bukkit.getLogger().log(Level.SEVERE, "This handler could not be registered");
+ timing = Timings.NULL_HANDLER;
}
- printStream.println("# Version " + Bukkit.getVersion()); - printStream.println("# Version " + Bukkit.getVersion());
- int entities = 0; - int entities = 0;
- int livingEntities = 0; - int livingEntities = 0;
@ -3644,8 +3654,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- printStream.println("# Entities " + entities); - printStream.println("# Entities " + entities);
- printStream.println("# LivingEntities " + livingEntities); - printStream.println("# LivingEntities " + livingEntities);
- } + handler = timing;
- }
- /** - /**
- * Resets all timings. - * Resets all timings.
- */ - */
@ -3657,7 +3668,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- TimingsCommand.timingStart = System.nanoTime(); - TimingsCommand.timingStart = System.nanoTime();
- } - }
- + public void startTiming() { handler.startTiming(); }
+ public void stopTiming() { handler.stopTiming(); }
- /** - /**
- * Ticked every tick by CraftBukkit to count the number of times a timer - * Ticked every tick by CraftBukkit to count the number of times a timer
- * caused TPS loss. - * caused TPS loss.
@ -3673,8 +3686,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- } - }
- } - }
+ Timing timing; -
- /** - /**
- * Starts timing to track a section of code. - * Starts timing to track a section of code.
- */ - */
@ -3685,19 +3697,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (parent != null && ++parent.timingDepth == 1) { - if (parent != null && ++parent.timingDepth == 1) {
- parent.start = start; - parent.start = start;
- } - }
+ new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace(); - }
+ try { - }
+ final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class); -
+ ofSafe.setAccessible(true);
+ timing = (Timing) ofSafe.invoke(null,"Minecraft", "(Deprecated API) " + name, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Bukkit.getLogger().log(Level.SEVERE, "This handler could not be registered");
+ timing = Timings.NULL_HANDLER;
}
+ handler = timing;
}
- /** - /**
- * Stops timing a section of code. - * Stops timing a section of code.
- */ - */
@ -3716,9 +3718,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- } - }
- } - }
+ public void startTiming() { handler.startTiming(); } -
+ public void stopTiming() { handler.stopTiming(); }
- /** - /**
- * Reset this timer, setting all values to zero. - * Reset this timer, setting all values to zero.
- */ - */

Datei anzeigen

@ -146,13 +146,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void disconnect(final Component reason) { public void disconnect(final Component reason) {
- this.disconnect(PaperAdventure.asAdventure(reason)); - this.disconnect(PaperAdventure.asAdventure(reason));
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); + this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
+ }
+
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
} }
- public void disconnect(net.kyori.adventure.text.Component reason) { - public void disconnect(net.kyori.adventure.text.Component reason) {
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
+ }
+
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) { + public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
// Paper end // Paper end
// CraftBukkit start - fire PlayerKickEvent // CraftBukkit start - fire PlayerKickEvent

Datei anzeigen

@ -48,8 +48,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ }); + });
+ } + }
+
+ } }
+ private void callPlayerUseUnknownEntityEvent(ServerboundInteractPacket packet, InteractionHand hand) { + private void callPlayerUseUnknownEntityEvent(ServerboundInteractPacket packet, InteractionHand hand) {
+ this.cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( + this.cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
@ -58,8 +58,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ packet.getActionType() == ServerboundInteractPacket.ActionType.ATTACK, + packet.getActionType() == ServerboundInteractPacket.ActionType.ATTACK,
+ hand == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND + hand == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
+ )); + ));
} + }
+ // Paper end + // Paper end
+
@Override @Override
public void handleClientCommand(ServerboundClientCommandPacket packet) { public void handleClientCommand(ServerboundClientCommandPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());

Datei anzeigen

@ -60,16 +60,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ return chunk.bukkitChunk; + return chunk.bukkitChunk;
+ // Paper end + // Paper end
+ } }
+
+ // Paper start + // Paper start
+ private void addTicket(int x, int z) { + private void addTicket(int x, int z) {
+ io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper + io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
} + }
+ // Paper end + // Paper end
+
@Override @Override
public Chunk getChunkAt(Block block) { public Chunk getChunkAt(Block block) {
Preconditions.checkArgument(block != null, "null block");
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public boolean unloadChunkRequest(int x, int z) { public boolean unloadChunkRequest(int x, int z) {
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot

Datei anzeigen

@ -35,18 +35,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+ } + }
+ // Paper end + // Paper end
+ } }
+
+ // Paper start + // Paper start
+ @Override + @Override
+ public void addAdditionalSaveData(CompoundTag nbt) { + public void addAdditionalSaveData(CompoundTag nbt) {
+ super.addAdditionalSaveData(nbt); + super.addAdditionalSaveData(nbt);
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); + nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
} + }
+ // Paper end + // Paper end
+
@Override @Override
public void setItemSlot(EquipmentSlot slot, ItemStack stack) { public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
super.setItemSlot(slot, stack);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java

Datei anzeigen

@ -39,9 +39,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (!this.isSilent()) { - if (!this.isSilent()) {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.WITCH_DRINK, this.getSoundSource(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F); - this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.WITCH_DRINK, this.getSoundSource(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F);
- } - }
-
- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
-
- attributemodifiable.removeModifier(Witch.SPEED_MODIFIER_DRINKING); - attributemodifiable.removeModifier(Witch.SPEED_MODIFIER_DRINKING);
- attributemodifiable.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING); - attributemodifiable.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING);
} }

Datei anzeigen

@ -137,9 +137,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public AdvancementDisplay getDisplay() { - public AdvancementDisplay getDisplay() {
- if (this.handle.getDisplay() == null) { - if (this.handle.getDisplay() == null) {
- return null; - return null;
- }
-
- return new CraftAdvancementDisplay(this.handle.getDisplay());
+ public io.papermc.paper.advancement.AdvancementDisplay getDisplay() { + public io.papermc.paper.advancement.AdvancementDisplay getDisplay() {
+ return this.handle.getDisplay() == null ? null : this.handle.getDisplay().paper; + return this.handle.getDisplay() == null ? null : this.handle.getDisplay().paper;
+ } }
+ +
+ @Deprecated @io.papermc.paper.annotation.DoNotUse + @Deprecated @io.papermc.paper.annotation.DoNotUse
+ public AdvancementDisplay getDisplay0() { // May be called by plugins via Commodore + public AdvancementDisplay getDisplay0() { // May be called by plugins via Commodore
@ -161,11 +164,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final var children = com.google.common.collect.ImmutableList.<org.bukkit.advancement.Advancement>builder(); + final var children = com.google.common.collect.ImmutableList.<org.bukkit.advancement.Advancement>builder();
+ for (Advancement advancement : this.handle.getChildren()) { + for (Advancement advancement : this.handle.getChildren()) {
+ children.add(advancement.bukkit); + children.add(advancement.bukkit);
} + }
+ return children.build(); + return children.build();
+ } + }
+
- return new CraftAdvancementDisplay(this.handle.getDisplay());
+ @Override + @Override
+ public org.bukkit.advancement.Advancement getRoot() { + public org.bukkit.advancement.Advancement getRoot() {
+ Advancement advancement = this.handle; + Advancement advancement = this.handle;
@ -173,7 +175,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ advancement = advancement.getParent(); + advancement = advancement.getParent();
+ } + }
+ return advancement.bukkit; + return advancement.bukkit;
} + }
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java

Datei anzeigen

@ -2322,13 +2322,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- @Deprecated - @Deprecated
- public void disconnect(Component reason) { - public void disconnect(Component reason) {
- this.disconnect(CraftChatMessage.fromComponent(reason)); - this.disconnect(CraftChatMessage.fromComponent(reason));
+ public void disconnect(String s) { - }
- // CraftBukkit end
-
public void disconnect(String s) {
+ // Paper start + // Paper start
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s)); + this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
} + }
- // CraftBukkit end +
- public void disconnect(String s) {
+ public void disconnect(final Component reason) { + public void disconnect(final Component reason) {
+ this.disconnect(PaperAdventure.asAdventure(reason)); + this.disconnect(PaperAdventure.asAdventure(reason));
+ } + }
@ -2809,13 +2810,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start + // Paper start
+ @Override @Override
+ public net.kyori.adventure.text.Component shutdownMessage() { + public net.kyori.adventure.text.Component shutdownMessage() {
+ String msg = getShutdownMessage(); + String msg = getShutdownMessage();
+ return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null; + return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null;
+ } + }
+ // Paper end + // Paper end
@Override + @Override
+ @Deprecated // Paper + @Deprecated // Paper
public String getShutdownMessage() { public String getShutdownMessage() {
return this.configuration.getString("settings.shutdown-message"); return this.configuration.getString("settings.shutdown-message");
@ -2892,12 +2893,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start + // Paper start
+ @Override @Override
+ public Merchant createMerchant(net.kyori.adventure.text.Component title) { + public Merchant createMerchant(net.kyori.adventure.text.Component title) {
+ return new org.bukkit.craftbukkit.inventory.CraftMerchantCustom(title == null ? InventoryType.MERCHANT.defaultTitle() : title); + return new org.bukkit.craftbukkit.inventory.CraftMerchantCustom(title == null ? InventoryType.MERCHANT.defaultTitle() : title);
+ } + }
+ // Paper end + // Paper end
@Override + @Override
+ @Deprecated // Paper + @Deprecated // Paper
public Merchant createMerchant(String title) { public Merchant createMerchant(String title) {
return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title);

Datei anzeigen

@ -31,13 +31,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Entity item = ((org.bukkit.craftbukkit.entity.CraftItem) bukkit).getHandle(); + Entity item = ((org.bukkit.craftbukkit.entity.CraftItem) bukkit).getHandle();
+ item.level.addFreshEntity(item); + item.level.addFreshEntity(item);
+ } + }
+ } }
+ } else { + } else {
+ for (Item bukkit : list) { + for (Item bukkit : list) {
+ if (bukkit.isValid()) { + if (bukkit.isValid()) {
+ bukkit.remove(); + bukkit.remove();
+ } + }
} + }
+ // Paper end + // Paper end
} }
} }

Datei anzeigen

@ -21,10 +21,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - let's make sure the implementation isn't as slow as possible + // Paper start - let's make sure the implementation isn't as slow as possible
+ int offX = chunkPos.x << 4; + int offX = chunkPos.x << 4;
+ int offZ = chunkPos.z << 4; + int offZ = chunkPos.z << 4;
+
- while (iterator.hasNext()) {
- BlockPos blockposition = (BlockPos) iterator.next();
+ int minChunkSection = io.papermc.paper.util.WorldUtil.getMinSection(world); + int minChunkSection = io.papermc.paper.util.WorldUtil.getMinSection(world);
+ int maxChunkSection = io.papermc.paper.util.WorldUtil.getMaxSection(world); + int maxChunkSection = io.papermc.paper.util.WorldUtil.getMaxSection(world);
+
- if (((ChunkAccess) object1).getBlockState(blockposition).getLightEmission() != 0) {
- protochunk.addLight(blockposition);
+ LevelChunkSection[] sections = achunksection; + LevelChunkSection[] sections = achunksection;
+ for (int sectionY = minChunkSection; sectionY <= maxChunkSection; ++sectionY) { + for (int sectionY = minChunkSection; sectionY <= maxChunkSection; ++sectionY) {
+ LevelChunkSection section = sections[sectionY - minChunkSection]; + LevelChunkSection section = sections[sectionY - minChunkSection];
@ -33,16 +37,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ continue; + continue;
+ } + }
+ int offY = sectionY << 4; + int offY = sectionY << 4;
+
- while (iterator.hasNext()) {
- BlockPos blockposition = (BlockPos) iterator.next();
+ for (int index = 0; index < (16 * 16 * 16); ++index) { + for (int index = 0; index < (16 * 16 * 16); ++index) {
+ if (section.states.get(index).getLightEmission() <= 0) { + if (section.states.get(index).getLightEmission() <= 0) {
+ continue; + continue;
+ } + }
+
- if (((ChunkAccess) object1).getBlockState(blockposition).getLightEmission() != 0) {
- protochunk.addLight(blockposition);
+ // index = x | (z << 4) | (y << 8) + // index = x | (z << 4) | (y << 8)
+ protochunk.addLight(new BlockPos(offX | (index & 15), offY | (index >>> 8), offZ | ((index >>> 4) & 15))); + protochunk.addLight(new BlockPos(offX | (index & 15), offY | (index >>> 8), offZ | ((index >>> 4) & 15)));
} }

Datei anzeigen

@ -1388,8 +1388,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.addPresetValues(); + this.addPresetValues();
+ return object == null ? -1 : data2.palette.idFor(object); + return object == null ? -1 : data2.palette.idFor(object);
+ // Paper end + // Paper end
+ } }
+
+ // Paper start - Anti-Xray - Add preset values + // Paper start - Anti-Xray - Add preset values
+ private void addPresetValues() { + private void addPresetValues() {
+ if (this.presetValues != null && this.data.configuration().factory() != PalettedContainer.Strategy.GLOBAL_PALETTE_FACTORY) { + if (this.presetValues != null && this.data.configuration().factory() != PalettedContainer.Strategy.GLOBAL_PALETTE_FACTORY) {
@ -1397,11 +1397,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.data.palette.idFor(presetValue); + this.data.palette.idFor(presetValue);
+ } + }
+ } + }
} + }
+ // Paper end + // Paper end
+
public T getAndSet(int x, int y, int z, T value) { public T getAndSet(int x, int y, int z, T value) {
this.acquire(); this.acquire();
@@ -0,0 +0,0 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer @@ -0,0 +0,0 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
data.palette.read(buf); data.palette.read(buf);
buf.readLongArray(data.storage.getRaw()); buf.readLongArray(data.storage.getRaw());
@ -1414,10 +1415,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start - Anti-Xray - Add chunk packet info + // Paper start - Anti-Xray - Add chunk packet info
+ @Override
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); }
@Override @Override
- public void write(FriendlyByteBuf buf) { - public void write(FriendlyByteBuf buf) {
+ @Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); }
+ @Override
+ public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) { + public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) {
this.acquire(); this.acquire();

Datei anzeigen

@ -49,12 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (stringreader.canRead() && stringreader.peek() == '/') { if (stringreader.canRead() && stringreader.peek() == '/') {
stringreader.skip(); stringreader.skip();
} }
-
- ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
-
- this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
- if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
- this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestions));
+ final String command = packet.getCommand(); + final String command = packet.getCommand();
+ final com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), command, true, null); + final com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), command, true, null);
+ event.callEvent(); + event.callEvent();
@ -62,10 +56,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // If the event isn't handled, we can assume that we have no completions, and so we'll ask the server + // If the event isn't handled, we can assume that we have no completions, and so we'll ask the server
+ if (!event.isHandled()) { + if (!event.isHandled()) {
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+
- ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
+ this.server.scheduleOnMain(() -> { // This needs to be on main + this.server.scheduleOnMain(() -> { // This needs to be on main
+ ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); + ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
+
- this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
- if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
- this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestions));
+ this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { + this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
+ if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer + if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
+ this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestions)); + this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestions));

Datei anzeigen

@ -509,7 +509,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else { } else {
- this.usedSectors.force(i1, j1); - this.usedSectors.force(i1, j1);
+ //this.usedSectors.force(i1, j1); // Paper - move this down so we can check if it fails to allocate + //this.usedSectors.force(i1, j1); // Paper - move this down so we can check if it fails to allocate
+ } }
+ // Paper start - recalculate header on header corruption + // Paper start - recalculate header on header corruption
+ if (offset < 2 || sectorLength <= 0 || ((long)offset * 4096L) > regionFileSize) { + if (offset < 2 || sectorLength <= 0 || ((long)offset * 4096L) > regionFileSize) {
+ if (canRecalcHeader) { + if (canRecalcHeader) {
@ -532,7 +532,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean failedToAllocate = !this.usedSectors.tryAllocate(offset, sectorLength); + boolean failedToAllocate = !this.usedSectors.tryAllocate(offset, sectorLength);
+ if (failedToAllocate) { + if (failedToAllocate) {
+ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.regionFile.toAbsolutePath()); + LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.regionFile.toAbsolutePath());
} + }
+ if (failedToAllocate & !canRecalcHeader) { + if (failedToAllocate & !canRecalcHeader) {
+ // location = chunkX | (chunkZ << 5); + // location = chunkX | (chunkZ << 5);
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() + + LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() +

Datei anzeigen

@ -31,19 +31,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- // CraftBukkit start - // CraftBukkit start
- if (worldserver.getWorld().getKeepSpawnInMemory()) { - if (worldserver.getWorld().getKeepSpawnInMemory()) {
- chunkproviderserver.addRegionTicket(TicketType.START, new ChunkPos(blockposition), 11, Unit.INSTANCE); - chunkproviderserver.addRegionTicket(TicketType.START, new ChunkPos(blockposition), 11, Unit.INSTANCE);
-
- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTime = SystemUtils.getMillis() + 10L;
- this.executeModerately();
- }
- }
+ // Paper start - configurable spawn reason + // Paper start - configurable spawn reason
+ int radiusBlocks = worldserver.paperConfig().spawn.keepSpawnLoadedRange * 16; + int radiusBlocks = worldserver.paperConfig().spawn.keepSpawnLoadedRange * 16;
+ int radiusChunks = radiusBlocks / 16 + ((radiusBlocks & 15) != 0 ? 1 : 0); + int radiusChunks = radiusBlocks / 16 + ((radiusBlocks & 15) != 0 ? 1 : 0);
+ int totalChunks = ((radiusChunks) * 2 + 1); + int totalChunks = ((radiusChunks) * 2 + 1);
+ totalChunks *= totalChunks; + totalChunks *= totalChunks;
+ worldloadlistener.setChunkRadius(radiusBlocks / 16); + worldloadlistener.setChunkRadius(radiusBlocks / 16);
+
- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTime = SystemUtils.getMillis() + 10L;
- this.executeModerately();
- }
- }
+ worldserver.addTicketsForSpawn(radiusBlocks, blockposition); + worldserver.addTicketsForSpawn(radiusBlocks, blockposition);
+ // Paper end + // Paper end

Datei anzeigen

@ -264,14 +264,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start + // Paper start
+ if (this.getUnhappyCounter() > 0) { + if (this.getUnhappyCounter() > 0) {
+ this.setUnhappyCounter(this.getUnhappyCounter() - 1); + this.setUnhappyCounter(this.getUnhappyCounter() - 1);
+ } }
+ if (this.isEffectiveAi()) { + if (this.isEffectiveAi()) {
+ if (level.spigotConfig.tickInactiveVillagers) { + if (level.spigotConfig.tickInactiveVillagers) {
+ this.customServerAiStep(); + this.customServerAiStep();
+ } else { + } else {
+ this.mobTick(true); + this.mobTick(true);
+ } + }
} + }
+ maybeDecayGossip(); + maybeDecayGossip();
+ // Paper end + // Paper end
+ +
@ -569,12 +569,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public static boolean checkEntityImmunities(Entity entity) - public static boolean checkEntityImmunities(Entity entity)
+ public static int checkEntityImmunities(Entity entity) // Paper - return # of ticks to get immunity + public static int checkEntityImmunities(Entity entity) // Paper - return # of ticks to get immunity
{ {
- // quick checks.
- if ( entity.wasTouchingWater || entity.remainingFireTicks > 0 )
- {
- return true;
+ // Paper start + // Paper start
+ SpigotWorldConfig config = entity.level.spigotConfig; + SpigotWorldConfig config = entity.level.spigotConfig;
+ int inactiveWakeUpImmunity = checkInactiveWakeup(entity); + int inactiveWakeUpImmunity = checkInactiveWakeup(entity);
+ if (inactiveWakeUpImmunity > -1) { + if (inactiveWakeUpImmunity > -1) {
+ return inactiveWakeUpImmunity; + return inactiveWakeUpImmunity;
+ } }
+ if (entity.remainingFireTicks > 0) { + if (entity.remainingFireTicks > 0) {
+ return 2; + return 2;
+ } + }
@ -583,18 +587,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ long inactiveFor = MinecraftServer.currentTick - entity.activatedTick; + long inactiveFor = MinecraftServer.currentTick - entity.activatedTick;
+ // Paper end + // Paper end
// quick checks. + // quick checks.
- if ( entity.wasTouchingWater || entity.remainingFireTicks > 0 )
+ if ( (entity.activationType != ActivationType.WATER && entity.wasTouchingWater && entity.isPushedByFluid()) ) // Paper + if ( (entity.activationType != ActivationType.WATER && entity.wasTouchingWater && entity.isPushedByFluid()) ) // Paper
{ + {
- return true;
+ return 100; // Paper + return 100; // Paper
+ } + }
+ // Paper start + // Paper start
+ if ( !entity.isOnGround() || entity.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D ) + if ( !entity.isOnGround() || entity.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D )
+ { + {
+ return 100; + return 100;
} + }
+ // Paper end + // Paper end
if ( !( entity instanceof AbstractArrow ) ) if ( !( entity instanceof AbstractArrow ) )
{ {
@ -624,7 +626,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
{ {
- return true; - return true;
+ return 20; // Paper + return 20; // Paper
+ } }
- if ( entity instanceof Villager && ( (Villager) entity ).canBreed() )
+ // Paper start + // Paper start
+ if (entity instanceof Bee) { + if (entity instanceof Bee) {
+ Bee bee = (Bee)entity; + Bee bee = (Bee)entity;
@ -652,8 +655,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return config.villagersWorkImmunityFor; + return config.villagersWorkImmunityFor;
+ } + }
+ } + }
} + }
- if ( entity instanceof Villager && ( (Villager) entity ).canBreed() )
+ if ( entity instanceof Llama && ( (Llama) entity ).inCaravan() ) + if ( entity instanceof Llama && ( (Llama) entity ).inCaravan() )
{ {
- return true; - return true;
@ -677,11 +679,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entity instanceof Creeper && ((Creeper) entity).isIgnited()) { // isExplosive if (entity instanceof Creeper && ((Creeper) entity).isIgnited()) { // isExplosive
- return true; - return true;
+ return 20; // Paper + return 20; // Paper
+ } }
+ // Paper start + // Paper start
+ if (entity instanceof Mob && ((Mob) entity).targetSelector.hasTasks() ) { + if (entity instanceof Mob && ((Mob) entity).targetSelector.hasTasks() ) {
+ return 0; + return 0;
} + }
+ if (entity instanceof Pillager) { + if (entity instanceof Pillager) {
+ Pillager pillager = (Pillager) entity; + Pillager pillager = (Pillager) entity;
+ // TODO:? + // TODO:?

Datei anzeigen

@ -37,12 +37,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private org.bukkit.util.Vector origin; + private org.bukkit.util.Vector origin;
+ @javax.annotation.Nullable + @javax.annotation.Nullable
+ private UUID originWorld; + private UUID originWorld;
+
+ public void setOrigin(@javax.annotation.Nonnull Location location) { + public void setOrigin(@javax.annotation.Nonnull Location location) {
+ this.origin = location.toVector(); + this.origin = location.toVector();
+ this.originWorld = location.getWorld().getUID(); + this.originWorld = location.getWorld().getUID();
+ } + }
+
+ @javax.annotation.Nullable + @javax.annotation.Nullable
+ public org.bukkit.util.Vector getOriginVector() { + public org.bukkit.util.Vector getOriginVector() {
+ return this.origin != null ? this.origin.clone() : null; + return this.origin != null ? this.origin.clone() : null;

Datei anzeigen

@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public java.util.UUID sourceEntityId; + public java.util.UUID sourceEntityId;
+ public java.util.UUID triggerEntityId; + public java.util.UUID triggerEntityId;
+ public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN;
+
+ private void loadPaperNBT(CompoundTag nbttagcompound) { + private void loadPaperNBT(CompoundTag nbttagcompound) {
+ if (!nbttagcompound.contains("Paper.ExpData", 10)) { // 10 = compound + if (!nbttagcompound.contains("Paper.ExpData", 10)) { // 10 = compound
+ return; + return;
@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ nbttagcompound.put("Paper.ExpData", comp); + nbttagcompound.put("Paper.ExpData", comp);
+ } + }
+
+ @io.papermc.paper.annotation.DoNotUse + @io.papermc.paper.annotation.DoNotUse
+ @Deprecated + @Deprecated
public ExperienceOrb(Level world, double x, double y, double z, int amount) { public ExperienceOrb(Level world, double x, double y, double z, int amount) {

Datei anzeigen

@ -112,8 +112,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return ImmutableList.copyOf(this.profilesByUUID.values()).stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit((long) limit); - return ImmutableList.copyOf(this.profilesByUUID.values()).stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit((long) limit);
+ // Paper start - allow better concurrency + // Paper start - allow better concurrency
+ return this.listTopMRUProfiles(limit).stream(); + return this.listTopMRUProfiles(limit).stream();
+ } }
+
+ private List<GameProfileCache.GameProfileInfo> listTopMRUProfiles(int limit) { + private List<GameProfileCache.GameProfileInfo> listTopMRUProfiles(int limit) {
+ try { + try {
+ this.stateLock.lock(); + this.stateLock.lock();
@ -121,8 +121,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } finally { + } finally {
+ this.stateLock.unlock(); + this.stateLock.unlock();
+ } + }
} + }
+ // Paper end + // Paper end
+
private static JsonElement writeGameProfile(GameProfileCache.GameProfileInfo entry, DateFormat dateFormat) { private static JsonElement writeGameProfile(GameProfileCache.GameProfileInfo entry, DateFormat dateFormat) {
JsonObject jsonobject = new JsonObject(); JsonObject jsonobject = new JsonObject();

Datei anzeigen

@ -197,7 +197,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (chunk instanceof ImposterProtoChunk) { - if (chunk instanceof ImposterProtoChunk) {
- // We then cycle through again to get the full chunk immediately, rather than after the ticket addition - // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
- chunk = this.world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); - chunk = this.world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
- }
+ if (!generate) { + if (!generate) {
+ ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z); + ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z);
+ if (immediate == null) { + if (immediate == null) {
@ -211,10 +210,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ world.getChunk(x, z); // make sure we're at ticket level 32 or lower + world.getChunk(x, z); // make sure we're at ticket level 32 or lower
+ return true; + return true;
+ } + }
+
- if (chunk instanceof net.minecraft.world.level.chunk.LevelChunk) {
- this.world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
- return true;
+ net.minecraft.world.level.chunk.storage.RegionFile file; + net.minecraft.world.level.chunk.storage.RegionFile file;
+ try { + try {
+ file = world.getChunkSource().chunkMap.regionFileCache.getRegionFile(chunkPos, false); + file = world.getChunkSource().chunkMap.regionFileCache.getRegionFile(chunkPos, false);
@ -236,6 +232,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // we do this so we do not re-read the chunk data on disk + // we do this so we do not re-read the chunk data on disk
} }
- if (chunk instanceof net.minecraft.world.level.chunk.LevelChunk) {
- this.world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
- return true;
- }
-
- return false; - return false;
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE); + world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
+ world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); + world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);

Datei anzeigen

@ -27,14 +27,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d8 = d5 - this.vehicleFirstGoodZ; double d8 = d5 - this.vehicleFirstGoodZ;
double d9 = entity.getDeltaMovement().lengthSqr(); double d9 = entity.getDeltaMovement().lengthSqr();
- double d10 = d6 * d6 + d7 * d7 + d8 * d8; - double d10 = d6 * d6 + d7 * d7 + d8 * d8;
-
+ // Paper start - fix large move vectors killing the server + // Paper start - fix large move vectors killing the server
+ double currDeltaX = toX - fromX; + double currDeltaX = toX - fromX;
+ double currDeltaY = toY - fromY; + double currDeltaY = toY - fromY;
+ double currDeltaZ = toZ - fromZ; + double currDeltaZ = toZ - fromZ;
+ double d10 = Math.max(d6 * d6 + d7 * d7 + d8 * d8, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); + double d10 = Math.max(d6 * d6 + d7 * d7 + d8 * d8, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1);
+ // Paper end - fix large move vectors killing the server + // Paper end - fix large move vectors killing the server
+
+ // Paper start - fix large move vectors killing the server + // Paper start - fix large move vectors killing the server
+ double otherFieldX = d3 - this.vehicleLastGoodX; + double otherFieldX = d3 - this.vehicleLastGoodX;
+ double otherFieldY = d4 - this.vehicleLastGoodY - 1.0E-6D; + double otherFieldY = d4 - this.vehicleLastGoodY - 1.0E-6D;

Datei anzeigen

@ -328,21 +328,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register( private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
- Material blockType, - Material blockType,
- Class<B> blockStateType,
- BiFunction<World, T, B> blockStateConstructor,
- BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
- ) {
- CraftBlockStates.register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
- }
-
- private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
- List<Material> blockTypes,
+ net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType, // Paper + net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType, // Paper
Class<B> blockStateType, Class<B> blockStateType,
- BiFunction<World, T, B> blockStateConstructor, - BiFunction<World, T, B> blockStateConstructor,
- BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor - BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
+ BiFunction<World, T, B> blockStateConstructor // Paper + BiFunction<World, T, B> blockStateConstructor // Paper
) { ) {
- CraftBlockStates.register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
- }
-
- private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
- List<Material> blockTypes,
- Class<B> blockStateType,
- BiFunction<World, T, B> blockStateConstructor,
- BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
- ) {
- BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, tileEntityConstructor); - BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, tileEntityConstructor);
- for (Material blockType : blockTypes) { - for (Material blockType : blockTypes) {
- CraftBlockStates.register(blockType, factory); - CraftBlockStates.register(blockType, factory);

Datei anzeigen

@ -185,7 +185,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ for ( int i = 0; i < tps.length; i++) { + for ( int i = 0; i < tps.length; i++) {
+ tpsAvg[i] = TicksPerSecondCommand.format( tps[i] ); + tpsAvg[i] = TicksPerSecondCommand.format( tps[i] );
+ } }
- sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
- sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: "
- + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
+ sender.sendMessage(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", ")); + sender.sendMessage(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
+ if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) { + if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) {
+ sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: " + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)"); + sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: " + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
@ -193,10 +196,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ sender.sendMessage(ChatColor.RED + "Warning: " + ChatColor.GOLD + " Memory usage on modern garbage collectors is not a stable value and it is perfectly normal to see it reach max. Please do not pay it much attention."); + sender.sendMessage(ChatColor.RED + "Warning: " + ChatColor.GOLD + " Memory usage on modern garbage collectors is not a stable value and it is perfectly normal to see it reach max. Please do not pay it much attention.");
+ hasShownMemoryWarning = true; + hasShownMemoryWarning = true;
+ } + }
} + }
- sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
- sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: "
- + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
+ // Paper end + // Paper end
return true; return true;

Datei anzeigen

@ -130,7 +130,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- ListTag list = CraftItemStack.getEnchantmentList(this.handle), listCopy; - ListTag list = CraftItemStack.getEnchantmentList(this.handle), listCopy;
- if (list == null) { - if (list == null) {
- return 0; - return 0;
- } + // Paper start - replace entire method
+ int level = getEnchantmentLevel(ench);
+ if (level > 0) {
+ final ItemMeta itemMeta = this.getItemMeta();
+ if (itemMeta == null) return 0;
+ itemMeta.removeEnchant(ench);
+ this.setItemMeta(itemMeta);
}
- int index = Integer.MIN_VALUE; - int index = Integer.MIN_VALUE;
- int level = Integer.MIN_VALUE; - int level = Integer.MIN_VALUE;
- int size = list.size(); - int size = list.size();
@ -162,14 +169,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (i != index) { - if (i != index) {
- listCopy.add(list.get(i)); - listCopy.add(list.get(i));
- } - }
+ // Paper start - replace entire method - }
+ int level = getEnchantmentLevel(ench);
+ if (level > 0) {
+ final ItemMeta itemMeta = this.getItemMeta();
+ if (itemMeta == null) return 0;
+ itemMeta.removeEnchant(ench);
+ this.setItemMeta(itemMeta);
}
- this.handle.getTag().put(ENCHANTMENTS.NBT, listCopy); - this.handle.getTag().put(ENCHANTMENTS.NBT, listCopy);
+ // Paper end + // Paper end

Datei anzeigen

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - optimise collisions + // Paper start - optimise collisions
+ static final UnsafeList<AABB> TEMP_COLLISION_LIST = new UnsafeList<>(1024); + static final UnsafeList<AABB> TEMP_COLLISION_LIST = new UnsafeList<>(1024);
+ static boolean tempCollisionListInUse; + static boolean tempCollisionListInUse;
+
+ public static UnsafeList<AABB> getTempCollisionList() { + public static UnsafeList<AABB> getTempCollisionList() {
+ if (!Bukkit.isPrimaryThread() || tempCollisionListInUse) { + if (!Bukkit.isPrimaryThread() || tempCollisionListInUse) {
+ return new UnsafeList<>(16); + return new UnsafeList<>(16);
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ((UnsafeList)list).setSize(0); + ((UnsafeList)list).setSize(0);
+ tempCollisionListInUse = false; + tempCollisionListInUse = false;
+ } + }
+
+ static final UnsafeList<Entity> TEMP_GET_ENTITIES_LIST = new UnsafeList<>(1024); + static final UnsafeList<Entity> TEMP_GET_ENTITIES_LIST = new UnsafeList<>(1024);
+ static boolean tempGetEntitiesListInUse; + static boolean tempGetEntitiesListInUse;
+ +
@ -1277,29 +1277,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- boolean flag1 = movement.y != vec3d1.y; - boolean flag1 = movement.y != vec3d1.y;
- boolean flag2 = movement.z != vec3d1.z; - boolean flag2 = movement.z != vec3d1.z;
- boolean flag3 = this.onGround || flag1 && movement.y < 0.0D; - boolean flag3 = this.onGround || flag1 && movement.y < 0.0D;
-
- if (this.maxUpStep() > 0.0F && flag3 && (flag || flag2)) {
- Vec3 vec3d2 = Entity.collideBoundingBox(this, new Vec3(movement.x, (double) this.maxUpStep(), movement.z), axisalignedbb, this.level, list);
- Vec3 vec3d3 = Entity.collideBoundingBox(this, new Vec3(0.0D, (double) this.maxUpStep(), 0.0D), axisalignedbb.expandTowards(movement.x, 0.0D, movement.z), this.level, list);
-
- if (vec3d3.y < (double) this.maxUpStep()) {
- Vec3 vec3d4 = Entity.collideBoundingBox(this, new Vec3(movement.x, 0.0D, movement.z), axisalignedbb.move(vec3d3), this.level, list).add(vec3d3);
-
- if (vec3d4.horizontalDistanceSqr() > vec3d2.horizontalDistanceSqr()) {
- vec3d2 = vec3d4;
+ // Paper start - optimise collisions + // Paper start - optimise collisions
+ // This is a copy of vanilla's except that it uses strictly AABB math + // This is a copy of vanilla's except that it uses strictly AABB math
+ if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) { + if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) {
+ return movement; + return movement;
+ } + }
+
- if (this.maxUpStep() > 0.0F && flag3 && (flag || flag2)) {
- Vec3 vec3d2 = Entity.collideBoundingBox(this, new Vec3(movement.x, (double) this.maxUpStep(), movement.z), axisalignedbb, this.level, list);
- Vec3 vec3d3 = Entity.collideBoundingBox(this, new Vec3(0.0D, (double) this.maxUpStep(), 0.0D), axisalignedbb.expandTowards(movement.x, 0.0D, movement.z), this.level, list);
+ final Level world = this.level; + final Level world = this.level;
+ final AABB currBoundingBox = this.getBoundingBox(); + final AABB currBoundingBox = this.getBoundingBox();
+
- if (vec3d3.y < (double) this.maxUpStep()) {
- Vec3 vec3d4 = Entity.collideBoundingBox(this, new Vec3(movement.x, 0.0D, movement.z), axisalignedbb.move(vec3d3), this.level, list).add(vec3d3);
+ if (io.papermc.paper.util.CollisionUtil.isEmpty(currBoundingBox)) { + if (io.papermc.paper.util.CollisionUtil.isEmpty(currBoundingBox)) {
+ return movement; + return movement;
+ } + }
+
- if (vec3d4.horizontalDistanceSqr() > vec3d2.horizontalDistanceSqr()) {
- vec3d2 = vec3d4;
+ final List<AABB> potentialCollisions = io.papermc.paper.util.CachedLists.getTempCollisionList(); + final List<AABB> potentialCollisions = io.papermc.paper.util.CachedLists.getTempCollisionList();
+ try { + try {
+ final double stepHeight = (double)this.maxUpStep(); + final double stepHeight = (double)this.maxUpStep();
@ -1326,15 +1323,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (vec3d2.horizontalDistanceSqr() > vec3d1.horizontalDistanceSqr()) { - if (vec3d2.horizontalDistanceSqr() > vec3d1.horizontalDistanceSqr()) {
- return vec3d2.add(Entity.collideBoundingBox(this, new Vec3(0.0D, -vec3d2.y + movement.y, 0.0D), axisalignedbb.move(vec3d2), this.level, list)); - return vec3d2.add(Entity.collideBoundingBox(this, new Vec3(0.0D, -vec3d2.y + movement.y, 0.0D), axisalignedbb.move(vec3d2), this.level, list));
- }
- }
+ io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, + io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks,
+ false, false, null, null); + false, false, null, null);
+
+ if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) {
+ io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions);
}
- }
- return vec3d1; - return vec3d1;
+ if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) {
+ io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions);
+ }
+
+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions); + final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions);
+ +
+ if (stepHeight > 0.0 + if (stepHeight > 0.0

Datei anzeigen

@ -25,10 +25,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- /* - /*
- if (!unloadChunk0(x, z, false)) { - if (!unloadChunk0(x, z, false)) {
- return false; - return false;
- }
-
- final long chunkKey = ChunkCoordIntPair.pair(x, z);
- world.getChunkProvider().unloadQueue.remove(chunkKey);
+ // Paper start - implement regenerateChunk method + // Paper start - implement regenerateChunk method
+ final ServerLevel serverLevel = this.world; + final ServerLevel serverLevel = this.world;
+ final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource(); + final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
@ -37,8 +33,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ for (final BlockPos blockPos : BlockPos.betweenClosed(chunkPos.getMinBlockX(), serverLevel.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), serverLevel.getMaxBuildHeight() - 1, chunkPos.getMaxBlockZ())) { + for (final BlockPos blockPos : BlockPos.betweenClosed(chunkPos.getMinBlockX(), serverLevel.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), serverLevel.getMaxBuildHeight() - 1, chunkPos.getMaxBlockZ())) {
+ levelChunk.removeBlockEntity(blockPos); + levelChunk.removeBlockEntity(blockPos);
+ serverLevel.setBlock(blockPos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), 16); + serverLevel.setBlock(blockPos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), 16);
+ } }
+
- final long chunkKey = ChunkCoordIntPair.pair(x, z);
- world.getChunkProvider().unloadQueue.remove(chunkKey);
+ for (final ChunkStatus chunkStatus : REGEN_CHUNK_STATUSES) { + for (final ChunkStatus chunkStatus : REGEN_CHUNK_STATUSES) {
+ final List<ChunkAccess> list = new ArrayList<>(); + final List<ChunkAccess> list = new ArrayList<>();
+ final int range = Math.max(1, chunkStatus.getRange()); + final int range = Math.max(1, chunkStatus.getRange());

Datei anzeigen

@ -119,8 +119,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper - moved into if below + // Paper - moved into if below
if (this.level instanceof ServerLevel) { if (this.level instanceof ServerLevel) {
- if (entity == null || entity.wasKilled((ServerLevel) this.level, this)) { - if (entity == null || entity.wasKilled((ServerLevel) this.level, this)) {
- this.gameEvent(GameEvent.ENTITY_DIE);
- this.dropAllDeathLoot(damageSource);
- this.createWitherRose(entityliving);
- }
+ // Paper - move below into if for onKill + // Paper - move below into if for onKill
+
- this.level.broadcastEntityEvent(this, (byte) 3);
+ // Paper start + // Paper start
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(damageSource); + org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(damageSource);
+ if (deathEvent == null || !deathEvent.isCancelled()) { + if (deathEvent == null || !deathEvent.isCancelled()) {
@ -148,15 +153,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (entity != null) { + if (entity != null) {
+ entity.wasKilled((ServerLevel) this.level, this); + entity.wasKilled((ServerLevel) this.level, this);
+ } + }
this.gameEvent(GameEvent.ENTITY_DIE); + this.gameEvent(GameEvent.ENTITY_DIE);
- this.dropAllDeathLoot(damageSource);
- this.createWitherRose(entityliving);
+ } else { + } else {
+ this.dead = false; + this.dead = false;
+ this.setHealth((float) deathEvent.getReviveHealth()); + this.setHealth((float) deathEvent.getReviveHealth());
} + }
-
- this.level.broadcastEntityEvent(this, (byte) 3);
+ // Paper end + // Paper end
+ this.createWitherRose(entityliving); + this.createWitherRose(entityliving);
} }

Datei anzeigen

@ -405,9 +405,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ tryPreloadClass(net.minecraft.world.level.lighting.LayerLightEventListener.class.getName()); + tryPreloadClass(net.minecraft.world.level.lighting.LayerLightEventListener.class.getName());
+ tryPreloadClass(net.minecraft.util.ExceptionCollector.class.getName()); + tryPreloadClass(net.minecraft.util.ExceptionCollector.class.getName());
+ // Paper end + // Paper end
+ } }
+ } }
+
+ // Paper start + // Paper start
+ private static void tryPreloadClass(String className) { + private static void tryPreloadClass(String className) {
+ tryPreloadClass(className, true); + tryPreloadClass(className, true);
@ -417,12 +417,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Class.forName(className); + Class.forName(className);
+ } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) {
+ if (printError) System.err.println("An expected class " + className + " was not found for preloading: " + e.getMessage()); + if (printError) System.err.println("An expected class " + className + " was not found for preloading: " + e.getMessage());
} + }
} + }
+ // Paper end + // Paper end
+
private static List<String> asList(String... params) { private static List<String> asList(String... params) {
return Arrays.asList(params); return Arrays.asList(params);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java --- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java

Datei anzeigen

@ -7674,12 +7674,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public ChunkAccess getChunkIfLoadedImmediately(int x, int z) { + public ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
+ throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet.");
+ } + }
+
+ @Override + @Override
+ public BlockState getBlockStateIfLoaded(BlockPos blockposition) { + public BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet.");
+ } + }
+
+ @Override + @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) { + public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet.");

Datei anzeigen

@ -55,14 +55,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) { + if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) {
+ return false; + return false;
+ } + }
+
- if (this.entity.isVehicle() || this.entity.isRemoved()) {
+ // Don't allow to teleport between worlds if remaining on vehicle + // Don't allow to teleport between worlds if remaining on vehicle
+ if (!dismount && this.entity.isPassenger() && location.getWorld() != this.getWorld()) { + if (!dismount && this.entity.isPassenger() && location.getWorld() != this.getWorld()) {
+ return false; + return false;
+ } + }
+ // Paper end + // Paper end
+
- if (this.entity.isVehicle() || this.entity.isRemoved()) {
+ if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API + if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API
return false; return false;
} }

Datei anzeigen

@ -15,17 +15,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static boolean isNearWater(LevelReader world, BlockPos pos) { private static boolean isNearWater(LevelReader world, BlockPos pos) {
- Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 1, 4)).iterator(); - Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, 0, -4), pos.offset(4, 1, 4)).iterator();
- + // Paper start - remove abstract block iteration
+ int xOff = pos.getX();
+ int yOff = pos.getY();
+ int zOff = pos.getZ();
- BlockPos blockposition1; - BlockPos blockposition1;
- -
- do { - do {
- if (!iterator.hasNext()) { - if (!iterator.hasNext()) {
- return false; - return false;
+ // Paper start - remove abstract block iteration
+ int xOff = pos.getX();
+ int yOff = pos.getY();
+ int zOff = pos.getZ();
+
+ for (int dz = -4; dz <= 4; ++dz) { + for (int dz = -4; dz <= 4; ++dz) {
+ int z = dz + zOff; + int z = dz + zOff;
+ for (int dx = -4; dx <= 4; ++dx) { + for (int dx = -4; dx <= 4; ++dx) {

Datei anzeigen

@ -170,13 +170,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start - optimise chunk tick iteration + // Paper start - optimise chunk tick iteration
+ } + }
+ } }
+ +
+ } finally { + } finally {
+ if (iterator1 instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) { + if (iterator1 instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
+ safeIterator.finishedIterating(); + safeIterator.finishedIterating();
+ } + }
} + }
+ // Paper end - optimise chunk tick iteration + // Paper end - optimise chunk tick iteration
this.level.timings.chunkTicks.stopTiming(); // Paper this.level.timings.chunkTicks.stopTiming(); // Paper
gameprofilerfiller.popPush("customSpawners"); gameprofilerfiller.popPush("customSpawners");
@ -186,15 +186,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} // Paper - timings } // Paper - timings
} }
- -
- gameprofilerfiller.popPush("broadcast"); + gameprofilerfiller.pop();
+ // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded
gameprofilerfiller.popPush("broadcast");
- list.forEach((chunkproviderserver_a1) -> { - list.forEach((chunkproviderserver_a1) -> {
- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing - this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
- chunkproviderserver_a1.holder.broadcastChanges(chunkproviderserver_a1.chunk); - chunkproviderserver_a1.holder.broadcastChanges(chunkproviderserver_a1.chunk);
- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing - this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
- }); - });
gameprofilerfiller.pop(); - gameprofilerfiller.pop();
+ // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded
+ gameprofilerfiller.popPush("broadcast");
+ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing + this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
+ if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { + if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) {
+ ReferenceOpenHashSet<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone(); + ReferenceOpenHashSet<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone();

Datei anzeigen

@ -173,7 +173,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (randomTickSpeed > 0) { if (randomTickSpeed > 0) {
- LevelChunkSection[] achunksection = chunk.getSections(); - LevelChunkSection[] achunksection = chunk.getSections();
- int j1 = achunksection.length; - int j1 = achunksection.length;
- + LevelChunkSection[] sections = chunk.getSections();
+ int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this);
+ for (int sectionIndex = 0; sectionIndex < sections.length; ++sectionIndex) {
+ LevelChunkSection section = sections[sectionIndex];
+ if (section == null || section.tickingList.size() == 0) {
+ continue;
+ }
- for (int k1 = 0; k1 < j1; ++k1) { - for (int k1 = 0; k1 < j1; ++k1) {
- LevelChunkSection chunksection = achunksection[k1]; - LevelChunkSection chunksection = achunksection[k1];
- -
@ -185,40 +192,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- -
- gameprofilerfiller.push("randomTick"); - gameprofilerfiller.push("randomTick");
- BlockState iblockdata3 = chunksection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - l1, blockposition2.getZ() - k); - BlockState iblockdata3 = chunksection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - l1, blockposition2.getZ() - k);
+ LevelChunkSection[] sections = chunk.getSections(); -
+ int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this);
+ for (int sectionIndex = 0; sectionIndex < sections.length; ++sectionIndex) {
+ LevelChunkSection section = sections[sectionIndex];
+ if (section == null || section.tickingList.size() == 0) {
+ continue;
+ }
- if (iblockdata3.isRandomlyTicking()) { - if (iblockdata3.isRandomlyTicking()) {
- iblockdata3.randomTick(this, blockposition2, this.random); - iblockdata3.randomTick(this, blockposition2, this.random);
- } - }
-
- FluidState fluid = iblockdata3.getFluidState();
-
- if (fluid.isRandomlyTicking()) {
- fluid.randomTick(this, blockposition2, this.random);
- }
-
- gameprofilerfiller.pop();
+ int yPos = (sectionIndex + minSection) << 4; + int yPos = (sectionIndex + minSection) << 4;
+ for (int a = 0; a < randomTickSpeed; ++a) { + for (int a = 0; a < randomTickSpeed; ++a) {
+ int tickingBlocks = section.tickingList.size(); + int tickingBlocks = section.tickingList.size();
+ int index = this.randomTickRandom.nextInt(16 * 16 * 16); + int index = this.randomTickRandom.nextInt(16 * 16 * 16);
+ if (index >= tickingBlocks) { + if (index >= tickingBlocks) {
+ continue; + continue;
+ } }
+
- FluidState fluid = iblockdata3.getFluidState();
+ long raw = section.tickingList.getRaw(index); + long raw = section.tickingList.getRaw(index);
+ int location = com.destroystokyo.paper.util.maplist.IBlockDataList.getLocationFromRaw(raw); + int location = com.destroystokyo.paper.util.maplist.IBlockDataList.getLocationFromRaw(raw);
+ int randomX = location & 15; + int randomX = location & 15;
+ int randomY = ((location >>> (4 + 4)) & 255) | yPos; + int randomY = ((location >>> (4 + 4)) & 255) | yPos;
+ int randomZ = (location >>> 4) & 15; + int randomZ = (location >>> 4) & 15;
+
- if (fluid.isRandomlyTicking()) {
- fluid.randomTick(this, blockposition2, this.random);
- }
+ BlockPos blockposition2 = blockposition.set(j + randomX, randomY, k + randomZ); + BlockPos blockposition2 = blockposition.set(j + randomX, randomY, k + randomZ);
+ BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw); + BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw);
+
- gameprofilerfiller.pop();
- }
+ iblockdata.randomTick(this, blockposition2, this.randomTickRandom); + iblockdata.randomTick(this, blockposition2, this.randomTickRandom);
+ // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock). + // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock).
+ // TODO CHECK ON UPDATE (ping the Canadian) + // TODO CHECK ON UPDATE (ping the Canadian)
@ -377,7 +379,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void recalcBlockCounts() { public void recalcBlockCounts() {
- class a implements PalettedContainer.CountConsumer<BlockState> { - class a implements PalettedContainer.CountConsumer<BlockState> {
- + // Paper start - unfuck this
+ this.tickingList.clear();
+ this.nonEmptyBlockCount = 0;
+ this.tickingBlockCount = 0;
+ this.tickingFluidCount = 0;
+ this.states.forEachLocation((BlockState iblockdata, int i) -> {
+ FluidState fluid = iblockdata.getFluidState();
- public int nonEmptyBlockCount; - public int nonEmptyBlockCount;
- public int tickingBlockCount; - public int tickingBlockCount;
- public int tickingFluidCount; - public int tickingFluidCount;
@ -392,38 +401,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (iblockdata.isRandomlyTicking()) { - if (iblockdata.isRandomlyTicking()) {
- this.tickingBlockCount += i; - this.tickingBlockCount += i;
- } - }
+ // Paper start - unfuck this
+ this.tickingList.clear();
+ this.nonEmptyBlockCount = 0;
+ this.tickingBlockCount = 0;
+ this.tickingFluidCount = 0;
+ this.states.forEachLocation((BlockState iblockdata, int i) -> {
+ FluidState fluid = iblockdata.getFluidState();
+
+ if (!iblockdata.isAir()) { + if (!iblockdata.isAir()) {
+ this.nonEmptyBlockCount = (short) (this.nonEmptyBlockCount + 1); + this.nonEmptyBlockCount = (short) (this.nonEmptyBlockCount + 1);
+ if (iblockdata.isRandomlyTicking()) { + if (iblockdata.isRandomlyTicking()) {
+ this.tickingBlockCount = (short)(this.tickingBlockCount + 1); + this.tickingBlockCount = (short)(this.tickingBlockCount + 1);
+ this.tickingList.add(i, iblockdata); + this.tickingList.add(i, iblockdata);
} }
+ } -
- if (!fluid.isEmpty()) { - if (!fluid.isEmpty()) {
- this.nonEmptyBlockCount += i; - this.nonEmptyBlockCount += i;
- if (fluid.isRandomlyTicking()) { - if (fluid.isRandomlyTicking()) {
- this.tickingFluidCount += i; - this.tickingFluidCount += i;
- } - }
+ if (!fluid.isEmpty()) { - }
+ this.nonEmptyBlockCount = (short) (this.nonEmptyBlockCount + 1);
+ if (fluid.isRandomlyTicking()) {
+ this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
}
- -
} }
- } - }
- a a0 = new a(); - a a0 = new a();
- + if (!fluid.isEmpty()) {
+ this.nonEmptyBlockCount = (short) (this.nonEmptyBlockCount + 1);
+ if (fluid.isRandomlyTicking()) {
+ this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
+ }
+ }
- this.states.count(a0); - this.states.count(a0);
- this.nonEmptyBlockCount = (short) a0.nonEmptyBlockCount; - this.nonEmptyBlockCount = (short) a0.nonEmptyBlockCount;
- this.tickingBlockCount = (short) a0.tickingBlockCount; - this.tickingBlockCount = (short) a0.tickingBlockCount;

Datei anzeigen

@ -74,26 +74,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.availableGoals.removeIf((wrappedGoal) -> { - this.availableGoals.removeIf((wrappedGoal) -> {
- return wrappedGoal.getGoal() == goal; - return wrappedGoal.getGoal() == goal;
- }); - });
- }
-
- private static boolean goalContainsAnyFlags(WrappedGoal goal, EnumSet<Goal.Flag> controls) {
- for(Goal.Flag flag : goal.getFlags()) {
- if (controls.contains(flag)) {
- return true;
+ // Paper start - remove streams from pathfindergoalselector + // Paper start - remove streams from pathfindergoalselector
+ for (java.util.Iterator<WrappedGoal> iterator = this.availableGoals.iterator(); iterator.hasNext();) { + for (java.util.Iterator<WrappedGoal> iterator = this.availableGoals.iterator(); iterator.hasNext();) {
+ WrappedGoal goalWrapped = iterator.next(); + WrappedGoal goalWrapped = iterator.next();
+ if (goalWrapped.getGoal() != goal) { + if (goalWrapped.getGoal() != goal) {
+ continue; + continue;
} + }
+ if (goalWrapped.isRunning()) { + if (goalWrapped.isRunning()) {
+ goalWrapped.stop(); + goalWrapped.stop();
+ } + }
+ iterator.remove(); + iterator.remove();
} + }
+ // Paper end - remove streams from pathfindergoalselector + // Paper end - remove streams from pathfindergoalselector
+ } }
- private static boolean goalContainsAnyFlags(WrappedGoal goal, EnumSet<Goal.Flag> controls) {
- for(Goal.Flag flag : goal.getFlags()) {
- if (controls.contains(flag)) {
- return true;
- }
- }
-
- return false; - return false;
+ private static boolean goalContainsAnyFlags(WrappedGoal goal, com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> controls) { + private static boolean goalContainsAnyFlags(WrappedGoal goal, com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> controls) {
+ return goal.getFlags().hasCommonElements(controls); // Paper + return goal.getFlags().hasCommonElements(controls); // Paper

Datei anzeigen

@ -281,10 +281,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (!iinventory.getItem(i).isEmpty()) { - if (!iinventory.getItem(i).isEmpty()) {
- ItemStack itemstack = iinventory.getItem(i).copy(); - ItemStack itemstack = iinventory.getItem(i).copy();
- // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection); - // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
- + // Paper start - replace logic; MAKE SURE TO CHECK FOR DIFFS ON UPDATES
+ return hopperPush(world, iinventory1, enumdirection, hopper);
+ // for (int i = 0; i < iinventory.getContainerSize(); ++i) {
+ // if (!iinventory.getItem(i).isEmpty()) {
+ // ItemStack itemstack = iinventory.getItem(i).copy();
+ // // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
- // CraftBukkit start - Call event when pushing items into other inventories - // CraftBukkit start - Call event when pushing items into other inventories
- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
- + // // CraftBukkit start - Call event when pushing items into other inventories
+ // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
- Inventory destinationInventory; - Inventory destinationInventory;
- // Have to special case large chests as they work oddly - // Have to special case large chests as they work oddly
- if (iinventory1 instanceof CompoundContainer) { - if (iinventory1 instanceof CompoundContainer) {
@ -294,26 +302,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } else { - } else {
- destinationInventory = new CraftInventory(iinventory); - destinationInventory = new CraftInventory(iinventory);
- } - }
-
- InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
- world.getCraftServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- hopper.setItem(i, itemstack);
- hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ // Paper start - replace logic; MAKE SURE TO CHECK FOR DIFFS ON UPDATES
+ return hopperPush(world, iinventory1, enumdirection, hopper);
+ // for (int i = 0; i < iinventory.getContainerSize(); ++i) {
+ // if (!iinventory.getItem(i).isEmpty()) {
+ // ItemStack itemstack = iinventory.getItem(i).copy();
+ // // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
+
+ // // CraftBukkit start - Call event when pushing items into other inventories
+ // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
+
+ // Inventory destinationInventory; + // Inventory destinationInventory;
+ // // Have to special case large chests as they work oddly + // // Have to special case large chests as they work oddly
+ // if (iinventory1 instanceof CompoundContainer) { + // if (iinventory1 instanceof CompoundContainer) {
@ -323,7 +311,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // } else { + // } else {
+ // destinationInventory = new CraftInventory(iinventory); + // destinationInventory = new CraftInventory(iinventory);
+ // } + // }
+
- InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
- world.getCraftServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- hopper.setItem(i, itemstack);
- hopper.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack1 = HopperBlockEntity.addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ // InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); + // InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ // world.getCraftServer().getPluginManager().callEvent(event); + // world.getCraftServer().getPluginManager().callEvent(event);
+ // if (event.isCancelled()) { + // if (event.isCancelled()) {
@ -411,7 +408,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null); - // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
- // CraftBukkit start - Call event on collection of items from inventories into the hopper - // CraftBukkit start - Call event on collection of items from inventories into the hopper
- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
- + // Paper start - replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING
+ if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { // If this logic changes, update above. this is left unused incase reflective plugins
+ return hopperPull(world, ihopper, iinventory, itemstack, i);
+ // ItemStack itemstack1 = itemstack.copy();
+ // // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
+ // // CraftBukkit start - Call event on collection of items from inventories into the hopper
+ // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
- Inventory sourceInventory; - Inventory sourceInventory;
- // Have to special case large chests as they work oddly - // Have to special case large chests as they work oddly
- if (iinventory instanceof CompoundContainer) { - if (iinventory instanceof CompoundContainer) {
@ -421,38 +425,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } else { - } else {
- sourceInventory = new CraftInventory(iinventory); - sourceInventory = new CraftInventory(iinventory);
- } - }
-
- InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
-
- Bukkit.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- iinventory.setItem(i, itemstack1);
-
- if (ihopper instanceof HopperBlockEntity) {
- ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
- }
-
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
- // CraftBukkit end
-
- if (itemstack2.isEmpty()) {
- iinventory.setChanged();
- return true;
- }
-
- itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
- iinventory.setItem(i, itemstack1);
+ // Paper start - replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING
+ if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { // If this logic changes, update above. this is left unused incase reflective plugins
+ return hopperPull(world, ihopper, iinventory, itemstack, i);
+ // ItemStack itemstack1 = itemstack.copy();
+ // // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
+ // // CraftBukkit start - Call event on collection of items from inventories into the hopper
+ // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot
+
+ // Inventory sourceInventory; + // Inventory sourceInventory;
+ // // Have to special case large chests as they work oddly + // // Have to special case large chests as they work oddly
+ // if (iinventory instanceof CompoundContainer) { + // if (iinventory instanceof CompoundContainer) {
@ -462,28 +434,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // } else { + // } else {
+ // sourceInventory = new CraftInventory(iinventory); + // sourceInventory = new CraftInventory(iinventory);
+ // } + // }
+
- InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
+ // InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false); + // InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
+
- Bukkit.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- iinventory.setItem(i, itemstack1);
+ // Bukkit.getServer().getPluginManager().callEvent(event); + // Bukkit.getServer().getPluginManager().callEvent(event);
+ // if (event.isCancelled()) { + // if (event.isCancelled()) {
+ // iinventory.setItem(i, itemstack1); + // iinventory.setItem(i, itemstack1);
+
- if (ihopper instanceof HopperBlockEntity) {
- ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
- }
+ // if (ihopper instanceof HopperBlockEntity) { + // if (ihopper instanceof HopperBlockEntity) {
+ // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot + // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot
+ // } + // }
+
- return false;
- }
- int origCount = event.getItem().getAmount(); // Spigot
- ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
- // CraftBukkit end
+ // return false; + // return false;
+ // } + // }
+ // int origCount = event.getItem().getAmount(); // Spigot + // int origCount = event.getItem().getAmount(); // Spigot
+ // ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null); + // ItemStack itemstack2 = HopperBlockEntity.addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
+ // // CraftBukkit end + // // CraftBukkit end
+
- if (itemstack2.isEmpty()) {
- iinventory.setChanged();
- return true;
- }
+ // if (itemstack2.isEmpty()) { + // if (itemstack2.isEmpty()) {
+ // iinventory.setChanged(); + // iinventory.setChanged();
+ // return true; + // return true;
+ // } + // }
+
- itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
- iinventory.setItem(i, itemstack1);
+ // itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot + // itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot
+ // iinventory.setItem(i, itemstack1); + // iinventory.setItem(i, itemstack1);
+ // Paper end + // Paper end

Datei anzeigen

@ -107,21 +107,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) { public void send(Packet<?> packet, @Nullable PacketSendListener callbacks) {
- if (this.isConnected()) { - if (this.isConnected()) {
- this.flushQueue(); - this.flushQueue();
- this.sendPacket(packet, callbacks);
- } else {
- this.queue.add(new Connection.PacketHolder(packet, callbacks));
+ // Paper start - handle oversized packets better + // Paper start - handle oversized packets better
+ boolean connected = this.isConnected(); + boolean connected = this.isConnected();
+ if (!connected && !preparing) { + if (!connected && !preparing) {
+ return; // Do nothing + return; // Do nothing
+ } }
+ packet.onPacketDispatch(getPlayer()); + packet.onPacketDispatch(getPlayer());
+ if (connected && (InnerUtil.canSendImmediate(this, packet) || ( + if (connected && (InnerUtil.canSendImmediate(this, packet) || (
+ io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() && + io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
+ (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty()) + (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
+ ))) { + ))) {
this.sendPacket(packet, callbacks); + this.sendPacket(packet, callbacks);
- } else {
- this.queue.add(new Connection.PacketHolder(packet, callbacks));
+ return; + return;
} + }
+ // write the packets to the queue, then flush - antixray hooks there already + // write the packets to the queue, then flush - antixray hooks there already
+ java.util.List<Packet> extraPackets = InnerUtil.buildExtraPackets(packet); + java.util.List<Packet> extraPackets = InnerUtil.buildExtraPackets(packet);
+ boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty(); + boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty();
@ -184,6 +185,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- private void flushQueue() { - private void flushQueue() {
- try { // Paper - add pending task queue
- if (this.channel != null && this.channel.isOpen()) {
- Queue queue = this.queue;
-
+ // Paper start - rewrite this to be safer if ran off main thread + // Paper start - rewrite this to be safer if ran off main thread
+ private boolean flushQueue() { // void -> boolean + private boolean flushQueue() { // void -> boolean
+ if (!isConnected()) { + if (!isConnected()) {
@ -193,16 +198,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return processQueue(); + return processQueue();
+ } else if (isPending) { + } else if (isPending) {
+ // Should only happen during login/status stages + // Should only happen during login/status stages
+ synchronized (this.queue) { synchronized (this.queue) {
- Connection.PacketHolder networkmanager_queuedpacket;
-
- while ((networkmanager_queuedpacket = (Connection.PacketHolder) this.queue.poll()) != null) {
- this.sendPacket(networkmanager_queuedpacket.packet, networkmanager_queuedpacket.listener);
- }
-
+ return this.processQueue(); + return this.processQueue();
+ } }
+ } }
+ return false; + return false;
+ } + }
+ private boolean processQueue() { + private boolean processQueue() {
try { // Paper - add pending task queue + try { // Paper - add pending task queue
- if (this.channel != null && this.channel.isOpen()) {
- Queue queue = this.queue;
+ if (this.queue.isEmpty()) return true; + if (this.queue.isEmpty()) return true;
+ // If we are on main, we are safe here in that nothing else should be processing queue off main anymore + // If we are on main, we are safe here in that nothing else should be processing queue off main anymore
+ // But if we are not on main due to login/status, the parent is synchronized on packetQueue + // But if we are not on main due to login/status, the parent is synchronized on packetQueue
@ -214,17 +223,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (queued == null) { + if (queued == null) {
+ return true; + return true;
+ } + }
+
- synchronized (this.queue) {
- Connection.PacketHolder networkmanager_queuedpacket;
+ // Paper start - checking isConsumed flag and skipping packet sending + // Paper start - checking isConsumed flag and skipping packet sending
+ if (queued.isConsumed()) { + if (queued.isConsumed()) {
+ continue; + continue;
+ } + }
+ // Paper end - checking isConsumed flag and skipping packet sending + // Paper end - checking isConsumed flag and skipping packet sending
+
- while ((networkmanager_queuedpacket = (Connection.PacketHolder) this.queue.poll()) != null) {
- this.sendPacket(networkmanager_queuedpacket.packet, networkmanager_queuedpacket.listener);
+ Packet<?> packet = queued.packet; + Packet<?> packet = queued.packet;
+ if (!packet.isReady()) { + if (!packet.isReady()) {
+ return false; + return false;
@ -232,10 +237,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ iterator.remove(); + iterator.remove();
+ if (queued.tryMarkConsumed()) { // Paper - try to mark isConsumed flag for de-duplicating packet + if (queued.tryMarkConsumed()) { // Paper - try to mark isConsumed flag for de-duplicating packet
+ this.sendPacket(packet, queued.listener); + this.sendPacket(packet, queued.listener);
} + }
- + }
} + }
}
+ return true; + return true;
} finally { // Paper start - add pending task queue } finally { // Paper start - add pending task queue
Runnable r; Runnable r;

Datei anzeigen

@ -136,17 +136,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- int chunkRange = level.spigotConfig.mobSpawnRange; - int chunkRange = level.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; - chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
- chunkRange = (chunkRange > 8) ? 8 : chunkRange; - chunkRange = (chunkRange > 8) ? 8 : chunkRange;
-
- final int finalChunkRange = chunkRange; // Paper for lambda below
- //double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; // Paper - use from event
- double blockRange = 16384.0D; // Paper
- // Spigot end
- long i = chunkcoordintpair.toLong();
+ // Paper start - optimise anyPlayerCloseEnoughForSpawning + // Paper start - optimise anyPlayerCloseEnoughForSpawning
+ final boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) { + final boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) {
+ return this.anyPlayerCloseEnoughForSpawning(this.getUpdatingChunkIfPresent(chunkcoordintpair.toLong()), chunkcoordintpair, reducedRange); + return this.anyPlayerCloseEnoughForSpawning(this.getUpdatingChunkIfPresent(chunkcoordintpair.toLong()), chunkcoordintpair, reducedRange);
+ } + }
- final int finalChunkRange = chunkRange; // Paper for lambda below
- //double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; // Paper - use from event
- double blockRange = 16384.0D; // Paper
- // Spigot end
- long i = chunkcoordintpair.toLong();
-
- if (!this.distanceManager.hasPlayersNearby(i)) { - if (!this.distanceManager.hasPlayersNearby(i)) {
+ final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) { + final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) {
+ // this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance + // this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance
@ -158,18 +158,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- Iterator iterator = this.playerMap.getPlayers(i).iterator(); - Iterator iterator = this.playerMap.getPlayers(i).iterator();
- -
- ServerPlayer entityplayer; - ServerPlayer entityplayer;
+ } -
+ Object[] backingSet = playersInRange.getBackingSet();
- do { - do {
- if (!iterator.hasNext()) { - if (!iterator.hasNext()) {
- return false; - return false;
+ if (reducedRange) { - }
+ for (int i = 0, len = backingSet.length; i < len; ++i) {
+ Object raw = backingSet[i];
+ if (!(raw instanceof ServerPlayer player)) {
+ continue;
}
- -
- entityplayer = (ServerPlayer) iterator.next(); - entityplayer = (ServerPlayer) iterator.next();
- // Paper start - add PlayerNaturallySpawnCreaturesEvent - // Paper start - add PlayerNaturallySpawnCreaturesEvent
@ -179,14 +172,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- event = entityplayer.playerNaturallySpawnedEvent; - event = entityplayer.playerNaturallySpawnedEvent;
- if (event == null || event.isCancelled()) return false; - if (event == null || event.isCancelled()) return false;
- blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); - blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
+ // don't check spectator and whatnot, already handled by mob spawn map update - }
+ if (euclideanDistanceSquared(chunkcoordintpair, player) < player.lastEntitySpawnRadiusSquared) {
+ return true; // in range
}
- // Paper end - // Paper end
- } while (!this.playerIsCloseEnoughForSpawning(entityplayer, chunkcoordintpair, blockRange)); // Spigot - } while (!this.playerIsCloseEnoughForSpawning(entityplayer, chunkcoordintpair, blockRange)); // Spigot
- -
- return true; - return true;
}
+ Object[] backingSet = playersInRange.getBackingSet();
+
+ if (reducedRange) {
+ for (int i = 0, len = backingSet.length; i < len; ++i) {
+ Object raw = backingSet[i];
+ if (!(raw instanceof ServerPlayer player)) {
+ continue;
+ }
+ // don't check spectator and whatnot, already handled by mob spawn map update
+ if (euclideanDistanceSquared(chunkcoordintpair, player) < player.lastEntitySpawnRadiusSquared) {
+ return true; // in range
+ }
+ } + }
+ } else { + } else {
+ final double range = (DistanceManager.MOB_SPAWN_RANGE * 16) * (DistanceManager.MOB_SPAWN_RANGE * 16); + final double range = (DistanceManager.MOB_SPAWN_RANGE * 16) * (DistanceManager.MOB_SPAWN_RANGE * 16);
@ -201,7 +204,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return true; // in range + return true; // in range
+ } + }
+ } + }
} + }
+ // no players in range + // no players in range
+ return false; + return false;
+ // Paper end - optimise anyPlayerCloseEnoughForSpawning + // Paper end - optimise anyPlayerCloseEnoughForSpawning

Datei anzeigen

@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- int k = pos.getZ(); - int k = pos.getZ();
+ return this.getBlockStateFinal(pos.getX(), pos.getY(), pos.getZ()); + return this.getBlockStateFinal(pos.getX(), pos.getY(), pos.getZ());
+ } + }
+
+ @Override + @Override
+ public BlockState getBlockState(final int x, final int y, final int z) { + public BlockState getBlockState(final int x, final int y, final int z) {
+ return this.getBlockStateFinal(x, y, z); + return this.getBlockStateFinal(x, y, z);
@ -116,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int) + // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
+ return this.sections[i].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15); + return this.sections[i].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
+
+ } + }
+ +
+ public BlockState getBlockState_unused(int i, int j, int k) { + public BlockState getBlockState_unused(int i, int j, int k) {

Datei anzeigen

@ -1,8 +1,9 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <1254957+zachbr@users.noreply.github.com> From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Mon, 29 Feb 2016 21:02:09 -0600 Date: Mon, 29 Feb 2016 21:02:09 -0600
Subject: [PATCH] Paper command Subject: [PATCH] Paper command
Co-authored-by: Zach Brown <1254957+zachbr@users.noreply.github.com>
diff --git a/src/main/java/io/papermc/paper/command/CommandUtil.java b/src/main/java/io/papermc/paper/command/CommandUtil.java diff --git a/src/main/java/io/papermc/paper/command/CommandUtil.java b/src/main/java/io/papermc/paper/command/CommandUtil.java
new file mode 100644 new file mode 100644

Datei anzeigen

@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Random player selection moved up for per player spawning and configuration + // Random player selection moved up for per player spawning and configuration
+ int j = world.players().size(); + int j = world.players().size();
+ if (j < 1) { + if (j < 1) {
return 0; + return 0;
+ } + }
+ +
+ net.minecraft.server.level.ServerPlayer entityhuman = world.players().get(randomsource.nextInt(j)); + net.minecraft.server.level.ServerPlayer entityhuman = world.players().get(randomsource.nextInt(j));
@ -56,16 +56,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (world.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { + if (world.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) {
+ --entityhuman.patrolSpawnDelay; + --entityhuman.patrolSpawnDelay;
+ patrolSpawnDelay = entityhuman.patrolSpawnDelay; + patrolSpawnDelay = entityhuman.patrolSpawnDelay;
} else { + } else {
- this.nextTick += 12000 + randomsource.nextInt(1200);
- long i = world.getDayTime() / 24000L;
+ this.nextTick--; + this.nextTick--;
+ patrolSpawnDelay = this.nextTick; + patrolSpawnDelay = this.nextTick;
+ } + }
+ +
+ if (patrolSpawnDelay > 0) { + if (patrolSpawnDelay > 0) {
+ return 0; return 0;
+ } else { } else {
- this.nextTick += 12000 + randomsource.nextInt(1200);
- long i = world.getDayTime() / 24000L;
+ long days; + long days;
+ if (world.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { + if (world.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) {
+ days = entityhuman.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_ONE_MINUTE is actually counting in ticks, a misnomer by Mojang + days = entityhuman.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_ONE_MINUTE is actually counting in ticks, a misnomer by Mojang

Datei anzeigen

@ -145,13 +145,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public String getLocale() { public String getLocale() {
return this.getHandle().locale; return this.getHandle().locale;
+ +
+ } }
+
+ // Paper start + // Paper start
+ public void setAffectsSpawning(boolean affects) { + public void setAffectsSpawning(boolean affects) {
+ this.getHandle().affectsSpawning = affects; + this.getHandle().affectsSpawning = affects;
} + }
+
+ @Override + @Override
+ public boolean getAffectsSpawning() { + public boolean getAffectsSpawning() {
+ return this.getHandle().affectsSpawning; + return this.getHandle().affectsSpawning;

Datei anzeigen

@ -127,11 +127,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ bukkitPlayer.unregisterEntity(self); + bukkitPlayer.unregisterEntity(self);
+ } + }
+ } + }
+
+ // Set the game profile here, we should have unregistered the entity via iterating all player entities above.
+ self.gameProfile = gameProfile;
- server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity)); - server.getPluginManager().callEvent(new PlayerShowEntityEvent(this, entity));
+ // Set the game profile here, we should have unregistered the entity via iterating all player entities above.
+ self.gameProfile = gameProfile;
+
+ // Re-register the game profile for all players + // Re-register the game profile for all players
+ for (ServerPlayer player : players) { + for (ServerPlayer player : players) {
+ CraftPlayer bukkitPlayer = player.getBukkitEntity(); + CraftPlayer bukkitPlayer = player.getBukkitEntity();

Datei anzeigen

@ -58,15 +58,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
short short0 = FlowingFluid.getCacheKey(pos, blockposition1); short short0 = FlowingFluid.getCacheKey(pos, blockposition1);
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> { - Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> {
- BlockState iblockdata1 = world.getBlockState(blockposition1); - BlockState iblockdata1 = world.getBlockState(blockposition1);
-
- return Pair.of(iblockdata1, iblockdata1.getFluidState());
- });
+ // Paper start + // Paper start
+ Pair pair = (Pair) short2objectmap.get(short0); + Pair pair = (Pair) short2objectmap.get(short0);
+ if (pair == null) { + if (pair == null) {
+ BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1); + BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1);
+ if (iblockdatax == null) continue; + if (iblockdatax == null) continue;
+
- return Pair.of(iblockdata1, iblockdata1.getFluidState());
- });
+ pair = Pair.of(iblockdatax, iblockdatax.getFluidState()); + pair = Pair.of(iblockdatax, iblockdatax.getFluidState());
+ short2objectmap.put(short0, pair); + short2objectmap.put(short0, pair);
+ } + }

Datei anzeigen

@ -98,24 +98,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if ( isRestarting ) + if ( isRestarting )
{ {
- System.out.println( "Attempting to restart with " + restartScript ); - System.out.println( "Attempting to restart with " + restartScript );
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript ); -
+ } else
+ {
+ System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
+ }
+ // Stop the watchdog
+ WatchdogThread.doStop();
- // Disable Watchdog - // Disable Watchdog
- WatchdogThread.doStop(); - WatchdogThread.doStop();
+ shutdownServer( isRestarting ); -
+ // Paper end
+ } catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
- // Kick all players - // Kick all players
- for ( ServerPlayer p : (List<ServerPlayer>) MinecraftServer.getServer().getPlayerList().players ) - for ( ServerPlayer p : (List<ServerPlayer>) MinecraftServer.getServer().getPlayerList().players )
- { - {
@ -130,6 +116,73 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- // Close the socket so we can rebind with the new process - // Close the socket so we can rebind with the new process
- MinecraftServer.getServer().getConnection().stop(); - MinecraftServer.getServer().getConnection().stop();
-
- // Give time for it to kick in
- try
- {
- Thread.sleep( 100 );
- } catch ( InterruptedException ex )
- {
- }
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
-
- // This will be done AFTER the server has completely halted
- Thread shutdownHook = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
- if ( os.contains( "win" ) )
- {
- Runtime.getRuntime().exec( "cmd /c start " + restartScript );
- } else
- {
- Runtime.getRuntime().exec( "sh " + restartScript );
- }
- } catch ( Exception e )
- {
- e.printStackTrace();
- }
- }
- };
-
- shutdownHook.setDaemon( true );
- Runtime.getRuntime().addShutdownHook( shutdownHook );
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
} else
{
System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
}
- System.exit( 0 );
+ // Stop the watchdog
+ WatchdogThread.doStop();
+
+ shutdownServer( isRestarting );
+ // Paper end
} catch ( Exception ex )
{
ex.printStackTrace();
}
}
+
+ // Paper start - sync copied from above with minor changes, async added + // Paper start - sync copied from above with minor changes, async added
+ private static void shutdownServer(boolean isRestarting) + private static void shutdownServer(boolean isRestarting)
+ { + {
@ -147,23 +200,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } catch ( InterruptedException ex ) + } catch ( InterruptedException ex )
+ { + {
+ } + }
+
- // Give time for it to kick in
- try
- {
- Thread.sleep( 100 );
- } catch ( InterruptedException ex )
- {
- }
+ closeSocket(); + closeSocket();
+
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
- }
+ // Actually shutdown + // Actually shutdown
+ try + try
+ { + {
@ -174,9 +213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ // Actually stop the JVM + // Actually stop the JVM
+ System.exit( 0 ); + System.exit( 0 );
+
- // This will be done AFTER the server has completely halted
- Thread shutdownHook = new Thread()
+ } else + } else
+ { + {
+ // Mark the server to shutdown at the end of the tick + // Mark the server to shutdown at the end of the tick
@ -228,63 +265,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ { + {
+ @Override + @Override
+ public void run() + public void run()
{ + {
- @Override
- public void run()
+ try + try
{ + {
- try
+ String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH); + String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
+ if ( os.contains( "win" ) ) + if ( os.contains( "win" ) )
{ + {
- String os = System.getProperty( "os.name" ).toLowerCase(java.util.Locale.ENGLISH);
- if ( os.contains( "win" ) )
- {
- Runtime.getRuntime().exec( "cmd /c start " + restartScript );
- } else
- {
- Runtime.getRuntime().exec( "sh " + restartScript );
- }
- } catch ( Exception e )
+ Runtime.getRuntime().exec( "cmd /c start " + restartScript ); + Runtime.getRuntime().exec( "cmd /c start " + restartScript );
+ } else + } else
{ + {
- e.printStackTrace();
+ Runtime.getRuntime().exec( "sh " + restartScript ); + Runtime.getRuntime().exec( "sh " + restartScript );
} + }
+ } catch ( Exception e ) + } catch ( Exception e )
+ { + {
+ e.printStackTrace(); + e.printStackTrace();
} + }
- }; + }
-
- shutdownHook.setDaemon( true );
- Runtime.getRuntime().addShutdownHook( shutdownHook );
- } else
- {
- System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
-
- // Actually shutdown
- try
- {
- MinecraftServer.getServer().close();
- } catch ( Throwable t )
- {
}
- }
- System.exit( 0 );
- } catch ( Exception ex )
+ }; + };
+ +
+ shutdownHook.setDaemon( true ); + shutdownHook.setDaemon( true );
+ Runtime.getRuntime().addShutdownHook( shutdownHook ); + Runtime.getRuntime().addShutdownHook( shutdownHook );
+ return true; + return true;
+ } else + } else
{ + {
- ex.printStackTrace();
+ return false; + return false;
} + }
} + }
+ // Paper end + // Paper end
+ +
} }

Datei anzeigen

@ -13176,16 +13176,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entityplayer.connection.send(packet); - entityplayer.connection.send(packet);
- }); - });
- } - }
-
- public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getOrScheduleFuture(ChunkStatus targetStatus, ChunkMap chunkStorage) {
- int i = targetStatus.getIndex();
- CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i);
-
- if (completablefuture != null) {
- Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = (Either) completablefuture.getNow(ChunkHolder.NOT_DONE_YET);
-
- if (either == null) {
- String s = "value in future for status: " + targetStatus + " was incorrectly set to null at chunk: " + this.pos;
+ // Paper start - per player view distance + // Paper start - per player view distance
+ // there can be potential desync with player's last mapped section and the view distance map, so use the + // there can be potential desync with player's last mapped section and the view distance map, so use the
+ // view distance map here. + // view distance map here.
@ -13195,6 +13185,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
- public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getOrScheduleFuture(ChunkStatus targetStatus, ChunkMap chunkStorage) {
- int i = targetStatus.getIndex();
- CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i);
-
- if (completablefuture != null) {
- Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = (Either) completablefuture.getNow(ChunkHolder.NOT_DONE_YET);
-
- if (either == null) {
- String s = "value in future for status: " + targetStatus + " was incorrectly set to null at chunk: " + this.pos;
-
- throw chunkStorage.debugFuturesAndCreateReportedException(new IllegalStateException("null value previously set for chunk status"), s); - throw chunkStorage.debugFuturesAndCreateReportedException(new IllegalStateException("null value previously set for chunk status"), s);
+ Object[] backingSet = players.getBackingSet(); + Object[] backingSet = players.getBackingSet();
+ for (int i = 0, len = backingSet.length; i < len; ++i) { + for (int i = 0, len = backingSet.length; i < len; ++i) {
@ -13258,8 +13258,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public final int getTicketLevel() { // Paper - final for inline public final int getTicketLevel() { // Paper - final for inline
- return this.ticketLevel; - return this.ticketLevel;
- } + return this.newChunkHolder.getTicketLevel(); // Paper - rewrite chunk system
- }
- public int getQueueLevel() { - public int getQueueLevel() {
- return this.queueLevel; - return this.queueLevel;
- } - }
@ -13285,9 +13286,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- completablefuture1.complete(null); // CraftBukkit - decompile error - completablefuture1.complete(null); // CraftBukkit - decompile error
- }); - });
- }); - });
+ return this.newChunkHolder.getTicketLevel(); // Paper - rewrite chunk system - }
} -
- private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) { - private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) {
- this.pendingFullStateConfirmation.cancel(false); - this.pendingFullStateConfirmation.cancel(false);
- playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state); - playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
@ -13823,15 +13823,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } finally { - } finally {
- super.close(); - super.close();
- } - }
-
+ throw new UnsupportedOperationException("Use ServerChunkCache#close"); // Paper - rewrite chunk system + throw new UnsupportedOperationException("Use ServerChunkCache#close"); // Paper - rewrite chunk system
+ } }
+ // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ protected void saveIncrementally() { + protected void saveIncrementally() {
+ this.level.chunkTaskScheduler.chunkHolderManager.autoSave(); // Paper - rewrite chunk system + this.level.chunkTaskScheduler.chunkHolderManager.autoSave(); // Paper - rewrite chunk system
} + }
+ // Paper end - - rewrite chunk system + // Paper end - - rewrite chunk system
+
protected void saveAllChunks(boolean flush) { protected void saveAllChunks(boolean flush) {
- if (flush) { - if (flush) {
- List<ChunkHolder> list = (List) io.papermc.paper.chunk.system.ChunkSystem.getVisibleChunkHolders(this.level).stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper - List<ChunkHolder> list = (List) io.papermc.paper.chunk.system.ChunkSystem.getVisibleChunkHolders(this.level).stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper
@ -14491,21 +14492,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- Set<ServerPlayer> set = this.playerMap.getPlayers(chunkPos.toLong()); - Set<ServerPlayer> set = this.playerMap.getPlayers(chunkPos.toLong());
- Builder<ServerPlayer> builder = ImmutableList.builder(); - Builder<ServerPlayer> builder = ImmutableList.builder();
- Iterator iterator = set.iterator(); - Iterator iterator = set.iterator();
-
- while (iterator.hasNext()) {
- ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- SectionPos sectionposition = entityplayer.getLastSectionPos();
-
- if (onlyOnWatchDistanceEdge && ChunkMap.isChunkOnRangeBorder(chunkPos.x, chunkPos.z, sectionposition.x(), sectionposition.z(), this.viewDistance) || !onlyOnWatchDistanceEdge && ChunkMap.isChunkInRange(chunkPos.x, chunkPos.z, sectionposition.x(), sectionposition.z(), this.viewDistance)) {
- builder.add(entityplayer);
- }
+ // Paper start - per player view distance + // Paper start - per player view distance
+ // there can be potential desync with player's last mapped section and the view distance map, so use the + // there can be potential desync with player's last mapped section and the view distance map, so use the
+ // view distance map here. + // view distance map here.
+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> players = this.playerChunkManager.broadcastMap.getObjectsInRange(chunkPos); + com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> players = this.playerChunkManager.broadcastMap.getObjectsInRange(chunkPos);
+ if (players == null) { + if (players == null) {
+ return java.util.Collections.emptyList(); + return java.util.Collections.emptyList();
+ } }
- while (iterator.hasNext()) { - return builder.build();
- ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- SectionPos sectionposition = entityplayer.getLastSectionPos();
+ List<ServerPlayer> ret = new java.util.ArrayList<>(players.size()); + List<ServerPlayer> ret = new java.util.ArrayList<>(players.size());
+
- if (onlyOnWatchDistanceEdge && ChunkMap.isChunkOnRangeBorder(chunkPos.x, chunkPos.z, sectionposition.x(), sectionposition.z(), this.viewDistance) || !onlyOnWatchDistanceEdge && ChunkMap.isChunkInRange(chunkPos.x, chunkPos.z, sectionposition.x(), sectionposition.z(), this.viewDistance)) {
- builder.add(entityplayer);
+ Object[] backingSet = players.getBackingSet(); + Object[] backingSet = players.getBackingSet();
+ for (int i = 0, len = backingSet.length; i < len; ++i) { + for (int i = 0, len = backingSet.length; i < len; ++i) {
+ if (!(backingSet[i] instanceof ServerPlayer player)) { + if (!(backingSet[i] instanceof ServerPlayer player)) {
@ -14513,11 +14518,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ if (!this.playerChunkManager.isChunkSent(player, chunkPos.x, chunkPos.z, onlyOnWatchDistanceEdge)) { + if (!this.playerChunkManager.isChunkSent(player, chunkPos.x, chunkPos.z, onlyOnWatchDistanceEdge)) {
+ continue; + continue;
} + }
+ ret.add(player); + ret.add(player);
} + }
+
- return builder.build();
+ return ret; + return ret;
+ // Paper end - per player view distance + // Paper end - per player view distance
} }
@ -14883,7 +14887,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- private void dumpTickets(String path) { - private void dumpTickets(String path) {
- try { - try {
- FileOutputStream fileoutputstream = new FileOutputStream(new File(path)); - FileOutputStream fileoutputstream = new FileOutputStream(new File(path));
- + // Paper - rewrite chunk system
- try { - try {
- ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().iterator(); - ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().iterator();
- -
@ -14904,8 +14909,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } catch (Throwable throwable1) { - } catch (Throwable throwable1) {
- throwable.addSuppressed(throwable1); - throwable.addSuppressed(throwable1);
- } - }
+ // Paper - rewrite chunk system -
- throw throwable; - throw throwable;
- } - }
- -
@ -15125,29 +15129,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- ChunkHolder.FullChunkStatus oldChunkState = ChunkHolder.getFullChunkStatus(playerchunk.oldTicketLevel); - ChunkHolder.FullChunkStatus oldChunkState = ChunkHolder.getFullChunkStatus(playerchunk.oldTicketLevel);
- ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel()); - ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel());
- currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)); - currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER));
- } + boolean needsFullScheduling = leastStatus == ChunkStatus.FULL && (chunkHolder == null || !chunkHolder.getChunkStatus().isOrAfter(ChunkHolder.FullChunkStatus.BORDER));
+
+ if ((chunkHolder == null || chunkHolder.getTicketLevel() > minLevel || needsFullScheduling) && !create) {
+ return ChunkHolder.UNLOADED_CHUNK_FUTURE;
}
- if (create && !currentlyUnloading) { - if (create && !currentlyUnloading) {
- // CraftBukkit end - // CraftBukkit end
- this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); - this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
- if (this.chunkAbsent(playerchunk, l)) { - if (this.chunkAbsent(playerchunk, l)) {
- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); - ProfilerFiller gameprofilerfiller = this.level.getProfiler();
-
- gameprofilerfiller.push("chunkLoad"); - gameprofilerfiller.push("chunkLoad");
- this.runDistanceManagerUpdates(); - this.runDistanceManagerUpdates();
- playerchunk = this.getVisibleChunkIfPresent(k); - playerchunk = this.getVisibleChunkIfPresent(k);
- gameprofilerfiller.pop(); - gameprofilerfiller.pop();
- if (this.chunkAbsent(playerchunk, l)) { - if (this.chunkAbsent(playerchunk, l)) {
- throw (IllegalStateException) Util.pauseInIde(new IllegalStateException("No chunk holder after ticket has been added")); - throw (IllegalStateException) Util.pauseInIde(new IllegalStateException("No chunk holder after ticket has been added"));
- }
- }
+ boolean needsFullScheduling = leastStatus == ChunkStatus.FULL && (chunkHolder == null || !chunkHolder.getChunkStatus().isOrAfter(ChunkHolder.FullChunkStatus.BORDER));
+
+ if ((chunkHolder == null || chunkHolder.getTicketLevel() > minLevel || needsFullScheduling) && !create) {
+ return ChunkHolder.UNLOADED_CHUNK_FUTURE;
}
- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap);
- }
+ io.papermc.paper.chunk.system.scheduling.NewChunkHolder.ChunkCompletion chunkCompletion = chunkHolder == null ? null : chunkHolder.getLastChunkCompletion(); + io.papermc.paper.chunk.system.scheduling.NewChunkHolder.ChunkCompletion chunkCompletion = chunkHolder == null ? null : chunkHolder.getLastChunkCompletion();
+ if (needsFullScheduling || chunkCompletion == null || !chunkCompletion.genStatus().isOrAfter(leastStatus)) { + if (needsFullScheduling || chunkCompletion == null || !chunkCompletion.genStatus().isOrAfter(leastStatus)) {
+ // schedule + // schedule
@ -15157,11 +15155,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ret.complete(Either.right(ChunkHolder.ChunkLoadingFailure.UNLOADED)); + ret.complete(Either.right(ChunkHolder.ChunkLoadingFailure.UNLOADED));
+ } else { + } else {
+ ret.complete(Either.left(chunk)); + ret.complete(Either.left(chunk));
+ } }
- }
+ }; + };
+
- private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) {
- return holder == null || holder.oldTicketLevel > maxLevel; // CraftBukkit using oldTicketLevel for isLoaded checks
+ this.level.chunkTaskScheduler.scheduleChunkLoad( + this.level.chunkTaskScheduler.scheduleChunkLoad(
+ chunkX, chunkZ, leastStatus, true, + chunkX, chunkZ, leastStatus, true,
+ isUrgent ? ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.BLOCKING : ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + isUrgent ? ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.BLOCKING : ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL,
@ -15172,12 +15169,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else { + } else {
+ // can return now + // can return now
+ return CompletableFuture.completedFuture(Either.left(chunkCompletion.chunk())); + return CompletableFuture.completedFuture(Either.left(chunkCompletion.chunk()));
+ } }
-
- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap);
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
} }
- private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) {
- return holder == null || holder.oldTicketLevel > maxLevel; // CraftBukkit using oldTicketLevel for isLoaded checks
- }
+ // Paper - rewrite chunk system + // Paper - rewrite chunk system
+
@Override @Override
public boolean hasChunk(int x, int z) { public boolean hasChunk(int x, int z) {
- ChunkHolder playerchunk = this.getVisibleChunkIfPresent((new ChunkPos(x, z)).toLong()); - ChunkHolder playerchunk = this.getVisibleChunkIfPresent((new ChunkPos(x, z)).toLong());
@ -16532,7 +16534,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (result.size() >= limit) { - if (result.size() >= limit) {
- return AbortableIterationConsumer.Continuation.ABORT; - return AbortableIterationConsumer.Continuation.ABORT;
- } - }
- } + // Paper start - optimise this call
+ //TODO use limit
+ if (filter instanceof net.minecraft.world.entity.EntityType entityTypeTest) {
+ ((ServerLevel) this).getEntityLookup().getEntities(entityTypeTest, box, result, predicate);
+ } else {
+ Predicate<? super T> test = (obj) -> {
+ return filter.tryCast(obj) != null;
+ };
+ predicate = predicate == null ? test : test.and((Predicate) predicate);
+ Class base;
+ if (filter == null || (base = filter.getBaseClass()) == null || base == Entity.class) {
+ ((ServerLevel) this).getEntityLookup().getEntities((Entity) null, box, (List) result, (Predicate)predicate);
+ } else {
+ ((ServerLevel) this).getEntityLookup().getEntities(base, null, box, (List) result, (Predicate)predicate); // Paper - optimise this call
}
- -
- if (entity instanceof EnderDragon) { - if (entity instanceof EnderDragon) {
- EnderDragon entityenderdragon = (EnderDragon) entity; - EnderDragon entityenderdragon = (EnderDragon) entity;
@ -16550,21 +16566,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- } - }
- } - }
+ // Paper start - optimise this call - }
+ //TODO use limit
+ if (filter instanceof net.minecraft.world.entity.EntityType entityTypeTest) {
+ ((ServerLevel) this).getEntityLookup().getEntities(entityTypeTest, box, result, predicate);
+ } else {
+ Predicate<? super T> test = (obj) -> {
+ return filter.tryCast(obj) != null;
+ };
+ predicate = predicate == null ? test : test.and((Predicate) predicate);
+ Class base;
+ if (filter == null || (base = filter.getBaseClass()) == null || base == Entity.class) {
+ ((ServerLevel) this).getEntityLookup().getEntities((Entity) null, box, (List) result, (Predicate)predicate);
+ } else {
+ ((ServerLevel) this).getEntityLookup().getEntities(base, null, box, (List) result, (Predicate)predicate); // Paper - optimise this call
}
- -
- return AbortableIterationConsumer.Continuation.CONTINUE; - return AbortableIterationConsumer.Continuation.CONTINUE;
- }); - });
@ -16972,9 +16974,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return protochunk1; - return protochunk1;
+ return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading + return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading
+ } }
+ } }
+
+ // Paper start - async chunk save for unload + // Paper start - async chunk save for unload
+ public record AsyncSaveData( + public record AsyncSaveData(
+ Tag blockTickList, // non-null if we had to go to the server's tick list + Tag blockTickList, // non-null if we had to go to the server's tick list
@ -16996,7 +16998,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (blockEntityNbt != null) { + if (blockEntityNbt != null) {
+ blockEntitiesSerialized.add(blockEntityNbt); + blockEntitiesSerialized.add(blockEntityNbt);
+ } + }
} + }
+ +
+ return new AsyncSaveData( + return new AsyncSaveData(
+ tickLists.get(BLOCK_TICKS_TAG), + tickLists.get(BLOCK_TICKS_TAG),
@ -17004,11 +17006,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ blockEntitiesSerialized, + blockEntitiesSerialized,
+ world.getGameTime() + world.getGameTime()
+ ); + );
} + }
+ // Paper end + // Paper end
+
private static void logErrors(ChunkPos chunkPos, int y, String message) { private static void logErrors(ChunkPos chunkPos, int y, String message) {
ChunkSerializer.LOGGER.error("Recoverable errors when loading section [" + chunkPos.x + ", " + y + ", " + chunkPos.z + "]: " + message); ChunkSerializer.LOGGER.error("Recoverable errors when loading section [" + chunkPos.x + ", " + y + ", " + chunkPos.z + "]: " + message);
}
@@ -0,0 +0,0 @@ public class ChunkSerializer { @@ -0,0 +0,0 @@ public class ChunkSerializer {
// CraftBukkit end // CraftBukkit end
@ -17148,11 +17151,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } catch (Throwable thr) { + } catch (Throwable thr) {
+ return CompletableFuture.failedFuture(thr); + return CompletableFuture.failedFuture(thr);
+ } + }
+ } }
+ @Nullable + @Nullable
+ public CompoundTag readSync(ChunkPos chunkPos) throws IOException { + public CompoundTag readSync(ChunkPos chunkPos) throws IOException {
+ return this.regionFileCache.read(chunkPos); + return this.regionFileCache.read(chunkPos);
} + }
+ // Paper end - async chunk io + // Paper end - async chunk io
- public void write(ChunkPos chunkPos, CompoundTag nbt) { - public void write(ChunkPos chunkPos, CompoundTag nbt) {
@ -17239,17 +17242,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- } - }
- }, this.entityDeserializerQueue::tell); - }, this.entityDeserializerQueue::tell);
+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - copy out read logic into readEntities + throw new UnsupportedOperationException(); // Paper - rewrite chunk system - copy out read logic into readEntities
+ } }
+
- private static ChunkPos readChunkPos(CompoundTag chunkNbt) {
+ // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ public static List<Entity> readEntities(ServerLevel level, CompoundTag compoundTag) { + public static List<Entity> readEntities(ServerLevel level, CompoundTag compoundTag) {
+ ListTag listTag = compoundTag.getList("Entities", 10); + ListTag listTag = compoundTag.getList("Entities", 10);
+ List<Entity> list = EntityType.loadEntitiesRecursive(listTag, level).collect(ImmutableList.toImmutableList()); + List<Entity> list = EntityType.loadEntitiesRecursive(listTag, level).collect(ImmutableList.toImmutableList());
+ return list; + return list;
} + }
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
+
- private static ChunkPos readChunkPos(CompoundTag chunkNbt) {
+ public static ChunkPos readChunkPos(CompoundTag chunkNbt) { // Paper - public + public static ChunkPos readChunkPos(CompoundTag chunkNbt) { // Paper - public
int[] is = chunkNbt.getIntArray("Position"); int[] is = chunkNbt.getIntArray("Position");
return new ChunkPos(is[0], is[1]); return new ChunkPos(is[0], is[1]);
@ -17291,6 +17294,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
- @Override
- public void flush(boolean sync) {
- this.worker.synchronize(sync).join();
- this.entityDeserializerQueue.runAll();
+ // Paper start - rewrite chunk system + // Paper start - rewrite chunk system
+ public static void copyEntities(final CompoundTag from, final CompoundTag into) { + public static void copyEntities(final CompoundTag from, final CompoundTag into) {
+ if (from == null) { + if (from == null) {
@ -17304,8 +17311,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final ListTag entitiesInto = into.getList("Entities", net.minecraft.nbt.Tag.TAG_COMPOUND); + final ListTag entitiesInto = into.getList("Entities", net.minecraft.nbt.Tag.TAG_COMPOUND);
+ into.put("Entities", entitiesInto); // this is in case into doesn't have any entities + into.put("Entities", entitiesInto); // this is in case into doesn't have any entities
+ entitiesInto.addAll(0, entitiesFrom.copy()); // need to copy, this is coming from the save thread + entitiesInto.addAll(0, entitiesFrom.copy()); // need to copy, this is coming from the save thread
+ } }
+
- private CompoundTag upgradeChunkTag(CompoundTag chunkNbt) {
+ public static CompoundTag saveEntityChunk(List<Entity> entities, ChunkPos chunkPos, ServerLevel level) { + public static CompoundTag saveEntityChunk(List<Entity> entities, ChunkPos chunkPos, ServerLevel level) {
+ return saveEntityChunk0(entities, chunkPos, level, false); + return saveEntityChunk0(entities, chunkPos, level, false);
+ } + }
@ -17331,14 +17339,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end - rewrite chunk system + // Paper end - rewrite chunk system
+ +
@Override + @Override
public void flush(boolean sync) { + public void flush(boolean sync) {
- this.worker.synchronize(sync).join();
- this.entityDeserializerQueue.runAll();
+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + throw new UnsupportedOperationException(); // Paper - rewrite chunk system
} + }
+
- private CompoundTag upgradeChunkTag(CompoundTag chunkNbt) {
+ public static CompoundTag upgradeChunkTag(CompoundTag chunkNbt) { // Paper - public and static + public static CompoundTag upgradeChunkTag(CompoundTag chunkNbt) { // Paper - public and static
int i = NbtUtils.getDataVersion(chunkNbt, -1); int i = NbtUtils.getDataVersion(chunkNbt, -1);
return ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY_CHUNK, chunkNbt, i, net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion()); // Paper - route to new converter system return ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.ENTITY_CHUNK, chunkNbt, i, net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion()); // Paper - route to new converter system

Datei anzeigen

@ -4545,13 +4545,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.hasSkyLight = hasBlockLight; // Nice variable name. + this.hasSkyLight = hasBlockLight; // Nice variable name.
+ this.theLightEngine = new ca.spottedleaf.starlight.common.light.StarLightInterface(chunkProvider, this.hasSkyLight, this.hasBlockLight, this); + this.theLightEngine = new ca.spottedleaf.starlight.common.light.StarLightInterface(chunkProvider, this.hasSkyLight, this.hasBlockLight, this);
+ // Paper end - replace light engine impl + // Paper end - replace light engine impl
+ } }
+
+ // Paper start - replace light engine impl + // Paper start - replace light engine impl
+ protected final ChunkAccess getChunk(final int chunkX, final int chunkZ) { + protected final ChunkAccess getChunk(final int chunkX, final int chunkZ) {
+ return ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkAtImmediately(chunkX, chunkZ); + return ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().getChunkAtImmediately(chunkX, chunkZ);
} + }
+
+ protected long relightCounter; + protected long relightCounter;
+ +
+ public int relight(java.util.Set<ChunkPos> chunks_param, + public int relight(java.util.Set<ChunkPos> chunks_param,
@ -5167,13 +5167,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else if (flag1) { + } else if (flag1) {
+ skyNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); + skyNibbles[y - minSection] = new ca.spottedleaf.starlight.common.light.SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG));
+ // Paper end - rewrite the light engine + // Paper end - rewrite the light engine
+ } }
+ +
+ // Paper start - rewrite the light engine + // Paper start - rewrite the light engine
+ } catch (Exception ex) { + } catch (Exception ex) {
+ LOGGER.warn("Failed to load light data for chunk " + chunkPos + " in world '" + world.getWorld().getName() + "', light will be regenerated", ex); + LOGGER.warn("Failed to load light data for chunk " + chunkPos + " in world '" + world.getWorld().getName() + "', light will be regenerated", ex);
+ flag = false; + flag = false;
} + }
+ // Paper end - rewrite light engine + // Paper end - rewrite light engine
} }
} }

Datei anzeigen

@ -17,12 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public int getBeeStingerCooldown() { + public int getBeeStingerCooldown() {
+ return getHandle().removeStingerTime; + return getHandle().removeStingerTime;
+ } + }
+
+ @Override + @Override
+ public void setBeeStingerCooldown(int ticks) { + public void setBeeStingerCooldown(int ticks) {
+ getHandle().removeStingerTime = ticks; + getHandle().removeStingerTime = ticks;
+ } + }
+
+ @Override + @Override
+ public int getBeeStingersInBody() { + public int getBeeStingersInBody() {
+ return getHandle().getStingerCount(); + return getHandle().getStingerCount();

Datei anzeigen

@ -271,13 +271,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected static final class SkyDataLayerStorageMap extends DataLayerStorageMap<SkyLightSectionStorage.SkyDataLayerStorageMap> { protected static final class SkyDataLayerStorageMap extends DataLayerStorageMap<SkyLightSectionStorage.SkyDataLayerStorageMap> {
int currentLowestY; int currentLowestY;
- final Long2IntOpenHashMap topSections; - final Long2IntOpenHashMap topSections;
- + private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
- public SkyDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays, Long2IntOpenHashMap columnToTopSection, int minSectionY) { - public SkyDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays, Long2IntOpenHashMap columnToTopSection, int minSectionY) {
- super(arrays); - super(arrays);
- this.topSections = columnToTopSection; - this.topSections = columnToTopSection;
- columnToTopSection.defaultReturnValue(minSectionY); - columnToTopSection.defaultReturnValue(minSectionY);
+ private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
+
+ // Paper start - avoid copying light data + // Paper start - avoid copying light data
+ public SkyDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> arrays, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int columnToTopSection, int minSectionY, boolean isVisible) { + public SkyDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> arrays, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int columnToTopSection, int minSectionY, boolean isVisible) {
+ super(arrays, isVisible); + super(arrays, isVisible);

Datei anzeigen

@ -16,17 +16,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- while (this.getYRot() - this.yRotO < -180.0F) { - while (this.getYRot() - this.yRotO < -180.0F) {
- this.yRotO -= 360.0F; - this.yRotO -= 360.0F;
- } - }
- + // Paper start - stop large pitch and yaw changes from crashing the server
+ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
- while (this.getYRot() - this.yRotO >= 180.0F) { - while (this.getYRot() - this.yRotO >= 180.0F) {
- this.yRotO += 360.0F; - this.yRotO += 360.0F;
- } - }
+ // Paper start - stop large pitch and yaw changes from crashing the server + this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F;
+ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
- while (this.yBodyRot - this.yBodyRotO < -180.0F) { - while (this.yBodyRot - this.yBodyRotO < -180.0F) {
- this.yBodyRotO -= 360.0F; - this.yBodyRotO -= 360.0F;
- } - }
+ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; + this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F;
- while (this.yBodyRot - this.yBodyRotO >= 180.0F) { - while (this.yBodyRot - this.yBodyRotO >= 180.0F) {
- this.yBodyRotO += 360.0F; - this.yBodyRotO += 360.0F;
@ -35,8 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- while (this.getXRot() - this.xRotO < -180.0F) { - while (this.getXRot() - this.xRotO < -180.0F) {
- this.xRotO -= 360.0F; - this.xRotO -= 360.0F;
- } - }
+ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; -
- while (this.getXRot() - this.xRotO >= 180.0F) { - while (this.getXRot() - this.xRotO >= 180.0F) {
- this.xRotO += 360.0F; - this.xRotO += 360.0F;
- } - }

Datei anzeigen

@ -397,8 +397,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (offers == null) { if (offers == null) {
- return cursor; - return cursor;
+ return; // Paper - Method returns void + return; // Paper - Method returns void
+ } }
+ - candidates.addAll(offers);
+ // Paper start - JLine update + // Paper start - JLine update
+ for (String completion : offers) { + for (String completion : offers) {
+ if (completion.isEmpty()) { + if (completion.isEmpty()) {
@ -406,10 +407,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ candidates.add(new Candidate(completion)); + candidates.add(new Candidate(completion));
} + }
- candidates.addAll(offers);
+ // Paper end + // Paper end
+
+ // Paper start - JLine handles cursor now + // Paper start - JLine handles cursor now
+ /* + /*
final int lastSpace = buffer.lastIndexOf(' '); final int lastSpace = buffer.lastIndexOf(' ');

Datei anzeigen

@ -25,10 +25,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ //this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState()); + //this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState());
+ } else { + } else {
+ eggEvent.setCancelled(true); + eggEvent.setCancelled(true);
+ } }
+ if (eggEvent.callEvent()) { + if (eggEvent.callEvent()) {
+ eggEvent.getNewState().update(true); + eggEvent.getNewState().update(true);
} + }
+ // Paper end - DragonEggFormEvent + // Paper end - DragonEggFormEvent
this.previouslyKilled = true; this.previouslyKilled = true;