mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
* Init 1.21.6
* Finish API patches
* Apply purpur patches & all paper server patches
* Apply some
* Apply all
* Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@6aafe29e 1.21.6 dev
PaperMC/Paper@ae7c74ec tweak mob goal keys, generate missing api
PaperMC/Paper@9ea1460b Revert "fix sponge-absorb deleting chest content (#12647)"
Purpur Changes:
PurpurMC/Purpur@eb0ba67d Updated Upstream (Paper)
PurpurMC/Purpur@7c6502dc Updated Upstream (Paper)
PurpurMC/Purpur@aa289e2c Updated Upstream (Paper)
PurpurMC/Purpur@b1d412fb Updated Upstream (Paper)
PurpurMC/Purpur@293e28a0 use empty registryaccess where context is not needed, closes #1676
PurpurMC/Purpur@452bb319 port PaperMC/Paper#12654, closes #1665
PurpurMC/Purpur@849bc79c register test subcommands used for debugging, closes #1675
* Fix build & diff
* Update vanilla attribute size
* [ci/skip] Forget to remove this
* Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@a24f9b20 1.21.6 dev
PaperMC/Paper@457a0a69 Bump version string and protocol version to 1.21.6 release
PaperMC/Paper@245b5473 Update base to 1.21.6
PaperMC/Paper@b28d77b3 Update Moonrise to 1.21.6
PaperMC/Paper@8318dcb7 Update DataConverter to 1.21.6-rc1
Purpur Changes:
PurpurMC/Purpur@b228e316 Updated Upstream (Paper)
PurpurMC/Purpur@d6562a57 make happy ghast takes-damage-from-water and always-drop-exp options work
PurpurMC/Purpur@08d989b6 inline import
PurpurMC/Purpur@61d7f559 Updated Upstream (Paper)
PurpurMC/Purpur@469a4de5 Merge branch 'ver/1.21.5' into ver/1.21.6
* Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@d2b1158e Set correct world access on BSL snapshots
* Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@023e6c29 Ensure waypoints are per world
PaperMC/Paper@40d5d31c Fix recursively converting JSON Text Components
* Update spigot mapping to remap reobf mapping to mojamp for plugins
* Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@1fcc4162 Implement FeatureHooks#isChunkSent for Moonrise chunk system
PaperMC/Paper@e4d7178a Implement WaypointTransmitter#isChunkVisible
PaperMC/Paper@8980ead7 Directly walk text component after converting from JSON
PaperMC/Paper@5613ed6d Provide env environment variable and copy spigots sys prop for overriding default repository
PaperMC/Paper@62b7f86d Avoid and discourage use of Maven Central as a CDN (#12689)
PaperMC/Paper@f5534cb7 [ci/skip] Run generators (#12691)
PaperMC/Paper@4781d28b Re-add Log4j Javadocs (#12693)
PaperMC/Paper@74fbcce5 Check type of Material in get/set stats (#12607)
PaperMC/Paper@4b3f967e Improve Fix MC-44654 (#12703)
PaperMC/Paper@a7dd2635 Enable spigot obfuscation support (#12695)
PaperMC/Paper@6a51c44e Cleanup Primed TNT Fix (#12704)
PaperMC/Paper@839c6a18 Fix #11169 (#12706)
PaperMC/Paper@c77d5f99 Fix MC-297591
PaperMC/Paper@219f86ee Implement chunk unload delay config option
PaperMC/Paper@e4eb69b8 Do not allow ticket level decreases to be processed asynchronously
PaperMC/Paper@71b0c768 Adds support for vanilla negative explosions (#12705)
PaperMC/Paper@3750927a [ci/skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657)
PaperMC/Paper@d61a51e8 Add ItemType#getBurnDuration() (#12604)
PaperMC/Paper@29fc8532 Allow empty paths in namespaced keys (#12687)
PaperMC/Paper@4419afb9 fix: Safely handle nanosecond overflow in ClickCallback (#12686)
PaperMC/Paper@56528821 Add `isProxyEnabled` method to ServerConfiguration (#12664)
PaperMC/Paper@c0dda0ea Add `isForceDefaultGameMode` method (#12673)
PaperMC/Paper@e714de63 Fix excess slot updates
PaperMC/Paper@6d0821d2 [ci/skip] Fix docs for Spawner class and cleanup (#12710)
PaperMC/Paper@cceffe3d Release ItemType and BlockType (#12708)
PaperMC/Paper@186e9e33 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601)
PaperMC/Paper@5edcf6dd Cleanup/command dispatching (#12713)
Purpur Changes:
PurpurMC/Purpur@baa196f5 Updated Upstream (Paper)
PurpurMC/Purpur@fdd1e980 Updated Upstream (Paper)
PurpurMC/Purpur@439f15db Updated Upstream (Paper)
PurpurMC/Purpur@46a28b93 [ci/skip] update version in README
PurpurMC/Purpur@162bd288 Updated Upstream (Paper)
PurpurMC/Purpur@afcdf9bb Updated Upstream (Paper)
* fix random tick order
Signed-off-by: hayanesuru <hayanesuru@outlook.jp>
* update optimize random tick
* fix mob spawning over limit
* optimize mob spawning
* fix FastBitRadixSort memory leak
* optimize brain collections
* [ci/skip] update comments
* Revert "fix FastBitRadixSort memory leak"
This reverts commit bdea683525.
* optimize brain collections
* fix async mob spawning data race
* [ci/skip] cleanup
* remove hash lookup in optimize random tick
* Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@803baf0b Support hidden entities in Waypoints (#12715)
PaperMC/Paper@1814d8b4 build: publish to fill (#12717)
PaperMC/Paper@e454fef4 Add support for private constructors in plugin main classes (#12652)
PaperMC/Paper@d0e808f4 Move player to correct position in vehicle move packet handler
PaperMC/Paper@46b4b0b8 Improve keepalive ping system
PaperMC/Paper@38c1ddb5 Add and use FeatureHooks.getAllEntities
PaperMC/Paper@2f083acb Ensure player entity schedulers are ticked when they are dead
PaperMC/Paper@7c90c7c4 Optimise EntityScheduler ticking
PaperMC/Paper@aa6ee44a Re-add global region scheduler tick erroneously removed in last commit
PaperMC/Paper@d7510efc Fix #12722 (#12726)
PaperMC/Paper@0caf75f8 Fix #12721 (#12725)
PaperMC/Paper@bee28792 Adventure 4.23.0 (#12690)
PaperMC/Paper@692e93a9 Fix MC-299110
PaperMC/Paper@ea10fa4a Don't mutate the position of Items for MC-4 Fix (#12702)
PaperMC/Paper@aa6cd74c Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668)
PaperMC/Paper@c9e89f49 Expose arrow velocity in EntityShootBowEvent for mobs (#12688)
PaperMC/Paper@7ec3174a Jump out of experimental phase
PaperMC/Paper@4e1a2555 Update try catch for command handling
PaperMC/Paper@e382e687 Fix 0 yield on explosion events
PaperMC/Paper@35b2c6ec Use dropped item for stats info (#12747)
PaperMC/Paper@bd79e20c [ci/skip] PluginManager#getPlugin and PluginManager#isPluginEnabled are case-insensitive (#12723)
Purpur Changes:
PurpurMC/Purpur@4a5974cf Updated Upstream (Paper)
PurpurMC/Purpur@3893bba0 this is important...
PurpurMC/Purpur@47e758fb Updated Upstream (Paper)
* Update PWT patch
* cleanup
* fix playermobcaps command
* fix Didn't fill chunk buffer in async chunk sending
* cleanup
* fix HurtByTargetGoal npe
* optimize collectSpawningChunks (#382)
* optimize collectSpawningChunks
* add bit set
* cleanup
* cleanup
* cleanup
* cleanup
* Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly
Paper Changes:
PaperMC/Paper@57c202e0 Allow adventure nbt codec to parse all tags
Purpur Changes:
PurpurMC/Purpur@a4776d7b Updated Upstream (Paper)
PurpurMC/Purpur@dfd8a7ad Fix phantom going at high speed when ridden (#1680)
* Fix diff
---------
Signed-off-by: hayanesuru <hayanesuru@outlook.jp>
Co-authored-by: hayanesuru <hayanesuru@outlook.jp>
227 lines
11 KiB
Diff
227 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 30 Nov 2022 21:51:16 +0100
|
|
Subject: [PATCH] Faster chunk serialization
|
|
|
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following mixins and classes:
|
|
* "net/caffeinemc/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java"
|
|
* "net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java"
|
|
* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/SimpleBitStorageMixin.java"
|
|
* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PalettedContainerMixin.java"
|
|
By: Angeline <jellysquid3@users.noreply.github.com>
|
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/util/BitStorage.java b/net/minecraft/util/BitStorage.java
|
|
index 02502d50f0255f5bbcc0ecb965abb48cc1a112da..e1f4ca261d106d176298b2afc016f5168abaa06b 100644
|
|
--- a/net/minecraft/util/BitStorage.java
|
|
+++ b/net/minecraft/util/BitStorage.java
|
|
@@ -38,4 +38,6 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti
|
|
return ret;
|
|
}
|
|
// Paper end - block counting
|
|
+
|
|
+ <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out); // Gale - Lithium - faster chunk serialization
|
|
}
|
|
diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java
|
|
index e6306a68c8652d4c5d22d5ecb1416f5f931f76ee..8091f0c0a536047ead4966e70785962e87faad9a 100644
|
|
--- a/net/minecraft/util/SimpleBitStorage.java
|
|
+++ b/net/minecraft/util/SimpleBitStorage.java
|
|
@@ -465,4 +465,45 @@ public class SimpleBitStorage implements BitStorage {
|
|
super(message);
|
|
}
|
|
}
|
|
+
|
|
+ // Gale start - Lithium - faster chunk serialization
|
|
+ @Override
|
|
+ public <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out) {
|
|
+ if (this.size >= Short.MAX_VALUE) {
|
|
+ throw new IllegalStateException("Array too large");
|
|
+ }
|
|
+
|
|
+ if (this.size != out.length) {
|
|
+ throw new IllegalStateException("Array size mismatch");
|
|
+ }
|
|
+
|
|
+ short[] mappings = new short[(int) (this.mask + 1)];
|
|
+
|
|
+ int idx = 0;
|
|
+
|
|
+ for (long word : this.data) {
|
|
+ long bits = word;
|
|
+
|
|
+ for (int elementIdx = 0; elementIdx < this.valuesPerLong; ++elementIdx) {
|
|
+ int value = (int) (bits & this.mask);
|
|
+ int remappedId = mappings[value];
|
|
+
|
|
+ if (remappedId == 0) {
|
|
+ remappedId = dstPalette.idFor(srcPalette.valueFor(value)) + 1;
|
|
+ mappings[value] = (short) remappedId;
|
|
+ }
|
|
+
|
|
+ out[idx] = (short) (remappedId - 1);
|
|
+ bits >>= this.bits;
|
|
+
|
|
+ ++idx;
|
|
+
|
|
+ if (idx >= this.size) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Gale end - Lithium - faster chunk serialization
|
|
+
|
|
}
|
|
diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java
|
|
index 5c1103ef028e5ffe6ce0eadc861dd3b2c8f3ed9f..828ced8aa5665c6f5d0b121947719c4e2ba591fe 100644
|
|
--- a/net/minecraft/util/ZeroBitStorage.java
|
|
+++ b/net/minecraft/util/ZeroBitStorage.java
|
|
@@ -80,4 +80,6 @@ public class ZeroBitStorage implements BitStorage {
|
|
return ret;
|
|
}
|
|
// Paper end - block counting
|
|
+
|
|
+ @Override public <T> void compact(net.minecraft.world.level.chunk.Palette<T> srcPalette, net.minecraft.world.level.chunk.Palette<T> dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization
|
|
}
|
|
diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
index a251ba67644cd02a0b00d7c8b0e2c64aa5e26291..59d48e7dc0911557c57a7e07f5f9013c010165bd 100644
|
|
--- a/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
+++ b/net/minecraft/world/level/chunk/PalettedContainer.java
|
|
@@ -24,6 +24,22 @@ import net.minecraft.util.ThreadingDetector;
|
|
import net.minecraft.util.ZeroBitStorage;
|
|
|
|
public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainerRO<T> {
|
|
+
|
|
+ // Gale start - Lithium - faster chunk serialization
|
|
+ private static final ThreadLocal<short[]> CACHED_ARRAY_4096 = ThreadLocal.withInitial(() -> new short[4096]);
|
|
+ private static final ThreadLocal<short[]> CACHED_ARRAY_64 = ThreadLocal.withInitial(() -> new short[64]);
|
|
+ private Optional<LongStream> asOptional(long[] data) {
|
|
+ return Optional.of(Arrays.stream(data));
|
|
+ }
|
|
+ private short[] getOrCreate(int size) {
|
|
+ return switch (size) {
|
|
+ case 64 -> CACHED_ARRAY_64.get();
|
|
+ case 4096 -> CACHED_ARRAY_4096.get();
|
|
+ default -> new short[size];
|
|
+ };
|
|
+ }
|
|
+ // Gale end - Lithium - faster chunk serialization
|
|
+
|
|
private static final int MIN_PALETTE_BITS = 0;
|
|
private final PaletteResize<T> dummyPaletteResize = (bits, objectAdded) -> 0;
|
|
public final IdMap<T> registry;
|
|
@@ -343,28 +359,54 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> registry, PalettedContainer.Strategy strategy) { // Paper - synchronize
|
|
this.acquire();
|
|
|
|
- PalettedContainerRO.PackedData var12;
|
|
+ // Gale start - Lithium - faster chunk serialization
|
|
+ Optional<LongStream> data = Optional.empty();
|
|
+ List<T> elements = null;
|
|
try {
|
|
- HashMapPalette<T> hashMapPalette = new HashMapPalette<>(registry, this.data.storage.getBits(), this.dummyPaletteResize);
|
|
- int size = strategy.size();
|
|
- int[] ints = new int[size];
|
|
- this.data.storage.unpack(ints);
|
|
- swapPalette(ints, id -> hashMapPalette.idFor(this.data.palette.valueFor(id)));
|
|
- int i = strategy.calculateBitsForSerialization(registry, hashMapPalette.getSize());
|
|
- Optional<LongStream> optional;
|
|
- if (i != 0) {
|
|
- SimpleBitStorage simpleBitStorage = new SimpleBitStorage(i, size, ints);
|
|
- optional = Optional.of(Arrays.stream(simpleBitStorage.getRaw()));
|
|
- } else {
|
|
- optional = Optional.empty();
|
|
+ // The palette that will be serialized
|
|
+ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<T> hashPalette = null;
|
|
+
|
|
+ final Palette<T> palette = this.data.palette();
|
|
+ final BitStorage storage = this.data.storage();
|
|
+ if (storage instanceof ZeroBitStorage || palette.getSize() == 1) {
|
|
+ // If the palette only contains one entry, don't attempt to repack it.
|
|
+ elements = List.of(palette.valueFor(0));
|
|
+ } else if (palette instanceof net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<T> lithiumHashPalette) {
|
|
+ hashPalette = lithiumHashPalette;
|
|
}
|
|
|
|
- var12 = new PalettedContainerRO.PackedData<>(hashMapPalette.getEntries(), optional);
|
|
+ if (elements == null) {
|
|
+ net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<T> compactedPalette = new net.caffeinemc.mods.lithium.common.world.chunk.LithiumHashPalette<>(registry, storage.getBits(), this.dummyPaletteResize);
|
|
+ short[] array = this.getOrCreate(strategy.size());
|
|
+
|
|
+ storage.compact(this.data.palette(), compactedPalette, array);
|
|
+
|
|
+ // If the palette didn't change during compaction, do a simple copy of the data array
|
|
+ if (hashPalette != null && hashPalette.getSize() == compactedPalette.getSize() && storage.getBits() == strategy.calculateBitsForSerialization(registry, hashPalette.getSize())) { // paletteSize can de-sync from palette - see https://github.com/CaffeineMC/lithium-fabric/issues/279
|
|
+ data = this.asOptional(storage.getRaw().clone());
|
|
+ elements = hashPalette.getElements();
|
|
+ } else {
|
|
+ int bits = strategy.calculateBitsForSerialization(registry, compactedPalette.getSize());
|
|
+ if (bits != 0) {
|
|
+ // Re-pack the integer array as the palette has changed size
|
|
+ SimpleBitStorage copy = new SimpleBitStorage(bits, array.length);
|
|
+ for (int i = 0; i < array.length; ++i) {
|
|
+ copy.set(i, array[i]);
|
|
+ }
|
|
+
|
|
+ // We don't need to clone the data array as we are the sole owner of it
|
|
+ data = this.asOptional(copy.getRaw());
|
|
+ }
|
|
+
|
|
+ elements = compactedPalette.getElements();
|
|
+ }
|
|
+ }
|
|
} finally {
|
|
this.release();
|
|
}
|
|
|
|
- return var12;
|
|
+ return new PalettedContainerRO.PackedData<>(elements, data);
|
|
+ // Gale end - Lithium - faster chunk serialization
|
|
}
|
|
|
|
private static <T> void swapPalette(int[] bits, IntUnaryOperator operator) {
|
|
@@ -404,13 +446,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
|
|
|
@Override
|
|
public void count(PalettedContainer.CountConsumer<T> countConsumer) {
|
|
- if (this.data.palette.getSize() == 1) {
|
|
- countConsumer.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
|
- } else {
|
|
- Int2IntOpenHashMap map = new Int2IntOpenHashMap();
|
|
- this.data.storage.getAll(id -> map.addTo(id, 1));
|
|
- map.int2IntEntrySet().forEach(idEntry -> countConsumer.accept(this.data.palette.valueFor(idEntry.getIntKey()), idEntry.getIntValue()));
|
|
+ // Gale start - Lithium - faster chunk serialization
|
|
+ int len = this.data.palette().getSize();
|
|
+
|
|
+ // Do not allocate huge arrays if we're using a large palette
|
|
+ if (len > 4096) {
|
|
+ // VanillaCopy
|
|
+ if (this.data.palette.getSize() == 1) {
|
|
+ countConsumer.accept(this.data.palette.valueFor(0), this.data.storage.getSize());
|
|
+ } else {
|
|
+ Int2IntOpenHashMap map = new Int2IntOpenHashMap();
|
|
+ this.data.storage.getAll(id -> map.addTo(id, 1));
|
|
+ map.int2IntEntrySet().forEach(idEntry -> countConsumer.accept(this.data.palette.valueFor(idEntry.getIntKey()), idEntry.getIntValue()));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ short[] counts = new short[len];
|
|
+
|
|
+ this.data.storage().getAll(i -> counts[i]++);
|
|
+
|
|
+ for (int i = 0; i < counts.length; i++) {
|
|
+ T obj = this.data.palette().valueFor(i);
|
|
+
|
|
+ if (obj != null) {
|
|
+ countConsumer.accept(obj, counts[i]);
|
|
+ }
|
|
}
|
|
+ // Gale end - Lithium - faster chunk serialization
|
|
}
|
|
|
|
record Configuration<T>(Palette.Factory factory, int bits) {
|