mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
Updated Upstream (Bukkit/CraftBukkit) & more patches
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e9ce88b9 SPIGOT-6562: Add more specific sculk sensor event CraftBukkit Changes: d7ef1e91 SPIGOT-6558: Attempt to improve SkullMeta e7a63287 SPIGOT-6562: Add more specific sculk sensor event
This commit is contained in:
parent
4d40e87b33
commit
ea0ec8c5a0
@ -1,153 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 6 Jul 2020 18:36:41 -0400
|
||||
Subject: [PATCH] Fix Concurrency issue in WeightedList
|
||||
1.17 Update: Looks like whatever this patch is trying to fix might be already fixed upstream, needs to be investigated
|
||||
if multiple threads from worldgen sort at same time, it will crash.
|
||||
So make a copy of the list for sorting purposes.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
index 0a65e442ddc31c06f3bb0ff5aa152daee7a210af..a81ad258b39b7472312ab1bedeeacaf26ffae4f7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
@@ -17,7 +17,7 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
||||
private final Set<MemoryModuleType<?>> exitErasedMemories;
|
||||
private final GateBehavior.OrderPolicy orderPolicy;
|
||||
private final GateBehavior.RunningPolicy runningPolicy;
|
||||
- private final WeightedList<Behavior<? super E>> behaviors = new WeightedList<>();
|
||||
+ private final WeightedList<Behavior<? super E>> behaviors = new WeightedList<>(false); // Paper - don't use a clone
|
||||
|
||||
public GateBehavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState, Set<MemoryModuleType<?>> memoriesToForgetWhenStopped, GateBehavior.OrderPolicy order, GateBehavior.RunningPolicy runMode, List<Pair<Behavior<? super E>, Integer>> tasks) {
|
||||
super(requiredMemoryState);
|
||||
@@ -65,10 +65,9 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
||||
}).forEach((behavior) -> {
|
||||
behavior.g(world, entity, time);
|
||||
});
|
||||
- Set set = this.exitErasedMemories;
|
||||
Brain behaviorcontroller = entity.getBrain();
|
||||
|
||||
- set.forEach(behaviorcontroller::removeMemory);
|
||||
+ this.exitErasedMemories.forEach(behaviorcontroller::eraseMemory); // Paper - decomp fix
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,11 +110,11 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
||||
static enum OrderPolicy {
|
||||
|
||||
ORDERED((weightedlist) -> {
|
||||
- }), SHUFFLED(WeightedList::a);
|
||||
+ }), SHUFFLED(WeightedList::shuffle);
|
||||
|
||||
private final Consumer<WeightedList<?>> consumer;
|
||||
|
||||
- private OrderPolicy(Consumer consumer) {
|
||||
+ private OrderPolicy(Consumer<WeightedList<?>> consumer) { // Paper - decomp fix
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
||||
index e4c1c58e9a9c744c7ebb9948a27766b84a081b9e..85df30ef7c03c2f8ae741a8cac8bf601490d2539 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WeightedList.java
|
||||
@@ -6,7 +6,7 @@ import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
-import com.mojang.serialization.OptionalDynamic;
|
||||
+
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -14,26 +14,32 @@ import java.util.stream.Stream;
|
||||
|
||||
public class WeightedList<U> {
|
||||
|
||||
- protected final List<WeightedList.WeightedEntry<U>> entries;
|
||||
+ protected final List<WeightedList.WeightedEntry<U>> list; // Paper - decompile conflict
|
||||
private final Random random;
|
||||
+ private final boolean isUnsafe; // Paper
|
||||
|
||||
- public WeightedList() {
|
||||
- this(Lists.newArrayList());
|
||||
+ // Paper start - add useClone option
|
||||
+ public WeightedList() { this(true); }
|
||||
+ public WeightedList(boolean isUnsafe) {
|
||||
+ this(Lists.newArrayList(), isUnsafe);
|
||||
}
|
||||
|
||||
- private WeightedList(List<WeightedList.WeightedEntry<U>> entries) {
|
||||
+ private WeightedList(List<WeightedList.WeightedEntry<U>> entries) { this(entries, true); }
|
||||
+ private WeightedList(List<WeightedList.WeightedEntry<U>> list, boolean isUnsafe) {
|
||||
+ this.isUnsafe = isUnsafe;
|
||||
+ // Paper end
|
||||
this.random = new Random();
|
||||
- this.entries = Lists.newArrayList(entries);
|
||||
+ this.list = Lists.newArrayList(list); // Paper - decompile conflict
|
||||
}
|
||||
|
||||
public static <U> Codec<WeightedList<U>> codec(Codec<U> codec) {
|
||||
- return WeightedList.entries.a(codec).listOf().xmap(WeightedList::new, (weightedlist) -> {
|
||||
- return weightedlist.a;
|
||||
+ return WeightedList.WeightedEntry.codec(codec).listOf().xmap(WeightedList::new, (weightedlist) -> { // Paper - decompile conflict
|
||||
+ return weightedlist.list; // Paper - decompile conflict
|
||||
});
|
||||
}
|
||||
|
||||
public WeightedList<U> add(U item, int weight) {
|
||||
- this.entries.add(new WeightedList.WeightedEntry<>(item, weight));
|
||||
+ this.list.add(new WeightedList.WeightedEntry<>(item, weight)); // Paper - decompile conflict
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -42,21 +48,20 @@ public class WeightedList<U> {
|
||||
}
|
||||
|
||||
public WeightedList<U> shuffle(Random random) {
|
||||
- this.entries.forEach((weightedlist_a) -> {
|
||||
- weightedlist_a.setRandom(random.nextFloat());
|
||||
- });
|
||||
- this.entries.sort(Comparator.comparingDouble((object) -> {
|
||||
- return ((WeightedList.WeightedEntry) object).getRandWeight();
|
||||
- }));
|
||||
- return this;
|
||||
+ // Paper start - make concurrent safe, work off a clone of the list
|
||||
+ List<WeightedList.WeightedEntry<U>> list = isUnsafe ? new java.util.ArrayList<WeightedList.WeightedEntry<U>>(this.list) : this.list;
|
||||
+ list.forEach((weightedlist_a) -> weightedlist_a.setRandom(random.nextFloat()));
|
||||
+ list.sort(Comparator.comparingDouble(WeightedEntry::getRandWeight));
|
||||
+ return isUnsafe ? new WeightedList<>(list, isUnsafe) : this;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
- return this.entries.isEmpty();
|
||||
+ return this.list.isEmpty(); // Paper - decompile conflict
|
||||
}
|
||||
|
||||
public Stream<U> stream() {
|
||||
- return this.entries.stream().map(WeightedList.entries::a);
|
||||
+ return this.list.stream().map(WeightedList.WeightedEntry::getData); // Paper - decompile conflict
|
||||
}
|
||||
|
||||
public U getOne(Random random) {
|
||||
@@ -64,7 +69,7 @@ public class WeightedList<U> {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
- return "WeightedList[" + this.entries + "]";
|
||||
+ return "WeightedList[" + this.list + "]"; // Paper - decompile conflict
|
||||
}
|
||||
|
||||
public static class WeightedEntry<T> {
|
||||
@@ -98,11 +103,7 @@ public class WeightedList<U> {
|
||||
return new Codec<WeightedList.WeightedEntry<E>>() {
|
||||
public <T> DataResult<Pair<WeightedList.WeightedEntry<E>, T>> decode(DynamicOps<T> dynamicops, T t0) {
|
||||
Dynamic<T> dynamic = new Dynamic(dynamicops, t0);
|
||||
- OptionalDynamic optionaldynamic = dynamic.get("data");
|
||||
- Codec codec1 = codec;
|
||||
-
|
||||
- codec.getClass();
|
||||
- return optionaldynamic.flatMap(codec1::parse).map((object) -> {
|
||||
+ return dynamic.get("data").flatMap(codec::parse).map((object) -> { // Paper - decompile error
|
||||
return new WeightedList.WeightedEntry<>(object, dynamic.get("weight").asInt(1));
|
||||
}).map((weightedlist_a) -> {
|
||||
return Pair.of(weightedlist_a, dynamicops.empty());
|
@ -8,7 +8,8 @@ to a chunk. The default values of -1 disable the limit. Although
|
||||
defaults are only included for certain entites, this allows setting
|
||||
limits for any entity type.
|
||||
|
||||
1.17: entities not in chunks anymore
|
||||
1.17: looks like tracking the count on should work fine just putting it in the EntityType#loadEntitiesRecursive, but
|
||||
the tracking count on save needs some more work to implement.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 7ebc85264a2cbfb601dfe5472b561cac1a7cf8bf..486e5438254348db68017228af131cba7defd637 100644
|
||||
|
@ -5,10 +5,10 @@ Subject: [PATCH] Use UserCache for player heads
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 354dcb1ddf74f39e367d50a8b8e2beeb9b2f9d02..b19d50bbe6c944ff66230ac013178bd036a438c8 100644
|
||||
index 6432f668f72c0543283b5a1439d01da81ff5b981..9405812b8c308d70de1e26ba55500301b24ecc3c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -166,7 +166,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
@@ -168,7 +168,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
if (name == null) {
|
||||
this.setProfile(null);
|
||||
} else {
|
||||
|
@ -40,7 +40,7 @@ index 1879ae835c437883f76330d6e2707460273d02db..df0ba7ed56fc635a4aa30934d1990043
|
||||
public BlockFace getRotation() {
|
||||
BlockData blockData = getBlockData();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 5e345224e698bd80133dc194385c033369a60a33..33994a050826d10d69f375f65ecce2b56116cca0 100644
|
||||
index 490df0dcfd0e1e0ab05943410493522f86444ef8..7cacc61fed0c610845c67894d1cc68e44f5e46fe 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -4,10 +4,8 @@ import com.google.common.collect.ImmutableMap.Builder;
|
||||
@ -68,7 +68,7 @@ index 5e345224e698bd80133dc194385c033369a60a33..33994a050826d10d69f375f65ecce2b5
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
@@ -149,6 +152,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
@@ -151,6 +154,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
return this.hasOwner() ? this.profile.getName() : null;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 6 Jul 2020 18:36:41 -0400
|
||||
Subject: [PATCH] Fix Concurrency issue in WeightedList
|
||||
|
||||
if multiple threads from worldgen sort at same time, it will crash.
|
||||
So make a copy of the list for sorting purposes.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
index 893c37cc7e33f4baa98131afca45a258600ddc75..09998d160a6d79fdb5a5041a5d572649a1532e6a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
@@ -16,7 +16,7 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
||||
private final Set<MemoryModuleType<?>> exitErasedMemories;
|
||||
private final GateBehavior.OrderPolicy orderPolicy;
|
||||
private final GateBehavior.RunningPolicy runningPolicy;
|
||||
- private final ShufflingList<Behavior<? super E>> behaviors = new ShufflingList<>();
|
||||
+ private final ShufflingList<Behavior<? super E>> behaviors = new ShufflingList<>(false); // Paper - don't use a clone
|
||||
|
||||
public GateBehavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState, Set<MemoryModuleType<?>> memoriesToForgetWhenStopped, GateBehavior.OrderPolicy order, GateBehavior.RunningPolicy runMode, List<Pair<Behavior<? super E>, Integer>> tasks) {
|
||||
super(requiredMemoryState);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
index d4c9def80154c3e62a0b6928057062a0808f339f..4fa64b1e2004810906bb0b174436c8e687a75ada 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
@@ -14,12 +14,25 @@ import java.util.stream.Stream;
|
||||
public class ShufflingList<U> {
|
||||
protected final List<ShufflingList.WeightedEntry<U>> entries;
|
||||
private final Random random = new Random();
|
||||
+ private final boolean isUnsafe; // Paper
|
||||
|
||||
public ShufflingList() {
|
||||
+ // Paper start
|
||||
+ this(true);
|
||||
+ }
|
||||
+ public ShufflingList(boolean isUnsafe) {
|
||||
+ this.isUnsafe = isUnsafe;
|
||||
+ // Paper end
|
||||
this.entries = Lists.newArrayList();
|
||||
}
|
||||
|
||||
private ShufflingList(List<ShufflingList.WeightedEntry<U>> list) {
|
||||
+ // Paper start
|
||||
+ this(list, true);
|
||||
+ }
|
||||
+ private ShufflingList(List<ShufflingList.WeightedEntry<U>> list, boolean isUnsafe) {
|
||||
+ this.isUnsafe = isUnsafe;
|
||||
+ // Paper end
|
||||
this.entries = Lists.newArrayList(list);
|
||||
}
|
||||
|
||||
@@ -35,11 +48,12 @@ public class ShufflingList<U> {
|
||||
}
|
||||
|
||||
public ShufflingList<U> shuffle() {
|
||||
- this.entries.forEach((entry) -> {
|
||||
- entry.setRandom(this.random.nextFloat());
|
||||
- });
|
||||
- this.entries.sort(Comparator.comparingDouble(ShufflingList.WeightedEntry::getRandWeight));
|
||||
- return this;
|
||||
+ // Paper start - make concurrent safe, work off a clone of the list
|
||||
+ List<ShufflingList.WeightedEntry<U>> list = this.isUnsafe ? Lists.newArrayList(this.entries) : this.entries;
|
||||
+ list.forEach(entry -> entry.setRandom(this.random.nextFloat()));
|
||||
+ list.sort(Comparator.comparingDouble(ShufflingList.WeightedEntry::getRandWeight));
|
||||
+ return this.isUnsafe ? new ShufflingList<>(list, this.isUnsafe) : this;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public Stream<U> stream() {
|
@ -2,18 +2,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 8 Oct 2020 00:00:25 -0400
|
||||
Subject: [PATCH] Fix "Not a string" Map Conversion spam
|
||||
1.17 Update: See if this is still needed, might be fixed upstream
|
||||
|
||||
The maps did convert successfully, but had noisy logs due to Spigot
|
||||
implementing this logic incorrectly.
|
||||
|
||||
This stops the spam by converting the old format to new before
|
||||
requesting the world.
|
||||
|
||||
Track spigot issue to see when fixed: https://hub.spigotmc.org/jira/browse/SPIGOT-6181
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
index 7582c7cd4235d212a0cf66a4c59ce0cedaa360ad..e7b178127228dea5a17ba0fbd6bae148d70e8eb5 100644
|
||||
index 15c6f9d1c43fbedac70526a84a010be83b4cae86..e90cb274ae07a259b90ec2badf35980ba684c5b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
@@ -12,6 +12,8 @@ import net.minecraft.core.BlockPos;
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
@ -22,20 +24,20 @@ index 7582c7cd4235d212a0cf66a4c59ce0cedaa360ad..e7b178127228dea5a17ba0fbd6bae148
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@@ -94,7 +96,26 @@ public class MapItemSavedData extends SavedData {
|
||||
@@ -104,7 +106,26 @@ public class MapItemSavedData extends SavedData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag tag) {
|
||||
- DataResult<ResourceKey<Level>> dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, tag.get("dimension"))); // CraftBukkit - decompile error
|
||||
public static MapItemSavedData load(CompoundTag nbt) {
|
||||
- DataResult dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, nbt.get("dimension")));
|
||||
+ // Paper start - fix "Not a string" spam
|
||||
+ Tag dimension = tag.get("dimension");
|
||||
+ Tag dimension = nbt.get("dimension");
|
||||
+ if (dimension instanceof NumericTag && ((NumericTag) dimension).getAsInt() >= CraftWorld.CUSTOM_DIMENSION_OFFSET) {
|
||||
+ long least = tag.getLong("UUIDLeast");
|
||||
+ long most = tag.getLong("UUIDMost");
|
||||
+ long least = nbt.getLong("UUIDLeast");
|
||||
+ long most = nbt.getLong("UUIDMost");
|
||||
+
|
||||
+ if (least != 0L && most != 0L) {
|
||||
+ this.uniqueId = new UUID(most, least);
|
||||
+ CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId);
|
||||
+ UUID uuid = new UUID(most, least);
|
||||
+ CraftWorld world = (CraftWorld) Bukkit.getWorld(uuid);
|
||||
+ if (world != null) {
|
||||
+ dimension = StringTag.create("minecraft:" + world.getName().toLowerCase(java.util.Locale.ENGLISH));
|
||||
+ } else {
|
||||
@ -49,4 +51,4 @@ index 7582c7cd4235d212a0cf66a4c59ce0cedaa360ad..e7b178127228dea5a17ba0fbd6bae148
|
||||
+ // Paper end - fix "Not a string" spam
|
||||
Logger logger = MapItemSavedData.LOGGER;
|
||||
|
||||
logger.getClass();
|
||||
Objects.requireNonNull(logger);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user