more work work work

This commit is contained in:
Aurora 2021-06-14 12:42:08 +02:00
parent d2cb88db9c
commit 8ca5a642ef
No known key found for this signature in database
GPG key ID: 89839F67B53656AD
32 changed files with 267 additions and 264 deletions

View file

@ -0,0 +1,159 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 4 Aug 2020 22:24:15 +0200
Subject: [PATCH] Optimize Pathfinder - Remove Streams / Optimized collections
1.17 Update: Please do this k thx bb
I utilized the IDE to convert streams to non streams code, so shouldn't
be any risk of behavior change. Only did minor optimization of the
generated code set to remove unnecessary things.
I expect us to just drop this patch on next major update and re-apply
it with the IDE again and re-apply the collections optimization.
Optimize collection by creating a list instead of a set of the key and value.
This lets us get faster foreach iteration, as well as avoids map lookups on
the values when needed.
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
index ba8ee93032aabe7ec4ecf52d452e1a580d6ebc20..2ef0e04af771e14f8d71aef4ccb81d3b81db7df5 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
@@ -33,28 +33,31 @@ public class PathFinder {
this.openSet.a();
this.nodeEvaluator.prepare(world, mob);
Node pathpoint = this.nodeEvaluator.getStart();
- Map<Target, BlockPos> map = (Map) positions.stream().collect(Collectors.toMap((blockposition) -> {
- return this.nodeEvaluator.getGoal((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
- }, Function.identity()));
- Path pathentity = this.findPath(pathpoint, map, followRange, distance, rangeMultiplier);
+ // Paper start - remove streams - and optimize collection
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
+ for (BlockPos blockposition : positions) {
+ map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal((double) blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockposition));
+ }
+ // Paper end
+ Path pathentity = this.a(pathpoint, map, followRange, distance, rangeMultiplier);
this.nodeEvaluator.done();
return pathentity;
}
@Nullable
- private Path findPath(Node startNode, Map<Target, BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
- Set<Target> set = positions.keySet();
+ private Path a(Node pathpoint, List<Map.Entry<Target, BlockPos>> list, float f, int i, float f1) { // Paper - optimize collection
+ //Set<PathDestination> set = map.keySet(); // Paper
- startNode.g = 0.0F;
- startNode.h = this.getBestH(startNode, set);
- startNode.f = startNode.h;
+ pathpoint.g = 0.0F;
+ pathpoint.h = this.a(pathpoint, list); // Paper - optimize collection
+ pathpoint.f = pathpoint.h;
this.openSet.a();
- this.openSet.a(startNode);
+ this.openSet.a(pathpoint);
Set<Node> set1 = ImmutableSet.of();
int j = 0;
- Set<Target> set2 = Sets.newHashSetWithExpectedSize(set.size());
- int k = (int) ((float) this.maxVisitedNodes * rangeMultiplier);
+ List<Map.Entry<Target, BlockPos>> set2 = Lists.newArrayListWithExpectedSize(list.size()); // Paper - optimize collection
+ int k = (int) ((float) this.maxVisitedNodes * f1);
while (!this.openSet.e()) {
++j;
@@ -65,14 +68,15 @@ public class PathFinder {
Node pathpoint1 = this.openSet.c();
pathpoint1.closed = true;
- Iterator iterator = set.iterator();
-
- while (iterator.hasNext()) {
- Target pathdestination = (Target) iterator.next();
+ // Paper start - optimize collection
+ for (int i1 = 0; i1 < list.size(); i1++) {
+ Map.Entry<Target, BlockPos> entry = list.get(i1);
+ Target pathdestination = entry.getKey();
- if (pathpoint1.distanceManhattan((Node) pathdestination) <= (float) distance) {
+ if (pathpoint1.distanceManhattan((Node) pathdestination) <= (float) i) {
pathdestination.setReached();
- set2.add(pathdestination);
+ set2.add(entry);
+ // Paper end
}
}
@@ -80,7 +84,7 @@ public class PathFinder {
break;
}
- if (pathpoint1.distanceTo(startNode) < followRange) {
+ if (pathpoint1.distanceTo(pathpoint) < f) {
int l = this.nodeEvaluator.getNeighbors(this.neighbors, pathpoint1);
for (int i1 = 0; i1 < l; ++i1) {
@@ -90,10 +94,10 @@ public class PathFinder {
pathpoint2.walkedDistance = pathpoint1.walkedDistance + f2;
float f3 = pathpoint1.g + f2 + pathpoint2.costMalus;
- if (pathpoint2.walkedDistance < followRange && (!pathpoint2.inOpenSet() || f3 < pathpoint2.g)) {
+ if (pathpoint2.walkedDistance < f && (!pathpoint2.inOpenSet() || f3 < pathpoint2.g)) {
pathpoint2.cameFrom = pathpoint1;
pathpoint2.g = f3;
- pathpoint2.h = this.getBestH(pathpoint2, set) * 1.5F;
+ pathpoint2.h = this.a(pathpoint2, list) * 1.5F; // Paper - list instead of set
if (pathpoint2.inOpenSet()) {
this.openSet.a(pathpoint2, pathpoint2.g + pathpoint2.h);
} else {
@@ -105,31 +109,32 @@ public class PathFinder {
}
}
- Optional<Path> optional = !set2.isEmpty() ? set2.stream().map((pathdestination1) -> {
- return this.reconstructPath(pathdestination1.getBestNode(), (BlockPos) positions.get(pathdestination1), true);
- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map((pathdestination1) -> {
- return this.reconstructPath(pathdestination1.getBestNode(), (BlockPos) positions.get(pathdestination1), false);
- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
-
- if (!optional.isPresent()) {
- return null;
- } else {
- Path pathentity = (Path) optional.get();
-
- return pathentity;
+ // Paper start - remove streams - and optimize collection
+ Path best = null;
+ boolean useSet1 = set2.isEmpty();
+ Comparator<Path> comparator = useSet1 ? Comparator.comparingInt(Path::getNodeCount)
+ : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
+ for (Map.Entry<Target, BlockPos> entry : useSet1 ? list : set2) {
+ Path pathEntity = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !useSet1);
+ if (best == null || comparator.compare(pathEntity, best) < 0)
+ best = pathEntity;
}
+ return best;
+ // Paper end
}
- private float getBestH(Node node, Set<Target> targets) {
+ private float a(Node pathpoint, List<Map.Entry<Target, BlockPos>> list) { // Paper - optimize collection
float f = Float.MAX_VALUE;
float f1;
- for (Iterator iterator = targets.iterator(); iterator.hasNext(); f = Math.min(f1, f)) {
- Target pathdestination = (Target) iterator.next();
+ // Paper start - optimize collection
+ for (int i = 0, listSize = list.size(); i < listSize; f = Math.min(f1, f), i++) { // Paper
+ Target pathdestination = list.get(i).getKey(); // Paper
+ // Paper end
- f1 = node.distanceTo(pathdestination);
- pathdestination.updateBest(f1, node);
+ f1 = pathpoint.distanceTo(pathdestination);
+ pathdestination.updateBest(f1, pathpoint);
}
return f;

View file

@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Wed, 12 Aug 2020 11:33:04 +0200
Subject: [PATCH] Import fastutil classes
1.17: YEET
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
index 95e166aa63f42c675df645a56e313bdffc2e8663..05f7d4a3835536f26f741d54a0884bd43fc82967 100644
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
@@ -16,6 +16,7 @@ import net.minecraft.CrashReport;
import net.minecraft.ReportedException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; // Paper
import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -25,7 +26,7 @@ public class SynchedEntityData {
private static final Logger LOGGER = LogManager.getLogger();
private static final Map<Class<? extends Entity>, Integer> ENTITY_ID_POOL = Maps.newHashMap();
private final Entity entity;
- private final it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<SynchedEntityData.DataItem<?>> entries = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); // Spigot - use better map // PAIL
+ private final Int2ObjectOpenHashMap<DataItem<?>> entries = new Int2ObjectOpenHashMap<>(); // Spigot - use better map // PAIL
// private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required
private boolean isEmpty = true;
private boolean isDirty;

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Fri, 14 Aug 2020 23:59:26 +0200
Subject: [PATCH] Remove armour stand double add to world
1.17 Update: YEET (?)
diff --git a/src/main/java/net/minecraft/world/item/ArmorStandItem.java b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
index a2dfcaac8a2a4a69e703de43be76d4fe369fd647..bed063497bb593683ea384605ae1a71a68f4fc1b 100644
--- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java
+++ b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
@@ -53,7 +53,7 @@ public class ArmorStandItem extends Item {
return InteractionResult.FAIL;
}
- worldserver.addFreshEntityWithPassengers(entityarmorstand);
+ // Paper - moved down
float f = (float) Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F;
entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F);
@@ -63,7 +63,7 @@ public class ArmorStandItem extends Item {
return InteractionResult.FAIL;
}
// CraftBukkit end
- world.addFreshEntity(entityarmorstand);
+ worldserver.addFreshEntityWithPassengers(entityarmorstand); // Paper - moved down
world.playSound((Player) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F);
}

View file

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Thu, 20 Aug 2020 19:24:13 -0700
Subject: [PATCH] Fix MC-99259 Wither Boss Bar doesn't update until
1.17 Update: This issue is marked as fixed on 1.17 - yeet!
invulnerability period is over
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
index edd231568b75330d0cffbecb03a7e9dbc55d5f94..1f330d852eb9b3a36570542e10a88ae065798714 100644
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -391,8 +391,9 @@ public class WitherBoss extends Monster implements RangedAttackMob {
this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
- this.bossEvent.setPercent(this.getHealth() / this.getMaxHealth());
+ //this.bossBattle.setProgress(this.getHealth() / this.getMaxHealth()); // Paper - Moved down
}
+ this.bossEvent.setPercent(this.getHealth() / this.getMaxHealth()); // Paper - Fix MC-99259 (Boss bar does not update until Wither invulnerability period ends)
}
public static boolean canDestroy(BlockState block) {

View file

@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ishland <ishlandmc@yeah.net>
Date: Sun, 23 Aug 2020 10:57:44 +0200
Subject: [PATCH] Fix MC-197271
Update 1.17: Fixed in openj9-0.23.0-m2 release
This patch only fixes an issue for servers running OpenJ9.
diff --git a/src/main/java/net/minecraft/data/BuiltinRegistries.java b/src/main/java/net/minecraft/data/BuiltinRegistries.java
index d64cebb4431664762a14670c7d9d782dd7894ed5..0c403ea85f7ea20f2f978e06313f8675abf204b6 100644
--- a/src/main/java/net/minecraft/data/BuiltinRegistries.java
+++ b/src/main/java/net/minecraft/data/BuiltinRegistries.java
@@ -48,11 +48,11 @@ public class BuiltinRegistries {
public static final Registry<StructureProcessorList> PROCESSOR_LIST = registerSimple(Registry.PROCESSOR_LIST_REGISTRY, () -> {
return ProcessorLists.b;
});
- public static final Registry<StructureTemplatePool> TEMPLATE_POOL = registerSimple(Registry.TEMPLATE_POOL_REGISTRY, Pools::bootstrap);
+ public static final Registry<StructureTemplatePool> TEMPLATE_POOL = registerSimple(Registry.TEMPLATE_POOL_REGISTRY, () -> Pools.bootstrap()); // Paper - MC-197271
public static final Registry<Biome> BIOME = registerSimple(Registry.BIOME_REGISTRY, () -> {
return Biomes.PLAINS;
});
- public static final Registry<NoiseGeneratorSettings> NOISE_GENERATOR_SETTINGS = registerSimple(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY, NoiseGeneratorSettings::bootstrap);
+ public static final Registry<NoiseGeneratorSettings> NOISE_GENERATOR_SETTINGS = registerSimple(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY, () -> NoiseGeneratorSettings.bootstrap()); // Paper - MC-197271
private static <T> Registry<T> registerSimple(ResourceKey<? extends Registry<T>> registryRef, Supplier<T> defaultValueSupplier) {
return registerSimple(registryRef, Lifecycle.stable(), defaultValueSupplier);
@@ -66,9 +66,9 @@ public class BuiltinRegistries {
ResourceLocation minecraftkey = registryRef.location();
BuiltinRegistries.LOADERS.put(minecraftkey, defaultValueSupplier);
- WritableRegistry<R> iregistrywritable = BuiltinRegistries.WRITABLE_REGISTRY;
+ WritableRegistry<R> iregistrywritable = (WritableRegistry<R>) BuiltinRegistries.WRITABLE_REGISTRY; // Paper - decompile fix
- return (WritableRegistry) iregistrywritable.register(registryRef, (Object) registry, lifecycle);
+ return (R) iregistrywritable.register((ResourceKey<R>) registryRef, registry, lifecycle); // Paper - decompile fix
}
public static <T> T register(Registry<? super T> registry, String id, T object) {
@@ -76,11 +76,11 @@ public class BuiltinRegistries {
}
public static <V, T extends V> T register(Registry<V> registry, ResourceLocation id, T object) {
- return ((WritableRegistry) registry).register(ResourceKey.create(registry.key(), id), object, Lifecycle.stable());
+ return (T) ((WritableRegistry) registry).register(ResourceKey.create(registry.key(), id), object, Lifecycle.stable()); // Paper - decompile fix
}
public static <V, T extends V> T registerMapping(Registry<V> iregistry, int rawId, ResourceKey<V> resourcekey, T object) {
- return ((WritableRegistry) iregistry).registerMapping(rawId, resourcekey, object, Lifecycle.stable());
+ return (T) ((WritableRegistry) iregistry).registerMapping(rawId, resourcekey, object, Lifecycle.stable()); // Paper - decompile fix
}
public static void bootstrap() {}

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 21 Aug 2020 21:05:28 -0400
Subject: [PATCH] MC-197883: Bandaid decode issue
1.17 Update: Marked as fixed in 1.17 on mojira, yeet
Mojang has a mix of type and name in the data sets, but you can only
use one.
This will retry as name if type is asked for and not found.
diff --git a/src/main/java/com/mojang/serialization/codecs/KeyDispatchCodec.java b/src/main/java/com/mojang/serialization/codecs/KeyDispatchCodec.java
index de7d1e5e0319c65775d932144c268c2d55bb7dc7..bd6a0e1b5454e880a4f2a16be7dc8da64b73e11d 100644
--- a/src/main/java/com/mojang/serialization/codecs/KeyDispatchCodec.java
+++ b/src/main/java/com/mojang/serialization/codecs/KeyDispatchCodec.java
@@ -48,7 +48,12 @@ public class KeyDispatchCodec<K, V> extends MapCodec<V> {
@Override
public <T> DataResult<V> decode(final DynamicOps<T> ops, final MapLike<T> input) {
- final T elementName = input.get(typeKey);
+ // Paper start - bandaid MC-197883
+ T elementName = input.get(typeKey);
+ if (elementName == null && "type".equals(typeKey)) {
+ elementName = input.get("name");
+ }
+ // Paper end
if (elementName == null) {
return DataResult.error("Input does not contain a key [" + typeKey + "]: " + input);
}