From 7b9e2e61e4d95c2ed8f368644c3715584d2fad8d Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:20:06 +0300 Subject: [PATCH] finish this --- ...03-Completely-remove-Mojang-profiler.patch | 2297 +---------------- .../0047-C2ME-Density-Function-Compiler.patch | 91 +- ...patch => 0048-Copper-Bulb-1gt-delay.patch} | 0 ...=> 0049-Petal-Multithreaded-Tracker.patch} | 0 ...lay.patch => 0050-Crafter-1gt-delay.patch} | 0 ...-SparklyPaper-Parallel-world-ticking.patch | 178 +- ...> 0052-Cleanup-dead-code-from-Paper.patch} | 74 +- .../0053-MSPT-Tracking-for-each-world.patch | 8 +- .../0054-Regionized-Chunk-Ticking.patch | 48 +- ...C2ME-Optimize-Aquifer-and-Beardifier.patch | 499 ++-- .../0056-Catch-update-suppressors.patch | 38 +- ...r-ShapelessRecipes-comparison-for-V.patch} | 0 ...ch => 0058-C2ME-The-End-Biome-Cache.patch} | 0 ...9-Euclidean-distance-squared-option.patch} | 0 ...Do-not-send-spectator-change-packet.patch} | 10 +- .../0061-Raytrace-Entity-Tracker.patch | 47 +- ...verListPingEvent-for-secondary-motd.patch} | 4 +- ...gurable-player-spawn-tracking-range.patch} | 0 .../0064-Linear-region-file-format.patch | 68 +- .../features/0065-Leaves-Protocol-Core.patch | 30 +- ....patch => 0066-Optimize-collections.patch} | 6 +- ...PR-Optimise-non-flush-packet-sending.patch | 12 +- ...atch => 0068-Optimize-level-ticking.patch} | 8 +- ...9-lithium-combined_heightmap_update.patch} | 4 +- .../features}/0070-Optimize-Moonrise.patch | 95 +- .../features/0071-Entity-Status-Lock.patch | 0 .../0072-lithium-sleeping_block_entity.patch | 196 +- .../0073-lithium-equipment_tracking.patch | 24 +- .../0074-Configurable-Files-Locations.patch | 45 + .../0015-Petal-Multithreaded-Tracker.patch | 8 +- ...016-Pufferfish-Optimize-mob-spawning.patch | 0 ...r-ShapelessRecipes-comparison-for-V.patch} | 0 .../features}/0018-Leaves-Protocol-Core.patch | 6 +- ...-SparklyPaper-Parallel-world-ticking.patch | 32 +- .../features}/0020-Optimize-Moonrise.patch | 0 .../divinemc/async/AsyncJoinHandler.java | 82 - .../divinemc/async/ExecutorShutdown.java | 9 - .../0075-Configurable-Files-Locations.patch | 62 - 38 files changed, 820 insertions(+), 3161 deletions(-) rename {patches/todo/minecraft-patches => divinemc-server/minecraft-patches/features}/0047-C2ME-Density-Function-Compiler.patch (95%) rename divinemc-server/minecraft-patches/features/{0047-Copper-Bulb-1gt-delay.patch => 0048-Copper-Bulb-1gt-delay.patch} (100%) rename divinemc-server/minecraft-patches/features/{0048-Petal-Multithreaded-Tracker.patch => 0049-Petal-Multithreaded-Tracker.patch} (100%) rename divinemc-server/minecraft-patches/features/{0049-Crafter-1gt-delay.patch => 0050-Crafter-1gt-delay.patch} (100%) rename patches/todo/minecraft-patches/0049-SparklyPaper-Parallel-world-ticking.patch => divinemc-server/minecraft-patches/features/0051-SparklyPaper-Parallel-world-ticking.patch (93%) rename divinemc-server/minecraft-patches/features/{0050-Cleanup-dead-code-from-Paper.patch => 0052-Cleanup-dead-code-from-Paper.patch} (58%) rename patches/todo/minecraft-patches/0050-MSPT-Tracking-for-each-world.patch => divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch (86%) rename patches/todo/minecraft-patches/0052-Regionized-Chunk-Ticking.patch => divinemc-server/minecraft-patches/features/0054-Regionized-Chunk-Ticking.patch (93%) rename patches/todo/minecraft-patches/0054-C2ME-Optimize-Aquifer-and-Beardifier.patch => divinemc-server/minecraft-patches/features/0055-C2ME-Optimize-Aquifer-and-Beardifier.patch (64%) rename patches/todo/minecraft-patches/0051-Catch-update-suppressors.patch => divinemc-server/minecraft-patches/features/0056-Catch-update-suppressors.patch (72%) rename divinemc-server/minecraft-patches/features/{0051-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch => 0057-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch} (100%) rename divinemc-server/minecraft-patches/features/{0052-C2ME-The-End-Biome-Cache.patch => 0058-C2ME-The-End-Biome-Cache.patch} (100%) rename divinemc-server/minecraft-patches/features/{0053-Euclidean-distance-squared-option.patch => 0059-Euclidean-distance-squared-option.patch} (100%) rename divinemc-server/minecraft-patches/features/{0054-Do-not-send-spectator-change-packet.patch => 0060-Do-not-send-spectator-change-packet.patch} (95%) rename patches/todo/minecraft-patches/0057-Raytrace-Entity-Tracker.patch => divinemc-server/minecraft-patches/features/0061-Raytrace-Entity-Tracker.patch (66%) rename divinemc-server/minecraft-patches/features/{0055-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch => 0062-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch} (92%) rename divinemc-server/minecraft-patches/features/{0056-Configurable-player-spawn-tracking-range.patch => 0063-Configurable-player-spawn-tracking-range.patch} (100%) rename patches/todo/minecraft-patches/0061-Linear-region-file-format.patch => divinemc-server/minecraft-patches/features/0064-Linear-region-file-format.patch (89%) rename patches/todo/minecraft-patches/0059-Leaves-Protocol-Core.patch => divinemc-server/minecraft-patches/features/0065-Leaves-Protocol-Core.patch (86%) rename divinemc-server/minecraft-patches/features/{0057-Optimize-collections.patch => 0066-Optimize-collections.patch} (95%) rename patches/todo/minecraft-patches/0060-Paper-PR-Optimise-non-flush-packet-sending.patch => divinemc-server/minecraft-patches/features/0067-Paper-PR-Optimise-non-flush-packet-sending.patch (86%) rename divinemc-server/minecraft-patches/features/{0058-Optimize-level-ticking.patch => 0068-Optimize-level-ticking.patch} (97%) rename divinemc-server/minecraft-patches/features/{0059-lithium-combined_heightmap_update.patch => 0069-lithium-combined_heightmap_update.patch} (94%) rename {patches/todo/minecraft-patches => divinemc-server/minecraft-patches/features}/0070-Optimize-Moonrise.patch (88%) rename patches/todo/minecraft-patches/0072-Entity-Status-Lock.patch => divinemc-server/minecraft-patches/features/0071-Entity-Status-Lock.patch (100%) rename patches/todo/minecraft-patches/0073-lithium-sleeping_block_entity.patch => divinemc-server/minecraft-patches/features/0072-lithium-sleeping_block_entity.patch (94%) rename patches/todo/minecraft-patches/0074-lithium-equipment_tracking.patch => divinemc-server/minecraft-patches/features/0073-lithium-equipment_tracking.patch (93%) create mode 100644 divinemc-server/minecraft-patches/features/0074-Configurable-Files-Locations.patch rename patches/todo/paper-patches/0014-Petal-Multithreaded-Tracker.patch => divinemc-server/paper-patches/features/0015-Petal-Multithreaded-Tracker.patch (93%) rename patches/todo/paper-patches/0015-Pufferfish-Optimize-mob-spawning.patch => divinemc-server/paper-patches/features/0016-Pufferfish-Optimize-mob-spawning.patch (100%) rename divinemc-server/paper-patches/features/{0015-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch => 0017-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch} (100%) rename {patches/todo/paper-patches => divinemc-server/paper-patches/features}/0018-Leaves-Protocol-Core.patch (87%) rename patches/todo/paper-patches/0017-SparklyPaper-Parallel-world-ticking.patch => divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch (96%) rename {patches/todo/paper-patches => divinemc-server/paper-patches/features}/0020-Optimize-Moonrise.patch (100%) delete mode 100644 divinemc-server/src/main/java/org/bxteam/divinemc/async/AsyncJoinHandler.java delete mode 100644 patches/todo/minecraft-patches/0075-Configurable-Files-Locations.patch diff --git a/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch b/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch index 3b5cb81..9ab94c6 100644 --- a/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch +++ b/divinemc-server/minecraft-patches/features/0003-Completely-remove-Mojang-profiler.patch @@ -59,18 +59,10 @@ index 9aa09e11032f539952edeeed119f7705c330db0a..9a7a40c1dcea57ba674d8431077d2477 contextConsumer.accept(executionContext1); executionContext1.runCommandQueue(); diff --git a/net/minecraft/commands/execution/ExecutionContext.java b/net/minecraft/commands/execution/ExecutionContext.java -index 18c7fff36ca26a659fa8ea022c93ea65f3199181..d2627a450f2481714aa1a9ecc9153a95bdab8e89 100644 +index 18c7fff36ca26a659fa8ea022c93ea65f3199181..444cc14e9b9e6b77254bc1c5ada00f8fcd185b93 100644 --- a/net/minecraft/commands/execution/ExecutionContext.java +++ b/net/minecraft/commands/execution/ExecutionContext.java -@@ -12,7 +12,6 @@ import net.minecraft.commands.ExecutionCommandSource; - import net.minecraft.commands.execution.tasks.BuildContexts; - import net.minecraft.commands.execution.tasks.CallFunction; - import net.minecraft.commands.functions.InstantiatedFunction; --import net.minecraft.util.profiling.ProfilerFiller; - import org.slf4j.Logger; - - public class ExecutionContext implements AutoCloseable { -@@ -20,7 +19,6 @@ public class ExecutionContext implements AutoCloseable { +@@ -20,7 +20,6 @@ public class ExecutionContext implements AutoCloseable { private static final Logger LOGGER = LogUtils.getLogger(); private final int commandLimit; private final int forkLimit; @@ -78,7 +70,7 @@ index 18c7fff36ca26a659fa8ea022c93ea65f3199181..d2627a450f2481714aa1a9ecc9153a95 @Nullable private TraceCallbacks tracer; private int commandQuota; -@@ -29,10 +27,9 @@ public class ExecutionContext implements AutoCloseable { +@@ -29,10 +28,9 @@ public class ExecutionContext implements AutoCloseable { private final List> newTopCommands = new ObjectArrayList<>(); private int currentFrameDepth; @@ -90,17 +82,15 @@ index 18c7fff36ca26a659fa8ea022c93ea65f3199181..d2627a450f2481714aa1a9ecc9153a95 this.commandQuota = commandLimit; } -@@ -131,10 +128,6 @@ public class ExecutionContext implements AutoCloseable { - return this.tracer; +@@ -132,7 +130,7 @@ public class ExecutionContext implements AutoCloseable { } -- public ProfilerFiller profiler() { + public ProfilerFiller profiler() { - return this.profiler; -- } -- - public int forkLimit() { - return this.forkLimit; ++ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; } + + public int forkLimit() { diff --git a/net/minecraft/commands/execution/tasks/BuildContexts.java b/net/minecraft/commands/execution/tasks/BuildContexts.java index 569abbea01f585990d2017c68580257275bbb06d..824ccbfa77cd1135d409f5f46e6ae5422d323036 100644 --- a/net/minecraft/commands/execution/tasks/BuildContexts.java @@ -1703,2277 +1693,6 @@ index 11884fc390d73b476632c372eb2d3d7876cdb7fd..6a4a63de2da352094d58c3c80c54ec16 - protected abstract void apply(T object, ResourceManager resourceManager, ProfilerFiller profiler); + protected abstract void apply(T object, ResourceManager resourceManager); } -diff --git a/net/minecraft/util/profiling/ActiveProfiler.java b/net/minecraft/util/profiling/ActiveProfiler.java -deleted file mode 100644 -index 4858d5fc2a577f612dcd82656d37be1f8a774aeb..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ActiveProfiler.java -+++ /dev/null -@@ -1,207 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.google.common.collect.Lists; --import com.google.common.collect.Maps; --import com.mojang.logging.LogUtils; --import it.unimi.dsi.fastutil.longs.LongArrayList; --import it.unimi.dsi.fastutil.longs.LongList; --import it.unimi.dsi.fastutil.objects.Object2LongMap; --import it.unimi.dsi.fastutil.objects.Object2LongMaps; --import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; --import it.unimi.dsi.fastutil.objects.ObjectArraySet; --import java.time.Duration; --import java.util.List; --import java.util.Map; --import java.util.Set; --import java.util.function.BooleanSupplier; --import java.util.function.IntSupplier; --import java.util.function.LongSupplier; --import java.util.function.Supplier; --import javax.annotation.Nullable; --import net.minecraft.Util; --import net.minecraft.util.profiling.metrics.MetricCategory; --import org.apache.commons.lang3.tuple.Pair; --import org.slf4j.Logger; -- --public class ActiveProfiler implements ProfileCollector { -- private static final long WARNING_TIME_NANOS = Duration.ofMillis(100L).toNanos(); -- private static final Logger LOGGER = LogUtils.getLogger(); -- private final List paths = Lists.newArrayList(); -- private final LongList startTimes = new LongArrayList(); -- private final Map entries = Maps.newHashMap(); -- private final IntSupplier getTickTime; -- private final LongSupplier getRealTime; -- private final long startTimeNano; -- private final int startTimeTicks; -- private String path = ""; -- private boolean started; -- @Nullable -- private ActiveProfiler.PathEntry currentEntry; -- private final BooleanSupplier suppressWarnings; -- private final Set> chartedPaths = new ObjectArraySet<>(); -- -- public ActiveProfiler(LongSupplier getRealTime, IntSupplier getTickTime, BooleanSupplier suppressWarnings) { -- this.startTimeNano = getRealTime.getAsLong(); -- this.getRealTime = getRealTime; -- this.startTimeTicks = getTickTime.getAsInt(); -- this.getTickTime = getTickTime; -- this.suppressWarnings = suppressWarnings; -- } -- -- @Override -- public void startTick() { -- if (this.started) { -- LOGGER.error("Profiler tick already started - missing endTick()?"); -- } else { -- this.started = true; -- this.path = ""; -- this.paths.clear(); -- this.push("root"); -- } -- } -- -- @Override -- public void endTick() { -- if (!this.started) { -- LOGGER.error("Profiler tick already ended - missing startTick()?"); -- } else { -- this.pop(); -- this.started = false; -- if (!this.path.isEmpty()) { -- LOGGER.error( -- "Profiler tick ended before path was fully popped (remainder: '{}'). Mismatched push/pop?", -- LogUtils.defer(() -> ProfileResults.demanglePath(this.path)) -- ); -- } -- } -- } -- -- @Override -- public void push(String name) { -- if (!this.started) { -- LOGGER.error("Cannot push '{}' to profiler if profiler tick hasn't started - missing startTick()?", name); -- } else { -- if (!this.path.isEmpty()) { -- this.path = this.path + "\u001e"; -- } -- -- this.path = this.path + name; -- this.paths.add(this.path); -- this.startTimes.add(Util.getNanos()); -- this.currentEntry = null; -- } -- } -- -- @Override -- public void push(Supplier nameSupplier) { -- this.push(nameSupplier.get()); -- } -- -- @Override -- public void markForCharting(MetricCategory category) { -- this.chartedPaths.add(Pair.of(this.path, category)); -- } -- -- @Override -- public void pop() { -- if (!this.started) { -- LOGGER.error("Cannot pop from profiler if profiler tick hasn't started - missing startTick()?"); -- } else if (this.startTimes.isEmpty()) { -- LOGGER.error("Tried to pop one too many times! Mismatched push() and pop()?"); -- } else { -- long nanos = Util.getNanos(); -- long l = this.startTimes.removeLong(this.startTimes.size() - 1); -- this.paths.removeLast(); -- long l1 = nanos - l; -- ActiveProfiler.PathEntry currentEntry = this.getCurrentEntry(); -- currentEntry.accumulatedDuration += l1; -- currentEntry.count++; -- currentEntry.maxDuration = Math.max(currentEntry.maxDuration, l1); -- currentEntry.minDuration = Math.min(currentEntry.minDuration, l1); -- if (l1 > WARNING_TIME_NANOS && !this.suppressWarnings.getAsBoolean()) { -- LOGGER.warn( -- "Something's taking too long! '{}' took aprox {} ms", -- LogUtils.defer(() -> ProfileResults.demanglePath(this.path)), -- LogUtils.defer(() -> l1 / 1000000.0) -- ); -- } -- -- this.path = this.paths.isEmpty() ? "" : this.paths.getLast(); -- this.currentEntry = null; -- } -- } -- -- @Override -- public void popPush(String name) { -- this.pop(); -- this.push(name); -- } -- -- @Override -- public void popPush(Supplier nameSupplier) { -- this.pop(); -- this.push(nameSupplier); -- } -- -- private ActiveProfiler.PathEntry getCurrentEntry() { -- if (this.currentEntry == null) { -- this.currentEntry = this.entries.computeIfAbsent(this.path, string -> new ActiveProfiler.PathEntry()); -- } -- -- return this.currentEntry; -- } -- -- @Override -- public void incrementCounter(String counterName, int increment) { -- this.getCurrentEntry().counters.addTo(counterName, increment); -- } -- -- @Override -- public void incrementCounter(Supplier counterNameSupplier, int increment) { -- this.getCurrentEntry().counters.addTo(counterNameSupplier.get(), increment); -- } -- -- @Override -- public ProfileResults getResults() { -- return new FilledProfileResults(this.entries, this.startTimeNano, this.startTimeTicks, this.getRealTime.getAsLong(), this.getTickTime.getAsInt()); -- } -- -- @Nullable -- @Override -- public ActiveProfiler.PathEntry getEntry(String entryId) { -- return this.entries.get(entryId); -- } -- -- @Override -- public Set> getChartedPaths() { -- return this.chartedPaths; -- } -- -- public static class PathEntry implements ProfilerPathEntry { -- long maxDuration = Long.MIN_VALUE; -- long minDuration = Long.MAX_VALUE; -- long accumulatedDuration; -- long count; -- final Object2LongOpenHashMap counters = new Object2LongOpenHashMap<>(); -- -- @Override -- public long getDuration() { -- return this.accumulatedDuration; -- } -- -- @Override -- public long getMaxDuration() { -- return this.maxDuration; -- } -- -- @Override -- public long getCount() { -- return this.count; -- } -- -- @Override -- public Object2LongMap getCounters() { -- return Object2LongMaps.unmodifiable(this.counters); -- } -- } --} -diff --git a/net/minecraft/util/profiling/ContinuousProfiler.java b/net/minecraft/util/profiling/ContinuousProfiler.java -deleted file mode 100644 -index 1a05f7063ec4e1f5414a0a0c43c308a224a0f027..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ContinuousProfiler.java -+++ /dev/null -@@ -1,38 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.util.function.BooleanSupplier; --import java.util.function.IntSupplier; --import java.util.function.LongSupplier; -- --public class ContinuousProfiler { -- private final LongSupplier realTime; -- private final IntSupplier tickCount; -- private final BooleanSupplier suppressWarnings; -- private ProfileCollector profiler = InactiveProfiler.INSTANCE; -- -- public ContinuousProfiler(LongSupplier realTime, IntSupplier tickTime, BooleanSupplier suppressWarnings) { -- this.realTime = realTime; -- this.tickCount = tickTime; -- this.suppressWarnings = suppressWarnings; -- } -- -- public boolean isEnabled() { -- return this.profiler != InactiveProfiler.INSTANCE; -- } -- -- public void disable() { -- this.profiler = InactiveProfiler.INSTANCE; -- } -- -- public void enable() { -- this.profiler = new ActiveProfiler(this.realTime, this.tickCount, this.suppressWarnings); -- } -- -- public ProfilerFiller getFiller() { -- return this.profiler; -- } -- -- public ProfileResults getResults() { -- return this.profiler.getResults(); -- } --} -diff --git a/net/minecraft/util/profiling/EmptyProfileResults.java b/net/minecraft/util/profiling/EmptyProfileResults.java -deleted file mode 100644 -index 76930ff8c88c4cfc687d09653720ca05e87bec1a..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/EmptyProfileResults.java -+++ /dev/null -@@ -1,47 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.nio.file.Path; --import java.util.Collections; --import java.util.List; -- --public class EmptyProfileResults implements ProfileResults { -- public static final EmptyProfileResults EMPTY = new EmptyProfileResults(); -- -- private EmptyProfileResults() { -- } -- -- @Override -- public List getTimes(String sectionPath) { -- return Collections.emptyList(); -- } -- -- @Override -- public boolean saveResults(Path path) { -- return false; -- } -- -- @Override -- public long getStartTimeNano() { -- return 0L; -- } -- -- @Override -- public int getStartTimeTicks() { -- return 0; -- } -- -- @Override -- public long getEndTimeNano() { -- return 0L; -- } -- -- @Override -- public int getEndTimeTicks() { -- return 0; -- } -- -- @Override -- public String getProfilerResults() { -- return ""; -- } --} -diff --git a/net/minecraft/util/profiling/FilledProfileResults.java b/net/minecraft/util/profiling/FilledProfileResults.java -deleted file mode 100644 -index 2787f4e5e50939d44253f1b8301fb24a2974ae11..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/FilledProfileResults.java -+++ /dev/null -@@ -1,313 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.google.common.base.Splitter; --import com.google.common.collect.Lists; --import com.google.common.collect.Maps; --import com.mojang.logging.LogUtils; --import it.unimi.dsi.fastutil.objects.Object2LongMap; --import it.unimi.dsi.fastutil.objects.Object2LongMaps; --import java.io.Writer; --import java.nio.charset.StandardCharsets; --import java.nio.file.Files; --import java.nio.file.Path; --import java.util.Collections; --import java.util.Comparator; --import java.util.Iterator; --import java.util.List; --import java.util.Locale; --import java.util.Map; --import java.util.Map.Entry; --import net.minecraft.ReportType; --import net.minecraft.SharedConstants; --import org.apache.commons.io.IOUtils; --import org.apache.commons.lang3.ObjectUtils; --import org.slf4j.Logger; -- --public class FilledProfileResults implements ProfileResults { -- private static final Logger LOGGER = LogUtils.getLogger(); -- private static final ProfilerPathEntry EMPTY = new ProfilerPathEntry() { -- @Override -- public long getDuration() { -- return 0L; -- } -- -- @Override -- public long getMaxDuration() { -- return 0L; -- } -- -- @Override -- public long getCount() { -- return 0L; -- } -- -- @Override -- public Object2LongMap getCounters() { -- return Object2LongMaps.emptyMap(); -- } -- }; -- private static final Splitter SPLITTER = Splitter.on('\u001e'); -- private static final Comparator> COUNTER_ENTRY_COMPARATOR = Entry.comparingByValue( -- Comparator.comparingLong(counterCollector -> counterCollector.totalValue) -- ) -- .reversed(); -- private final Map entries; -- private final long startTimeNano; -- private final int startTimeTicks; -- private final long endTimeNano; -- private final int endTimeTicks; -- private final int tickDuration; -- -- public FilledProfileResults(Map entries, long startTimeNano, int startTimeTicks, long endTimeNano, int endTimeTicks) { -- this.entries = entries; -- this.startTimeNano = startTimeNano; -- this.startTimeTicks = startTimeTicks; -- this.endTimeNano = endTimeNano; -- this.endTimeTicks = endTimeTicks; -- this.tickDuration = endTimeTicks - startTimeTicks; -- } -- -- private ProfilerPathEntry getEntry(String key) { -- ProfilerPathEntry profilerPathEntry = this.entries.get(key); -- return profilerPathEntry != null ? profilerPathEntry : EMPTY; -- } -- -- @Override -- public List getTimes(String sectionPath) { -- String string = sectionPath; -- ProfilerPathEntry entry = this.getEntry("root"); -- long duration = entry.getDuration(); -- ProfilerPathEntry entry1 = this.getEntry(sectionPath); -- long duration1 = entry1.getDuration(); -- long count = entry1.getCount(); -- List list = Lists.newArrayList(); -- if (!sectionPath.isEmpty()) { -- sectionPath = sectionPath + "\u001e"; -- } -- -- long l = 0L; -- -- for (String string1 : this.entries.keySet()) { -- if (isDirectChild(sectionPath, string1)) { -- l += this.getEntry(string1).getDuration(); -- } -- } -- -- float f = (float)l; -- if (l < duration1) { -- l = duration1; -- } -- -- if (duration < l) { -- duration = l; -- } -- -- for (String string2 : this.entries.keySet()) { -- if (isDirectChild(sectionPath, string2)) { -- ProfilerPathEntry entry2 = this.getEntry(string2); -- long duration2 = entry2.getDuration(); -- double d = duration2 * 100.0 / l; -- double d1 = duration2 * 100.0 / duration; -- String sub = string2.substring(sectionPath.length()); -- list.add(new ResultField(sub, d, d1, entry2.getCount())); -- } -- } -- -- if ((float)l > f) { -- list.add(new ResultField("unspecified", ((float)l - f) * 100.0 / l, ((float)l - f) * 100.0 / duration, count)); -- } -- -- Collections.sort(list); -- list.add(0, new ResultField(string, 100.0, l * 100.0 / duration, count)); -- return list; -- } -- -- private static boolean isDirectChild(String sectionPath, String entry) { -- return entry.length() > sectionPath.length() && entry.startsWith(sectionPath) && entry.indexOf(30, sectionPath.length() + 1) < 0; -- } -- -- private Map getCounterValues() { -- Map map = Maps.newTreeMap(); -- this.entries -- .forEach( -- (string, profilerPathEntry) -> { -- Object2LongMap counters = profilerPathEntry.getCounters(); -- if (!counters.isEmpty()) { -- List parts = SPLITTER.splitToList(string); -- counters.forEach( -- (string1, _long) -> map.computeIfAbsent(string1, string2 -> new FilledProfileResults.CounterCollector()) -- .addValue(parts.iterator(), _long) -- ); -- } -- } -- ); -- return map; -- } -- -- @Override -- public long getStartTimeNano() { -- return this.startTimeNano; -- } -- -- @Override -- public int getStartTimeTicks() { -- return this.startTimeTicks; -- } -- -- @Override -- public long getEndTimeNano() { -- return this.endTimeNano; -- } -- -- @Override -- public int getEndTimeTicks() { -- return this.endTimeTicks; -- } -- -- @Override -- public boolean saveResults(Path path) { -- Writer writer = null; -- -- boolean var4; -- try { -- Files.createDirectories(path.getParent()); -- writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8); -- writer.write(this.getProfilerResults(this.getNanoDuration(), this.getTickDuration())); -- return true; -- } catch (Throwable var8) { -- LOGGER.error("Could not save profiler results to {}", path, var8); -- var4 = false; -- } finally { -- IOUtils.closeQuietly(writer); -- } -- -- return var4; -- } -- -- protected String getProfilerResults(long timeSpan, int tickSpan) { -- StringBuilder stringBuilder = new StringBuilder(); -- ReportType.PROFILE.appendHeader(stringBuilder, List.of()); -- stringBuilder.append("Version: ").append(SharedConstants.getCurrentVersion().id()).append('\n'); -- stringBuilder.append("Time span: ").append(timeSpan / 1000000L).append(" ms\n"); -- stringBuilder.append("Tick span: ").append(tickSpan).append(" ticks\n"); -- stringBuilder.append("// This is approximately ") -- .append(String.format(Locale.ROOT, "%.2f", tickSpan / ((float)timeSpan / 1.0E9F))) -- .append(" ticks per second. It should be ") -- .append(20) -- .append(" ticks per second\n\n"); -- stringBuilder.append("--- BEGIN PROFILE DUMP ---\n\n"); -- this.appendProfilerResults(0, "root", stringBuilder); -- stringBuilder.append("--- END PROFILE DUMP ---\n\n"); -- Map counterValues = this.getCounterValues(); -- if (!counterValues.isEmpty()) { -- stringBuilder.append("--- BEGIN COUNTER DUMP ---\n\n"); -- this.appendCounters(counterValues, stringBuilder, tickSpan); -- stringBuilder.append("--- END COUNTER DUMP ---\n\n"); -- } -- -- return stringBuilder.toString(); -- } -- -- @Override -- public String getProfilerResults() { -- StringBuilder stringBuilder = new StringBuilder(); -- this.appendProfilerResults(0, "root", stringBuilder); -- return stringBuilder.toString(); -- } -- -- private static StringBuilder indentLine(StringBuilder builder, int indents) { -- builder.append(String.format(Locale.ROOT, "[%02d] ", indents)); -- -- for (int i = 0; i < indents; i++) { -- builder.append("| "); -- } -- -- return builder; -- } -- -- private void appendProfilerResults(int depth, String sectionPath, StringBuilder builder) { -- List times = this.getTimes(sectionPath); -- Object2LongMap counters = ObjectUtils.firstNonNull(this.entries.get(sectionPath), EMPTY).getCounters(); -- counters.forEach( -- (string, _long) -> indentLine(builder, depth) -- .append('#') -- .append(string) -- .append(' ') -- .append(_long) -- .append('/') -- .append(_long / this.tickDuration) -- .append('\n') -- ); -- if (times.size() >= 3) { -- for (int i = 1; i < times.size(); i++) { -- ResultField resultField = times.get(i); -- indentLine(builder, depth) -- .append(resultField.name) -- .append('(') -- .append(resultField.count) -- .append('/') -- .append(String.format(Locale.ROOT, "%.0f", (float)resultField.count / this.tickDuration)) -- .append(')') -- .append(" - ") -- .append(String.format(Locale.ROOT, "%.2f", resultField.percentage)) -- .append("%/") -- .append(String.format(Locale.ROOT, "%.2f", resultField.globalPercentage)) -- .append("%\n"); -- if (!"unspecified".equals(resultField.name)) { -- try { -- this.appendProfilerResults(depth + 1, sectionPath + "\u001e" + resultField.name, builder); -- } catch (Exception var9) { -- builder.append("[[ EXCEPTION ").append(var9).append(" ]]"); -- } -- } -- } -- } -- } -- -- private void appendCounterResults(int indents, String name, FilledProfileResults.CounterCollector collector, int tickSpan, StringBuilder builder) { -- indentLine(builder, indents) -- .append(name) -- .append(" total:") -- .append(collector.selfValue) -- .append('/') -- .append(collector.totalValue) -- .append(" average: ") -- .append(collector.selfValue / tickSpan) -- .append('/') -- .append(collector.totalValue / tickSpan) -- .append('\n'); -- collector.children -- .entrySet() -- .stream() -- .sorted(COUNTER_ENTRY_COMPARATOR) -- .forEach(entry -> this.appendCounterResults(indents + 1, entry.getKey(), entry.getValue(), tickSpan, builder)); -- } -- -- private void appendCounters(Map counters, StringBuilder builder, int tickSpan) { -- counters.forEach((string, counterCollector) -> { -- builder.append("-- Counter: ").append(string).append(" --\n"); -- this.appendCounterResults(0, "root", counterCollector.children.get("root"), tickSpan, builder); -- builder.append("\n\n"); -- }); -- } -- -- @Override -- public int getTickDuration() { -- return this.tickDuration; -- } -- -- static class CounterCollector { -- long selfValue; -- long totalValue; -- final Map children = Maps.newHashMap(); -- -- public void addValue(Iterator counters, long value) { -- this.totalValue += value; -- if (!counters.hasNext()) { -- this.selfValue += value; -- } else { -- this.children.computeIfAbsent(counters.next(), string -> new FilledProfileResults.CounterCollector()).addValue(counters, value); -- } -- } -- } --} -diff --git a/net/minecraft/util/profiling/InactiveProfiler.java b/net/minecraft/util/profiling/InactiveProfiler.java -deleted file mode 100644 -index dbeb1117938b0f118250bc66d41676bc35a6aa1e..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/InactiveProfiler.java -+++ /dev/null -@@ -1,81 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.google.common.collect.ImmutableSet; --import java.util.Set; --import java.util.function.Supplier; --import javax.annotation.Nullable; --import net.minecraft.util.profiling.metrics.MetricCategory; --import org.apache.commons.lang3.tuple.Pair; -- --public class InactiveProfiler implements ProfileCollector { -- public static final InactiveProfiler INSTANCE = new InactiveProfiler(); -- -- private InactiveProfiler() { -- } -- -- @Override -- public void startTick() { -- } -- -- @Override -- public void endTick() { -- } -- -- @Override -- public void push(String name) { -- } -- -- @Override -- public void push(Supplier nameSupplier) { -- } -- -- @Override -- public void markForCharting(MetricCategory category) { -- } -- -- @Override -- public void pop() { -- } -- -- @Override -- public void popPush(String name) { -- } -- -- @Override -- public void popPush(Supplier nameSupplier) { -- } -- -- @Override -- public Zone zone(String name) { -- return Zone.INACTIVE; -- } -- -- @Override -- public Zone zone(Supplier name) { -- return Zone.INACTIVE; -- } -- -- @Override -- public void incrementCounter(String counterName, int increment) { -- } -- -- @Override -- public void incrementCounter(Supplier counterNameSupplier, int increment) { -- } -- -- @Override -- public ProfileResults getResults() { -- return EmptyProfileResults.EMPTY; -- } -- -- @Nullable -- @Override -- public ActiveProfiler.PathEntry getEntry(String entryId) { -- return null; -- } -- -- @Override -- public Set> getChartedPaths() { -- return ImmutableSet.of(); -- } --} -diff --git a/net/minecraft/util/profiling/ProfileCollector.java b/net/minecraft/util/profiling/ProfileCollector.java -deleted file mode 100644 -index 7ea05ee86d9afe648a5301bdd9fcff9b91e1ba36..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ProfileCollector.java -+++ /dev/null -@@ -1,15 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.util.Set; --import javax.annotation.Nullable; --import net.minecraft.util.profiling.metrics.MetricCategory; --import org.apache.commons.lang3.tuple.Pair; -- --public interface ProfileCollector extends ProfilerFiller { -- ProfileResults getResults(); -- -- @Nullable -- ActiveProfiler.PathEntry getEntry(String entryId); -- -- Set> getChartedPaths(); --} -diff --git a/net/minecraft/util/profiling/ProfileResults.java b/net/minecraft/util/profiling/ProfileResults.java -deleted file mode 100644 -index 47d68f2b8d0dbe2f0e268c3d00eec434d8964f7a..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ProfileResults.java -+++ /dev/null -@@ -1,34 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.nio.file.Path; --import java.util.List; -- --public interface ProfileResults { -- char PATH_SEPARATOR = '\u001e'; -- -- List getTimes(String sectionPath); -- -- boolean saveResults(Path path); -- -- long getStartTimeNano(); -- -- int getStartTimeTicks(); -- -- long getEndTimeNano(); -- -- int getEndTimeTicks(); -- -- default long getNanoDuration() { -- return this.getEndTimeNano() - this.getStartTimeNano(); -- } -- -- default int getTickDuration() { -- return this.getEndTimeTicks() - this.getStartTimeTicks(); -- } -- -- String getProfilerResults(); -- -- static String demanglePath(String path) { -- return path.replace('\u001e', '.'); -- } --} -diff --git a/net/minecraft/util/profiling/Profiler.java b/net/minecraft/util/profiling/Profiler.java -deleted file mode 100644 -index cbd57d68e169ed044f325a776075da78b473b6f3..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/Profiler.java -+++ /dev/null -@@ -1,58 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.mojang.jtracy.TracyClient; --import java.util.Objects; --import java.util.concurrent.atomic.AtomicInteger; -- --public final class Profiler { -- private static final ThreadLocal TRACY_FILLER = ThreadLocal.withInitial(TracyZoneFiller::new); -- private static final ThreadLocal ACTIVE = new ThreadLocal<>(); -- private static final AtomicInteger ACTIVE_COUNT = new AtomicInteger(); -- -- private Profiler() { -- } -- -- public static Profiler.Scope use(ProfilerFiller profiler) { -- startUsing(profiler); -- return Profiler::stopUsing; -- } -- -- private static void startUsing(ProfilerFiller profiler) { -- if (ACTIVE.get() != null) { -- throw new IllegalStateException("Profiler is already active"); -- } else { -- ProfilerFiller profilerFiller = decorateFiller(profiler); -- ACTIVE.set(profilerFiller); -- ACTIVE_COUNT.incrementAndGet(); -- profilerFiller.startTick(); -- } -- } -- -- private static void stopUsing() { -- ProfilerFiller profilerFiller = ACTIVE.get(); -- if (profilerFiller == null) { -- throw new IllegalStateException("Profiler was not active"); -- } else { -- ACTIVE.remove(); -- ACTIVE_COUNT.decrementAndGet(); -- profilerFiller.endTick(); -- } -- } -- -- private static ProfilerFiller decorateFiller(ProfilerFiller filler) { -- return ProfilerFiller.combine(getDefaultFiller(), filler); -- } -- -- public static ProfilerFiller get() { -- return ACTIVE_COUNT.get() == 0 ? getDefaultFiller() : Objects.requireNonNullElseGet(ACTIVE.get(), Profiler::getDefaultFiller); -- } -- -- private static ProfilerFiller getDefaultFiller() { -- return (ProfilerFiller)(TracyClient.isAvailable() ? TRACY_FILLER.get() : InactiveProfiler.INSTANCE); -- } -- -- public interface Scope extends AutoCloseable { -- @Override -- void close(); -- } --} -diff --git a/net/minecraft/util/profiling/ProfilerFiller.java b/net/minecraft/util/profiling/ProfilerFiller.java -deleted file mode 100644 -index aed01a8c918361d2302ba5219117e32aac98e19d..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ProfilerFiller.java -+++ /dev/null -@@ -1,151 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.util.function.Supplier; --import net.minecraft.util.profiling.metrics.MetricCategory; -- --public interface ProfilerFiller { -- String ROOT = "root"; -- -- void startTick(); -- -- void endTick(); -- -- void push(String name); -- -- void push(Supplier nameSupplier); -- -- void pop(); -- -- void popPush(String name); -- -- void popPush(Supplier nameSupplier); -- -- default void addZoneText(String text) { -- } -- -- default void addZoneValue(long value) { -- } -- -- default void setZoneColor(int color) { -- } -- -- default Zone zone(String name) { -- this.push(name); -- return new Zone(this); -- } -- -- default Zone zone(Supplier name) { -- this.push(name); -- return new Zone(this); -- } -- -- void markForCharting(MetricCategory category); -- -- default void incrementCounter(String entryId) { -- this.incrementCounter(entryId, 1); -- } -- -- void incrementCounter(String counterName, int increment); -- -- default void incrementCounter(Supplier entryIdSupplier) { -- this.incrementCounter(entryIdSupplier, 1); -- } -- -- void incrementCounter(Supplier counterNameSupplier, int increment); -- -- static ProfilerFiller combine(ProfilerFiller first, ProfilerFiller second) { -- if (first == InactiveProfiler.INSTANCE) { -- return second; -- } else { -- return (ProfilerFiller)(second == InactiveProfiler.INSTANCE ? first : new ProfilerFiller.CombinedProfileFiller(first, second)); -- } -- } -- -- public static class CombinedProfileFiller implements ProfilerFiller { -- private final ProfilerFiller first; -- private final ProfilerFiller second; -- -- public CombinedProfileFiller(ProfilerFiller first, ProfilerFiller second) { -- this.first = first; -- this.second = second; -- } -- -- @Override -- public void startTick() { -- this.first.startTick(); -- this.second.startTick(); -- } -- -- @Override -- public void endTick() { -- this.first.endTick(); -- this.second.endTick(); -- } -- -- @Override -- public void push(String name) { -- this.first.push(name); -- this.second.push(name); -- } -- -- @Override -- public void push(Supplier nameSupplier) { -- this.first.push(nameSupplier); -- this.second.push(nameSupplier); -- } -- -- @Override -- public void markForCharting(MetricCategory category) { -- this.first.markForCharting(category); -- this.second.markForCharting(category); -- } -- -- @Override -- public void pop() { -- this.first.pop(); -- this.second.pop(); -- } -- -- @Override -- public void popPush(String name) { -- this.first.popPush(name); -- this.second.popPush(name); -- } -- -- @Override -- public void popPush(Supplier nameSupplier) { -- this.first.popPush(nameSupplier); -- this.second.popPush(nameSupplier); -- } -- -- @Override -- public void incrementCounter(String counterName, int increment) { -- this.first.incrementCounter(counterName, increment); -- this.second.incrementCounter(counterName, increment); -- } -- -- @Override -- public void incrementCounter(Supplier counterNameSupplier, int increment) { -- this.first.incrementCounter(counterNameSupplier, increment); -- this.second.incrementCounter(counterNameSupplier, increment); -- } -- -- @Override -- public void addZoneText(String text) { -- this.first.addZoneText(text); -- this.second.addZoneText(text); -- } -- -- @Override -- public void addZoneValue(long value) { -- this.first.addZoneValue(value); -- this.second.addZoneValue(value); -- } -- -- @Override -- public void setZoneColor(int color) { -- this.first.setZoneColor(color); -- this.second.setZoneColor(color); -- } -- } --} -diff --git a/net/minecraft/util/profiling/ProfilerPathEntry.java b/net/minecraft/util/profiling/ProfilerPathEntry.java -deleted file mode 100644 -index c073262f663309e6f73e67b303927b3996ea0c16..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ProfilerPathEntry.java -+++ /dev/null -@@ -1,13 +0,0 @@ --package net.minecraft.util.profiling; -- --import it.unimi.dsi.fastutil.objects.Object2LongMap; -- --public interface ProfilerPathEntry { -- long getDuration(); -- -- long getMaxDuration(); -- -- long getCount(); -- -- Object2LongMap getCounters(); --} -diff --git a/net/minecraft/util/profiling/ResultField.java b/net/minecraft/util/profiling/ResultField.java -deleted file mode 100644 -index cdb8132e70b7c6b43aaf67510fb9e509bc9de0c4..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/ResultField.java -+++ /dev/null -@@ -1,28 +0,0 @@ --package net.minecraft.util.profiling; -- --public final class ResultField implements Comparable { -- public final double percentage; -- public final double globalPercentage; -- public final long count; -- public final String name; -- -- public ResultField(String name, double percentage, double globalPercentage, long count) { -- this.name = name; -- this.percentage = percentage; -- this.globalPercentage = globalPercentage; -- this.count = count; -- } -- -- @Override -- public int compareTo(ResultField resultField) { -- if (resultField.percentage < this.percentage) { -- return -1; -- } else { -- return resultField.percentage > this.percentage ? 1 : resultField.name.compareTo(this.name); -- } -- } -- -- public int getColor() { -- return (this.name.hashCode() & 11184810) + -12303292; -- } --} -diff --git a/net/minecraft/util/profiling/SingleTickProfiler.java b/net/minecraft/util/profiling/SingleTickProfiler.java -deleted file mode 100644 -index d6679254d3f2705ddf151bbb5695280d2be6ee59..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/SingleTickProfiler.java -+++ /dev/null -@@ -1,51 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.mojang.logging.LogUtils; --import java.io.File; --import java.util.function.LongSupplier; --import javax.annotation.Nullable; --import net.minecraft.SharedConstants; --import net.minecraft.Util; --import org.slf4j.Logger; -- --public class SingleTickProfiler { -- private static final Logger LOGGER = LogUtils.getLogger(); -- private final LongSupplier realTime; -- private final long saveThreshold; -- private int tick; -- private final File location; -- private ProfileCollector profiler = InactiveProfiler.INSTANCE; -- -- public SingleTickProfiler(LongSupplier realTime, String location, long saveThreshold) { -- this.realTime = realTime; -- this.location = new File("debug", location); -- this.saveThreshold = saveThreshold; -- } -- -- public ProfilerFiller startTick() { -- this.profiler = new ActiveProfiler(this.realTime, () -> this.tick, () -> true); -- this.tick++; -- return this.profiler; -- } -- -- public void endTick() { -- if (this.profiler != InactiveProfiler.INSTANCE) { -- ProfileResults results = this.profiler.getResults(); -- this.profiler = InactiveProfiler.INSTANCE; -- if (results.getNanoDuration() >= this.saveThreshold) { -- File file = new File(this.location, "tick-results-" + Util.getFilenameFormattedDateTime() + ".txt"); -- results.saveResults(file.toPath()); -- LOGGER.info("Recorded long tick -- wrote info to: {}", file.getAbsolutePath()); -- } -- } -- } -- -- @Nullable -- public static SingleTickProfiler createTickProfiler(String name) { -- return SharedConstants.DEBUG_MONITOR_TICK_TIMES ? new SingleTickProfiler(Util.timeSource, name, SharedConstants.MAXIMUM_TICK_TIME_NANOS) : null; -- } -- -- public static ProfilerFiller decorateFiller(ProfilerFiller profiler, @Nullable SingleTickProfiler singleTickProfiler) { -- return singleTickProfiler != null ? ProfilerFiller.combine(singleTickProfiler.startTick(), profiler) : profiler; -- } --} -diff --git a/net/minecraft/util/profiling/TracyZoneFiller.java b/net/minecraft/util/profiling/TracyZoneFiller.java -deleted file mode 100644 -index 4f855149f2a06379ecdc7d9218e40ef4887e1d6f..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/TracyZoneFiller.java -+++ /dev/null -@@ -1,140 +0,0 @@ --package net.minecraft.util.profiling; -- --import com.mojang.jtracy.Plot; --import com.mojang.jtracy.TracyClient; --import com.mojang.logging.LogUtils; --import java.lang.StackWalker.Option; --import java.lang.StackWalker.StackFrame; --import java.util.ArrayList; --import java.util.HashMap; --import java.util.List; --import java.util.Map; --import java.util.Optional; --import java.util.Set; --import java.util.function.Supplier; --import net.minecraft.SharedConstants; --import net.minecraft.util.profiling.metrics.MetricCategory; --import org.slf4j.Logger; -- --public class TracyZoneFiller implements ProfilerFiller { -- private static final Logger LOGGER = LogUtils.getLogger(); -- private static final StackWalker STACK_WALKER = StackWalker.getInstance(Set.of(Option.RETAIN_CLASS_REFERENCE), 5); -- private final List activeZones = new ArrayList<>(); -- private final Map plots = new HashMap<>(); -- private final String name = Thread.currentThread().getName(); -- -- @Override -- public void startTick() { -- } -- -- @Override -- public void endTick() { -- for (TracyZoneFiller.PlotAndValue plotAndValue : this.plots.values()) { -- plotAndValue.set(0); -- } -- } -- -- @Override -- public void push(String name) { -- String string = ""; -- String string1 = ""; -- int i = 0; -- if (SharedConstants.IS_RUNNING_IN_IDE) { -- Optional optional = STACK_WALKER.walk( -- stream -> stream.filter( -- stackFrame1 -> stackFrame1.getDeclaringClass() != TracyZoneFiller.class -- && stackFrame1.getDeclaringClass() != ProfilerFiller.CombinedProfileFiller.class -- ) -- .findFirst() -- ); -- if (optional.isPresent()) { -- StackFrame stackFrame = optional.get(); -- string = stackFrame.getMethodName(); -- string1 = stackFrame.getFileName(); -- i = stackFrame.getLineNumber(); -- } -- } -- -- com.mojang.jtracy.Zone zone = TracyClient.beginZone(name, string, string1, i); -- this.activeZones.add(zone); -- } -- -- @Override -- public void push(Supplier nameSupplier) { -- this.push(nameSupplier.get()); -- } -- -- @Override -- public void pop() { -- if (this.activeZones.isEmpty()) { -- LOGGER.error("Tried to pop one too many times! Mismatched push() and pop()?"); -- } else { -- com.mojang.jtracy.Zone zone = this.activeZones.removeLast(); -- zone.close(); -- } -- } -- -- @Override -- public void popPush(String name) { -- this.pop(); -- this.push(name); -- } -- -- @Override -- public void popPush(Supplier nameSupplier) { -- this.pop(); -- this.push(nameSupplier.get()); -- } -- -- @Override -- public void markForCharting(MetricCategory category) { -- } -- -- @Override -- public void incrementCounter(String counterName, int increment) { -- this.plots.computeIfAbsent(counterName, string -> new TracyZoneFiller.PlotAndValue(this.name + " " + counterName)).add(increment); -- } -- -- @Override -- public void incrementCounter(Supplier counterNameSupplier, int increment) { -- this.incrementCounter(counterNameSupplier.get(), increment); -- } -- -- private com.mojang.jtracy.Zone activeZone() { -- return this.activeZones.getLast(); -- } -- -- @Override -- public void addZoneText(String text) { -- this.activeZone().addText(text); -- } -- -- @Override -- public void addZoneValue(long value) { -- this.activeZone().addValue(value); -- } -- -- @Override -- public void setZoneColor(int color) { -- this.activeZone().setColor(color); -- } -- -- static final class PlotAndValue { -- private final Plot plot; -- private int value; -- -- PlotAndValue(String name) { -- this.plot = TracyClient.createPlot(name); -- this.value = 0; -- } -- -- void set(int value) { -- this.value = value; -- this.plot.setValue(value); -- } -- -- void add(int value) { -- this.set(this.value + value); -- } -- } --} -diff --git a/net/minecraft/util/profiling/Zone.java b/net/minecraft/util/profiling/Zone.java -deleted file mode 100644 -index 01bd7726e89f2e1b3c16a39b18385fcbb8716ebc..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/Zone.java -+++ /dev/null -@@ -1,53 +0,0 @@ --package net.minecraft.util.profiling; -- --import java.util.function.Supplier; --import javax.annotation.Nullable; -- --public class Zone implements AutoCloseable { -- public static final Zone INACTIVE = new Zone(null); -- @Nullable -- private final ProfilerFiller profiler; -- -- Zone(@Nullable ProfilerFiller profiler) { -- this.profiler = profiler; -- } -- -- public Zone addText(String text) { -- if (this.profiler != null) { -- this.profiler.addZoneText(text); -- } -- -- return this; -- } -- -- public Zone addText(Supplier text) { -- if (this.profiler != null) { -- this.profiler.addZoneText(text.get()); -- } -- -- return this; -- } -- -- public Zone addValue(long value) { -- if (this.profiler != null) { -- this.profiler.addZoneValue(value); -- } -- -- return this; -- } -- -- public Zone setColor(int color) { -- if (this.profiler != null) { -- this.profiler.setZoneColor(color); -- } -- -- return this; -- } -- -- @Override -- public void close() { -- if (this.profiler != null) { -- this.profiler.pop(); -- } -- } --} -diff --git a/net/minecraft/util/profiling/metrics/MetricCategory.java b/net/minecraft/util/profiling/metrics/MetricCategory.java -deleted file mode 100644 -index 6bf739dc8f427bd4368431aa060a06845141fedb..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/MetricCategory.java -+++ /dev/null -@@ -1,23 +0,0 @@ --package net.minecraft.util.profiling.metrics; -- --public enum MetricCategory { -- PATH_FINDING("pathfinding"), -- EVENT_LOOPS("event-loops"), -- CONSECUTIVE_EXECUTORS("consecutive-executors"), -- TICK_LOOP("ticking"), -- JVM("jvm"), -- CHUNK_RENDERING("chunk rendering"), -- CHUNK_RENDERING_DISPATCHING("chunk rendering dispatching"), -- CPU("cpu"), -- GPU("gpu"); -- -- private final String description; -- -- private MetricCategory(final String description) { -- this.description = description; -- } -- -- public String getDescription() { -- return this.description; -- } --} -diff --git a/net/minecraft/util/profiling/metrics/MetricSampler.java b/net/minecraft/util/profiling/metrics/MetricSampler.java -deleted file mode 100644 -index 8fd601585ed6a2548b82b1f35209a9dba1797b1b..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/MetricSampler.java -+++ /dev/null -@@ -1,217 +0,0 @@ --package net.minecraft.util.profiling.metrics; -- --import io.netty.buffer.ByteBuf; --import io.netty.buffer.ByteBufAllocator; --import it.unimi.dsi.fastutil.ints.Int2DoubleMap; --import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap; --import java.util.Locale; --import java.util.function.Consumer; --import java.util.function.DoubleSupplier; --import java.util.function.ToDoubleFunction; --import javax.annotation.Nullable; -- --public class MetricSampler { -- private final String name; -- private final MetricCategory category; -- private final DoubleSupplier sampler; -- private final ByteBuf ticks; -- private final ByteBuf values; -- private volatile boolean isRunning; -- @Nullable -- private final Runnable beforeTick; -- @Nullable -- final MetricSampler.ThresholdTest thresholdTest; -- private double currentValue; -- -- protected MetricSampler( -- String name, MetricCategory category, DoubleSupplier sampler, @Nullable Runnable beforeTick, @Nullable MetricSampler.ThresholdTest thresholdTest -- ) { -- this.name = name; -- this.category = category; -- this.beforeTick = beforeTick; -- this.sampler = sampler; -- this.thresholdTest = thresholdTest; -- this.values = ByteBufAllocator.DEFAULT.buffer(); -- this.ticks = ByteBufAllocator.DEFAULT.buffer(); -- this.isRunning = true; -- } -- -- public static MetricSampler create(String name, MetricCategory category, DoubleSupplier sampler) { -- return new MetricSampler(name, category, sampler, null, null); -- } -- -- public static MetricSampler create(String name, MetricCategory category, T context, ToDoubleFunction sampler) { -- return builder(name, category, sampler, context).build(); -- } -- -- public static MetricSampler.MetricSamplerBuilder builder(String name, MetricCategory category, ToDoubleFunction sampler, T context) { -- if (sampler == null) { -- throw new IllegalStateException(); -- } else { -- return new MetricSampler.MetricSamplerBuilder<>(name, category, sampler, context); -- } -- } -- -- public void onStartTick() { -- if (!this.isRunning) { -- throw new IllegalStateException("Not running"); -- } else { -- if (this.beforeTick != null) { -- this.beforeTick.run(); -- } -- } -- } -- -- public void onEndTick(int tickTime) { -- this.verifyRunning(); -- this.currentValue = this.sampler.getAsDouble(); -- this.values.writeDouble(this.currentValue); -- this.ticks.writeInt(tickTime); -- } -- -- public void onFinished() { -- this.verifyRunning(); -- this.values.release(); -- this.ticks.release(); -- this.isRunning = false; -- } -- -- private void verifyRunning() { -- if (!this.isRunning) { -- throw new IllegalStateException(String.format(Locale.ROOT, "Sampler for metric %s not started!", this.name)); -- } -- } -- -- DoubleSupplier getSampler() { -- return this.sampler; -- } -- -- public String getName() { -- return this.name; -- } -- -- public MetricCategory getCategory() { -- return this.category; -- } -- -- public MetricSampler.SamplerResult result() { -- Int2DoubleMap map = new Int2DoubleOpenHashMap(); -- int i = Integer.MIN_VALUE; -- int i1 = Integer.MIN_VALUE; -- -- while (this.values.isReadable(8)) { -- int _int = this.ticks.readInt(); -- if (i == Integer.MIN_VALUE) { -- i = _int; -- } -- -- map.put(_int, this.values.readDouble()); -- i1 = _int; -- } -- -- return new MetricSampler.SamplerResult(i, i1, map); -- } -- -- public boolean triggersThreshold() { -- return this.thresholdTest != null && this.thresholdTest.test(this.currentValue); -- } -- -- @Override -- public boolean equals(Object other) { -- if (this == other) { -- return true; -- } else if (other != null && this.getClass() == other.getClass()) { -- MetricSampler metricSampler = (MetricSampler)other; -- return this.name.equals(metricSampler.name) && this.category.equals(metricSampler.category); -- } else { -- return false; -- } -- } -- -- @Override -- public int hashCode() { -- return this.name.hashCode(); -- } -- -- public static class MetricSamplerBuilder { -- private final String name; -- private final MetricCategory category; -- private final DoubleSupplier sampler; -- private final T context; -- @Nullable -- private Runnable beforeTick; -- @Nullable -- private MetricSampler.ThresholdTest thresholdTest; -- -- public MetricSamplerBuilder(String name, MetricCategory category, ToDoubleFunction sampler, T context) { -- this.name = name; -- this.category = category; -- this.sampler = () -> sampler.applyAsDouble(context); -- this.context = context; -- } -- -- public MetricSampler.MetricSamplerBuilder withBeforeTick(Consumer beforeTick) { -- this.beforeTick = () -> beforeTick.accept(this.context); -- return this; -- } -- -- public MetricSampler.MetricSamplerBuilder withThresholdAlert(MetricSampler.ThresholdTest thresholdTest) { -- this.thresholdTest = thresholdTest; -- return this; -- } -- -- public MetricSampler build() { -- return new MetricSampler(this.name, this.category, this.sampler, this.beforeTick, this.thresholdTest); -- } -- } -- -- public static class SamplerResult { -- private final Int2DoubleMap recording; -- private final int firstTick; -- private final int lastTick; -- -- public SamplerResult(int firstTick, int lastTick, Int2DoubleMap recording) { -- this.firstTick = firstTick; -- this.lastTick = lastTick; -- this.recording = recording; -- } -- -- public double valueAtTick(int tick) { -- return this.recording.get(tick); -- } -- -- public int getFirstTick() { -- return this.firstTick; -- } -- -- public int getLastTick() { -- return this.lastTick; -- } -- } -- -- public interface ThresholdTest { -- boolean test(double value); -- } -- -- public static class ValueIncreasedByPercentage implements MetricSampler.ThresholdTest { -- private final float percentageIncreaseThreshold; -- private double previousValue = Double.MIN_VALUE; -- -- public ValueIncreasedByPercentage(float percentageIncreaseThreshold) { -- this.percentageIncreaseThreshold = percentageIncreaseThreshold; -- } -- -- @Override -- public boolean test(double value) { -- boolean flag; -- if (this.previousValue != Double.MIN_VALUE && !(value <= this.previousValue)) { -- flag = (value - this.previousValue) / this.previousValue >= this.percentageIncreaseThreshold; -- } else { -- flag = false; -- } -- -- this.previousValue = value; -- return flag; -- } -- } --} -diff --git a/net/minecraft/util/profiling/metrics/MetricsRegistry.java b/net/minecraft/util/profiling/metrics/MetricsRegistry.java -deleted file mode 100644 -index 9b6a6aa2e94ceffc014194d218a36925a54e7abc..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/MetricsRegistry.java -+++ /dev/null -@@ -1,85 +0,0 @@ --package net.minecraft.util.profiling.metrics; -- --import java.util.List; --import java.util.Map; --import java.util.Objects; --import java.util.WeakHashMap; --import java.util.stream.Collectors; --import javax.annotation.Nullable; -- --public class MetricsRegistry { -- public static final MetricsRegistry INSTANCE = new MetricsRegistry(); -- private final WeakHashMap measuredInstances = new WeakHashMap<>(); -- -- private MetricsRegistry() { -- } -- -- public void add(ProfilerMeasured key) { -- this.measuredInstances.put(key, null); -- } -- -- public List getRegisteredSamplers() { -- Map> map = this.measuredInstances -- .keySet() -- .stream() -- .flatMap(profilerMeasured -> profilerMeasured.profiledMetrics().stream()) -- .collect(Collectors.groupingBy(MetricSampler::getName)); -- return aggregateDuplicates(map); -- } -- -- private static List aggregateDuplicates(Map> samplers) { -- return samplers.entrySet().stream().map(entry -> { -- String string = entry.getKey(); -- List list = entry.getValue(); -- return (MetricSampler)(list.size() > 1 ? new MetricsRegistry.AggregatedMetricSampler(string, list) : list.get(0)); -- }).collect(Collectors.toList()); -- } -- -- static class AggregatedMetricSampler extends MetricSampler { -- private final List delegates; -- -- AggregatedMetricSampler(String name, List delegates) { -- super(name, delegates.get(0).getCategory(), () -> averageValueFromDelegates(delegates), () -> beforeTick(delegates), thresholdTest(delegates)); -- this.delegates = delegates; -- } -- -- private static MetricSampler.ThresholdTest thresholdTest(List samplers) { -- return value -> samplers.stream().anyMatch(metricSampler -> metricSampler.thresholdTest != null && metricSampler.thresholdTest.test(value)); -- } -- -- private static void beforeTick(List samplers) { -- for (MetricSampler metricSampler : samplers) { -- metricSampler.onStartTick(); -- } -- } -- -- private static double averageValueFromDelegates(List samplers) { -- double d = 0.0; -- -- for (MetricSampler metricSampler : samplers) { -- d += metricSampler.getSampler().getAsDouble(); -- } -- -- return d / samplers.size(); -- } -- -- @Override -- public boolean equals(@Nullable Object other) { -- if (this == other) { -- return true; -- } else if (other == null || this.getClass() != other.getClass()) { -- return false; -- } else if (!super.equals(other)) { -- return false; -- } else { -- MetricsRegistry.AggregatedMetricSampler aggregatedMetricSampler = (MetricsRegistry.AggregatedMetricSampler)other; -- return this.delegates.equals(aggregatedMetricSampler.delegates); -- } -- } -- -- @Override -- public int hashCode() { -- return Objects.hash(super.hashCode(), this.delegates); -- } -- } --} -diff --git a/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java b/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java -deleted file mode 100644 -index a9bb6f4303e84f99d74a4285377cd9ea20ebed60..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java -+++ /dev/null -@@ -1,9 +0,0 @@ --package net.minecraft.util.profiling.metrics; -- --import java.util.Set; --import java.util.function.Supplier; --import net.minecraft.util.profiling.ProfileCollector; -- --public interface MetricsSamplerProvider { -- Set samplers(Supplier profiles); --} -diff --git a/net/minecraft/util/profiling/metrics/ProfilerMeasured.java b/net/minecraft/util/profiling/metrics/ProfilerMeasured.java -deleted file mode 100644 -index 3057e9caa1936d114e07b3dfbd0dffd8aca1223c..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/ProfilerMeasured.java -+++ /dev/null -@@ -1,7 +0,0 @@ --package net.minecraft.util.profiling.metrics; -- --import java.util.List; -- --public interface ProfilerMeasured { -- List profiledMetrics(); --} -diff --git a/net/minecraft/util/profiling/metrics/package-info.java b/net/minecraft/util/profiling/metrics/package-info.java -deleted file mode 100644 -index 4cfaf358f9d7d07c8d58dc152a1c85d6c7824d57..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/package-info.java -+++ /dev/null -@@ -1,8 +0,0 @@ --@ParametersAreNonnullByDefault --@MethodsReturnNonnullByDefault --@FieldsAreNonnullByDefault --package net.minecraft.util.profiling.metrics; -- --import javax.annotation.ParametersAreNonnullByDefault; --import net.minecraft.FieldsAreNonnullByDefault; --import net.minecraft.MethodsReturnNonnullByDefault; -diff --git a/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java -deleted file mode 100644 -index b26c1f0f07b38a3da8d81af915e8043d55d5060f..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java -+++ /dev/null -@@ -1,168 +0,0 @@ --package net.minecraft.util.profiling.metrics.profiling; -- --import com.google.common.collect.ImmutableSet; --import com.google.common.collect.Lists; --import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; --import java.nio.file.Path; --import java.time.Instant; --import java.util.Collection; --import java.util.HashSet; --import java.util.List; --import java.util.Map; --import java.util.Set; --import java.util.concurrent.Executor; --import java.util.concurrent.TimeUnit; --import java.util.function.Consumer; --import java.util.function.LongSupplier; --import javax.annotation.Nullable; --import net.minecraft.util.profiling.ActiveProfiler; --import net.minecraft.util.profiling.ContinuousProfiler; --import net.minecraft.util.profiling.EmptyProfileResults; --import net.minecraft.util.profiling.InactiveProfiler; --import net.minecraft.util.profiling.ProfileCollector; --import net.minecraft.util.profiling.ProfileResults; --import net.minecraft.util.profiling.ProfilerFiller; --import net.minecraft.util.profiling.metrics.MetricSampler; --import net.minecraft.util.profiling.metrics.MetricsSamplerProvider; --import net.minecraft.util.profiling.metrics.storage.MetricsPersister; --import net.minecraft.util.profiling.metrics.storage.RecordedDeviation; -- --public class ActiveMetricsRecorder implements MetricsRecorder { -- public static final int PROFILING_MAX_DURATION_SECONDS = 10; -- @Nullable -- private static Consumer globalOnReportFinished = null; -- private final Map> deviationsBySampler = new Object2ObjectOpenHashMap<>(); -- private final ContinuousProfiler taskProfiler; -- private final Executor ioExecutor; -- private final MetricsPersister metricsPersister; -- private final Consumer onProfilingEnd; -- private final Consumer onReportFinished; -- private final MetricsSamplerProvider metricsSamplerProvider; -- private final LongSupplier wallTimeSource; -- private final long deadlineNano; -- private int currentTick; -- private ProfileCollector singleTickProfiler; -- private volatile boolean killSwitch; -- private Set thisTickSamplers = ImmutableSet.of(); -- -- private ActiveMetricsRecorder( -- MetricsSamplerProvider metricsSamplerProvider, -- LongSupplier wallTimeSource, -- Executor ioExecutor, -- MetricsPersister metricPersister, -- Consumer onProfilerEnd, -- Consumer onReportFinished -- ) { -- this.metricsSamplerProvider = metricsSamplerProvider; -- this.wallTimeSource = wallTimeSource; -- this.taskProfiler = new ContinuousProfiler(wallTimeSource, () -> this.currentTick, () -> false); -- this.ioExecutor = ioExecutor; -- this.metricsPersister = metricPersister; -- this.onProfilingEnd = onProfilerEnd; -- this.onReportFinished = globalOnReportFinished == null ? onReportFinished : onReportFinished.andThen(globalOnReportFinished); -- this.deadlineNano = wallTimeSource.getAsLong() + TimeUnit.NANOSECONDS.convert(10L, TimeUnit.SECONDS); -- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> this.currentTick, () -> true); -- this.taskProfiler.enable(); -- } -- -- public static ActiveMetricsRecorder createStarted( -- MetricsSamplerProvider metricsSamplerProvider, -- LongSupplier wallTimeSource, -- Executor ioExecutor, -- MetricsPersister metricsPersister, -- Consumer onProfilerEnd, -- Consumer onReportFinished -- ) { -- return new ActiveMetricsRecorder(metricsSamplerProvider, wallTimeSource, ioExecutor, metricsPersister, onProfilerEnd, onReportFinished); -- } -- -- @Override -- public synchronized void end() { -- if (this.isRecording()) { -- this.killSwitch = true; -- } -- } -- -- @Override -- public synchronized void cancel() { -- if (this.isRecording()) { -- this.singleTickProfiler = InactiveProfiler.INSTANCE; -- this.onProfilingEnd.accept(EmptyProfileResults.EMPTY); -- this.cleanup(this.thisTickSamplers); -- } -- } -- -- @Override -- public void startTick() { -- this.verifyStarted(); -- this.thisTickSamplers = this.metricsSamplerProvider.samplers(() -> this.singleTickProfiler); -- -- for (MetricSampler metricSampler : this.thisTickSamplers) { -- metricSampler.onStartTick(); -- } -- -- this.currentTick++; -- } -- -- @Override -- public void endTick() { -- this.verifyStarted(); -- if (this.currentTick != 0) { -- for (MetricSampler metricSampler : this.thisTickSamplers) { -- metricSampler.onEndTick(this.currentTick); -- if (metricSampler.triggersThreshold()) { -- RecordedDeviation recordedDeviation = new RecordedDeviation(Instant.now(), this.currentTick, this.singleTickProfiler.getResults()); -- this.deviationsBySampler.computeIfAbsent(metricSampler, metricSampler1 -> Lists.newArrayList()).add(recordedDeviation); -- } -- } -- -- if (!this.killSwitch && this.wallTimeSource.getAsLong() <= this.deadlineNano) { -- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> this.currentTick, () -> true); -- } else { -- this.killSwitch = false; -- ProfileResults results = this.taskProfiler.getResults(); -- this.singleTickProfiler = InactiveProfiler.INSTANCE; -- this.onProfilingEnd.accept(results); -- this.scheduleSaveResults(results); -- } -- } -- } -- -- @Override -- public boolean isRecording() { -- return this.taskProfiler.isEnabled(); -- } -- -- @Override -- public ProfilerFiller getProfiler() { -- return ProfilerFiller.combine(this.taskProfiler.getFiller(), this.singleTickProfiler); -- } -- -- private void verifyStarted() { -- if (!this.isRecording()) { -- throw new IllegalStateException("Not started!"); -- } -- } -- -- private void scheduleSaveResults(ProfileResults results) { -- HashSet set = new HashSet<>(this.thisTickSamplers); -- this.ioExecutor.execute(() -> { -- Path path = this.metricsPersister.saveReports(set, this.deviationsBySampler, results); -- this.cleanup(set); -- this.onReportFinished.accept(path); -- }); -- } -- -- private void cleanup(Collection samplers) { -- for (MetricSampler metricSampler : samplers) { -- metricSampler.onFinished(); -- } -- -- this.deviationsBySampler.clear(); -- this.taskProfiler.disable(); -- } -- -- public static void registerGlobalCompletionCallback(Consumer globalOnReportFinished) { -- ActiveMetricsRecorder.globalOnReportFinished = globalOnReportFinished; -- } --} -diff --git a/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java -deleted file mode 100644 -index 12d7b7c86115b667bd8f940206985d9ed4b837d4..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java -+++ /dev/null -@@ -1,34 +0,0 @@ --package net.minecraft.util.profiling.metrics.profiling; -- --import net.minecraft.util.profiling.InactiveProfiler; --import net.minecraft.util.profiling.ProfilerFiller; -- --public class InactiveMetricsRecorder implements MetricsRecorder { -- public static final MetricsRecorder INSTANCE = new InactiveMetricsRecorder(); -- -- @Override -- public void end() { -- } -- -- @Override -- public void cancel() { -- } -- -- @Override -- public void startTick() { -- } -- -- @Override -- public boolean isRecording() { -- return false; -- } -- -- @Override -- public ProfilerFiller getProfiler() { -- return InactiveProfiler.INSTANCE; -- } -- -- @Override -- public void endTick() { -- } --} -diff --git a/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java -deleted file mode 100644 -index 48e7211e01691a677c52cf1f5982b0c179eaf83b..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java -+++ /dev/null -@@ -1,17 +0,0 @@ --package net.minecraft.util.profiling.metrics.profiling; -- --import net.minecraft.util.profiling.ProfilerFiller; -- --public interface MetricsRecorder { -- void end(); -- -- void cancel(); -- -- void startTick(); -- -- boolean isRecording(); -- -- ProfilerFiller getProfiler(); -- -- void endTick(); --} -diff --git a/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java b/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java -deleted file mode 100644 -index 44f6dfd6efb8bd7894d6b15b45ea6cdd8babd234..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java -+++ /dev/null -@@ -1,37 +0,0 @@ --package net.minecraft.util.profiling.metrics.profiling; -- --import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; --import java.util.Set; --import java.util.function.Supplier; --import java.util.stream.Collectors; --import net.minecraft.util.TimeUtil; --import net.minecraft.util.profiling.ActiveProfiler; --import net.minecraft.util.profiling.ProfileCollector; --import net.minecraft.util.profiling.metrics.MetricCategory; --import net.minecraft.util.profiling.metrics.MetricSampler; -- --public class ProfilerSamplerAdapter { -- private final Set previouslyFoundSamplerNames = new ObjectOpenHashSet<>(); -- -- public Set newSamplersFoundInProfiler(Supplier profiles) { -- Set set = profiles.get() -- .getChartedPaths() -- .stream() -- .filter(pair -> !this.previouslyFoundSamplerNames.contains(pair.getLeft())) -- .map(pair -> samplerForProfilingPath(profiles, pair.getLeft(), pair.getRight())) -- .collect(Collectors.toSet()); -- -- for (MetricSampler metricSampler : set) { -- this.previouslyFoundSamplerNames.add(metricSampler.getName()); -- } -- -- return set; -- } -- -- private static MetricSampler samplerForProfilingPath(Supplier profiles, String name, MetricCategory category) { -- return MetricSampler.create(name, category, () -> { -- ActiveProfiler.PathEntry entry = profiles.get().getEntry(name); -- return entry == null ? 0.0 : (double)entry.getMaxDuration() / TimeUtil.NANOSECONDS_PER_MILLISECOND; -- }); -- } --} -diff --git a/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java b/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java -deleted file mode 100644 -index f59e633e3dfae3f1b27f94a912b749e164213198..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java -+++ /dev/null -@@ -1,106 +0,0 @@ --package net.minecraft.util.profiling.metrics.profiling; -- --import com.google.common.base.Stopwatch; --import com.google.common.base.Ticker; --import com.google.common.collect.ImmutableSet; --import com.google.common.collect.ImmutableSet.Builder; --import com.mojang.logging.LogUtils; --import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; --import java.util.Set; --import java.util.concurrent.TimeUnit; --import java.util.function.LongSupplier; --import java.util.function.Supplier; --import java.util.function.ToDoubleFunction; --import java.util.stream.IntStream; --import net.minecraft.SystemReport; --import net.minecraft.util.profiling.ProfileCollector; --import net.minecraft.util.profiling.metrics.MetricCategory; --import net.minecraft.util.profiling.metrics.MetricSampler; --import net.minecraft.util.profiling.metrics.MetricsRegistry; --import net.minecraft.util.profiling.metrics.MetricsSamplerProvider; --import org.slf4j.Logger; --import oshi.SystemInfo; --import oshi.hardware.CentralProcessor; -- --public class ServerMetricsSamplersProvider implements MetricsSamplerProvider { -- private static final Logger LOGGER = LogUtils.getLogger(); -- private final Set samplers = new ObjectOpenHashSet<>(); -- private final ProfilerSamplerAdapter samplerFactory = new ProfilerSamplerAdapter(); -- -- public ServerMetricsSamplersProvider(LongSupplier timeSource, boolean dedicatedServer) { -- this.samplers.add(tickTimeSampler(timeSource)); -- if (dedicatedServer) { -- this.samplers.addAll(runtimeIndependentSamplers()); -- } -- } -- -- public static Set runtimeIndependentSamplers() { -- Builder builder = ImmutableSet.builder(); -- -- try { -- ServerMetricsSamplersProvider.CpuStats cpuStats = new ServerMetricsSamplersProvider.CpuStats(); -- IntStream.range(0, cpuStats.nrOfCpus) -- .mapToObj(i -> MetricSampler.create("cpu#" + i, MetricCategory.CPU, () -> cpuStats.loadForCpu(i))) -- .forEach(builder::add); -- } catch (Throwable var2) { -- LOGGER.warn("Failed to query cpu, no cpu stats will be recorded", var2); -- } -- -- builder.add( -- MetricSampler.create( -- "heap MiB", MetricCategory.JVM, () -> SystemReport.sizeInMiB(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) -- ) -- ); -- builder.addAll(MetricsRegistry.INSTANCE.getRegisteredSamplers()); -- return builder.build(); -- } -- -- @Override -- public Set samplers(Supplier profiles) { -- this.samplers.addAll(this.samplerFactory.newSamplersFoundInProfiler(profiles)); -- return this.samplers; -- } -- -- public static MetricSampler tickTimeSampler(final LongSupplier timeSource) { -- Stopwatch stopwatch = Stopwatch.createUnstarted(new Ticker() { -- @Override -- public long read() { -- return timeSource.getAsLong(); -- } -- }); -- ToDoubleFunction toDoubleFunction = stopwatch1 -> { -- if (stopwatch1.isRunning()) { -- stopwatch1.stop(); -- } -- -- long l = stopwatch1.elapsed(TimeUnit.NANOSECONDS); -- stopwatch1.reset(); -- return l; -- }; -- MetricSampler.ValueIncreasedByPercentage valueIncreasedByPercentage = new MetricSampler.ValueIncreasedByPercentage(2.0F); -- return MetricSampler.builder("ticktime", MetricCategory.TICK_LOOP, toDoubleFunction, stopwatch) -- .withBeforeTick(Stopwatch::start) -- .withThresholdAlert(valueIncreasedByPercentage) -- .build(); -- } -- -- static class CpuStats { -- private final SystemInfo systemInfo = new SystemInfo(); -- private final CentralProcessor processor = this.systemInfo.getHardware().getProcessor(); -- public final int nrOfCpus = this.processor.getLogicalProcessorCount(); -- private long[][] previousCpuLoadTick = this.processor.getProcessorCpuLoadTicks(); -- private double[] currentLoad = this.processor.getProcessorCpuLoadBetweenTicks(this.previousCpuLoadTick); -- private long lastPollMs; -- -- public double loadForCpu(int index) { -- long l = System.currentTimeMillis(); -- if (this.lastPollMs == 0L || this.lastPollMs + 501L < l) { -- this.currentLoad = this.processor.getProcessorCpuLoadBetweenTicks(this.previousCpuLoadTick); -- this.previousCpuLoadTick = this.processor.getProcessorCpuLoadTicks(); -- this.lastPollMs = l; -- } -- -- return this.currentLoad[index] * 100.0; -- } -- } --} -diff --git a/net/minecraft/util/profiling/metrics/profiling/package-info.java b/net/minecraft/util/profiling/metrics/profiling/package-info.java -deleted file mode 100644 -index f823bd9a9a819d7d7ca2cbf83af5b37b19fa301e..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/profiling/package-info.java -+++ /dev/null -@@ -1,8 +0,0 @@ --@ParametersAreNonnullByDefault --@MethodsReturnNonnullByDefault --@FieldsAreNonnullByDefault --package net.minecraft.util.profiling.metrics.profiling; -- --import javax.annotation.ParametersAreNonnullByDefault; --import net.minecraft.FieldsAreNonnullByDefault; --import net.minecraft.MethodsReturnNonnullByDefault; -diff --git a/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java b/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java -deleted file mode 100644 -index 43d63490b8c5337b426966608085ee3de1347a96..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java -+++ /dev/null -@@ -1,125 +0,0 @@ --package net.minecraft.util.profiling.metrics.storage; -- --import com.mojang.logging.LogUtils; --import java.io.IOException; --import java.io.UncheckedIOException; --import java.io.Writer; --import java.nio.charset.StandardCharsets; --import java.nio.file.Files; --import java.nio.file.Path; --import java.nio.file.Paths; --import java.time.ZoneId; --import java.time.format.DateTimeFormatter; --import java.util.List; --import java.util.Locale; --import java.util.Map; --import java.util.Set; --import java.util.stream.Collectors; --import java.util.stream.Stream; --import net.minecraft.Util; --import net.minecraft.resources.ResourceLocation; --import net.minecraft.util.CsvOutput; --import net.minecraft.util.profiling.ProfileResults; --import net.minecraft.util.profiling.metrics.MetricCategory; --import net.minecraft.util.profiling.metrics.MetricSampler; --import org.apache.commons.io.IOUtils; --import org.slf4j.Logger; -- --public class MetricsPersister { -- public static final Path PROFILING_RESULTS_DIR = Paths.get("debug/profiling"); -- public static final String METRICS_DIR_NAME = "metrics"; -- public static final String DEVIATIONS_DIR_NAME = "deviations"; -- public static final String PROFILING_RESULT_FILENAME = "profiling.txt"; -- private static final Logger LOGGER = LogUtils.getLogger(); -- private final String rootFolderName; -- -- public MetricsPersister(String rootFolderName) { -- this.rootFolderName = rootFolderName; -- } -- -- public Path saveReports(Set samplers, Map> deviations, ProfileResults results) { -- try { -- Files.createDirectories(PROFILING_RESULTS_DIR); -- } catch (IOException var8) { -- throw new UncheckedIOException(var8); -- } -- -- try { -- Path path = Files.createTempDirectory("minecraft-profiling"); -- path.toFile().deleteOnExit(); -- Files.createDirectories(PROFILING_RESULTS_DIR); -- Path path1 = path.resolve(this.rootFolderName); -- Path path2 = path1.resolve("metrics"); -- this.saveMetrics(samplers, path2); -- if (!deviations.isEmpty()) { -- this.saveDeviations(deviations, path1.resolve("deviations")); -- } -- -- this.saveProfilingTaskExecutionResult(results, path1); -- return path; -- } catch (IOException var7) { -- throw new UncheckedIOException(var7); -- } -- } -- -- private void saveMetrics(Set samplers, Path path) { -- if (samplers.isEmpty()) { -- throw new IllegalArgumentException("Expected at least one sampler to persist"); -- } else { -- Map> map = samplers.stream().collect(Collectors.groupingBy(MetricSampler::getCategory)); -- map.forEach((metricCategory, list) -> this.saveCategory(metricCategory, (List)list, path)); -- } -- } -- -- private void saveCategory(MetricCategory category, List samplers, Path path) { -- Path path1 = path.resolve(Util.sanitizeName(category.getDescription(), ResourceLocation::validPathChar) + ".csv"); -- Writer writer = null; -- -- try { -- Files.createDirectories(path1.getParent()); -- writer = Files.newBufferedWriter(path1, StandardCharsets.UTF_8); -- CsvOutput.Builder builder = CsvOutput.builder(); -- builder.addColumn("@tick"); -- -- for (MetricSampler metricSampler : samplers) { -- builder.addColumn(metricSampler.getName()); -- } -- -- CsvOutput csvOutput = builder.build(writer); -- List list = samplers.stream().map(MetricSampler::result).collect(Collectors.toList()); -- int min = list.stream().mapToInt(MetricSampler.SamplerResult::getFirstTick).summaryStatistics().getMin(); -- int max = list.stream().mapToInt(MetricSampler.SamplerResult::getLastTick).summaryStatistics().getMax(); -- -- for (int i = min; i <= max; i++) { -- int i1 = i; -- Stream stream = list.stream().map(samplerResult -> String.valueOf(samplerResult.valueAtTick(i1))); -- Object[] objects = Stream.concat(Stream.of(String.valueOf(i)), stream).toArray(String[]::new); -- csvOutput.writeRow(objects); -- } -- -- LOGGER.info("Flushed metrics to {}", path1); -- } catch (Exception var18) { -- LOGGER.error("Could not save profiler results to {}", path1, var18); -- } finally { -- IOUtils.closeQuietly(writer); -- } -- } -- -- private void saveDeviations(Map> deviations, Path path) { -- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss.SSS", Locale.UK).withZone(ZoneId.systemDefault()); -- deviations.forEach( -- (metricSampler, list) -> list.forEach( -- recordedDeviation -> { -- String string = dateTimeFormatter.format(recordedDeviation.timestamp); -- Path path1 = path.resolve(Util.sanitizeName(metricSampler.getName(), ResourceLocation::validPathChar)) -- .resolve(String.format(Locale.ROOT, "%d@%s.txt", recordedDeviation.tick, string)); -- recordedDeviation.profilerResultAtTick.saveResults(path1); -- } -- ) -- ); -- } -- -- private void saveProfilingTaskExecutionResult(ProfileResults results, Path outputPath) { -- results.saveResults(outputPath.resolve("profiling.txt")); -- } --} -diff --git a/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java b/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java -deleted file mode 100644 -index 4f73764d32ddbb7142ca46f68a0291e1ac200b65..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java -+++ /dev/null -@@ -1,16 +0,0 @@ --package net.minecraft.util.profiling.metrics.storage; -- --import java.time.Instant; --import net.minecraft.util.profiling.ProfileResults; -- --public final class RecordedDeviation { -- public final Instant timestamp; -- public final int tick; -- public final ProfileResults profilerResultAtTick; -- -- public RecordedDeviation(Instant timestamp, int tick, ProfileResults profilerResultAtTick) { -- this.timestamp = timestamp; -- this.tick = tick; -- this.profilerResultAtTick = profilerResultAtTick; -- } --} -diff --git a/net/minecraft/util/profiling/metrics/storage/package-info.java b/net/minecraft/util/profiling/metrics/storage/package-info.java -deleted file mode 100644 -index a2af6177a16997835eb91de3c6f4f83ee5e7e944..0000000000000000000000000000000000000000 ---- a/net/minecraft/util/profiling/metrics/storage/package-info.java -+++ /dev/null -@@ -1,8 +0,0 @@ --@ParametersAreNonnullByDefault --@MethodsReturnNonnullByDefault --@FieldsAreNonnullByDefault --package net.minecraft.util.profiling.metrics.storage; -- --import javax.annotation.ParametersAreNonnullByDefault; --import net.minecraft.FieldsAreNonnullByDefault; --import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/net/minecraft/util/thread/AbstractConsecutiveExecutor.java b/net/minecraft/util/thread/AbstractConsecutiveExecutor.java index f4aa10bbd98f514f27224346b3b9332f2218602d..ff319fa2ddea43d5b3c55897b1aaaf9fe137abbc 100644 --- a/net/minecraft/util/thread/AbstractConsecutiveExecutor.java diff --git a/patches/todo/minecraft-patches/0047-C2ME-Density-Function-Compiler.patch b/divinemc-server/minecraft-patches/features/0047-C2ME-Density-Function-Compiler.patch similarity index 95% rename from patches/todo/minecraft-patches/0047-C2ME-Density-Function-Compiler.patch rename to divinemc-server/minecraft-patches/features/0047-C2ME-Density-Function-Compiler.patch index 3abb81c..6982fd6 100644 --- a/patches/todo/minecraft-patches/0047-C2ME-Density-Function-Compiler.patch +++ b/divinemc-server/minecraft-patches/features/0047-C2ME-Density-Function-Compiler.patch @@ -11,38 +11,38 @@ All functions provided by vanilla are implemented. About Density function: https://minecraft.wiki/w/Density_function diff --git a/net/minecraft/util/CubicSpline.java b/net/minecraft/util/CubicSpline.java -index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144ce355565 100644 +index c04229bbed9d1162ecec99b8042d1707e2fc09bc..45b01de060362d88a5f02a76d6e6dc01748a55f5 100644 --- a/net/minecraft/util/CubicSpline.java +++ b/net/minecraft/util/CubicSpline.java -@@ -254,31 +254,47 @@ public interface CubicSpline> extends ToFloatFun +@@ -254,31 +254,47 @@ public interface CubicSpline> extends Bound @Override - public float apply(C object) { -- float f = this.coordinate.apply(object); + public float apply(C input) { +- float f = this.coordinate.apply(input); - int i = findIntervalStart(this.locations, f); - int i1 = this.locations.length - 1; - if (i < 0) { -- return linearExtend(f, this.locations, this.values.get(0).apply(object), this.derivatives, 0); +- return linearExtend(f, this.locations, this.values.get(0).apply(input), this.derivatives, 0); - } else if (i == i1) { -- return linearExtend(f, this.locations, this.values.get(i1).apply(object), this.derivatives, i1); +- return linearExtend(f, this.locations, this.values.get(i1).apply(input), this.derivatives, i1); + // DivineMC start - Density Function Compiler -+ float point = this.coordinate.apply(object); ++ float point = this.coordinate.apply(input); + int rangeForLocation = findIntervalStart(this.locations, point); + int last = this.locations.length - 1; + if (rangeForLocation < 0) { -+ return linearExtend(point, this.locations, this.values.get(0).apply(object), this.derivatives, 0); ++ return linearExtend(point, this.locations, this.values.get(0).apply(input), this.derivatives, 0); + } else if (rangeForLocation == last) { -+ return linearExtend(point, this.locations, this.values.get(last).apply(object), this.derivatives, last); ++ return linearExtend(point, this.locations, this.values.get(last).apply(input), this.derivatives, last); } else { - float f1 = this.locations[i]; - float f2 = this.locations[i + 1]; - float f3 = (f - f1) / (f2 - f1); -- ToFloatFunction toFloatFunction = (ToFloatFunction)this.values.get(i); -- ToFloatFunction toFloatFunction1 = (ToFloatFunction)this.values.get(i + 1); +- BoundedFloatFunction boundedFloatFunction = (BoundedFloatFunction)this.values.get(i); +- BoundedFloatFunction boundedFloatFunction1 = (BoundedFloatFunction)this.values.get(i + 1); - float f4 = this.derivatives[i]; - float f5 = this.derivatives[i + 1]; -- float f6 = toFloatFunction.apply(object); -- float f7 = toFloatFunction1.apply(object); +- float f6 = boundedFloatFunction.apply(input); +- float f7 = boundedFloatFunction1.apply(input); - float f8 = f4 * (f2 - f1) - (f7 - f6); - float f9 = -f5 * (f2 - f1) + (f7 - f6); - return Mth.lerp(f3, f6, f7) + f3 * (1.0F - f3) * Mth.lerp(f3, f8, f9); @@ -50,8 +50,8 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144 + float loc1 = this.locations[rangeForLocation + 1]; + float locDist = loc1 - loc0; + float k = (point - loc0) / locDist; -+ float n = this.values.get(rangeForLocation).apply(object); -+ float o = this.values.get(rangeForLocation + 1).apply(object); ++ float n = this.values.get(rangeForLocation).apply(input); ++ float o = this.values.get(rangeForLocation + 1).apply(input); + float onDist = o - n; + float p = this.derivatives[rangeForLocation] * locDist - onDist; + float q = -this.derivatives[rangeForLocation + 1] * locDist + onDist; @@ -82,7 +82,7 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144 } @VisibleForTesting -@@ -313,5 +329,27 @@ public interface CubicSpline> extends ToFloatFun +@@ -313,5 +329,27 @@ public interface CubicSpline> extends Bound this.derivatives ); } @@ -111,10 +111,10 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144 } } diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java -index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af1080501f 100644 +index f2fd59359c69a379b9b0a359c7fc917890b3bb74..90531d659d8be9178d8e7ed9fc20a57d204cf07e 100644 --- a/net/minecraft/world/level/levelgen/DensityFunctions.java +++ b/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -275,38 +275,66 @@ public final class DensityFunctions { +@@ -281,38 +281,66 @@ public final class DensityFunctions { @Override public void fillArray(double[] array, DensityFunction.ContextProvider contextProvider) { @@ -210,7 +210,7 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af } @Override -@@ -683,7 +711,105 @@ public final class DensityFunctions { +@@ -756,7 +784,105 @@ public final class DensityFunctions { } } @@ -317,7 +317,7 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af @Override public double compute(DensityFunction.FunctionContext context) { return this.wrapped.compute(context); -@@ -704,7 +830,19 @@ public final class DensityFunctions { +@@ -777,7 +903,19 @@ public final class DensityFunctions { return this.wrapped.maxValue(); } @@ -339,14 +339,10 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af FlatCache("flat_cache"), Cache2D("cache_2d"), diff --git a/net/minecraft/world/level/levelgen/NoiseChunk.java b/net/minecraft/world/level/levelgen/NoiseChunk.java -index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd803e0a1dd 100644 +index ff0c2aa0cdf7a88f67e6438dbd17d9c2bc39107a..3c3615043ab87da45b7ea47bf2f632a91a60dbc6 100644 --- a/net/minecraft/world/level/levelgen/NoiseChunk.java +++ b/net/minecraft/world/level/levelgen/NoiseChunk.java -@@ -4,9 +4,11 @@ import com.google.common.collect.Lists; - import it.unimi.dsi.fastutil.longs.Long2IntMap; - import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; - import java.util.ArrayList; -+import java.util.Arrays; +@@ -8,6 +8,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -354,7 +350,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 import javax.annotation.Nullable; import net.minecraft.core.QuartPos; import net.minecraft.core.SectionPos; -@@ -20,7 +22,18 @@ import net.minecraft.world.level.chunk.ChunkAccess; +@@ -21,7 +22,18 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.levelgen.blending.Blender; import net.minecraft.world.level.levelgen.material.MaterialRuleList; @@ -374,7 +370,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 private final NoiseSettings noiseSettings; final int cellCountXZ; final int cellCountY; -@@ -56,7 +69,47 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -57,7 +69,47 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct long interpolationCounter; long arrayInterpolationCounter; int arrayIndex; @@ -423,7 +419,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 @Override public DensityFunction.FunctionContext forIndex(int arrayIndex) { NoiseChunk.this.cellStartBlockY = (arrayIndex + NoiseChunk.this.cellNoiseMinY) * NoiseChunk.this.cellHeight; -@@ -76,7 +129,23 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -77,7 +129,23 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct values[i] = function.compute(NoiseChunk.this); } } @@ -448,16 +444,16 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 public static NoiseChunk forChunk( ChunkAccess chunk, -@@ -135,7 +204,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -140,7 +208,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } NoiseRouter noiseRouter = random.router(); - NoiseRouter noiseRouter1 = noiseRouter.mapAll(this::wrap); + NoiseRouter noiseRouter1 = noiseRouter.mapAll(org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.enableDensityFunctionCompiler ? modifyVisitor1(this::wrap) : this::wrap); // DivineMC - Density Function Compiler + this.preliminarySurfaceLevel = noiseRouter1.preliminarySurfaceLevel(); if (!noiseGeneratorSettings.isAquifersEnabled()) { this.aquifer = Aquifer.createDisabled(fluidPicker); - } else { -@@ -150,7 +219,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -156,7 +224,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct DensityFunction densityFunction = DensityFunctions.cacheAllInCell( DensityFunctions.add(noiseRouter1.finalDensity(), DensityFunctions.BeardifierMarker.INSTANCE) ) @@ -466,7 +462,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 list.add(context -> this.aquifer.computeSubstance(context, densityFunction.compute(context))); if (noiseGeneratorSettings.oreVeinsEnabled()) { list.add(OreVeinifier.create(noiseRouter1.veinToggle(), noiseRouter1.veinRidged(), noiseRouter1.veinGap(), random.oreRandom())); -@@ -162,12 +231,14 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -167,12 +235,14 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct protected Climate.Sampler cachedClimateSampler(NoiseRouter noiseRouter, List points) { return new Climate.Sampler( @@ -487,7 +483,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 points ); } -@@ -366,6 +437,13 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -378,6 +448,13 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } private DensityFunction wrapNew(DensityFunction densityFunction) { @@ -501,7 +497,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 if (densityFunction instanceof DensityFunctions.Marker marker) { return (DensityFunction)(switch (marker.type()) { case Interpolated -> new NoiseChunk.NoiseInterpolator(marker.wrapped()); -@@ -475,10 +553,48 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -487,10 +564,48 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct BlockState calculate(DensityFunction.FunctionContext context); } @@ -551,7 +547,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 Cache2D(DensityFunction function) { this.function = function; -@@ -515,9 +631,92 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -527,9 +642,92 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } } @@ -646,7 +642,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 CacheAllInCell(final DensityFunction noiseFilter) { this.noiseFiller = noiseFilter; -@@ -527,18 +726,51 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -539,18 +737,51 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct @Override public double compute(DensityFunction.FunctionContext context) { @@ -708,7 +704,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 } @Override -@@ -557,13 +789,84 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -569,13 +800,84 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } } @@ -794,7 +790,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 CacheOnce(final DensityFunction function) { this.function = function; -@@ -571,34 +874,82 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -583,34 +885,82 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct @Override public double compute(DensityFunction.FunctionContext context) { @@ -897,14 +893,15 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 } @Override -@@ -612,9 +963,63 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -624,10 +974,64 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } } - class FlatCache implements DensityFunctions.MarkerOrMarked, NoiseChunk.NoiseChunkDensityFunction { + class FlatCache implements DensityFunctions.MarkerOrMarked, NoiseChunk.NoiseChunkDensityFunction, IFastCacheLike { // DivineMC - Density Function Compiler private DensityFunction noiseFiller; - final double[][] values; + final double[] values; + final int sizeXZ; + // DivineMC start - Density Function Compiler + @Override + public double c2me$getCached(int x, int y, int z, EvalType evalType) { @@ -914,7 +911,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 + int l = j - (NoiseChunk.this).firstNoiseZ; + int m = this.values.length; + if (k >= 0 && l >= 0 && k < m && l < m) { -+ return this.values[k][l]; ++ return this.values[k + l * this.values.length]; + } else { + return Double.longBitsToDouble(CACHE_MISS_NAN_BITS); + } @@ -929,7 +926,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 + int l = j1 - (NoiseChunk.this).firstNoiseZ; + int m = this.values.length; + if (k >= 0 && l >= 0 && k < m && l < m) { -+ res[i] = this.values[k][l]; ++ res[i] = this.values[k + l * this.values.length]; + } else { + System.out.println("partial flat cache hit"); + return false; // partial hit possible @@ -962,7 +959,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 FlatCache(final DensityFunction noiseFiller, final boolean computeValues) { this.noiseFiller = noiseFiller; -@@ -673,7 +1078,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -686,7 +1090,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct } } @@ -971,7 +968,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 double[][] slice0; double[][] slice1; private DensityFunction noiseFiller; -@@ -692,6 +1097,104 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -705,6 +1109,104 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct private double valueZ0; private double valueZ1; private double value; @@ -1076,7 +1073,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 NoiseInterpolator(final DensityFunction noiseFilter) { this.noiseFiller = noiseFilter; -@@ -741,16 +1244,18 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -754,16 +1256,18 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct @Override public double compute(DensityFunction.FunctionContext context) { @@ -1105,7 +1102,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8 this.noise000, this.noise100, this.noise010, -@@ -760,8 +1265,45 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct +@@ -773,8 +1277,45 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct this.noise011, this.noise111 ) diff --git a/divinemc-server/minecraft-patches/features/0047-Copper-Bulb-1gt-delay.patch b/divinemc-server/minecraft-patches/features/0048-Copper-Bulb-1gt-delay.patch similarity index 100% rename from divinemc-server/minecraft-patches/features/0047-Copper-Bulb-1gt-delay.patch rename to divinemc-server/minecraft-patches/features/0048-Copper-Bulb-1gt-delay.patch diff --git a/divinemc-server/minecraft-patches/features/0048-Petal-Multithreaded-Tracker.patch b/divinemc-server/minecraft-patches/features/0049-Petal-Multithreaded-Tracker.patch similarity index 100% rename from divinemc-server/minecraft-patches/features/0048-Petal-Multithreaded-Tracker.patch rename to divinemc-server/minecraft-patches/features/0049-Petal-Multithreaded-Tracker.patch diff --git a/divinemc-server/minecraft-patches/features/0049-Crafter-1gt-delay.patch b/divinemc-server/minecraft-patches/features/0050-Crafter-1gt-delay.patch similarity index 100% rename from divinemc-server/minecraft-patches/features/0049-Crafter-1gt-delay.patch rename to divinemc-server/minecraft-patches/features/0050-Crafter-1gt-delay.patch diff --git a/patches/todo/minecraft-patches/0049-SparklyPaper-Parallel-world-ticking.patch b/divinemc-server/minecraft-patches/features/0051-SparklyPaper-Parallel-world-ticking.patch similarity index 93% rename from patches/todo/minecraft-patches/0049-SparklyPaper-Parallel-world-ticking.patch rename to divinemc-server/minecraft-patches/features/0051-SparklyPaper-Parallel-world-ticking.patch index c9dd6d9..a10e450 100644 --- a/patches/todo/minecraft-patches/0049-SparklyPaper-Parallel-world-ticking.patch +++ b/divinemc-server/minecraft-patches/features/0051-SparklyPaper-Parallel-world-ticking.patch @@ -6,10 +6,10 @@ Subject: [PATCH] SparklyPaper: Parallel world ticking Original project: https://github.com/SparklyPower/SparklyPaper diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790ae77f9178 100644 +index 467065e3b40df17f38716499259b46663c174fd0..a95db39c5ca9f4de9afe64b1cbc75ca8e86b8521 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -@@ -1142,7 +1142,7 @@ public final class ChunkHolderManager { +@@ -1129,7 +1129,7 @@ public final class ChunkHolderManager { if (changedFullStatus.isEmpty()) { return; } @@ -18,7 +18,7 @@ index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790a // These will be handled on the next ServerChunkCache$MainThreadExecutor#pollTask, as it runs the distance manager update // which will invoke processTicketUpdates this.offThreadPendingFullLoadUpdate.addAll(changedFullStatus); -@@ -1163,7 +1163,13 @@ public final class ChunkHolderManager { +@@ -1150,7 +1150,13 @@ public final class ChunkHolderManager { // note: never call while inside the chunk system, this will absolutely break everything public void processUnloads() { @@ -33,7 +33,7 @@ index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790a if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) { throw new IllegalStateException("Cannot unload chunks recursively"); -@@ -1429,7 +1435,7 @@ public final class ChunkHolderManager { +@@ -1416,7 +1422,7 @@ public final class ChunkHolderManager { if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) { throw new IllegalStateException("Cannot update ticket level while unloading chunks or updating entity manager"); } @@ -65,10 +65,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..544c05c94b535174d97675ea3c21706d // The variable 'k' holds the maximum redstone power value of any adjacent blocks. // If 'k' has the highest level of all neighbors, then the power level of this diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java -index ac27ff24f018d8798921c5152e679ceed1e88d8d..ec7d1353b19e55b00c558df8981323efb9b88bdf 100644 +index 181fdb493f64442c659165c10e237ebc198fb6e2..43363235f3dc696973eee99548b1ae551cada371 100644 --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -401,8 +401,10 @@ public interface DispenseItemBehavior { +@@ -410,8 +410,10 @@ public interface DispenseItemBehavior { // CraftBukkit start level.captureTreeGeneration = false; if (!level.capturedBlockStates.isEmpty()) { @@ -78,22 +78,22 @@ index ac27ff24f018d8798921c5152e679ceed1e88d8d..ec7d1353b19e55b00c558df8981323ef + org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.getTreeTypeTL(); + net.minecraft.world.level.block.SaplingBlock.setTreeTypeTL(null); + // DivineMC end - Parallel world ticking - org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level.getWorld()); + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level); List states = new java.util.ArrayList<>(level.capturedBlockStates.values()); level.capturedBlockStates.clear(); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229cd7b2a9d 100644 +index d311370b1ab05d63e0926e762fe5a938b25a42cb..495fbb4285f7da79e35118cae9212cb29b057d97 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -290,6 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function threadFunction) { - ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system -@@ -322,24 +323,36 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop serverPlayer1.connection.suspendFlushing()); this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit -@@ -1707,28 +1732,43 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread currentThread = (ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread) Thread.currentThread(); + currentThread.currentlyTickingServerLevel = serverLevel; - -- try { -- serverLevel.tick(hasTimeLeft); -- } catch (Throwable var7) { -- CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world"); -- serverLevel.fillReportDetails(crashReport); -- throw new ReportedException(crashReport); ++ + try { + tickLevel(serverLevel, hasTimeLeft); + } finally { @@ -209,7 +203,13 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229 + } else { + tickLevel(serverLevel, hasTimeLeft); + } -+ + +- try { +- serverLevel.tick(hasTimeLeft); +- } catch (Throwable var7) { +- CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world"); +- serverLevel.fillReportDetails(crashReport); +- throw new ReportedException(crashReport); + serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions } @@ -224,7 +224,7 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229 this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked this.tickConnection(); -@@ -1806,6 +1846,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, ServerLevel> oldLevels = this.levels; Map, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels); newLevels.remove(level.dimension()); @@ -333,10 +333,10 @@ index 3836d60ce84fb26f30a609486a5755d3fd1c94f1..1aab02441e4dfa7703963855d77bb918 } } else if (this.visible.remove(advancementHolder)) { diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index d90341ff814bb2b14867b7d9a401ae9672076f5b..f61470206e2c689187f37b44eda0d1942ac3bbc4 100644 +index 78f831bf369906396860a73b9aaff5dc67bcfa09..3a3346ef4df6fb424189306c2617b391a4bd2a84 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -218,6 +218,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -311,6 +311,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } // DivineMC end - Pufferfish: SIMD Support @@ -347,14 +347,14 @@ index d90341ff814bb2b14867b7d9a401ae9672076f5b..f61470206e2c689187f37b44eda0d194 + } + // DivineMC end - Parallel world ticking + - this.setPvpAllowed(properties.pvp); - this.setFlightAllowed(properties.allowFlight); - this.setMotd(properties.motd); + // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading + LOGGER.info("Default game type: {}", properties.gameMode.get()); + // Paper start - Unix domain socket support diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index bf680624bc6c618dfa0eeeb74c103ff6716fd27e..2039e636b1a52aff5403621e7281d618e4b87864 100644 +index 0a32c1106d3eebb8b4aa75b27b489169052897db..bfc200f39a22664204b5aa66d3911abdb368e563 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -175,8 +175,12 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -176,8 +176,12 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon // call mid-tick tasks for chunk system if ((i & 7) == 0) { @@ -370,19 +370,19 @@ index bf680624bc6c618dfa0eeeb74c103ff6716fd27e..2039e636b1a52aff5403621e7281d618 } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a299be8de 100644 +index 01ad6566c236bac2141f75fa9cf37844e3d97637..f22762d2e0c97246415669baa7b3d713bb6e929a 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -180,7 +180,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -186,7 +186,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + public final ServerChunkCache chunkSource; private final MinecraftServer server; public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type - private int lastSpawnChunkRadius; - final EntityTickList entityTickList = new EntityTickList(); + final EntityTickList entityTickList = new EntityTickList(this); // DivineMC - Parallel world ticking private final ServerWaypointManager waypointManager; // Paper - rewrite chunk system private final GameEventDispatcher gameEventDispatcher; -@@ -217,6 +217,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -225,6 +225,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean hasRidableMoveEvent = false; // Purpur - Ridables public net.minecraft.world.item.ItemStack ominousBanner; // DivineMC - Optimize Raids public org.bxteam.divinemc.util.tps.TPSCalculator tpsCalculator = new org.bxteam.divinemc.util.tps.TPSCalculator(); // DivineMC - Lag Compensation @@ -390,7 +390,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -680,7 +681,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -704,7 +705,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.sleepStatus = new SleepStatus(); this.gameEventDispatcher = new GameEventDispatcher(this); this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); @@ -399,7 +399,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a // Paper start - rewrite chunk system this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks())); this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this); -@@ -698,6 +699,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -722,6 +723,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.preciseTime = this.serverLevelData.getDayTime(); // Purpur - Configurable daylight cycle this.ominousBanner = Objects.requireNonNullElse(this.registryAccess(), net.minecraft.core.RegistryAccess.EMPTY).lookup(Registries.BANNER_PATTERN).map(Raid::getOminousBannerInstance).orElse(null); // DivineMC - Optimize Raids @@ -407,7 +407,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a } // Paper start -@@ -1300,12 +1302,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1336,12 +1338,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (fluidState.is(fluid)) { fluidState.tick(this, pos, blockState); } @@ -425,7 +425,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a } private void tickBlock(BlockPos pos, Block block) { -@@ -1313,12 +1315,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1349,12 +1351,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (blockState.is(block)) { blockState.tick(this, pos, this.random); } @@ -443,7 +443,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a } // Paper start - log detailed entity tick information -@@ -1581,6 +1583,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1614,6 +1616,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } private void addPlayer(ServerPlayer player) { @@ -451,7 +451,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a Entity entity = this.getEntity(player.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID()); -@@ -1593,7 +1596,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1626,7 +1629,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit start private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { @@ -467,10 +467,10 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a // Paper start - extra debug info if (entity.valid) { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a08fe9cbe8 100644 +index dd933185b1afadae52b51c95bb566bb453a9bfed..7eed31f8fcc7c0e1b83bd5e1eb8157580a2afd00 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -431,6 +431,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -444,6 +444,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc private boolean compassBar = false; // Purpur - Add compass command private boolean ramBar = false; // Purpur - Implement rambar commands public boolean smoothWorldTeleport; // DivineMC - Smooth teleport API @@ -478,7 +478,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0 // Paper start - rewrite chunk system private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; -@@ -748,6 +749,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -724,6 +725,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc @Override public void tick() { @@ -486,7 +486,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0 // CraftBukkit start if (this.joining) { this.joining = false; -@@ -1438,6 +1440,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1548,6 +1550,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc return this; } else { // CraftBukkit start @@ -494,7 +494,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0 /* this.isChangingDimension = true; LevelData levelData = level.getLevelData(); -@@ -1783,6 +1786,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1896,6 +1899,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc return OptionalInt.empty(); } else { // CraftBukkit start @@ -507,7 +507,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0 this.containerMenu = abstractContainerMenu; // Moved up if (!this.isImmobile()) this.connection -@@ -1847,6 +1856,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1960,6 +1969,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc } @Override public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { @@ -520,7 +520,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0 // Paper end - Inventory close reason this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec87fc30b8 100644 +index c8e68bbb210457366822f2c4a01afb49693035ac..8524060daabd3bc34c938313f30ed247759bdd5a 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -149,6 +149,7 @@ public abstract class PlayerList { @@ -530,8 +530,8 @@ index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec + if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureOnlyTickThread("Cannot place new player off-main"); // DivineMC - Parallel world ticking player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed - GameProfile gameProfile = player.getGameProfile(); -@@ -683,6 +684,14 @@ public abstract class PlayerList { + NameAndId nameAndId = player.nameAndId(); +@@ -600,6 +601,14 @@ public abstract class PlayerList { } public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, @Nullable org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, @Nullable org.bukkit.Location location) { @@ -544,9 +544,9 @@ index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec + } + // DivineMC end - Parallel world ticking player.stopRiding(); // CraftBukkit + // TeleportTransition teleportTransition = player.findRespawnPositionAndUseSpawnBlock(!keepInventory, TeleportTransition.DO_NOTHING); this.players.remove(player); - this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -693,6 +702,7 @@ public abstract class PlayerList { +@@ -610,6 +619,7 @@ public abstract class PlayerList { ServerPlayer serverPlayer = player; Level fromWorld = player.level(); player.wonGame = false; @@ -640,10 +640,10 @@ index f9e7532f86122a379692561a639a209a126e8bba..839f6b7696ef85314da185bedba7cfc5 if (isLocatorBarEnabledFor(player)) { if (!connection.isBroken()) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d98186206a0ad 100644 +index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..167c244433fd77b5d0cc0975965f04c5d88001fa 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -3480,14 +3480,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3549,14 +3549,34 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name if (this.portalProcess != null) { if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) { this.setPortalCooldown(); @@ -670,8 +670,8 @@ index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d9818 + entity.teleport(portalDestination); + } } -+ if (this.portalProcess != null) -+ entity.portalProcess.confirmParallelAsHandled(); ++ ++ if (this.portalProcess != null) entity.portalProcess.confirmParallelAsHandled(); + }; + + if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) { @@ -684,9 +684,9 @@ index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d9818 } else if (this.portalProcess.hasExpired()) { this.portalProcess = null; } -@@ -4064,6 +4084,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - } +@@ -4134,6 +4154,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + @Nullable private Entity teleportCrossDimension(ServerLevel oldLevel, ServerLevel newLevel, TeleportTransition teleportTransition) { + if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(newLevel, "Cannot teleport entity to another world off-main, from world " + oldLevel.getWorld().getName() + " to world " + newLevel.getWorld().getName()); // DivineMC - Parallel world ticking List passengers = this.getPassengers(); @@ -753,10 +753,10 @@ index 91f6d43b3785ddad7db8eb529ba3293c45f3588d..7fd5f40ee928330769bbe0c5e8da17fa + // DivineMC end - Parallel world ticking } diff --git a/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java b/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java -index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb465e3af2 100644 +index 6adf1b2250234ede6e6f498ed0990ab523f09b8e..a8ae790a7b9bfd0d78cac0577bb7a4ddac7f064b 100644 --- a/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java +++ b/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java -@@ -44,15 +44,31 @@ public class GoToPotentialJobSite extends Behavior { +@@ -43,15 +43,31 @@ public class GoToPotentialJobSite extends Behavior { Optional memory = entity.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE); memory.ifPresent(globalPos -> { BlockPos blockPos = globalPos.pos(); @@ -778,9 +778,9 @@ index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb + } + }; -- DebugPackets.sendPoiTicketCountPacket(level, blockPos); +- level.debugSynchronizers().updatePoi(blockPos); + Runnable debugPacketTask = () -> { -+ DebugPackets.sendPoiTicketCountPacket(entityLevel, blockPos); ++ level.debugSynchronizers().updatePoi(blockPos); + }; + + if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) { @@ -796,7 +796,7 @@ index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb entity.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE); } diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java -index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe0590ecff 100644 +index 94424c01b0c4a28c7eafd5c02d068b9c41e451e2..087fc14bbfaf63bf5ba5724e10c6f005a404f733 100644 --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java @@ -793,13 +793,24 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -808,7 +808,7 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe - BiPredicate> biPredicate = POI_MEMORIES.get(moduleType); - if (type.isPresent() && biPredicate.test(this, type.get())) { - poiManager.release(pos.pos()); -- DebugPackets.sendPoiTicketCountPacket(level, pos.pos()); +- level.debugSynchronizers().updatePoi(pos.pos()); + // DivineMC start - Parallel world ticking + Runnable releasePoiTask = () -> { + PoiManager poiManager = level.getPoiManager(); @@ -816,7 +816,7 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe + BiPredicate> biPredicate = POI_MEMORIES.get(moduleType); + if (type.isPresent() && biPredicate.test(this, type.get())) { + poiManager.release(pos.pos()); -+ DebugPackets.sendPoiTicketCountPacket(level, pos.pos()); ++ level.debugSynchronizers().updatePoi(pos.pos()); + } + }; + @@ -831,10 +831,10 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe }); } diff --git a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd7352788d9286fe 100644 +index 382c8b51fbf908068f4e5bef01d71441f8c85d1a..71df0cd87e66fd052aea5dc9c6961a53235531d5 100644 --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -119,43 +119,53 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -104,43 +104,53 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { if (serverPlayer.connection.isAcceptingMessages()) { @@ -848,12 +848,12 @@ index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd735278 - return; - } - // CraftBukkit end -- if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { // Purpur - Configurable Ender Pearl RNG +- if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.isSpawningMonsters()) { // Purpur - Configurable Ender Pearl RNG - Endermite endermite = EntityType.ENDERMITE.create(serverLevel, EntitySpawnReason.TRIGGERED); - if (endermite != null) { - endermite.setPlayerSpawned(true); // Purpur - Add back player spawned endermite API - endermite.snapTo(preTeleportX, preTeleportY, preTeleportZ, preTeleportYRot, preTeleportXRot); // Paper - spawn endermite at pre teleport position as teleport has been moved up -- serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); +- serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); // Paper - add reason + // DivineMC start - Parallel world ticking + java.util.function.Consumer teleportPlayerCrossDimensionTask = taskServerPlayer -> { + // CraftBukkit start @@ -866,12 +866,12 @@ index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd735278 + return; + } + // CraftBukkit end -+ if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { // Purpur - Configurable Ender Pearl RNG ++ if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.isSpawningMonsters()) { // Purpur - Configurable Ender Pearl RNG + Endermite endermite = EntityType.ENDERMITE.create(serverLevel, EntitySpawnReason.TRIGGERED); + if (endermite != null) { + endermite.setPlayerSpawned(true); // Purpur - Add back player spawned endermite API + endermite.snapTo(preTeleportX, preTeleportY, preTeleportZ, preTeleportYRot, preTeleportXRot); // Paper - spawn endermite at pre teleport position as teleport has been moved up -+ serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); ++ serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); // Paper - add reason + } } - } @@ -941,13 +941,13 @@ index 4354aafdd29c397d1318ae71dc365e7ca0aa781c..97397e5849d3ddc14506776431a69939 this.containerId = containerId; } diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index d3892cc9ef3ab66a45fe3ab72e8a5ef8b904b7c0..6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082 100644 +index 358d69bdca0aa46d1952d3ef9bf9b65dc39a3338..d04167eccda1fe29abe7fc28cab0c837a14e47ab 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -398,8 +398,10 @@ public final class ItemStack implements DataComponentHolder { +@@ -399,8 +399,10 @@ public final class ItemStack implements DataComponentHolder { if (interactionResult.consumesAction() && serverLevel.captureTreeGeneration && !serverLevel.capturedBlockStates.isEmpty()) { serverLevel.captureTreeGeneration = false; - org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(clickedPos, serverLevel.getWorld()); + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(clickedPos, serverLevel); - org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; - net.minecraft.world.level.block.SaplingBlock.treeType = null; + // DivineMC start - Parallel world ticking @@ -958,10 +958,10 @@ index d3892cc9ef3ab66a45fe3ab72e8a5ef8b904b7c0..6b5b6d73897ded23dd2fbf17abb1b5c1 serverLevel.capturedBlockStates.clear(); org.bukkit.event.world.StructureGrowEvent structureEvent = null; diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d674302304be3232 100644 +index b94b946986258fed3c6d68d9972a657e176d08a4..250978ef6e09c8744065d143af38b99914bd25ec 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -160,6 +160,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -166,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur - Purpur config files public final org.bxteam.divinemc.config.DivineWorldConfig divineConfig; // DivineMC - Configuration @@ -969,7 +969,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 public static @Nullable BlockPos lastPhysicsProblem; // Spigot private int tileTickPosition; public final Map explosionDensityCache = new java.util.HashMap<>(); // Paper - Optimize explosions -@@ -1134,6 +1135,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1088,6 +1089,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { @@ -977,7 +977,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 // CraftBukkit start - tree generation if (this.captureTreeGeneration) { // Paper start - Protect Bedrock and End Portal/Frames from being destroyed -@@ -1517,11 +1519,12 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1471,11 +1473,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // DivineMC - optimize block entity removals - Fix MC-117075 } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { tickingBlockEntity.tick(); @@ -994,7 +994,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 } } this.blockEntityTickers.removeMarkedEntries(); // DivineMC - optimize block entity removals - Fix MC-117075 -@@ -1541,7 +1544,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1495,7 +1498,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -1007,7 +1007,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -1678,6 +1685,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1637,6 +1644,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Nullable @Override public BlockEntity getBlockEntity(BlockPos pos) { @@ -1015,7 +1015,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 // Paper start - Perf: Optimize capturedTileEntities lookup net.minecraft.world.level.block.entity.BlockEntity blockEntity; if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) { -@@ -1694,6 +1702,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1653,6 +1661,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } public void setBlockEntity(BlockEntity blockEntity) { @@ -1023,7 +1023,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { // CraftBukkit start -@@ -1778,6 +1787,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1738,6 +1747,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { @@ -1031,7 +1031,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023 List list = Lists.newArrayList(); // Paper start - rewrite chunk system -@@ -2100,8 +2110,15 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -2087,8 +2097,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public abstract RecipeAccess recipeAccess(); public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) { @@ -1079,7 +1079,7 @@ index d306f5f524dc64618df94c9783c2168dc561a5e3..6a0c4dc2ff5e3d82e811db63dc9da7b9 return true; } else { diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..48c5c13f993f5c30912833a99c82071942c83401 100644 +index 7d7e7a87f5c9bbd9535bf2105e05d7abf08fc3dc..11356bfa7b12739f9bb9f780d7fcafeb39775d12 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -66,6 +66,7 @@ public class RedStoneWireBlock extends Block { @@ -1186,7 +1186,7 @@ index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..48c5c13f993f5c30912833a99c820719 public static int getColorForPower(int power) { diff --git a/net/minecraft/world/level/block/SaplingBlock.java b/net/minecraft/world/level/block/SaplingBlock.java -index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c33903b53 100644 +index a5e4959c1b5133cfaeb9259d7e59b38a06453785..f63098847017f65ff24057e29c8b5a8d24a9d795 100644 --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java @@ -26,6 +26,26 @@ public class SaplingBlock extends VegetationBlock implements BonemealableBlock { @@ -1226,7 +1226,7 @@ index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c + org.bukkit.TreeType treeTypeLocal = SaplingBlock.getTreeTypeTL(); + SaplingBlock.setTreeTypeTL(null); + // DivineMC end - Parallel world ticking - org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level.getWorld()); + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); java.util.List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); level.capturedBlockStates.clear(); org.bukkit.event.world.StructureGrowEvent event = null; @@ -1238,7 +1238,7 @@ index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c } if (event == null || !event.isCancelled()) { diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -index 5a094257a31f0500278a706a418e1697f8810ffb..3df0633fe4e632f7d42289facf4ad79978d50c40 100644 +index 1b2f8c4e1e362dc63fde2c7139039f0ce7eb762f..7c2acea8af6a3110d782b9b3afeac0915ac127da 100644 --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java @@ -76,6 +76,12 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co @@ -1356,10 +1356,10 @@ index d23f255de9208f42125fa358a9e8194c984fe4d3..92e9bc9ba577474ca1108b8d06157395 // CraftBukkit end } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 1ffd82f8459525c73ea2f4a57568eb5966b312dd..306590a29f8b6db6c0c68814f3fa28f3f26e448b 100644 +index 3a9843c30f685d2e1f0cd54ace5dddfa9e2314fa..f68731273f9ca583b3dac6ecb13c1ac9fcc06bed 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -365,6 +365,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -374,6 +374,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot @Nullable @Override public BlockState setBlockState(BlockPos pos, BlockState state, int flags) { diff --git a/divinemc-server/minecraft-patches/features/0050-Cleanup-dead-code-from-Paper.patch b/divinemc-server/minecraft-patches/features/0052-Cleanup-dead-code-from-Paper.patch similarity index 58% rename from divinemc-server/minecraft-patches/features/0050-Cleanup-dead-code-from-Paper.patch rename to divinemc-server/minecraft-patches/features/0052-Cleanup-dead-code-from-Paper.patch index e853db0..0b21a9d 100644 --- a/divinemc-server/minecraft-patches/features/0050-Cleanup-dead-code-from-Paper.patch +++ b/divinemc-server/minecraft-patches/features/0052-Cleanup-dead-code-from-Paper.patch @@ -23,11 +23,57 @@ index 3f85f9e9551b2eed6e66ab8036dbb1f40fb8bbac..78650957bacc0e26d3299a8de7f8bfc5 } // Paper end - Buffer joins to world } +diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java +index 3e4241976fdfe65bc0aae90a9097770745c0ddf1..ae0eb872f59be23126a7d44056607058c81a0e81 100644 +--- a/net/minecraft/network/PacketProcessor.java ++++ b/net/minecraft/network/PacketProcessor.java +@@ -71,28 +71,8 @@ public class PacketProcessor implements AutoCloseable { + this.closed = true; + } + +- // Paper start - detailed watchdog information +- public static final java.util.concurrent.ConcurrentLinkedDeque packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>(); +- static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong(); +- +- public static long getTotalProcessedPackets() { +- return totalMainThreadPacketsProcessed.get(); +- } +- +- public static java.util.List getCurrentPacketProcessors() { +- java.util.List listeners = new java.util.ArrayList<>(4); +- for (PacketListener listener : packetProcessing) { +- listeners.add(listener); +- } +- +- return listeners; +- } +- // Paper end - detailed watchdog information +- + record ListenerAndPacket(T listener, Packet packet) { + public void handle() { +- packetProcessing.push(this.listener); // Paper - detailed watchdog information +- try { // Paper - detailed watchdog information + if (this.listener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players + if (this.listener.shouldHandleMessage(this.packet)) { + try { +@@ -107,12 +87,6 @@ public class PacketProcessor implements AutoCloseable { + } else { + PacketProcessor.LOGGER.debug("Ignoring packet due to disconnection: {}", this.packet); + } +- // Paper start - detailed watchdog information +- } finally { +- totalMainThreadPacketsProcessed.getAndIncrement(); +- packetProcessing.pop(); +- } +- // Paper end - detailed watchdog information + } + } + } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa486cf3a71 100644 +index f22762d2e0c97246415669baa7b3d713bb6e929a..8e1705b301c8e880d0a8dbce1025890b3265b77b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1370,13 +1370,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1372,13 +1372,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information public void tickNonPassenger(Entity entity) { @@ -41,7 +87,7 @@ index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa4 entity.setOldPosAndRot(); entity.tickCount++; entity.totalEntityAge++; // Paper - age-like counter for all entities -@@ -1389,13 +1383,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1391,13 +1385,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (Entity entity1 : entity.getPassengers()) { this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 } @@ -56,7 +102,7 @@ index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa4 private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2 diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..72628fab95b76b67630594611f894a5ecdad5fc3 100644 +index 167c244433fd77b5d0cc0975965f04c5d88001fa..2bf4f7c612318c6cb3f21f111811cc28766298e0 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1117,29 +1117,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name @@ -103,3 +149,23 @@ index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..72628fab95b76b67630594611f894a5e } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { +@@ -5027,9 +5001,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public void setDeltaMovement(Vec3 deltaMovement) { +- synchronized (this.posLock) { // Paper - detailed watchdog information + this.deltaMovement = deltaMovement; +- } // Paper - detailed watchdog information + } + + public void addDeltaMovement(Vec3 addend) { +@@ -5127,9 +5099,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + // Paper end - Block invalid positions and bounding box + if (this.position.x != x || this.position.y != y || this.position.z != z) { +- synchronized (this.posLock) { // Paper - detailed watchdog information + this.position = new Vec3(x, y, z); +- } // Paper - detailed watchdog information + int floor = Mth.floor(x); + int floor1 = Mth.floor(y); + int floor2 = Mth.floor(z); diff --git a/patches/todo/minecraft-patches/0050-MSPT-Tracking-for-each-world.patch b/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch similarity index 86% rename from patches/todo/minecraft-patches/0050-MSPT-Tracking-for-each-world.patch rename to divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch index a53246e..018d121 100644 --- a/patches/todo/minecraft-patches/0050-MSPT-Tracking-for-each-world.patch +++ b/divinemc-server/minecraft-patches/features/0053-MSPT-Tracking-for-each-world.patch @@ -5,10 +5,10 @@ Subject: [PATCH] MSPT Tracking for each world diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index aad1f6dffc6831baa8a573add5bbd229cd7b2a9d..a7871b4591593e6b1efa3dc17053de9df600f24c 100644 +index 495fbb4285f7da79e35118cae9212cb29b057d97..88296555274b67dc504c4765bc9bf049545ca19a 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1678,7 +1678,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> { @@ -21,10 +21,10 @@ index 411e1284a208ca1a097cf6eaa92e1e0d2203d83d..3f60d1b0ac91cfd3418e791222cd7267 if (var2 instanceof ClosedChannelException) { LOGGER.info("Connection closed during protocol change"); diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0e3754963 100644 +index bfc200f39a22664204b5aa66d3911abdb368e563..50daa39747a0f07c4d31a13c4410819a82d5f076 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -57,6 +57,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -58,6 +58,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; private final ServerLevel level; @@ -32,7 +32,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 public final Thread mainThread; final ThreadedLevelLightEngine lightEngine; public final ServerChunkCache.MainThreadExecutor mainThreadProcessor; -@@ -70,8 +71,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -71,8 +72,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon private final long[] lastChunkPos = new long[4]; private final ChunkStatus[] lastChunkStatus = new ChunkStatus[4]; private final ChunkAccess[] lastChunk = new ChunkAccess[4]; @@ -45,7 +45,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 @Nullable @VisibleForDebug private NaturalSpawner.SpawnState lastSpawnState; -@@ -153,36 +156,253 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -154,36 +157,253 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon return load ? this.syncLoad(chunkX, chunkZ, toStatus) : null; } // Paper end - rewrite chunk system @@ -312,7 +312,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 } // Paper end - chunk tick iteration optimisations -@@ -507,14 +727,21 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -502,14 +722,21 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon long gameTime = this.level.getGameTime(); long l = gameTime - this.lastInhabitedUpdate; this.lastInhabitedUpdate = gameTime; @@ -338,7 +338,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 // DivineMC start - Pufferfish: Optimize mob spawning if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableAsyncSpawning) { for (ServerPlayer player : this.level.players) { -@@ -558,14 +785,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -553,14 +780,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } private void broadcastChangedChunks() { @@ -363,7 +363,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 } private void tickChunks(long timeInhabited) { -@@ -615,23 +846,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -610,23 +841,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon filteredSpawningCategories = List.of(); } @@ -404,13 +404,13 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0 - this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations + this.iterateTickingChunksFaster(spawns); // Paper - chunk tick iteration optimisations // DivineMC - Regionized Chunk Ticking if (_boolean) { - this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); + this.level.tickCustomSpawners(this.spawnEnemies); } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a283f740b1 100644 +index 33f9e1306c6e0315f256ab65aa594624b47593ae..668e20075c875775ac0bf355d7318c3ff1426fc0 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -191,7 +191,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -197,7 +197,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe private final LevelTicks blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded); private final LevelTicks fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded); private final PathTypeCache pathTypesByPosCache = new PathTypeCache(); @@ -419,7 +419,7 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2 volatile boolean isUpdatingNavigations; protected final Raids raids; private final ObjectLinkedOpenHashSet blockEvents = new ObjectLinkedOpenHashSet<>(); -@@ -806,6 +806,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -834,6 +834,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.dragonFight.tick(); } @@ -433,7 +433,7 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2 io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR this.entityTickList .forEach( -@@ -1828,22 +1835,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1849,22 +1856,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (Shapes.joinIsNotEmpty(collisionShape, collisionShape1, BooleanOp.NOT_SAME)) { List list = new ObjectArrayList<>(); @@ -465,19 +465,19 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2 try { this.isUpdatingNavigations = true; diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b2285eafe 100644 +index 250978ef6e09c8744065d143af38b99914bd25ec..e6d0977091042bb1b91c70190f6366cb4bd4d3c4 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -106,7 +106,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl - public static final int MIN_ENTITY_SPAWN_Y = -20000000; - public final org.bxteam.divinemc.util.BlockEntityTickersList blockEntityTickers = new org.bxteam.divinemc.util.BlockEntityTickersList(); // Paper - public // DivineMC - optimize block entity removals - Fix MC-117075 - protected final NeighborUpdater neighborUpdater; +@@ -112,7 +112,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + .build(); + public final org.bxteam.divinemc.util.BlockEntityTickersList blockEntityTickers = new org.bxteam.divinemc.util.BlockEntityTickersList(); // DivineMC - optimize block entity removals - Fix MC-117075 + protected final CollectingNeighborUpdater neighborUpdater; - private final List pendingBlockEntityTickers = Lists.newArrayList(); + private final List pendingBlockEntityTickers = java.util.Collections.synchronizedList(Lists.newArrayList()); // DivineMC - Regionized Chunk Ticking private boolean tickingBlockEntities; public final Thread thread; private final boolean isDebug; -@@ -138,7 +138,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -144,7 +144,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public boolean captureBlockStates = false; public boolean captureTreeGeneration = false; @@ -486,9 +486,9 @@ index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b public Map capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates @Nullable public List captureDrops; -@@ -1503,10 +1503,14 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1457,10 +1457,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - protected void tickBlockEntities() { + public void tickBlockEntities() { this.tickingBlockEntities = true; - if (!this.pendingBlockEntityTickers.isEmpty()) { - this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); @@ -505,10 +505,10 @@ index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b // Spigot start boolean runsNormally = this.tickRateManager().runsNormally(); diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -index 028eae2f9a459b60e92f3344091083aa93b54485..51e5a54aff069cac14deef6c04899d3a469842ce 100644 +index 879be2d05ef0fcfb8fab0c9f4e5bf66d7fce730b..ff8fde0d294c96755cdcdcef0cbf57dd259e06a7 100644 --- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -@@ -46,7 +46,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { +@@ -53,7 +53,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { this.addAndRun(pos, new CollectingNeighborUpdater.MultiNeighborUpdate(pos.immutable(), block, orientation, facing)); } @@ -517,7 +517,7 @@ index 028eae2f9a459b60e92f3344091083aa93b54485..51e5a54aff069cac14deef6c04899d3a boolean flag = this.count > 0; boolean flag1 = this.maxChainedNeighborUpdates >= 0 && this.count >= this.maxChainedNeighborUpdates; this.count++; -@@ -65,7 +65,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { +@@ -72,7 +72,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { } } diff --git a/patches/todo/minecraft-patches/0054-C2ME-Optimize-Aquifer-and-Beardifier.patch b/divinemc-server/minecraft-patches/features/0055-C2ME-Optimize-Aquifer-and-Beardifier.patch similarity index 64% rename from patches/todo/minecraft-patches/0054-C2ME-Optimize-Aquifer-and-Beardifier.patch rename to divinemc-server/minecraft-patches/features/0055-C2ME-Optimize-Aquifer-and-Beardifier.patch index 5ea5d36..1720060 100644 --- a/patches/todo/minecraft-patches/0054-C2ME-Optimize-Aquifer-and-Beardifier.patch +++ b/divinemc-server/minecraft-patches/features/0055-C2ME-Optimize-Aquifer-and-Beardifier.patch @@ -11,26 +11,24 @@ As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric) Licensed under: MIT (https://opensource.org/licenses/MIT) diff --git a/net/minecraft/world/level/levelgen/Aquifer.java b/net/minecraft/world/level/levelgen/Aquifer.java -index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1add5bd9a 100644 +index 1e1536099261f578fa56b9f84f28157e4a9abafa..e88890ef7de33c30e062d7da2beef6d12d75d296 100644 --- a/net/minecraft/world/level/levelgen/Aquifer.java +++ b/net/minecraft/world/level/levelgen/Aquifer.java -@@ -85,6 +85,15 @@ public interface Aquifer { +@@ -98,6 +98,13 @@ public interface Aquifer { private final int minGridZ; private final int gridSizeX; private final int gridSizeZ; + // DivineMC start - C2ME: Optimize Aquifer -+ private int c2me$dist1; -+ private int c2me$dist2; -+ private int c2me$dist3; -+ private long c2me$pos1; -+ private long c2me$pos2; -+ private long c2me$pos3; ++ private int c2me$packed1; ++ private int c2me$packed2; ++ private int c2me$packed3; + private double c2me$mutableDoubleThingy; ++ private short[] c2me$packedBlockPositions; + // DivineMC end - C2ME: Optimize Aquifer private static final int[][] SURFACE_SAMPLING_OFFSETS_IN_CHUNKS = new int[][]{ {0, 0}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1} }; -@@ -120,6 +129,36 @@ public interface Aquifer { +@@ -133,6 +140,41 @@ public interface Aquifer { this.aquiferCache = new Aquifer.FluidStatus[i4]; this.aquiferLocationCache = new long[i4]; Arrays.fill(this.aquiferLocationCache, Long.MAX_VALUE); @@ -41,8 +39,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + + int sizeY = this.aquiferLocationCache.length / (this.gridSizeX * this.gridSizeZ); + ++ this.c2me$packedBlockPositions = new short[this.aquiferLocationCache.length]; ++ + final RandomSource random = com.ishland.c2me.opts.worldgen.general.common.random_instances.RandomUtils.getRandom(this.positionalRandomFactory); -+ // index: y, z, x + for (int y = 0; y < sizeY; y++) { + for (int z = 0; z < this.gridSizeZ; z++) { + for (int x = 0; x < this.gridSizeX; x++) { @@ -50,11 +49,15 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + final int y1 = y + this.minGridY; + final int z1 = z + this.minGridZ; + com.ishland.c2me.opts.worldgen.general.common.random_instances.RandomUtils.derive(this.positionalRandomFactory, random, x1, y1, z1); -+ int x2 = x1 * 16 + random.nextInt(10); -+ int y2 = y1 * 12 + random.nextInt(9); -+ int z2 = z1 * 16 + random.nextInt(10); ++ int r0 = random.nextInt(10); ++ int r1 = random.nextInt(9); ++ int r2 = random.nextInt(10); ++ int x2 = x1 * 16 + r0; ++ int y2 = y1 * 12 + r1; ++ int z2 = z1 * 16 + r2; + int index = this.getIndex(x1, y1, z1); + this.aquiferLocationCache[index] = BlockPos.asLong(x2, y2, z2); ++ this.c2me$packedBlockPositions[index] = (short) ((r0 << 8) | (r1 << 4) | r2); + } + } + } @@ -64,118 +67,122 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + } + } + // DivineMC end - C2ME: Optimize Aquifer - } - - private int getIndex(int gridX, int gridY, int gridZ) { -@@ -132,140 +171,24 @@ public interface Aquifer { - @Nullable - @Override - public BlockState computeSubstance(DensityFunction.FunctionContext context, double substance) { -+ // DivineMC start - C2ME: Optimize Aquifer - int i = context.blockX(); -- int i1 = context.blockY(); -- int i2 = context.blockZ(); -+ int j = context.blockY(); -+ int k = context.blockZ(); - if (substance > 0.0) { + int i5 = this.adjustSurfaceLevel( + noiseChunk.maxPreliminarySurfaceLevel(fromGridX(this.minGridX, 0), fromGridZ(this.minGridZ, 0), fromGridX(i, 9), fromGridZ(i3, 9)) + ); +@@ -154,142 +196,23 @@ public interface Aquifer { this.shouldScheduleFluidUpdate = false; return null; } else { ++ // DivineMC start - C2ME: Optimize Aquifer + int i = context.blockX(); +- int i1 = context.blockY(); +- int i2 = context.blockZ(); - Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(i, i1, i2); -- if (fluidStatus.at(i1).is(Blocks.LAVA)) { -+ Aquifer.FluidStatus fluidLevel = this.globalFluidPicker.computeFluid(i, j, k); -+ if (fluidLevel.at(j).is(Blocks.LAVA)) { +- if (i1 > this.skipSamplingAboveY) { ++ int j = context.blockY(); ++ int k = context.blockZ(); ++ Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(i, j, k); ++ if (j > this.skipSamplingAboveY) { this.shouldScheduleFluidUpdate = false; - return Blocks.LAVA.defaultBlockState(); +- return fluidStatus.at(i1); +- } else if (fluidStatus.at(i1).is(Blocks.LAVA)) { ++ return fluidStatus.at(j); ++ } else if (fluidStatus.at(j).is(Blocks.LAVA)) { + this.shouldScheduleFluidUpdate = false; + return SharedConstants.DEBUG_DISABLE_FLUID_GENERATION ? Blocks.AIR.defaultBlockState() : Blocks.LAVA.defaultBlockState(); } else { -- int i3 = Math.floorDiv(i - 5, 16); -- int i4 = Math.floorDiv(i1 + 1, 12); -- int i5 = Math.floorDiv(i2 - 5, 16); +- int i3 = gridX(i + -5); +- int i4 = gridY(i1 + 1); +- int i5 = gridZ(i2 + -5); - int i6 = Integer.MAX_VALUE; - int i7 = Integer.MAX_VALUE; - int i8 = Integer.MAX_VALUE; - int i9 = Integer.MAX_VALUE; -- long l = 0L; -- long l1 = 0L; -- long l2 = 0L; -- long l3 = 0L; +- int i10 = 0; +- int i11 = 0; +- int i12 = 0; +- int i13 = 0; - -- for (int i10 = 0; i10 <= 1; i10++) { -- for (int i11 = -1; i11 <= 1; i11++) { -- for (int i12 = 0; i12 <= 1; i12++) { -- int i13 = i3 + i10; -- int i14 = i4 + i11; -- int i15 = i5 + i12; -- int index = this.getIndex(i13, i14, i15); -- long l4 = this.aquiferLocationCache[index]; -- long l5; -- if (l4 != Long.MAX_VALUE) { -- l5 = l4; +- for (int i14 = 0; i14 <= 1; i14++) { +- for (int i15 = -1; i15 <= 1; i15++) { +- for (int i16 = 0; i16 <= 1; i16++) { +- int i17 = i3 + i14; +- int i18 = i4 + i15; +- int i19 = i5 + i16; +- int index = this.getIndex(i17, i18, i19); +- long l = this.aquiferLocationCache[index]; +- long l1; +- if (l != Long.MAX_VALUE) { +- l1 = l; - } else { -- RandomSource randomSource = this.positionalRandomFactory.at(i13, i14, i15); -- l5 = BlockPos.asLong( -- i13 * 16 + randomSource.nextInt(10), i14 * 12 + randomSource.nextInt(9), i15 * 16 + randomSource.nextInt(10) +- RandomSource randomSource = this.positionalRandomFactory.at(i17, i18, i19); +- l1 = BlockPos.asLong( +- fromGridX(i17, randomSource.nextInt(10)), +- fromGridY(i18, randomSource.nextInt(9)), +- fromGridZ(i19, randomSource.nextInt(10)) - ); -- this.aquiferLocationCache[index] = l5; +- this.aquiferLocationCache[index] = l1; - } - -- int i16 = BlockPos.getX(l5) - i; -- int i17 = BlockPos.getY(l5) - i1; -- int i18 = BlockPos.getZ(l5) - i2; -- int i19 = i16 * i16 + i17 * i17 + i18 * i18; -- if (i6 >= i19) { -- l3 = l2; -- l2 = l1; -- l1 = l; -- l = l5; +- int i20 = BlockPos.getX(l1) - i; +- int i21 = BlockPos.getY(l1) - i1; +- int i22 = BlockPos.getZ(l1) - i2; +- int i23 = i20 * i20 + i21 * i21 + i22 * i22; +- if (i6 >= i23) { +- i13 = i12; +- i12 = i11; +- i11 = i10; +- i10 = index; - i9 = i8; - i8 = i7; - i7 = i6; -- i6 = i19; -- } else if (i7 >= i19) { -- l3 = l2; -- l2 = l1; -- l1 = l5; +- i6 = i23; +- } else if (i7 >= i23) { +- i13 = i12; +- i12 = i11; +- i11 = index; - i9 = i8; - i8 = i7; -- i7 = i19; -- } else if (i8 >= i19) { -- l3 = l2; -- l2 = l5; +- i7 = i23; +- } else if (i8 >= i23) { +- i13 = i12; +- i12 = index; - i9 = i8; -- i8 = i19; -- } else if (i9 >= i19) { -- l3 = l5; -- i9 = i19; +- i8 = i23; +- } else if (i9 >= i23) { +- i13 = index; +- i9 = i23; - } - } - } - } - -- Aquifer.FluidStatus aquiferStatus = this.getAquiferStatus(l); +- Aquifer.FluidStatus aquiferStatus = this.getAquiferStatus(i10); - double d = similarity(i6, i7); - BlockState blockState = aquiferStatus.at(i1); +- BlockState blockState1 = SharedConstants.DEBUG_DISABLE_FLUID_GENERATION ? Blocks.AIR.defaultBlockState() : blockState; - if (d <= 0.0) { - if (d >= FLOWING_UPDATE_SIMULARITY) { -- Aquifer.FluidStatus aquiferStatus1 = this.getAquiferStatus(l1); +- Aquifer.FluidStatus aquiferStatus1 = this.getAquiferStatus(i11); - this.shouldScheduleFluidUpdate = !aquiferStatus.equals(aquiferStatus1); - } else { - this.shouldScheduleFluidUpdate = false; - } - -- return blockState; +- return blockState1; - } else if (blockState.is(Blocks.WATER) && this.globalFluidPicker.computeFluid(i, i1 - 1, i2).at(i1 - 1).is(Blocks.LAVA)) { - this.shouldScheduleFluidUpdate = true; -- return blockState; +- return blockState1; - } else { - MutableDouble mutableDouble = new MutableDouble(Double.NaN); -- Aquifer.FluidStatus aquiferStatus2 = this.getAquiferStatus(l1); +- Aquifer.FluidStatus aquiferStatus2 = this.getAquiferStatus(i11); - double d1 = d * this.calculatePressure(context, mutableDouble, aquiferStatus, aquiferStatus2); - if (substance + d1 > 0.0) { - this.shouldScheduleFluidUpdate = false; - return null; - } else { -- Aquifer.FluidStatus aquiferStatus3 = this.getAquiferStatus(l2); +- Aquifer.FluidStatus aquiferStatus3 = this.getAquiferStatus(i12); - double d2 = similarity(i6, i8); - if (d2 > 0.0) { - double d3 = d * d2 * this.calculatePressure(context, mutableDouble, aquiferStatus, aquiferStatus3); @@ -200,12 +207,12 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 - if (!flag && !flag1 && !flag2) { - this.shouldScheduleFluidUpdate = d2 >= FLOWING_UPDATE_SIMULARITY - && similarity(i6, i9) >= FLOWING_UPDATE_SIMULARITY -- && !aquiferStatus.equals(this.getAquiferStatus(l3)); +- && !aquiferStatus.equals(this.getAquiferStatus(i13)); - } else { - this.shouldScheduleFluidUpdate = true; - } - -- return blockState; +- return blockState1; - } - } + aquiferExtracted$refreshDistPosIdx(i, j, k); @@ -216,8 +223,8 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 } @Override -@@ -278,65 +201,28 @@ public interface Aquifer { - return 1.0 - Math.abs(secondDistance - firstDistance) / 25.0; +@@ -302,65 +225,28 @@ public interface Aquifer { + return 1.0 - (secondDistance - firstDistance) / 25.0; } + // DivineMC start - C2ME: Optimize Aquifer @@ -263,7 +270,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 - d11 = d10 / 10.0; - } - } -- ++ double d = 0.5 * (double)(fluidLevel.fluidLevel + fluidLevel2.fluidLevel); ++ final double q = aquiferExtracted$getQ(i, d, abs); + - double d10x = 2.0; - double d12; - if (!(d11 < -2.0) && !(d11 > 2.0)) { @@ -278,9 +287,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 - } else { - d12 = 0.0; - } -+ double d = 0.5 * (double)(fluidLevel.fluidLevel + fluidLevel2.fluidLevel); -+ final double q = aquiferExtracted$getQ(i, d, abs); - +- - return 2.0 * (d12 + d11); + return aquiferExtracted$postCalculateDensity(context, substance, q); } @@ -290,49 +297,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 } + // DivineMC end - C2ME: Optimize Aquifer - private int gridX(int x) { - return Math.floorDiv(x, 16); -@@ -350,23 +236,25 @@ public interface Aquifer { - return Math.floorDiv(z, 16); - } - -- private Aquifer.FluidStatus getAquiferStatus(long packedPos) { -- int x = BlockPos.getX(packedPos); -- int y = BlockPos.getY(packedPos); -- int z = BlockPos.getZ(packedPos); -- int i = this.gridX(x); -- int i1 = this.gridY(y); -- int i2 = this.gridZ(z); -- int index = this.getIndex(i, i1, i2); -- Aquifer.FluidStatus fluidStatus = this.aquiferCache[index]; -- if (fluidStatus != null) { -- return fluidStatus; -+ // DivineMC start - C2ME: Optimize Aquifer -+ private Aquifer.FluidStatus getAquiferStatus(long pos) { -+ int i = BlockPos.getX(pos); -+ int j = BlockPos.getY(pos); -+ int k = BlockPos.getZ(pos); -+ int l = i >> 4; // C2ME - inline: floorDiv(i, 16) -+ int m = Math.floorDiv(j, 12); // C2ME - inline -+ int n = k >> 4; // C2ME - inline: floorDiv(k, 16) -+ int o = this.getIndex(l, m, n); -+ Aquifer.FluidStatus fluidLevel = this.aquiferCache[o]; -+ if (fluidLevel != null) { -+ return fluidLevel; - } else { -- Aquifer.FluidStatus fluidStatus1 = this.computeFluid(x, y, z); -- this.aquiferCache[index] = fluidStatus1; -- return fluidStatus1; -+ Aquifer.FluidStatus fluidLevel2 = this.computeFluid(i, j, k); -+ this.aquiferCache[o] = fluidLevel2; -+ return fluidLevel2; - } - } -+ // DivineMC end - C2ME: Optimize Aquifer - - private Aquifer.FluidStatus computeFluid(int x, int y, int z) { - Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(x, y, z); -@@ -407,22 +295,21 @@ public interface Aquifer { + private static int gridX(int x) { + return x >> 4; +@@ -441,22 +327,21 @@ public interface Aquifer { } private int computeSurfaceLevel(int x, int y, int z, Aquifer.FluidStatus fluidStatus, int maxSurfaceLevel, boolean fluidPresent) { @@ -363,7 +330,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 int i; if (d1 > 0.0) { -@@ -453,12 +340,12 @@ public interface Aquifer { +@@ -487,12 +372,12 @@ public interface Aquifer { private BlockState computeFluidType(int x, int y, int z, Aquifer.FluidStatus fluidStatus, int surfaceLevel) { BlockState blockState = fluidStatus.fluidType; if (surfaceLevel <= -10 && surfaceLevel != DimensionType.WAY_BELOW_MIN_Y && fluidStatus.fluidType != Blocks.LAVA.defaultBlockState()) { @@ -382,15 +349,15 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 if (Math.abs(d) > 0.3) { blockState = Blocks.LAVA.defaultBlockState(); } -@@ -466,5 +353,183 @@ public interface Aquifer { +@@ -500,5 +385,218 @@ public interface Aquifer { return blockState; } + + // DivineMC start - C2ME: Optimize Aquifer -+ private @org.jetbrains.annotations.Nullable BlockState aquiferExtracted$applyPost(DensityFunction.FunctionContext pos, double density, int j, int i, int k) { -+ Aquifer.FluidStatus fluidLevel2 = this.getAquiferStatus(this.c2me$pos1); -+ double d = similarity(this.c2me$dist1, this.c2me$dist2); ++ private @Nullable BlockState aquiferExtracted$applyPost(DensityFunction.FunctionContext pos, double density, int j, int i, int k) { ++ Aquifer.FluidStatus fluidLevel2 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed1)); ++ double d = similarity(c2me$unpackPackedDist(this.c2me$packed1), c2me$unpackPackedDist(this.c2me$packed2)); + BlockState blockState = fluidLevel2.at(j); + if (d <= 0.0) { + this.shouldScheduleFluidUpdate = d >= FLOWING_UPDATE_SIMULARITY; @@ -400,7 +367,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + return blockState; + } else { + this.c2me$mutableDoubleThingy = Double.NaN; -+ Aquifer.FluidStatus fluidLevel3 = this.getAquiferStatus(this.c2me$pos2); ++ Aquifer.FluidStatus fluidLevel3 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed2)); + double e = d * this.c2me$calculateDensityModified(pos, fluidLevel2, fluidLevel3); + if (density + e > 0.0) { + this.shouldScheduleFluidUpdate = false; @@ -412,11 +379,12 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + } + + private BlockState aquiferExtracted$getFinalBlockState(DensityFunction.FunctionContext pos, double density, double d, Aquifer.FluidStatus fluidLevel2, Aquifer.FluidStatus fluidLevel3, BlockState blockState) { -+ Aquifer.FluidStatus fluidLevel4 = this.getAquiferStatus(this.c2me$pos3); -+ double f = similarity(this.c2me$dist1, this.c2me$dist3); ++ Aquifer.FluidStatus fluidLevel4 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed3)); ++ int dist3 = c2me$unpackPackedDist(this.c2me$packed3); ++ double f = similarity(c2me$unpackPackedDist(this.c2me$packed1), dist3); + if (aquiferExtracted$extractedCheckFG(pos, density, d, fluidLevel2, f, fluidLevel4)) return null; + -+ double g = similarity(this.c2me$dist2, this.c2me$dist3); ++ double g = similarity(c2me$unpackPackedDist(this.c2me$packed2), dist3); + if (aquiferExtracted$extractedCheckFG(pos, density, d, fluidLevel3, g, fluidLevel4)) return null; + + this.shouldScheduleFluidUpdate = true; @@ -438,51 +406,61 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + int gx = (x - 5) >> 4; + int gy = Math.floorDiv(y + 1, 12); + int gz = (z - 5) >> 4; -+ int dist1 = Integer.MAX_VALUE; -+ int dist2 = Integer.MAX_VALUE; -+ int dist3 = Integer.MAX_VALUE; -+ long pos1 = 0; -+ long pos2 = 0; -+ long pos3 = 0; ++ int A = Integer.MAX_VALUE; ++ int B = Integer.MAX_VALUE; ++ int C = Integer.MAX_VALUE; + ++ int index = 12; // 12 max + for (int offY = -1; offY <= 1; ++offY) { ++ int gymul = (gy + offY) * 12; + for (int offZ = 0; offZ <= 1; ++offZ) { -+ for (int offX = 0; offX <= 1; ++offX) { -+ int posIdx = this.getIndex(gx + offX, gy + offY, gz + offZ); ++ int gzmul = (gz + offZ) << 4; + -+ long position = this.aquiferLocationCache[posIdx]; ++ int index0 = index - 1; ++ int posIdx0 = this.getIndex(gx, gy + offY, gz + offZ); ++ int position0 = this.c2me$packedBlockPositions[posIdx0]; ++ int dx0 = (gx << 4) + c2me$unpackPackedX(position0) - x; ++ int dy0 = gymul + c2me$unpackPackedY(position0) - y; ++ int dz0 = gzmul + c2me$unpackPackedZ(position0) - z; ++ int dist_0 = dx0 * dx0 + dy0 * dy0 + dz0 * dz0; + -+ int dx = BlockPos.getX(position) - x; -+ int dy = BlockPos.getY(position) - y; -+ int dz = BlockPos.getZ(position) - z; -+ int dist = dx * dx + dy * dy + dz * dz; ++ int index1 = index - 2; ++ int posIdx1 = posIdx0 + 1; ++ int position1 = this.c2me$packedBlockPositions[posIdx1]; ++ int dx1 = ((gx + 1) << 4) + c2me$unpackPackedX(position1) - x; ++ int dy1 = gymul + c2me$unpackPackedY(position1) - y; ++ int dz1 = gzmul + c2me$unpackPackedZ(position1) - z; ++ int dist_1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1; + -+ if (dist3 >= dist) { -+ pos3 = position; -+ dist3 = dist; -+ } -+ if (dist2 >= dist) { -+ pos3 = pos2; -+ dist3 = dist2; -+ pos2 = position; -+ dist2 = dist; -+ } -+ if (dist1 >= dist) { -+ pos2 = pos1; -+ dist2 = dist1; -+ pos1 = position; -+ dist1 = dist; -+ } ++ int p0 = (dist_0 << 20) | (index0 << 16) | posIdx0; ++ if (p0 <= C) { ++ int n01 = Math.max(A, p0); ++ A = Math.min(A, p0); ++ ++ int n02 = Math.max(B, n01); ++ B = Math.min(B, n01); ++ ++ C = Math.min(C, n02); + } ++ ++ int p1 = (dist_1 << 20) | (index1 << 16) | posIdx1; ++ if (p1 <= C) { ++ int n11 = Math.max(A, p1); ++ A = Math.min(A, p1); ++ ++ int n12 = Math.max(B, n11); ++ B = Math.min(B, n11); ++ ++ C = Math.min(C, n12); ++ } ++ ++ index -= 2; + } + } + -+ this.c2me$dist1 = dist1; -+ this.c2me$dist2 = dist2; -+ this.c2me$dist3 = dist3; -+ this.c2me$pos1 = pos1; -+ this.c2me$pos2 = pos2; -+ this.c2me$pos3 = pos3; ++ this.c2me$packed1 = A; ++ this.c2me$packed2 = B; ++ this.c2me$packed3 = C; + } + + private double c2me$calculateDensityModified( @@ -563,101 +541,142 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1 + } + return q; + } ++ ++ private Aquifer.FluidStatus c2me$getWaterLevelIndexed(int index) { ++ return this.getAquiferStatus(index); ++ } ++ ++ private static int c2me$unpackPackedX(int packed) { ++ return packed >> 8; ++ } ++ ++ private static int c2me$unpackPackedY(int packed) { ++ return (packed >> 4) & 0b1111; ++ } ++ ++ private static int c2me$unpackPackedZ(int packed) { ++ return packed & 0b1111; ++ } ++ ++ private static int c2me$unpackPackedDist(int packed) { ++ return packed >> 20; ++ } ++ ++ private static int c2me$unpackPackedPosIdx(int packed) { ++ return packed & 0xffff; ++ } + // DivineMC end - C2ME: Optimize Aquifer } } diff --git a/net/minecraft/world/level/levelgen/Beardifier.java b/net/minecraft/world/level/levelgen/Beardifier.java -index 86c15d2d90e63d21cb83622a7b29e11151a4f64a..2c0c0546046857056b8445f59828fdf9821ea001 100644 +index c9ddfc8670614c2d8629066b0cc805d18e4f662f..fc1f1fcac84197a2652dfd3869ef505f1a6140f1 100644 --- a/net/minecraft/world/level/levelgen/Beardifier.java +++ b/net/minecraft/world/level/levelgen/Beardifier.java -@@ -29,6 +29,17 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { - }); - private final ObjectListIterator pieceIterator; - private final ObjectListIterator junctionIterator; +@@ -35,6 +35,15 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { + private final List junctions; + @Nullable + private final BoundingBox affectedBox; + // DivineMC start - C2ME: Optimize Beardifier + private Beardifier.Rigid[] c2me$pieceArray; + private JigsawJunction[] c2me$junctionArray; + + private void c2me$initArrays() { -+ this.c2me$pieceArray = com.google.common.collect.Iterators.toArray(this.pieceIterator, Beardifier.Rigid.class); -+ this.pieceIterator.back(Integer.MAX_VALUE); -+ this.c2me$junctionArray = com.google.common.collect.Iterators.toArray(this.junctionIterator, JigsawJunction.class); -+ this.junctionIterator.back(Integer.MAX_VALUE); ++ this.c2me$pieceArray = this.pieces.toArray(Beardifier.Rigid[]::new); ++ this.c2me$junctionArray = this.junctions.toArray(JigsawJunction[]::new); + } + // DivineMC end - C2ME: Optimize Beardifier public static Beardifier forStructuresInChunk(StructureManager structureManager, ChunkPos chunkPos) { - int minBlockX = chunkPos.getMinBlockX(); -@@ -75,50 +86,44 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { - this.junctionIterator = junctionIterator; + List list = structureManager.startsForStructure(chunkPos, structure -> structure.terrainAdaptation() != TerrainAdjustment.NONE); +@@ -109,53 +118,54 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { + } } + // DivineMC start - C2ME: Optimize Beardifier @Override public double compute(DensityFunction.FunctionContext context) { + if (this.affectedBox == null) { + return 0.0; +- } else { +- int i = context.blockX(); +- int i1 = context.blockY(); +- int i2 = context.blockZ(); +- if (!this.affectedBox.isInside(i, i1, i2)) { +- return 0.0; +- } else { +- double d = 0.0; +- +- for (Beardifier.Rigid rigid : this.pieces) { +- BoundingBox boundingBox = rigid.box(); +- int groundLevelDelta = rigid.groundLevelDelta(); +- int max = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX())); +- int max1 = Math.max(0, Math.max(boundingBox.minZ() - i2, i2 - boundingBox.maxZ())); +- int i3 = boundingBox.minY() + groundLevelDelta; +- int i4 = i1 - i3; +- +- int i5 = switch (rigid.terrainAdjustment()) { +- case NONE -> 0; +- case BURY, BEARD_THIN -> i4; +- case BEARD_BOX -> Math.max(0, Math.max(i3 - i1, i1 - boundingBox.maxY())); +- case ENCAPSULATE -> Math.max(0, Math.max(boundingBox.minY() - i1, i1 - boundingBox.maxY())); +- }; +- +- d += switch (rigid.terrainAdjustment()) { +- case NONE -> 0.0; +- case BURY -> getBuryContribution(max, i5 / 2.0, max1); +- case BEARD_THIN, BEARD_BOX -> getBeardContribution(max, i5, max1, i4) * 0.8; +- case ENCAPSULATE -> getBuryContribution(max / 2.0, i5 / 2.0, max1 / 2.0) * 0.8; +- }; +- } ++ } + +- for (JigsawJunction jigsawJunction : this.junctions) { +- int i6 = i - jigsawJunction.getSourceX(); +- int groundLevelDelta = i1 - jigsawJunction.getSourceGroundY(); +- int max = i2 - jigsawJunction.getSourceZ(); +- d += getBeardContribution(i6, groundLevelDelta, max, groundLevelDelta) * 0.4; +- } ++ int i = context.blockX(); ++ int j = context.blockY(); ++ int k = context.blockZ(); + +- return d; +- } ++ if (this.affectedBox.isInside(i, j, k)) { ++ return 0.0; ++ } ++ + if (this.c2me$pieceArray == null || this.c2me$junctionArray == null) { + this.c2me$initArrays(); + } - int i = context.blockX(); -- int i1 = context.blockY(); -- int i2 = context.blockZ(); -+ int j = context.blockY(); -+ int k = context.blockZ(); - double d = 0.0; - -- while (this.pieceIterator.hasNext()) { -- Beardifier.Rigid rigid = this.pieceIterator.next(); -- BoundingBox boundingBox = rigid.box(); -- int groundLevelDelta = rigid.groundLevelDelta(); -- int max = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX())); -- int max1 = Math.max(0, Math.max(boundingBox.minZ() - i2, i2 - boundingBox.maxZ())); -- int i3 = boundingBox.minY() + groundLevelDelta; -- int i4 = i1 - i3; -- -- int i5 = switch (rigid.terrainAdjustment()) { -- case NONE -> 0; -- case BURY, BEARD_THIN -> i4; -- case BEARD_BOX -> Math.max(0, Math.max(i3 - i1, i1 - boundingBox.maxY())); -- case ENCAPSULATE -> Math.max(0, Math.max(boundingBox.minY() - i1, i1 - boundingBox.maxY())); -- }; -+ for (Beardifier.Rigid piece : this.c2me$pieceArray) { -+ BoundingBox blockBox = piece.box(); -+ int l = piece.groundLevelDelta(); -+ int m = Math.max(0, Math.max(blockBox.minX() - i, i - blockBox.maxX())); -+ int n = Math.max(0, Math.max(blockBox.minZ() - k, k - blockBox.maxZ())); -+ int o = blockBox.minY() + l; ++ ++ double d = 0.0; ++ ++ for (Beardifier.Rigid rigid : this.pieces) { ++ BoundingBox boundingBox = rigid.box(); ++ int l = rigid.groundLevelDelta(); ++ int m = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX())); ++ int n = Math.max(0, Math.max(boundingBox.minZ() - k, k - boundingBox.maxZ())); ++ int o = boundingBox.minY() + l; + int p = j - o; - -- d += switch (rigid.terrainAdjustment()) { -+ d += switch (piece.terrainAdjustment()) { // 2 switch statement merged - case NONE -> 0.0; -- case BURY -> getBuryContribution(max, i5 / 2.0, max1); -- case BEARD_THIN, BEARD_BOX -> getBeardContribution(max, i5, max1, i4) * 0.8; -- case ENCAPSULATE -> getBuryContribution(max / 2.0, i5 / 2.0, max1 / 2.0) * 0.8; ++ ++ d += switch (rigid.terrainAdjustment()) { ++ case NONE -> 0.0; + case BURY -> getBuryContribution(m, (double)p / 2.0, n); + case BEARD_THIN -> getBeardContribution(m, p, n, p) * 0.8; -+ case BEARD_BOX -> getBeardContribution(m, Math.max(0, Math.max(o - j, j - blockBox.maxY())), n, p) * 0.8; -+ case ENCAPSULATE -> getBuryContribution((double)m / 2.0, (double)Math.max(0, Math.max(blockBox.minY() - j, j - blockBox.maxY())) / 2.0, (double)n / 2.0) * 0.8; - }; - } - -- this.pieceIterator.back(Integer.MAX_VALUE); -- -- while (this.junctionIterator.hasNext()) { -- JigsawJunction jigsawJunction = this.junctionIterator.next(); -- int i6 = i - jigsawJunction.getSourceX(); -- int groundLevelDelta = i1 - jigsawJunction.getSourceGroundY(); -- int max = i2 - jigsawJunction.getSourceZ(); -- d += getBeardContribution(i6, groundLevelDelta, max, groundLevelDelta) * 0.4; -+ for (JigsawJunction jigsawJunction : this.c2me$junctionArray) { ++ case BEARD_BOX ->getBeardContribution(m, Math.max(0, Math.max(o - j, j - boundingBox.maxY())), n, p) * 0.8; ++ case ENCAPSULATE -> getBuryContribution((double)m / 2.0, (double)Math.max(0, Math.max(boundingBox.minY() - j, j - boundingBox.maxY())) / 2.0, (double)n / 2.0) * 0.8; ++ }; ++ } ++ ++ for (JigsawJunction jigsawJunction : this.junctions) { + int r = i - jigsawJunction.getSourceX(); + int l = j - jigsawJunction.getSourceGroundY(); + int m = k - jigsawJunction.getSourceZ(); + d += getBeardContribution(r, l, m, l) * 0.4; } - -- this.junctionIterator.back(Integer.MAX_VALUE); - return d; ++ ++ return d; } + // DivineMC end - C2ME: Optimize Beardifier diff --git a/patches/todo/minecraft-patches/0051-Catch-update-suppressors.patch b/divinemc-server/minecraft-patches/features/0056-Catch-update-suppressors.patch similarity index 72% rename from patches/todo/minecraft-patches/0051-Catch-update-suppressors.patch rename to divinemc-server/minecraft-patches/features/0056-Catch-update-suppressors.patch index 387a601..fb7add5 100644 --- a/patches/todo/minecraft-patches/0051-Catch-update-suppressors.patch +++ b/divinemc-server/minecraft-patches/features/0056-Catch-update-suppressors.patch @@ -4,26 +4,26 @@ Date: Sun, 23 Feb 2025 01:14:54 +0300 Subject: [PATCH] Catch update suppressors -diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java -index 4535858701b2bb232b9d2feb2af6551526232ddc..aa4dd7517e8be167aef1eaf7aa907e3ce7cc0e62 100644 ---- a/net/minecraft/network/protocol/PacketUtils.java -+++ b/net/minecraft/network/protocol/PacketUtils.java -@@ -27,6 +27,10 @@ public class PacketUtils { - if (processor.shouldHandleMessage(packet)) { - try { - packet.handle(processor); -+ // DivineMC start - Catch update suppressors -+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) { -+ LOGGER.info(e.getMessage()); -+ // DivineMC end - Catch update suppressors - } catch (Exception var4) { - if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) { - throw makeReportedException(var4, packet, processor); +diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java +index ae0eb872f59be23126a7d44056607058c81a0e81..e76530da9641acc482aa0f030c4dc2670b1f7b14 100644 +--- a/net/minecraft/network/PacketProcessor.java ++++ b/net/minecraft/network/PacketProcessor.java +@@ -77,6 +77,10 @@ public class PacketProcessor implements AutoCloseable { + if (this.listener.shouldHandleMessage(this.packet)) { + try { + this.packet.handle(this.listener); ++ // DivineMC start - Catch update suppressors ++ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) { ++ LOGGER.info(e.getMessage()); ++ // DivineMC end - Catch update suppressors + } catch (Exception var3) { + if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) { + throw PacketUtils.makeReportedException(var3, this.packet, this.listener); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index a7871b4591593e6b1efa3dc17053de9df600f24c..7f5f7d82ac8748758964c24f6c9377dda1dabb14 100644 +index 88296555274b67dc504c4765bc9bf049545ca19a..3ea69f961797e390aabb697ad9a7f007e549d04d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1687,6 +1687,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - Use single player info update packet on join for (int i = 0; i < this.players.size(); ++i) { -@@ -264,7 +265,7 @@ public abstract class PlayerList { +@@ -265,7 +266,7 @@ public abstract class PlayerList { // Paper start - Add Listing API for Player if (entityplayer1.getBukkitEntity().isListed(bukkitPlayer)) { // Paper end - Add Listing API for Player @@ -59,7 +59,7 @@ index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671 // Paper start - Add Listing API for Player } else { entityplayer1.connection.send(ClientboundPlayerInfoUpdatePacket.createSinglePlayerInitializing(player, false)); -@@ -280,7 +281,10 @@ public abstract class PlayerList { +@@ -281,7 +282,10 @@ public abstract class PlayerList { } // Paper start - Use single player info update packet on join if (!onlinePlayers.isEmpty()) { @@ -71,7 +71,7 @@ index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671 } // Paper end - Use single player info update packet on join player.sentListPacket = true; -@@ -1389,4 +1393,69 @@ public abstract class PlayerList { +@@ -1399,4 +1403,69 @@ public abstract class PlayerList { public boolean isAllowCommandsForAllPlayers() { return this.allowCommandsForAllPlayers; } diff --git a/patches/todo/minecraft-patches/0057-Raytrace-Entity-Tracker.patch b/divinemc-server/minecraft-patches/features/0061-Raytrace-Entity-Tracker.patch similarity index 66% rename from patches/todo/minecraft-patches/0057-Raytrace-Entity-Tracker.patch rename to divinemc-server/minecraft-patches/features/0061-Raytrace-Entity-Tracker.patch index 757ab1d..4002ecd 100644 --- a/patches/todo/minecraft-patches/0057-Raytrace-Entity-Tracker.patch +++ b/divinemc-server/minecraft-patches/features/0061-Raytrace-Entity-Tracker.patch @@ -9,33 +9,20 @@ Original license: Custom License Original project: https://github.com/LogisticsCraft/OcclusionCulling Original license: MIT -diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 7ca147cf9da67c399806056e5092841f7ca32321..a6bf257ca93e4b3819b65b4ef4ba71d9e2b40933 100644 ---- a/net/minecraft/server/level/ChunkMap.java -+++ b/net/minecraft/server/level/ChunkMap.java -@@ -1421,7 +1421,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper - double d2 = d * d; - // Paper start - Configurable entity tracking range by Y -- boolean flag = d1 <= d2; -+ boolean flag = d1 <= d2 && !entity.isCulled(); // DivineMC - Raytrace Entity Tracker - if (flag && level.paperConfig().entities.trackingRangeY.enabled) { - double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1); - if (rangeY != -1) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index cb77b3ab59542bc4e8b50aecb23d98186206a0ad..fa48496222ea922204163d48988246c44e09851f 100644 +index 2bf4f7c612318c6cb3f21f111811cc28766298e0..ee33af29c7f98df04f687dde627413e186c42221 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -145,7 +145,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; +@@ -147,7 +147,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; import org.jetbrains.annotations.Contract; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker -+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // DivineMC - Raytrace Entity Tracker +-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker ++public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // DivineMC - Raytrace Entity Tracker public static javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino"); // Purpur - Configurable entity base attributes // CraftBukkit start private static final int CURRENT_LEVEL = 2; -@@ -5495,4 +5495,47 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5535,4 +5535,47 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return false; } // Purpur end - Ridables @@ -84,30 +71,22 @@ index cb77b3ab59542bc4e8b50aecb23d98186206a0ad..fa48496222ea922204163d48988246c4 + // DivineMC end - Raytrace Entity Tracker } diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 0159627e2c9a540d062073faf9018f5215e10866..26f6941dfbe0453ed5b091e408d8422901f4ca32 100644 +index e680780a0e46e9e5f9126bd11a20b918e8c36066..3a50f4d2e434e9766656a7e2a1da8c1ed483c97d 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1093,6 +1093,7 @@ public class EntityType implements FeatureElement, EntityTypeT - public EntityDimensions dimensions; +@@ -1201,6 +1201,7 @@ public class EntityType implements FeatureElement, EntityTypeT private final float spawnDimensionsScale; private final FeatureFlagSet requiredFeatures; + private final boolean allowedInPeaceful; + public boolean skipRaytracingCheck = false; // DivineMC - Raytrace Entity Tracker private static EntityType register(ResourceKey> key, EntityType.Builder builder) { return Registry.register(BuiltInRegistries.ENTITY_TYPE, key, builder.build(key)); diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272f42c3d02 100644 +index 9a6355328ca25ae7c183b68e890106776d82204e..6a8e50598da5e08ce6694c226012a44f88483f71 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -122,7 +122,6 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.scores.PlayerTeam; - import net.minecraft.world.scores.Scoreboard; --import net.minecraft.world.scores.Team; - import org.slf4j.Logger; - - public abstract class Player extends LivingEntity { -@@ -222,6 +221,25 @@ public abstract class Player extends LivingEntity { +@@ -183,6 +183,25 @@ public abstract class Player extends Avatar implements ContainerUser { public int burpDelay = 0; // Purpur - Burp delay public boolean canPortalInstant = false; // Purpur - Add portal permission bypass public int sixRowEnderchestSlotCount = -1; // Purpur - Barrels and enderchests 6 rows @@ -133,7 +112,7 @@ index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272 // CraftBukkit start public boolean fauxSleeping; -@@ -310,6 +328,25 @@ public abstract class Player extends LivingEntity { +@@ -269,6 +288,25 @@ public abstract class Player extends Avatar implements ContainerUser { @Override public void tick() { @@ -159,8 +138,8 @@ index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272 // Purpur start - Burp delay if (this.burpDelay > 0 && --this.burpDelay == 0) { this.level().playSound(null, getX(), getY(), getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 1.0F, this.level().random.nextFloat() * 0.1F + 0.9F); -@@ -1466,6 +1503,7 @@ public abstract class Player extends LivingEntity { - if (this.containerMenu != null && this.hasContainerOpen()) { +@@ -1314,6 +1352,7 @@ public abstract class Player extends Avatar implements ContainerUser { + if (this.hasContainerOpen()) { this.doCloseContainer(); } + if (this.cullTask != null) this.cullTask.signalStop(); // DivineMC - Raytrace Entity Tracker diff --git a/divinemc-server/minecraft-patches/features/0055-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch b/divinemc-server/minecraft-patches/features/0062-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch similarity index 92% rename from divinemc-server/minecraft-patches/features/0055-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch rename to divinemc-server/minecraft-patches/features/0062-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch index 6964d8e..5081b84 100644 --- a/divinemc-server/minecraft-patches/features/0055-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch +++ b/divinemc-server/minecraft-patches/features/0062-Paper-PR-Fire-ServerListPingEvent-for-secondary-motd.patch @@ -8,10 +8,10 @@ Original project: https://github.com/PaperMC/Paper Paper pull request: https://github.com/PaperMC/Paper/pull/8074 diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 1a280122b4ff661c2d2fad359ddfb671a1d8f324..c8ce9e591475df1485227d34316fc02c3ec33f3e 100644 +index 34b2cee473713d7830537c37100f37b0b38bc067..5106bfb8b48d963dca4784db1787123e9475ada0 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -208,10 +208,15 @@ public abstract class PlayerList { +@@ -209,10 +209,15 @@ public abstract class PlayerList { mutableComponent.withStyle(ChatFormatting.YELLOW); Component joinMessage = mutableComponent; // Paper - Adventure serverGamePacketListenerImpl.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot()); diff --git a/divinemc-server/minecraft-patches/features/0056-Configurable-player-spawn-tracking-range.patch b/divinemc-server/minecraft-patches/features/0063-Configurable-player-spawn-tracking-range.patch similarity index 100% rename from divinemc-server/minecraft-patches/features/0056-Configurable-player-spawn-tracking-range.patch rename to divinemc-server/minecraft-patches/features/0063-Configurable-player-spawn-tracking-range.patch diff --git a/patches/todo/minecraft-patches/0061-Linear-region-file-format.patch b/divinemc-server/minecraft-patches/features/0064-Linear-region-file-format.patch similarity index 89% rename from patches/todo/minecraft-patches/0061-Linear-region-file-format.patch rename to divinemc-server/minecraft-patches/features/0064-Linear-region-file-format.patch index e474456..d501445 100644 --- a/patches/todo/minecraft-patches/0061-Linear-region-file-format.patch +++ b/divinemc-server/minecraft-patches/features/0064-Linear-region-file-format.patch @@ -21,10 +21,10 @@ index a814512fcfb85312474ae2c2c21443843bf57831..215d4444fbd9821811fbd4724de088db public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite( final int chunkX, final int chunkZ, final CompoundTag compound diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java -index f5ed467c0880e4bcdf1b9ae773a5aac21c4381c3..64c157252f2288b507025ea96bfe4f76c635f1d9 100644 +index b83ccf7bbd134e97e14bfe8331cc9d2a26b9ec9c..a9ddee8c77ad653cd7875dc96797191750cc2781 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java -@@ -1260,7 +1260,7 @@ public final class MoonriseRegionFileIO { +@@ -1261,7 +1261,7 @@ public final class MoonriseRegionFileIO { this.regionDataController.finishWrite(this.chunkX, this.chunkZ, writeData); // Paper start - flush regionfiles on save if (this.world.paperConfig().chunks.flushRegionsOnSave) { @@ -33,7 +33,7 @@ index f5ed467c0880e4bcdf1b9ae773a5aac21c4381c3..64c157252f2288b507025ea96bfe4f76 if (regionFile != null) { regionFile.flush(); } // else: evicted from cache, which should have called flush -@@ -1470,7 +1470,7 @@ public final class MoonriseRegionFileIO { +@@ -1477,7 +1477,7 @@ public final class MoonriseRegionFileIO { public static interface IORunnable { @@ -60,15 +60,15 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..23f6ed26b531ea570fdf2ae48c1e2710 + public void moonrise$write(final org.bxteam.divinemc.region.IRegionFile regionFile) throws IOException; // DivineMC - Buffered Linear region format } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 5969e9d929c709500670b086485f68b26a8475ae..1c6749f3492195955c907c1e9812786b0936580a 100644 +index 3ea69f961797e390aabb697ad9a7f007e549d04d..30fb5b93ebb4b5f21c64f6589c33496df5242b1d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -942,10 +942,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> REGION_SHIFT, chunkPos.z >> REGION_SHIFT); @@ -282,7 +282,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 if (ret != null) { return ret; } -@@ -297,7 +317,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -298,7 +318,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise FileUtil.createDirectoriesSafe(this.folder); @@ -291,7 +291,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 this.regionCache.putAndMoveToFirst(key, ret); -@@ -311,7 +331,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -312,7 +332,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO DIVINEMC - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); // DivineMC - Rebrand } @@ -300,7 +300,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 synchronized (regionfile) { try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z); -@@ -346,7 +366,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -347,7 +367,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @Nullable public CompoundTag read(ChunkPos chunkPos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing @@ -309,7 +309,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 if (regionFile == null) { return null; } -@@ -385,7 +405,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -386,7 +406,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing @@ -318,16 +318,16 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 if (regionFile == null) { return; } -@@ -399,7 +419,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise - } +@@ -401,7 +421,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { // Paper - rewrite chunk system - public -- RegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system -+ org.bxteam.divinemc.region.IRegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system // DivineMC - Buffered Linear region format - // Paper start - rewrite chunk system - if (regionFile == null) { - // if the RegionFile doesn't exist, no point in deleting from it -@@ -429,7 +449,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { +- RegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system ++ org.bxteam.divinemc.region.IRegionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system // DivineMC - Buffered Linear region format + // Paper start - rewrite chunk system + if (regionFile == null) { + // if the RegionFile doesn't exist, no point in deleting from it +@@ -432,7 +452,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); @@ -336,7 +336,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17 try { regionFile.close(); } catch (final IOException ex) { -@@ -445,7 +465,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -448,7 +468,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); diff --git a/patches/todo/minecraft-patches/0059-Leaves-Protocol-Core.patch b/divinemc-server/minecraft-patches/features/0065-Leaves-Protocol-Core.patch similarity index 86% rename from patches/todo/minecraft-patches/0059-Leaves-Protocol-Core.patch rename to divinemc-server/minecraft-patches/features/0065-Leaves-Protocol-Core.patch index 5d4ecf2..6c0e667 100644 --- a/patches/todo/minecraft-patches/0059-Leaves-Protocol-Core.patch +++ b/divinemc-server/minecraft-patches/features/0065-Leaves-Protocol-Core.patch @@ -35,10 +35,10 @@ index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..c3be4c2fd4a544967322a45d3b8c0fe7 }; } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 7f5f7d82ac8748758964c24f6c9377dda1dabb14..5969e9d929c709500670b086485f68b26a8475ae 100644 +index 30fb5b93ebb4b5f21c64f6589c33496df5242b1d..60fb143765a9c8fa45b555b4b4c78232c7cf863c 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1789,6 +1789,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginMessagerChannels; // Paper end - retain certain values @@ -59,7 +59,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { this.server = server; -@@ -74,6 +75,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -75,6 +76,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack this.pluginMessagerChannels = cookie.channels(); this.keepAlive = cookie.keepAlive(); // Paper end @@ -67,7 +67,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a } // Paper start - configuration phase API -@@ -165,6 +167,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -166,6 +168,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { @@ -86,7 +86,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a // Paper start if (!(packet.payload() instanceof final net.minecraft.network.protocol.common.custom.DiscardedPayload discardedPayload)) { return; -@@ -230,6 +244,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -231,6 +245,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII); if (register) { bridge.addChannel(channel); @@ -95,19 +95,19 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a bridge.removeChannel(channel); } diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index e4513af9b89222cec9f9573a053504ec87fc30b8..0888ba7853f07909e9915d35f706d39a1c6cf307 100644 +index 5106bfb8b48d963dca4784db1787123e9475ada0..eab5505b10c1044f864a7327b18f1389fd09765f 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -343,6 +343,8 @@ public abstract class PlayerList { - return; - } +@@ -251,6 +251,8 @@ public abstract class PlayerList { + return; + } + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // DivineMC - Leaves Protocol Core + - final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); - if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -516,6 +518,7 @@ public abstract class PlayerList { + if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure +@@ -441,6 +443,7 @@ public abstract class PlayerList { return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); } public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { @@ -115,7 +115,7 @@ index e4513af9b89222cec9f9573a053504ec87fc30b8..0888ba7853f07909e9915d35f706d39a // Paper end - Fix kick event leave message not being sent org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar ServerLevel serverLevel = player.level(); -@@ -1459,6 +1462,7 @@ public abstract class PlayerList { +@@ -1403,6 +1406,7 @@ public abstract class PlayerList { serverPlayer.connection.send(clientboundUpdateRecipesPacket); serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer); } diff --git a/divinemc-server/minecraft-patches/features/0057-Optimize-collections.patch b/divinemc-server/minecraft-patches/features/0066-Optimize-collections.patch similarity index 95% rename from divinemc-server/minecraft-patches/features/0057-Optimize-collections.patch rename to divinemc-server/minecraft-patches/features/0066-Optimize-collections.patch index f043c2c..c7b2f87 100644 --- a/divinemc-server/minecraft-patches/features/0057-Optimize-collections.patch +++ b/divinemc-server/minecraft-patches/features/0066-Optimize-collections.patch @@ -54,10 +54,10 @@ index 5fb9a4cebf7407b8166ea5716c48a68e658d68d3..304ff53e2c21c6153ff8f04436eae66b public int serverViewDistance; public final WorldGenContext worldGenContext; // Paper - public diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index b94b946986258fed3c6d68d9972a657e176d08a4..f3110b736764a36abe5778c8a6bbf50f7349016c 100644 +index e6d0977091042bb1b91c70190f6366cb4bd4d3c4..ccf9e2d5ef57ecdf1c7471620c5baa33575738e2 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -258,7 +258,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -259,7 +259,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public final List getEntitiesOfClass(final Class entityClass, final AABB boundingBox, final Predicate predicate) { @@ -66,7 +66,7 @@ index b94b946986258fed3c6d68d9972a657e176d08a4..f3110b736764a36abe5778c8a6bbf50f ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate); -@@ -267,7 +267,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -268,7 +268,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public final List moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate predicate) { diff --git a/patches/todo/minecraft-patches/0060-Paper-PR-Optimise-non-flush-packet-sending.patch b/divinemc-server/minecraft-patches/features/0067-Paper-PR-Optimise-non-flush-packet-sending.patch similarity index 86% rename from patches/todo/minecraft-patches/0060-Paper-PR-Optimise-non-flush-packet-sending.patch rename to divinemc-server/minecraft-patches/features/0067-Paper-PR-Optimise-non-flush-packet-sending.patch index fcaea45..55ab80e 100644 --- a/patches/todo/minecraft-patches/0060-Paper-PR-Optimise-non-flush-packet-sending.patch +++ b/divinemc-server/minecraft-patches/features/0067-Paper-PR-Optimise-non-flush-packet-sending.patch @@ -24,7 +24,7 @@ up on this optimisation before he came along. Locally this patch drops the entity tracker tick by a full 1.5x. diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 3f60d1b0ac91cfd3418e791222cd7267774b367a..882a912ba3f23ee8239c24068704d9ec9a7f7c40 100644 +index f6e5fb11b471c34cbc7f3082b23c0a2a14331363..b63e976bfa89c0be75910954788500901c322ba1 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -150,6 +150,7 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -45,14 +45,14 @@ index 3f60d1b0ac91cfd3418e791222cd7267774b367a..882a912ba3f23ee8239c24068704d9ec if (this.delayedDisconnect != null) { @@ -474,7 +476,13 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.channel.eventLoop().inEventLoop()) { - this.doSendPacket(packet, channelFutureListener, flag); + this.doSendPacket(packet, sendListener, flush); } else { -- this.channel.eventLoop().execute(() -> this.doSendPacket(packet, channelFutureListener, flag)); +- this.channel.eventLoop().execute(() -> this.doSendPacket(packet, sendListener, flush)); + // Paper start - Optimise non-flush packet sending -+ if (!flag && org.bxteam.divinemc.config.DivineConfig.NetworkCategory.optimizeNonFlushPacketSending) { -+ this.eventLoop.lazyExecute(() -> this.doSendPacket(packet, channelFutureListener, flag)); ++ if (!flush && org.bxteam.divinemc.config.DivineConfig.NetworkCategory.optimizeNonFlushPacketSending) { ++ this.eventLoop.lazyExecute(() -> this.doSendPacket(packet, sendListener, flush)); + } else { -+ this.channel.eventLoop().execute(() -> this.doSendPacket(packet, channelFutureListener, flag)); ++ this.channel.eventLoop().execute(() -> this.doSendPacket(packet, sendListener, flush)); + } + // Paper end - Optimise non-flush packet sending } diff --git a/divinemc-server/minecraft-patches/features/0058-Optimize-level-ticking.patch b/divinemc-server/minecraft-patches/features/0068-Optimize-level-ticking.patch similarity index 97% rename from divinemc-server/minecraft-patches/features/0058-Optimize-level-ticking.patch rename to divinemc-server/minecraft-patches/features/0068-Optimize-level-ticking.patch index 5720193..ea768c1 100644 --- a/divinemc-server/minecraft-patches/features/0058-Optimize-level-ticking.patch +++ b/divinemc-server/minecraft-patches/features/0068-Optimize-level-ticking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimize level ticking diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea3b100555 100644 +index 668e20075c875775ac0bf355d7318c3ff1426fc0..8c9a1266bfbd1eb2b7612a07df126ea1ba792027 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -929,9 +929,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -944,9 +944,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper start - optimise random ticking private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); @@ -20,7 +20,7 @@ index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom; final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294(); -@@ -940,42 +941,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -955,42 +956,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final int offsetZ = cpos.z << 4; for (int sectionIndex = 0, sectionsLen = sections.length; sectionIndex < sectionsLen; sectionIndex++) { @@ -73,7 +73,7 @@ index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea public void tickChunk(LevelChunk chunk, int randomTickSpeed) { diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 3a9843c30f685d2e1f0cd54ace5dddfa9e2314fa..ae58d4978d2f8c0f61b5c743282f7241bd29b747 100644 +index f68731273f9ca583b3dac6ecb13c1ac9fcc06bed..ac56a14097a9f61bb9aa46e8bc3e01e6d82ba496 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -84,7 +84,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot diff --git a/divinemc-server/minecraft-patches/features/0059-lithium-combined_heightmap_update.patch b/divinemc-server/minecraft-patches/features/0069-lithium-combined_heightmap_update.patch similarity index 94% rename from divinemc-server/minecraft-patches/features/0059-lithium-combined_heightmap_update.patch rename to divinemc-server/minecraft-patches/features/0069-lithium-combined_heightmap_update.patch index 6b4b067..4045702 100644 --- a/divinemc-server/minecraft-patches/features/0059-lithium-combined_heightmap_update.patch +++ b/divinemc-server/minecraft-patches/features/0069-lithium-combined_heightmap_update.patch @@ -10,10 +10,10 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index ae58d4978d2f8c0f61b5c743282f7241bd29b747..ef98a02b982fd9e0992e0a40879d8cf498417cbf 100644 +index ac56a14097a9f61bb9aa46e8bc3e01e6d82ba496..aa4b184943eb2ce4683ffd65ff7268ae8880d932 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -388,10 +388,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -389,10 +389,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot return null; } else { Block block = state.getBlock(); diff --git a/patches/todo/minecraft-patches/0070-Optimize-Moonrise.patch b/divinemc-server/minecraft-patches/features/0070-Optimize-Moonrise.patch similarity index 88% rename from patches/todo/minecraft-patches/0070-Optimize-Moonrise.patch rename to divinemc-server/minecraft-patches/features/0070-Optimize-Moonrise.patch index 431d745..10b4c59 100644 --- a/patches/todo/minecraft-patches/0070-Optimize-Moonrise.patch +++ b/divinemc-server/minecraft-patches/features/0070-Optimize-Moonrise.patch @@ -68,19 +68,17 @@ index 2d24d03bbdb5ee0d862cbfff2219f58afffafe12..b4c55b8fee8dbab278e096580702a052 protected boolean addEntity(final Entity entity, final boolean fromDisk, final boolean event) { diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3e80dfa36 100644 +index a95db39c5ca9f4de9afe64b1cbc75ca8e86b8521..7cca448dedb167f177c1fa3ba8d13077955a2a5b 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -@@ -73,37 +73,51 @@ public final class ChunkHolderManager { +@@ -75,37 +75,49 @@ public final class ChunkHolderManager { private static final long NO_TIMEOUT_MARKER = Long.MIN_VALUE; public final ReentrantAreaLock ticketLockArea; -- private final ConcurrentLong2ReferenceChainedHashTable> tickets = new ConcurrentLong2ReferenceChainedHashTable<>(); +- private final ConcurrentLong2ReferenceChainedHashTable tickets = new ConcurrentLong2ReferenceChainedHashTable<>(); - private final ConcurrentLong2ReferenceChainedHashTable sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>(); -+ // DivineMC start - Optimize Moonrise -+ private final ConcurrentLong2ReferenceChainedHashTable> tickets = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F); ++ private final ConcurrentLong2ReferenceChainedHashTable tickets = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F); + private final ConcurrentLong2ReferenceChainedHashTable sectionToChunkToExpireCount = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F); -+ // DivineMC end - Optimize Moonrise final ChunkUnloadQueue unloadQueue; - private final ConcurrentLong2ReferenceChainedHashTable chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f); @@ -140,9 +138,9 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 + } + // DivineMC end - Optimize Moonrise - private final ConcurrentLong2ReferenceChainedHashTable ticketCounters = new ConcurrentLong2ReferenceChainedHashTable<>(); - -@@ -226,26 +240,29 @@ public final class ChunkHolderManager { + // mapping of counter id -> (mapping of pos->count) + private final ConcurrentLong2ReferenceChainedHashTable ticketCounters = new ConcurrentLong2ReferenceChainedHashTable<>(); +@@ -229,26 +241,29 @@ public final class ChunkHolderManager { this.taskScheduler.setShutdown(true); } @@ -179,7 +177,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 holder.lastAutoSave = currentTick; if (holder.save(false) != null) { -@@ -259,10 +276,11 @@ public final class ChunkHolderManager { +@@ -262,10 +277,11 @@ public final class ChunkHolderManager { for (final NewChunkHolder holder : reschedule) { if (holder.getChunkStatus().isOrAfter(FullChunkStatus.FULL)) { @@ -190,10 +188,10 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 } + // DivineMC end - Optimize Moonrise - public void saveAllChunks(final boolean flush, final boolean shutdown, final boolean logProgress) { - final List holders = this.getChunkHolders(); -@@ -461,8 +479,8 @@ public final class ChunkHolderManager { - final Long2ObjectOpenHashMap> ret = new Long2ObjectOpenHashMap<>(); + public void saveAllChunks(final boolean flush, final boolean shutdown, final boolean logProgress, + final boolean emergency) { +@@ -469,8 +485,8 @@ public final class ChunkHolderManager { + final Long2ObjectOpenHashMap> ret = new Long2ObjectOpenHashMap<>(); final Long2ObjectOpenHashMap sections = new Long2ObjectOpenHashMap<>(); final int sectionShift = this.taskScheduler.getChunkSystemLockShift(); - for (final PrimitiveIterator.OfLong iterator = this.tickets.keyIterator(); iterator.hasNext();) { @@ -203,7 +201,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 sections.computeIfAbsent( CoordinateUtils.getChunkKey( CoordinateUtils.getChunkX(coord) >> sectionShift, -@@ -559,7 +577,7 @@ public final class ChunkHolderManager { +@@ -567,7 +583,7 @@ public final class ChunkHolderManager { chunkZ >> sectionShift ); @@ -212,18 +210,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 return new Long2IntOpenHashMap(); }).addTo(chunkKey, 1); } -@@ -603,8 +621,8 @@ public final class ChunkHolderManager { - - final ReentrantAreaLock.Node ticketLock = lock ? this.ticketLockArea.lock(chunkX, chunkZ) : null; - try { -- final SortedArraySet ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (final long keyInMap) -> { -- return (SortedArraySet)SortedArraySet.create(4); -+ final SortedArraySet ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (keyInMap) -> { // DivineMC - Optimize Moonrise -+ return SortedArraySet.create(4); // DivineMC - Optimize Moonrise - }); - - final int levelBefore = getTicketLevelAt(ticketsAtChunk); -@@ -784,8 +802,8 @@ public final class ChunkHolderManager { +@@ -763,8 +779,8 @@ public final class ChunkHolderManager { final Long2ObjectOpenHashMap sections = new Long2ObjectOpenHashMap<>(); final int sectionShift = this.taskScheduler.getChunkSystemLockShift(); @@ -234,9 +221,9 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 sections.computeIfAbsent( CoordinateUtils.getChunkKey( CoordinateUtils.getChunkX(coord) >> sectionShift, -@@ -836,8 +854,8 @@ public final class ChunkHolderManager { - final List scheduledTasks = new ArrayList<>(); - final List changedFullStatus = new ArrayList<>(); +@@ -818,8 +834,8 @@ public final class ChunkHolderManager { + + Ticket[] removedList = new Ticket[4]; - for (final PrimitiveIterator.OfLong iterator = this.sectionToChunkToExpireCount.keyIterator(); iterator.hasNext();) { - final long sectionKey = iterator.nextLong(); @@ -245,7 +232,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 if (!this.sectionToChunkToExpireCount.containsKey(sectionKey)) { // removed concurrently -@@ -1145,18 +1163,18 @@ public final class ChunkHolderManager { +@@ -1132,18 +1148,18 @@ public final class ChunkHolderManager { if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking && !TickThread.isTickThreadFor(world) || !TickThread.isTickThread()) { // DivineMC - Parallel world ticking // These will be handled on the next ServerChunkCache$MainThreadExecutor#pollTask, as it runs the distance manager update // which will invoke processTicketUpdates @@ -268,7 +255,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 PlatformHooks.get().onChunkHolderDelete(this.world, holder.vanillaChunkHolder); this.chunkHolders.remove(CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ)); } -@@ -1320,6 +1338,27 @@ public final class ChunkHolderManager { +@@ -1307,6 +1323,27 @@ public final class ChunkHolderManager { } } @@ -296,7 +283,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 public enum TicketOperationType { ADD, REMOVE, ADD_IF_REMOVED, ADD_AND_REMOVE } -@@ -1479,8 +1518,10 @@ public final class ChunkHolderManager { +@@ -1466,8 +1503,10 @@ public final class ChunkHolderManager { // only call on tick thread private void processOffThreadFullUpdates() { @@ -309,7 +296,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 NewChunkHolder toUpdate; while ((toUpdate = offThreadPendingFullLoadUpdate.poll()) != null) { -@@ -1492,7 +1533,7 @@ public final class ChunkHolderManager { +@@ -1479,7 +1518,7 @@ public final class ChunkHolderManager { private boolean processPendingFullUpdate() { this.processOffThreadFullUpdates(); @@ -319,10 +306,10 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3 boolean ret = false; diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java -index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0aabdab5e 100644 +index 2409c83b03cfa1f0285f6f7c3508dbdf53750316..6318aedb621134d4f3e33480a2e97ddf7be6b433 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java -@@ -646,12 +646,20 @@ public final class NewChunkHolder { +@@ -645,12 +645,20 @@ public final class NewChunkHolder { } public final ChunkHolder vanillaChunkHolder; @@ -343,7 +330,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 this.vanillaChunkHolder = new ChunkHolder( new ChunkPos(chunkX, chunkZ), ChunkHolderManager.MAX_TICKET_LEVEL, world, world.getLightEngine(), null, world.getChunkSource().chunkMap -@@ -792,9 +800,11 @@ public final class NewChunkHolder { +@@ -791,9 +799,11 @@ public final class NewChunkHolder { // note: these are completed with null to indicate that no write occurred // they are also completed with null to indicate a null write occurred @@ -358,7 +345,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 public static final record UnloadTask(CallbackCompletable completable, PrioritisedExecutor.PrioritisedTask task, LazyRunnable toRun) {} -@@ -879,7 +889,11 @@ public final class NewChunkHolder { +@@ -878,7 +888,11 @@ public final class NewChunkHolder { MoonriseRegionFileIO.scheduleSave(this.world, this.chunkX, this.chunkZ, data, type); } @@ -371,7 +358,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 final ReentrantAreaLock.Node schedulingLock = this.scheduler.schedulingLockArea.lock(this.chunkX, this.chunkZ); try { // can only write to these fields while holding the schedule lock -@@ -1192,6 +1206,7 @@ public final class NewChunkHolder { +@@ -1191,6 +1205,7 @@ public final class NewChunkHolder { for (int dz = -NEIGHBOUR_RADIUS; dz <= NEIGHBOUR_RADIUS; ++dz) { for (int dx = -NEIGHBOUR_RADIUS; dx <= NEIGHBOUR_RADIUS; ++dx) { final NewChunkHolder holder = (dx | dz) == 0 ? this : this.scheduler.chunkHolderManager.getChunkHolder(dx + this.chunkX, dz + this.chunkZ); @@ -379,7 +366,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 if (loaded) { if (holder.setNeighbourFullLoaded(-dx, -dz)) { changedFullStatus.add(holder); -@@ -1216,6 +1231,19 @@ public final class NewChunkHolder { +@@ -1215,6 +1230,19 @@ public final class NewChunkHolder { private void updateCurrentState(final FullChunkStatus to) { this.currentFullChunkStatus = to; @@ -399,7 +386,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 } // only to be called on the main thread, no locks need to be held -@@ -1350,7 +1378,7 @@ public final class NewChunkHolder { +@@ -1349,7 +1377,7 @@ public final class NewChunkHolder { return this.requestedGenStatus; } @@ -408,7 +395,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0 void addStatusConsumer(final ChunkStatus status, final Consumer consumer) { this.statusWaiters.computeIfAbsent(status, (final ChunkStatus keyInMap) -> { -@@ -1396,7 +1424,7 @@ public final class NewChunkHolder { +@@ -1384,7 +1412,7 @@ public final class NewChunkHolder { }, Priority.HIGHEST); } @@ -430,10 +417,10 @@ index 93fd23027c00cef76562098306737272fda1350a..10c9aecb99bc3055104f50266542e249 } diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java b/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java -index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..1ac37db68341672481cd4bbdf7bab90572c35453 100644 +index 5c7b3804cdbcb0a873a0d195325c2658760a8914..4bb64bc5a31951a83d29d0c88919b1fa96e994a3 100644 --- a/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java +++ b/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java -@@ -325,7 +325,7 @@ public final class SWMRNibbleArray { +@@ -326,7 +326,7 @@ public final class SWMRNibbleArray { } // operation type: updating @@ -443,10 +430,10 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..1ac37db68341672481cd4bbdf7bab905 return false; } diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java -index 50bc5b940812432bc472e5b272582efb8bbfc7a7..0bece4ed69b332174cbe37f82df1f7da9276d591 100644 +index d03d075d5c56b7d2beb5f0aafecbb69f5b3bbf5b..ce3b8f4161dde3e2758c5d33445da15027fb0f33 100644 --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -127,15 +127,13 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches +@@ -128,15 +128,13 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches public boolean inEntityTickingRange(long chunkPos) { // Paper start - rewrite chunk system @@ -465,10 +452,10 @@ index 50bc5b940812432bc472e5b272582efb8bbfc7a7..0bece4ed69b332174cbe37f82df1f7da } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 45bf13dc23b886ea2d660c38c74becf0e3754963..b05fb5946564264771f998cff418513916eb6adb 100644 +index 50daa39747a0f07c4d31a13c4410819a82d5f076..124bf62b7dd7fb72b4cc076e909449ddfe7793ae 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -672,8 +672,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -667,8 +667,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon public boolean isPositionTicking(long chunkPos) { // Paper start - rewrite chunk system @@ -479,18 +466,18 @@ index 45bf13dc23b886ea2d660c38c74becf0e3754963..b05fb5946564264771f998cff4185139 } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82b30aca8a 100644 +index 8c9a1266bfbd1eb2b7612a07df126ea1ba792027..8db13a734eae1ee946fcf9363d289f5f98d7b6d5 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -179,6 +179,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -186,6 +186,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final ServerChunkCache chunkSource; private final MinecraftServer server; public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type + public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager.LevelHolderData chunkHolderData; // DivineMC - Optimize Moonrise - private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(this); // DivineMC - Parallel world ticking private final ServerWaypointManager waypointManager; -@@ -691,6 +692,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + // Paper - rewrite chunk system +@@ -715,6 +716,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper start - rewrite chunk system this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks())); this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this); @@ -498,7 +485,7 @@ index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82 this.entityDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController( new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController.EntityRegionFileStorage( new RegionStorageInfo(levelStorageAccess.getLevelId(), dimension, "entities"), -@@ -846,8 +848,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -882,8 +884,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public boolean shouldTickBlocksAt(long chunkPos) { // Paper start - rewrite chunk system @@ -508,7 +495,7 @@ index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82 // Paper end - rewrite chunk system } -@@ -2584,16 +2585,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2648,16 +2649,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean isPositionTickingWithEntitiesLoaded(long chunkPos) { // Paper start - rewrite chunk system diff --git a/patches/todo/minecraft-patches/0072-Entity-Status-Lock.patch b/divinemc-server/minecraft-patches/features/0071-Entity-Status-Lock.patch similarity index 100% rename from patches/todo/minecraft-patches/0072-Entity-Status-Lock.patch rename to divinemc-server/minecraft-patches/features/0071-Entity-Status-Lock.patch diff --git a/patches/todo/minecraft-patches/0073-lithium-sleeping_block_entity.patch b/divinemc-server/minecraft-patches/features/0072-lithium-sleeping_block_entity.patch similarity index 94% rename from patches/todo/minecraft-patches/0073-lithium-sleeping_block_entity.patch rename to divinemc-server/minecraft-patches/features/0072-lithium-sleeping_block_entity.patch index 624745e..ba3f5de 100644 --- a/patches/todo/minecraft-patches/0073-lithium-sleeping_block_entity.patch +++ b/divinemc-server/minecraft-patches/features/0072-lithium-sleeping_block_entity.patch @@ -15,7 +15,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/core/component/PatchedDataComponentMap.java b/net/minecraft/core/component/PatchedDataComponentMap.java -index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f59875d0d 100644 +index 766b6080160d87742ef4d8caa73b3b8fa52d5589..541d22fdc559717c7fda692c23abae581ee05a7f 100644 --- a/net/minecraft/core/component/PatchedDataComponentMap.java +++ b/net/minecraft/core/component/PatchedDataComponentMap.java @@ -14,7 +14,7 @@ import java.util.Map.Entry; @@ -27,7 +27,7 @@ index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f private final DataComponentMap prototype; private Reference2ObjectMap, Optional> patch; private boolean copyOnWrite; -@@ -135,6 +135,7 @@ public final class PatchedDataComponentMap implements DataComponentMap { +@@ -140,6 +140,7 @@ public final class PatchedDataComponentMap implements DataComponentMap { } private void ensureMapOwnership() { @@ -35,7 +35,7 @@ index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f if (this.copyOnWrite) { this.patch = new Reference2ObjectArrayMap<>(this.patch); this.copyOnWrite = false; -@@ -238,4 +239,22 @@ public final class PatchedDataComponentMap implements DataComponentMap { +@@ -243,4 +244,22 @@ public final class PatchedDataComponentMap implements DataComponentMap { public String toString() { return "{" + this.stream().map(TypedDataComponent::toString).collect(Collectors.joining(", ")) + "}"; } @@ -71,10 +71,10 @@ index 3092454bf7071deca75fecfc203072593fe5c7e7..098dd4647ae1500195729d6531e90c2b } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b50afea7c2e4c61a3df196e74afd8f82b30aca8a..dc5889c97b4aa1fe9be83b1c10c7c855e5a96d45 100644 +index 8db13a734eae1ee946fcf9363d289f5f98d7b6d5..6b72ffe12b0ce259558b5475f4c059dad3694484 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2438,6 +2438,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2500,6 +2500,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (TickingBlockEntity tickingBlockEntity : this.blockEntityTickers) { BlockPos pos = tickingBlockEntity.getPos(); @@ -83,10 +83,10 @@ index b50afea7c2e4c61a3df196e74afd8f82b30aca8a..dc5889c97b4aa1fe9be83b1c10c7c855 } } diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java -index b382665cc125b8b5c0938e5e55984e4bf91d37ff..c112b58996494d97fcd226fc490fe2718a417806 100644 +index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..ded99b157865f5bcfd64b3082c628a71d3747507 100644 --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack; +@@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -96,10 +96,10 @@ index b382665cc125b8b5c0938e5e55984e4bf91d37ff..c112b58996494d97fcd226fc490fe271 int getContainerSize(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d82ed6dcd49b4f0bd040d2bd3a6f0f54cd87758f..bae2cf89e9bc71a360fe471f7d3e703705488f3a 100644 +index ee33af29c7f98df04f687dde627413e186c42221..5904b574e9cc64fadd63ec59a79be23436770865 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -5075,6 +5075,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5133,6 +5133,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.setBoundingBox(this.makeBoundingBox()); } // Paper end - Block invalid positions and bounding box @@ -119,7 +119,7 @@ index d82ed6dcd49b4f0bd040d2bd3a6f0f54cd87758f..bae2cf89e9bc71a360fe471f7d3e7037 public void checkDespawn() { diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4a4a3f72f 100644 +index b5d7e5738ce043fdc08cd4872c9daaf952251b9a..a65fa538c930ab94e815b2aac19beefe0bde6da2 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java @@ -35,7 +35,7 @@ import net.minecraft.world.level.storage.ValueInput; @@ -131,7 +131,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4 private static final EntityDataAccessor DATA_ITEM = SynchedEntityData.defineId(ItemEntity.class, EntityDataSerializers.ITEM_STACK); private static final float FLOAT_HEIGHT = 0.1F; public static final float EYE_HEIGHT = 0.2125F; -@@ -551,6 +551,25 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -542,6 +542,25 @@ public class ItemEntity extends Entity implements TraceableEntity { } public void setItem(ItemStack stack) { @@ -157,7 +157,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4 this.getEntityData().set(DATA_ITEM, stack); this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate // Purpur start - Item entity immunities -@@ -636,4 +655,75 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -623,4 +642,75 @@ public class ItemEntity extends Entity implements TraceableEntity { public SlotAccess getSlot(int slot) { return slot == 0 ? SlotAccess.of(this::getItem, this::setItem) : super.getSlot(slot); } @@ -234,7 +234,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index 6a008c86f4e360c916b93f0e3a62a9d8b43e74e6..e19439bc89a2bd982aeb04323d0d83bcbd556117 100644 +index 8643d46d21852e9e14f9b2448f1c0eb26a737ebb..91eeb18926278763fbd6650d02c30cc33b9992fb 100644 --- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java @@ -21,7 +21,7 @@ import net.minecraft.world.level.storage.ValueOutput; @@ -281,10 +281,10 @@ index 97397e5849d3ddc14506776431a69939a2204765..3af415d58e32d89ac7c9289d5a003fc1 ItemStack item = container.getItem(i); if (!item.isEmpty()) { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04dce9cac60 100644 +index d04167eccda1fe29abe7fc28cab0c837a14e47ab..64576f34fc452724a56572c1589830128e50d2bc 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -94,7 +94,7 @@ import org.apache.commons.lang3.function.TriConsumer; +@@ -96,7 +96,7 @@ import org.apache.commons.lang3.function.TriConsumer; import org.apache.commons.lang3.mutable.MutableBoolean; import org.slf4j.Logger; @@ -293,7 +293,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d private static final List OP_NBT_WARNING = List.of( Component.translatable("item.op_warning.line1").withStyle(ChatFormatting.RED, ChatFormatting.BOLD), Component.translatable("item.op_warning.line2").withStyle(ChatFormatting.RED), -@@ -982,6 +982,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -983,6 +983,7 @@ public final class ItemStack implements DataComponentHolder { @Nullable public T set(DataComponentType component, @Nullable T value) { @@ -301,7 +301,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d return this.components.set(component, value); } -@@ -1332,6 +1333,23 @@ public final class ItemStack implements DataComponentHolder { +@@ -1336,6 +1337,23 @@ public final class ItemStack implements DataComponentHolder { } public void setCount(int count) { @@ -325,7 +325,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d this.count = count; } -@@ -1387,4 +1405,90 @@ public final class ItemStack implements DataComponentHolder { +@@ -1391,4 +1409,90 @@ public final class ItemStack implements DataComponentHolder { public boolean canDestroyBlock(BlockState state, Level level, BlockPos pos, Player player) { return this.getItem().canDestroyBlock(this, state, level, pos, player); } @@ -417,10 +417,10 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af9750bbddfa 100644 +index ccf9e2d5ef57ecdf1c7471620c5baa33575738e2..1f33d4e9df33670abbb80b15f499960a64578e70 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1521,7 +1521,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1475,7 +1475,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Spigot end if (tickingBlockEntity.isRemoved()) { this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // DivineMC - optimize block entity removals - Fix MC-117075 @@ -429,7 +429,7 @@ index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af97 tickingBlockEntity.tick(); // DivineMC start - Parallel world ticking ++tickedEntities; -@@ -2204,4 +2204,25 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -2195,4 +2195,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END; } // Purpur end - Add allow water in end world option @@ -456,7 +456,7 @@ index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af97 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java -index 3eb11df5d14ec63911be630ca99d8d9903723f9b..30dfd88822086d0769fab256401cff690f1c2bf5 100644 +index 1a805c9926ef1a5641abbe8cdaca06508f1020a5..4b9ac0140c2ca40655cb9d396073f22718722f74 100644 --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java @@ -440,7 +440,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @@ -505,7 +505,7 @@ index 558751ade918a92a1173096ccfeacf238f4260d0..1a2c56330dc5d75a566b98232d38da54 @Override diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java -index 46a27f60ba407dacdac190b5e292ab3f1db5a078..5496fb061d6adea71b509f8cc455891b1c759d8e 100644 +index 73b602eee0da94f657b4b4cb654147f7ba41c1a4..64bc18c1831e58f114ad1c245183f107c84109ab 100644 --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java @@ -38,7 +38,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; @@ -656,10 +656,10 @@ index 57eae0dbb614f57e2a352613c7490145bbfeb5a1..e6d04ab20e800cc1db245efbf9cf23ae + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b9461ceea4e9 100644 +index a4a4150beab8f2fa409a2d1d495a56679aecbae3..30cedca5e54d2da058e733cc44cff766920b46ff 100644 --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -20,7 +20,7 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; @@ -668,7 +668,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946 // CraftBukkit start - add fields and methods public java.util.List transaction = new java.util.ArrayList<>(); private int maxStack = MAX_STACK; -@@ -138,6 +138,7 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { +@@ -139,6 +139,7 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { @Override protected void setItems(NonNullList items) { this.items = items; @@ -676,7 +676,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946 } @Override -@@ -190,4 +191,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { +@@ -197,4 +198,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity { double d2 = this.worldPosition.getZ() + 0.5 + unitVec3i.getZ() / 2.0; this.level.playSound(null, d, d1, d2, sound, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F); } @@ -694,7 +694,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab39e4fc20c 100644 +index 7c2acea8af6a3110d782b9b3afeac0915ac127da..ccad8ed53e846ee0838420a74c8dc4b3e033e0d2 100644 --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java @@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -714,7 +714,7 @@ index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab3 } @Override -@@ -206,4 +207,98 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co +@@ -210,4 +211,98 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); } // CraftBukkit end @@ -814,19 +814,19 @@ index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab3 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1dc4ec40f 100644 +index 15d3f2f2959c3463f96f410b87c5f0106298352c..ec126adfcd21744e640344b8365bf54eff6a944d 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -34,7 +34,7 @@ import net.minecraft.world.level.storage.ValueInput; +@@ -36,7 +36,7 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; import org.slf4j.Logger; --public abstract class BlockEntity { -+public abstract class BlockEntity implements net.caffeinemc.mods.lithium.common.block.entity.inventory_comparator_tracking.ComparatorTracker, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SetChangedHandlingBlockEntity { // DivineMC - lithium: sleeping_block_entity +-public abstract class BlockEntity implements DebugValueSource { ++public abstract class BlockEntity implements DebugValueSource, net.caffeinemc.mods.lithium.common.block.entity.inventory_comparator_tracking.ComparatorTracker, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SetChangedHandlingBlockEntity { // DivineMC - lithium: sleeping_block_entity static boolean ignoreBlockEntityUpdates; // Paper - Perf: Optimize Hoppers // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); -@@ -56,6 +56,7 @@ public abstract class BlockEntity { +@@ -58,6 +58,7 @@ public abstract class BlockEntity implements DebugValueSource { this.validateBlockState(blockState); this.blockState = blockState; this.persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); // Paper - always init @@ -834,7 +834,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1 } private void validateBlockState(BlockState state) { -@@ -239,6 +240,7 @@ public abstract class BlockEntity { +@@ -241,6 +242,7 @@ public abstract class BlockEntity implements DebugValueSource { if (this.level != null) { if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers setChanged(this.level, this.worldPosition, this.blockState); @@ -842,7 +842,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1 } } -@@ -271,7 +273,9 @@ public abstract class BlockEntity { +@@ -273,7 +275,9 @@ public abstract class BlockEntity implements DebugValueSource { } public void setRemoved() { @@ -852,7 +852,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1 } public void clearRemoved() { -@@ -311,6 +315,7 @@ public abstract class BlockEntity { +@@ -313,6 +317,7 @@ public abstract class BlockEntity implements DebugValueSource { public void setBlockState(BlockState blockState) { this.validateBlockState(blockState); this.blockState = blockState; @@ -860,7 +860,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1 } protected void applyImplicitComponents(DataComponentGetter componentGetter) { -@@ -424,4 +429,32 @@ public abstract class BlockEntity { +@@ -430,4 +435,32 @@ public abstract class BlockEntity implements DebugValueSource { return this.persistentLore; } // Purpur end - Persistent BlockEntity Lore and DisplayName @@ -894,7 +894,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd43249e965de 100644 +index 8602a42967ebc28821d6156c07e0aad69c12fa9d..da0fe1ad7bf907b31e6ad0c2587543c36607d361 100644 --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java @@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -906,7 +906,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 private static final int INGREDIENT_SLOT = 3; private static final int FUEL_SLOT = 4; private static final int[] SLOTS_FOR_UP = new int[]{3}; -@@ -135,6 +135,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -136,6 +136,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements } public static void serverTick(Level level, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity) { @@ -914,7 +914,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 ItemStack itemStack = blockEntity.items.get(4); if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) { // CraftBukkit start -@@ -152,6 +153,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -153,6 +154,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements itemStack.shrink(1); } // CraftBukkit end @@ -922,7 +922,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 setChanged(level, pos, state); } -@@ -166,7 +168,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -167,7 +169,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements } else if (!isBrewable || !itemStack1.is(blockEntity.ingredient)) { blockEntity.brewTime = 0; } @@ -931,7 +931,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 setChanged(level, pos, state); } else if (isBrewable && blockEntity.fuel > 0) { blockEntity.fuel--; -@@ -179,6 +181,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -180,6 +182,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements blockEntity.brewTime = event.getBrewingTime(); // 400 -> event.getTotalBrewTime() // Paper - use brewing time from event // CraftBukkit end blockEntity.ingredient = itemStack1.getItem(); @@ -939,7 +939,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 setChanged(level, pos, state); } -@@ -285,6 +288,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -286,6 +289,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements } this.fuel = input.getByteOr("Fuel", (byte)0); @@ -947,7 +947,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432 } @Override -@@ -331,4 +335,53 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -332,4 +336,53 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements protected AbstractContainerMenu createMenu(int id, Inventory player) { return new BrewingStandMenu(id, player, this, this.dataAccess); } @@ -1086,19 +1086,19 @@ index fb7932e17d7d00ee3050e71c88510fa23befb1bb..d4f8dc6e37eea8da251e3dfb917607a7 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d744462129 100644 +index c0d4dd95812172a86e5b6f4217bf3cb9d7ee6f2a..151e99d1e9100865fa6f8211a53174a9aa99fea1 100644 --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.properties.ChestType; +@@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.ChestType; import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; -public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity { +public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeEmitter, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity, net.caffeinemc.mods.lithium.api.inventory.LithiumInventory { // DivineMC - lithium: sleeping_block_entity private static final int EVENT_SET_OPEN_COUNT = 1; + public static final Component DEFAULT_NAME = Component.translatable("container.chest"); private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); - public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { -@@ -127,6 +127,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement +@@ -133,6 +133,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement public static void lidAnimateTick(Level level, BlockPos pos, BlockState state, ChestBlockEntity blockEntity) { blockEntity.chestLidController.tickLid(); @@ -1106,7 +1106,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7 } public static void playSound(Level level, BlockPos pos, BlockState state, SoundEvent sound) { -@@ -148,6 +149,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement +@@ -154,6 +155,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement @Override public boolean triggerEvent(int id, int type) { if (id == 1) { @@ -1114,7 +1114,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7 this.chestLidController.shouldBeOpen(type > 0); return true; } else { -@@ -177,6 +179,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement +@@ -189,6 +191,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement @Override protected void setItems(NonNullList items) { this.items = items; @@ -1122,7 +1122,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7 } @Override -@@ -217,4 +220,51 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement +@@ -229,4 +232,51 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement Block block = state.getBlock(); level.blockEvent(pos, block, 1, eventParam); } @@ -1175,19 +1175,19 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -index 969ac280ae563e3412dba406ba68ceaa8a75d519..5c73f153fe62c7280b6d226668eb88fab3e5f7b8 100644 +index 6b05556a84ae6a8f08025439db29db207325bb7a..456f00b44ec58350d2faaa1a36be38ff0107bcfe 100644 --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -22,7 +22,7 @@ import net.minecraft.world.level.storage.ValueInput; +@@ -21,7 +21,7 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; import org.slf4j.Logger; --public class ChiseledBookShelfBlockEntity extends BlockEntity implements Container { -+public class ChiseledBookShelfBlockEntity extends BlockEntity implements Container, net.caffeinemc.mods.lithium.api.inventory.LithiumTransferConditionInventory { // DivineMC - lithium: sleeping_block_entity +-public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBackedContainer { ++public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBackedContainer, net.caffeinemc.mods.lithium.api.inventory.LithiumTransferConditionInventory { // DivineMC - lithium: sleeping_block_entity public static final int MAX_BOOKS_IN_STORAGE = 6; private static final Logger LOGGER = LogUtils.getLogger(); private static final int DEFAULT_LAST_INTERACTED_SLOT = -1; -@@ -195,4 +195,11 @@ public class ChiseledBookShelfBlockEntity extends BlockEntity implements Contain +@@ -170,4 +170,11 @@ public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBac public void removeComponentsFromTag(ValueOutput output) { output.discard("Items"); } @@ -1200,7 +1200,7 @@ index 969ac280ae563e3412dba406ba68ceaa8a75d519..5c73f153fe62c7280b6d226668eb88fa + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed50808e933 100644 +index a631ad830d4820fbf983ef321b40f3192db4527f..861b29a2ffa728d6e19ac715b4467dd974e4363e 100644 --- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java @@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -1212,7 +1212,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5 public static final int CONTAINER_WIDTH = 3; public static final int CONTAINER_HEIGHT = 3; public static final int CONTAINER_SIZE = 9; -@@ -169,6 +169,7 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme +@@ -170,6 +170,7 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme } }); this.containerData.set(9, input.getIntOr("triggered", 0)); @@ -1220,7 +1220,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5 } @Override -@@ -278,10 +279,12 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme +@@ -279,10 +280,12 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme level.setBlock(pos, state.setValue(CrafterBlock.CRAFTING, false), 3); } } @@ -1233,7 +1233,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5 } public int getRedstoneSignal() { -@@ -300,4 +303,43 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme +@@ -301,4 +304,43 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme private boolean slotCanBeDisabled(int slot) { return slot > -1 && slot < 9 && this.items.get(slot).isEmpty(); } @@ -1278,7 +1278,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e538d6467 100644 +index b4a155cc914092dad83977df714fbbc033c69d19..f3cd91636539ebd201f6a22ca5a4f8a8b78d643d 100644 --- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -1288,9 +1288,9 @@ index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e -public class DispenserBlockEntity extends RandomizableContainerBlockEntity { +public class DispenserBlockEntity extends RandomizableContainerBlockEntity implements net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, net.caffeinemc.mods.lithium.api.inventory.LithiumInventory { // DivineMC - lithium: sleeping_block_entity public static final int CONTAINER_SIZE = 9; + private static final Component DEFAULT_NAME = Component.translatable("container.dispenser"); private NonNullList items = NonNullList.withSize(9, ItemStack.EMPTY); - -@@ -134,10 +134,23 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { +@@ -135,10 +135,23 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { @Override protected void setItems(NonNullList items) { this.items = items; @@ -1315,10 +1315,10 @@ index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36a58c7a93 100644 +index e5cbc9f6d7989e993da566f5f9c239a3fe8c7e8b..4ad785f7d1a5c24a26568c628529751e6bb1bc32 100644 --- a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java -@@ -9,7 +9,7 @@ import net.minecraft.world.level.Level; +@@ -10,7 +10,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -1327,7 +1327,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36 private final ChestLidController chestLidController = new ChestLidController(); public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { @Override -@@ -57,11 +57,13 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity +@@ -58,11 +58,13 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity public static void lidAnimateTick(Level level, BlockPos pos, BlockState state, EnderChestBlockEntity blockEntity) { blockEntity.chestLidController.tickLid(); @@ -1341,7 +1341,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36 this.chestLidController.shouldBeOpen(type > 0); return true; } else { -@@ -95,4 +97,35 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity +@@ -97,4 +99,35 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity public float getOpenNess(float partialTicks) { return this.chestLidController.getOpenness(partialTicks); } @@ -1378,7 +1378,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585c9145a73 100644 +index daf4f28d04a1ad1e034c6d7dedba9e4e2272f2ea..3afb0ce74c5378ce909c1a1e6182aaae5fddefb4 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -28,7 +28,7 @@ import net.minecraft.world.level.storage.ValueInput; @@ -1390,7 +1390,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 public static final int MOVE_ITEM_SPEED = 8; public static final int HOPPER_CONTAINER_SIZE = 5; private static final int[][] CACHED_SLOTS = new int[54][]; -@@ -118,6 +118,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -119,6 +119,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override public void setBlockState(BlockState blockState) { @@ -1398,7 +1398,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 super.setBlockState(blockState); this.facing = blockState.getValue(HopperBlock.FACING); } -@@ -136,6 +137,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -137,6 +138,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen boolean result = tryMoveItems(level, pos, state, blockEntity, () -> { return suckInItems(level, blockEntity); }); @@ -1406,7 +1406,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 if (!result && blockEntity.level.spigotConfig.hopperCheck > 1) { blockEntity.setCooldown(blockEntity.level.spigotConfig.hopperCheck); } -@@ -198,6 +200,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -199,6 +201,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (flag) { blockEntity.setCooldown(level.spigotConfig.hopperTransfer); // Spigot setChanged(level, pos, state); @@ -1414,7 +1414,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 return true; } } -@@ -374,6 +377,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -375,6 +378,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private static void applyCooldown(final Hopper hopper) { if (hopper instanceof HopperBlockEntity blockEntity && blockEntity.getLevel() != null) { blockEntity.setCooldown(blockEntity.getLevel().spigotConfig.hopperTransfer); @@ -1422,7 +1422,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 } } -@@ -417,11 +421,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -418,11 +422,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen // Paper end - Perf: Optimize Hoppers private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) { @@ -1443,7 +1443,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 if (isFullContainer(attachedContainer, opposite)) { // DivineMC start - SparklyPaper: Allow throttling hopper checks if the target container is full if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.hopperThrottleWhenFull && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.hopperThrottleSkipTicks > 0) { -@@ -535,10 +547,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -536,10 +548,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean suckInItems(Level level, Hopper hopper) { BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); BlockState blockState = level.getBlockState(blockPos); @@ -1463,7 +1463,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 for (int i : getSlots(sourceContainer, direction)) { if (tryTakeInItemFromSlot(hopper, sourceContainer, i, direction, level)) { // Spigot -@@ -550,7 +570,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -551,7 +571,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } else { boolean flag = hopper.isGridAligned() && blockState.isCollisionShapeFullBlock(level, blockPos) && !blockState.is(BlockTags.DOES_NOT_BLOCK_HOPPERS); if (!flag) { @@ -1472,7 +1472,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 if (addItem(hopper, itemEntity)) { return true; } -@@ -720,7 +740,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -721,7 +741,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen // CraftBukkit start @Nullable private static Container runHopperInventorySearchEvent( @@ -1481,7 +1481,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 org.bukkit.craftbukkit.block.CraftBlock hopper, org.bukkit.craftbukkit.block.CraftBlock searchLocation, org.bukkit.event.inventory.HopperInventorySearchEvent.ContainerType containerType -@@ -848,6 +868,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -849,6 +869,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } public void setCooldown(int cooldownTime) { @@ -1501,7 +1501,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 this.cooldownTime = cooldownTime; } -@@ -867,6 +900,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -868,6 +901,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override protected void setItems(NonNullList items) { this.items = items; @@ -1509,7 +1509,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 } public static void entityInside(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) { -@@ -881,4 +915,749 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -882,4 +916,749 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen protected AbstractContainerMenu createMenu(int id, Inventory player) { return new HopperMenu(id, player, this); } @@ -2260,7 +2260,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585 + } } diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349d1e85bd5 100644 +index e2a2811464ff7455e513944b7565f9f226a5ed34..7458e0257996eb1d68237234de526cfd85020bb9 100644 --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java @@ -32,7 +32,7 @@ import net.minecraft.world.level.storage.ValueOutput; @@ -2272,7 +2272,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349 public static final int COLUMNS = 9; public static final int ROWS = 3; public static final int CONTAINER_SIZE = 27; -@@ -134,6 +134,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -135,6 +135,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl doNeighborUpdates(level, pos, state); } } @@ -2280,7 +2280,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349 } public ShulkerBoxBlockEntity.AnimationStatus getAnimationStatus() { -@@ -174,6 +175,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -175,6 +176,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl @Override public boolean triggerEvent(int id, int type) { @@ -2288,7 +2288,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349 if (id == 1) { this.openCount = type; if (type == 0) { -@@ -265,6 +267,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -266,6 +268,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl @Override protected void setItems(NonNullList items) { this.itemStacks = items; @@ -2296,7 +2296,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349 } @Override -@@ -306,4 +309,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -307,4 +310,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl OPENED, CLOSING; } @@ -2337,10 +2337,10 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349 + // DivineMC end - lithium: sleeping_block_entity } diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41aae6db47f 100644 +index 5f6fbc7eaa5522bd5e0692c9c2d280457a284e71..03d49e37a39ad9d1963d86da3aff88782db6a201 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -85,7 +85,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; +@@ -84,7 +84,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -2349,7 +2349,7 @@ index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41a protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{ Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP }; -@@ -157,6 +157,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -156,6 +156,7 @@ public abstract class BlockBehaviour implements FeatureElement { BlockState neighborState, RandomSource random ) { @@ -2358,21 +2358,21 @@ index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41a } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 9cd2a05683d879f56b6e62dfd49ac30341deeb06..aefe2b36becfe248effd39bbcd91169ee09beb39 100644 +index aa4b184943eb2ce4683ffd65ff7268ae8880d932..120c5284cda3785cb8f4254860b4f88f20fa6828 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -891,12 +891,14 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - (pos, ticker1) -> { +@@ -931,12 +931,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot + (blockPos, rebindableTickingBlockEntityWrapper) -> { TickingBlockEntity tickingBlockEntity = this.createTicker(blockEntity, ticker); - if (ticker1 != null) { -+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(ticker1); // DivineMC - lithium: sleeping_block_entity - ticker1.rebind(tickingBlockEntity); - return (LevelChunk.RebindableTickingBlockEntityWrapper)ticker1; + if (rebindableTickingBlockEntityWrapper != null) { ++ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(rebindableTickingBlockEntityWrapper); // DivineMC - lithium: sleeping_block_entity + rebindableTickingBlockEntityWrapper.rebind(tickingBlockEntity); + return (LevelChunk.RebindableTickingBlockEntityWrapper)rebindableTickingBlockEntityWrapper; } else if (this.isInLevel()) { - LevelChunk.RebindableTickingBlockEntityWrapper rebindableTickingBlockEntityWrapper = new LevelChunk.RebindableTickingBlockEntityWrapper( + LevelChunk.RebindableTickingBlockEntityWrapper rebindableTickingBlockEntityWrapper1 = new LevelChunk.RebindableTickingBlockEntityWrapper( tickingBlockEntity ); + if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(rebindableTickingBlockEntityWrapper); // DivineMC - lithium: sleeping_block_entity - this.level.addBlockEntityTicker(rebindableTickingBlockEntityWrapper); - return rebindableTickingBlockEntityWrapper; + this.level.addBlockEntityTicker(rebindableTickingBlockEntityWrapper1); + return rebindableTickingBlockEntityWrapper1; } else { diff --git a/patches/todo/minecraft-patches/0074-lithium-equipment_tracking.patch b/divinemc-server/minecraft-patches/features/0073-lithium-equipment_tracking.patch similarity index 93% rename from patches/todo/minecraft-patches/0074-lithium-equipment_tracking.patch rename to divinemc-server/minecraft-patches/features/0073-lithium-equipment_tracking.patch index 6da05f1..81ea3b9 100644 --- a/patches/todo/minecraft-patches/0074-lithium-equipment_tracking.patch +++ b/divinemc-server/minecraft-patches/features/0073-lithium-equipment_tracking.patch @@ -16,7 +16,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/world/entity/EntityEquipment.java b/net/minecraft/world/entity/EntityEquipment.java -index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa296cd1c1 100644 +index 1e00a7bd89d885cabb4b9ca3c86fbd8cd93cebf5..4fb31f578c2a4a5dc137c38de8f641597ce80465 100644 --- a/net/minecraft/world/entity/EntityEquipment.java +++ b/net/minecraft/world/entity/EntityEquipment.java @@ -7,7 +7,7 @@ import java.util.Objects; @@ -40,10 +40,10 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa private EntityEquipment(EnumMap items) { this.items = items; -@@ -29,7 +34,13 @@ public class EntityEquipment { +@@ -28,7 +33,13 @@ public class EntityEquipment { + } public ItemStack set(EquipmentSlot slot, ItemStack stack) { - stack.getItem().verifyComponentsAfterLoad(stack); - return Objects.requireNonNullElse(this.items.put(slot, stack), ItemStack.EMPTY); + // DivineMC start - lithium: equipment_tracking + ItemStack oldStack = Objects.requireNonNullElse(this.items.put(slot, stack), ItemStack.EMPTY); @@ -55,7 +55,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa } public ItemStack get(EquipmentSlot slot) { -@@ -56,8 +67,23 @@ public class EntityEquipment { +@@ -55,8 +66,23 @@ public class EntityEquipment { } public void setAll(EntityEquipment equipment) { @@ -79,7 +79,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa } public void dropAll(LivingEntity entity) { -@@ -70,6 +96,7 @@ public class EntityEquipment { +@@ -69,6 +95,7 @@ public class EntityEquipment { public void clear() { this.items.replaceAll((equipmentSlot, itemStack) -> ItemStack.EMPTY); @@ -87,7 +87,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa } // Paper start - EntityDeathEvent -@@ -78,4 +105,98 @@ public class EntityEquipment { +@@ -77,4 +104,98 @@ public class EntityEquipment { return this.items.containsKey(slot); } // Paper end - EntityDeathEvent @@ -187,10 +187,10 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa + // DivineMC end - lithium: equipment_tracking } diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc9706996e8da 100644 +index 86370c9f6e83e5815922080c10336d394075b4e9..85e287bc66c4e2be6f703c3206fe53bba3d15a6d 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -433,9 +433,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -439,9 +439,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.getSleepingPos().ifPresent(this::setPosToBed); } @@ -209,8 +209,8 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970 + // DivineMC end - lithium: equipment_tracking super.baseTick(); - if (this.fireImmune() || this.level().isClientSide) { -@@ -3413,6 +3421,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) { +@@ -3444,6 +3452,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public void detectEquipmentUpdates() { Map map = this.collectEquipmentChanges(); if (map != null) { @@ -218,7 +218,7 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970 this.handleHandSwap(map); if (!map.isEmpty()) { this.handleEquipmentChanges(map); -@@ -3422,6 +3431,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3453,6 +3462,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @Nullable private Map collectEquipmentChanges() { @@ -234,7 +234,7 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970 // Paper start - EntityEquipmentChangedEvent record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange { diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 83fdd22eeb141079e05018ebf5cef70e7eb78726..81f6d57e6bd225998f4c44a78b4aab2166fde1f0 100644 +index 79c652fbbc3ecef289e6358c325d98e509f5c216..434f5a331e0beb582dd8229e697ed1c1eecba8cc 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -528,8 +528,9 @@ public class ArmorStand extends LivingEntity { diff --git a/divinemc-server/minecraft-patches/features/0074-Configurable-Files-Locations.patch b/divinemc-server/minecraft-patches/features/0074-Configurable-Files-Locations.patch new file mode 100644 index 0000000..79b1971 --- /dev/null +++ b/divinemc-server/minecraft-patches/features/0074-Configurable-Files-Locations.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: dan28000 <84990628+dan28000@users.noreply.github.com> +Date: Mon, 6 Oct 2025 14:17:59 +0200 +Subject: [PATCH] Configurable Files Locations + + +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index eab5505b10c1044f864a7327b18f1389fd09765f..c16fabf873f69adee6ba6d6dbf9b07574e82a12d 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -99,10 +99,12 @@ import net.minecraft.world.scores.Team; + import org.slf4j.Logger; + + public abstract class PlayerList { +- public static final File USERBANLIST_FILE = new File("banned-players.json"); +- public static final File IPBANLIST_FILE = new File("banned-ips.json"); +- public static final File OPLIST_FILE = new File("ops.json"); +- public static final File WHITELIST_FILE = new File("whitelist.json"); ++ // DivineMC start - Configurable Files Locations ++ public static File USERBANLIST_FILE = new File("banned-players.json"); ++ public static File IPBANLIST_FILE = new File("banned-ips.json"); ++ public static File OPLIST_FILE = new File("ops.json"); ++ public static File WHITELIST_FILE = new File("whitelist.json"); ++ // DivineMC end - Configurable Files Locations + public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full"); + public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login"); + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -140,10 +142,17 @@ public abstract class PlayerList { + this.server = server; + this.registries = registries; + this.playerIo = playerIo; ++ // DivineMC start - Configurable Files Locations ++ USERBANLIST_FILE = (File) server.options.valueOf("banned-players"); ++ IPBANLIST_FILE = (File) server.options.valueOf("banned-ips"); ++ OPLIST_FILE = (File) server.options.valueOf("ops"); ++ WHITELIST_FILE = (File) server.options.valueOf("whitelist"); ++ + this.whitelist = new UserWhiteList(WHITELIST_FILE, notificationService); + this.ops = new ServerOpList(OPLIST_FILE, notificationService); + this.bans = new UserBanList(USERBANLIST_FILE, notificationService); + this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService); ++ // DivineMC end - Configurable Files Locations + } + + abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor diff --git a/patches/todo/paper-patches/0014-Petal-Multithreaded-Tracker.patch b/divinemc-server/paper-patches/features/0015-Petal-Multithreaded-Tracker.patch similarity index 93% rename from patches/todo/paper-patches/0014-Petal-Multithreaded-Tracker.patch rename to divinemc-server/paper-patches/features/0015-Petal-Multithreaded-Tracker.patch index acacd42..2261cf4 100644 --- a/patches/todo/paper-patches/0014-Petal-Multithreaded-Tracker.patch +++ b/divinemc-server/paper-patches/features/0015-Petal-Multithreaded-Tracker.patch @@ -32,10 +32,10 @@ index d7398b1ecf2660c29fb7d106b48fe02d3736603e..ab499a7eaccdc1578ec64f90f54f79b0 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 8d967f179e7b36517ecc6f29381bf69e57eb7a85..8e376ae6d3a8cadd3e7ac15f8d2c5666694461a0 100644 +index 6b8841a1a84f6316b89b052328bbb549b4acbe21..56aac091b6c126132d75835af340fae40e3a03f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2904,7 +2904,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2825,7 +2825,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa Iterator iterator = collection.iterator(); while (iterator.hasNext()) { AttributeInstance genericInstance = iterator.next(); @@ -45,10 +45,10 @@ index 8d967f179e7b36517ecc6f29381bf69e57eb7a85..8e376ae6d3a8cadd3e7ac15f8d2c5666 break; } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 7725870545b4c87dc5e7536d04c710999ea6932b..afbcad33bd8feb5246f320fafff5c4a2c2e366e4 100644 +index 782cfca296cd0f5cced549d29ce6eb94ec74319c..36be4be04cc63b387680be6233fed00123fe6c9f 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1805,6 +1805,26 @@ public class CraftEventFactory { +@@ -1804,6 +1804,26 @@ public class CraftEventFactory { } public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) { diff --git a/patches/todo/paper-patches/0015-Pufferfish-Optimize-mob-spawning.patch b/divinemc-server/paper-patches/features/0016-Pufferfish-Optimize-mob-spawning.patch similarity index 100% rename from patches/todo/paper-patches/0015-Pufferfish-Optimize-mob-spawning.patch rename to divinemc-server/paper-patches/features/0016-Pufferfish-Optimize-mob-spawning.patch diff --git a/divinemc-server/paper-patches/features/0015-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch b/divinemc-server/paper-patches/features/0017-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch similarity index 100% rename from divinemc-server/paper-patches/features/0015-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch rename to divinemc-server/paper-patches/features/0017-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch diff --git a/patches/todo/paper-patches/0018-Leaves-Protocol-Core.patch b/divinemc-server/paper-patches/features/0018-Leaves-Protocol-Core.patch similarity index 87% rename from patches/todo/paper-patches/0018-Leaves-Protocol-Core.patch rename to divinemc-server/paper-patches/features/0018-Leaves-Protocol-Core.patch index 439443a..98dd7f9 100644 --- a/patches/todo/paper-patches/0018-Leaves-Protocol-Core.patch +++ b/divinemc-server/paper-patches/features/0018-Leaves-Protocol-Core.patch @@ -7,10 +7,10 @@ Original project: https://github.com/LeavesMC/Leaves Original license: GPLv3 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c70526274391debfa694dbd82ed613d99bca37d1..d0d7885a7be04ff25b2e3716587df18ee337ff59 100644 +index 277858c99144c03a1ae34cfd430779d0908aad29..cf9448416116f9488df6bc0ea7caa17d59f9d677 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -511,6 +511,7 @@ public final class CraftServer implements Server { +@@ -499,6 +499,7 @@ public final class CraftServer implements Server { this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark @@ -18,7 +18,7 @@ index c70526274391debfa694dbd82ed613d99bca37d1..d0d7885a7be04ff25b2e3716587df18e } public boolean getCommandBlockOverride(String command) { -@@ -1102,6 +1103,7 @@ public final class CraftServer implements Server { +@@ -1047,6 +1048,7 @@ public final class CraftServer implements Server { org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur - Purpur config files this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); diff --git a/patches/todo/paper-patches/0017-SparklyPaper-Parallel-world-ticking.patch b/divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch similarity index 96% rename from patches/todo/paper-patches/0017-SparklyPaper-Parallel-world-ticking.patch rename to divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch index 45cb47a..5b089de 100644 --- a/patches/todo/paper-patches/0017-SparklyPaper-Parallel-world-ticking.patch +++ b/divinemc-server/paper-patches/features/0019-SparklyPaper-Parallel-world-ticking.patch @@ -248,10 +248,10 @@ index ab499a7eaccdc1578ec64f90f54f79b0da3c0e96..6bcb8069de18e8a0f4ee9d5c71b6bdd1 } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) { // DivineMC start - Multithreaded Tracker diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9c928bf60 100644 +index c1d099a3f8feccf71cad7f617c3f739120b13992..6bac46bfbb30fbc9bf2b174dd4550b49ed07acfc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -471,7 +471,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -462,7 +462,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean unloadChunkRequest(int x, int z) { @@ -266,7 +266,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 if (this.isChunkLoaded(x, z)) { this.world.getChunkSource().removeTicketWithRadius(TicketType.PLUGIN, new ChunkPos(x, z), 1); } -@@ -497,6 +503,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -488,6 +494,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -274,7 +274,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -547,7 +554,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -538,7 +545,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -289,7 +289,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 warnUnsafeChunk("loading a faraway chunk", x, z); // Paper ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper -@@ -775,6 +788,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -751,6 +764,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -297,15 +297,15 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 this.world.captureTreeGeneration = true; this.world.captureBlockStates = true; boolean grownTree = this.generateTree(loc, type); -@@ -890,6 +904,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - } - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer configurator) { - // Paper end - expand explosion API +@@ -852,6 +866,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + private boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer configurator) { + // Paper end - expand explosion API + if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); // DivineMC - Parallel world ticking net.minecraft.world.level.Level.ExplosionInteraction explosionType; if (!breakBlocks) { explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks -@@ -981,6 +996,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -908,6 +923,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -313,7 +313,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); -@@ -1011,6 +1027,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -923,6 +939,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, Holder bb) { BlockPos pos = new BlockPos(x, 0, z); @@ -321,7 +321,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -2319,6 +2336,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1902,6 +1919,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -330,7 +330,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9 } // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index 7a0d37dec5a1af05a4fb78f791a9bd652aaf4806..92487ba35bb0a5584b16ee6c3234aa3430c9ebce 100644 +index 52b3362259ed1ba2ce5379230b2c3b06b0ff6249..1d8c9f94198b558a6b4cdc5d4981b6b4e946903b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -75,6 +75,11 @@ public class CraftBlock implements Block { @@ -569,10 +569,10 @@ index 196835bdf95ba0e149b2977e9ef41698971f501f..b35dbe2b6e75ec89483aef093474c675 net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java -index 7d9f79eec2cb36a88b3b25154a02f2aee7ec1e21..02664f27a81e7836ba7d307d7b45988d329a4437 100644 +index 03418a9d7cca79a6fa682b64f9d901a4af3e1d58..f0af6319089b477c5d63aec521aee4cc69b52f23 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java -@@ -195,14 +195,16 @@ public final class CraftBlockStates { +@@ -196,14 +196,16 @@ public final class CraftBlockStates { BlockPos pos = craftBlock.getPosition(); net.minecraft.world.level.block.state.BlockState state = craftBlock.getNMS(); BlockEntity blockEntity = craftBlock.getHandle().getBlockEntity(pos); @@ -627,7 +627,7 @@ index e4e2e42d0ca25df7fe9f2dd4275610e45fcb2c84..93bf7beab3b00973a19e51d48a9dfb26 // Paper start - name threads according to running plugin final String nameBefore = thread.getName(); diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index dffff76bf6df39dd26892edc2b4988fafab282e7..1a26dac92cb48bf892f7524a58e1031e5f83bcfb 100644 +index 0e5b10153821fda6056791e1c216d05a9ac8e5bc..85699885e6be932758978eec5d2b8ff22944c7c3 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -112,6 +112,23 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre diff --git a/patches/todo/paper-patches/0020-Optimize-Moonrise.patch b/divinemc-server/paper-patches/features/0020-Optimize-Moonrise.patch similarity index 100% rename from patches/todo/paper-patches/0020-Optimize-Moonrise.patch rename to divinemc-server/paper-patches/features/0020-Optimize-Moonrise.patch diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/async/AsyncJoinHandler.java b/divinemc-server/src/main/java/org/bxteam/divinemc/async/AsyncJoinHandler.java deleted file mode 100644 index e7ddee8..0000000 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/async/AsyncJoinHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.bxteam.divinemc.async; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import net.minecraft.server.MinecraftServer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.bxteam.divinemc.config.DivineConfig; -import org.bxteam.divinemc.spark.ThreadDumperRegistry; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.function.Supplier; - -public class AsyncJoinHandler { - private static final String THREAD_PREFIX = "Async Join Thread"; - public static final Logger LOGGER = LogManager.getLogger(AsyncJoinHandler.class.getSimpleName()); - public static ExecutorService JOIN_EXECUTOR; - - private static boolean enabled = false; - - public static void init(boolean enabled, int threadCount) { - AsyncJoinHandler.enabled = enabled; - - if (enabled) { - if (JOIN_EXECUTOR != null) { - JOIN_EXECUTOR.shutdown(); - } - - JOIN_EXECUTOR = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled && - DivineConfig.AsyncCategory.asyncJoinUseVirtualThreads - ? Executors.newVirtualThreadPerTaskExecutor() - : Executors.newFixedThreadPool( - threadCount, - new ThreadFactoryBuilder() - .setNameFormat(THREAD_PREFIX) - .setDaemon(true) - .build() - ); - - ThreadDumperRegistry.REGISTRY.add(THREAD_PREFIX); - - LOGGER.info("Initialized AsyncJoinHandler with {} threads", threadCount); - } - } - - public static void runAsync(Supplier task, java.util.function.Consumer callback) { - if (!enabled || JOIN_EXECUTOR == null) { - T result = task.get(); - callback.accept(result); - return; - } - - CompletableFuture.supplyAsync(task, JOIN_EXECUTOR) - .thenAccept(result -> { - MinecraftServer.getServer().execute(() -> callback.accept(result)); - }) - .exceptionally(ex -> { - LOGGER.error("Error during async join operation", ex); - return null; - }); - } - - public static void runAsync(Runnable asyncTask) { - if (!enabled || JOIN_EXECUTOR == null) { - asyncTask.run(); - return; - } - - CompletableFuture.runAsync(asyncTask, JOIN_EXECUTOR) - .thenRun(() -> MinecraftServer.getServer().execute(asyncTask)) - .exceptionally(ex -> { - LOGGER.error("Error during async join operation", ex); - return null; - }); - } - - public static Executor getExecutor() { - return enabled && JOIN_EXECUTOR != null ? JOIN_EXECUTOR : Runnable::run; - } -} diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/async/ExecutorShutdown.java b/divinemc-server/src/main/java/org/bxteam/divinemc/async/ExecutorShutdown.java index 5586e16..ef38608 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/async/ExecutorShutdown.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/async/ExecutorShutdown.java @@ -58,14 +58,5 @@ public class ExecutorShutdown { AsyncPathProcessor.PATH_PROCESSING_EXECUTOR.awaitTermination(10L, TimeUnit.SECONDS); } catch (InterruptedException ignored) { } } - - if (AsyncJoinHandler.JOIN_EXECUTOR != null) { - LOGGER.info("Shutting down async join executor..."); - AsyncJoinHandler.JOIN_EXECUTOR.shutdown(); - - try { - AsyncJoinHandler.JOIN_EXECUTOR.awaitTermination(10L, TimeUnit.SECONDS); - } catch (InterruptedException ignored) { } - } } } diff --git a/patches/todo/minecraft-patches/0075-Configurable-Files-Locations.patch b/patches/todo/minecraft-patches/0075-Configurable-Files-Locations.patch deleted file mode 100644 index 8e5cf49..0000000 --- a/patches/todo/minecraft-patches/0075-Configurable-Files-Locations.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: dan28000 <84990628+dan28000@users.noreply.github.com> -Date: Mon, 6 Oct 2025 14:17:59 +0200 -Subject: [PATCH] Configurable-Files-Locations - - -diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index a0d45f72e7c35883996214a2c5420d6a996a58aa..2c6aa5bac80e6383f935e368eb1aa69ca4b46d70 100644 ---- a/net/minecraft/server/players/PlayerList.java -+++ b/net/minecraft/server/players/PlayerList.java -@@ -101,10 +101,12 @@ import net.minecraft.world.scores.Team; - import org.slf4j.Logger; - - public abstract class PlayerList { -- public static final File USERBANLIST_FILE = new File("banned-players.json"); -- public static final File IPBANLIST_FILE = new File("banned-ips.json"); -- public static final File OPLIST_FILE = new File("ops.json"); -- public static final File WHITELIST_FILE = new File("whitelist.json"); -+ // DivineMC - make configurable location of files start -+ public static File USERBANLIST_FILE = new File("banned-players.json"); -+ public static File IPBANLIST_FILE = new File("banned-ips.json"); -+ public static File OPLIST_FILE = new File("ops.json"); -+ public static File WHITELIST_FILE = new File("whitelist.json"); -+ // DivineMC - make configurable location of files end - public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full"); - public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login"); - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -113,10 +115,12 @@ public abstract class PlayerList { - private final MinecraftServer server; - public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety - private final Map playersByUUID = Maps.newHashMap(); -- private final UserBanList bans = new UserBanList(USERBANLIST_FILE); -- private final IpBanList ipBans = new IpBanList(IPBANLIST_FILE); -- private final ServerOpList ops = new ServerOpList(OPLIST_FILE); -- private final UserWhiteList whitelist = new UserWhiteList(WHITELIST_FILE); -+ // DivineMC - make configurable location of files start -+ private final UserBanList bans; -+ private final IpBanList ipBans; -+ private final ServerOpList ops; -+ private final UserWhiteList whitelist; -+ // DivineMC - make configurable location of files end - // CraftBukkit start - // private final Map stats = Maps.newHashMap(); - // private final Map advancements = Maps.newHashMap(); -@@ -144,6 +148,17 @@ public abstract class PlayerList { - this.registries = registries; - this.maxPlayers = maxPlayers; - this.playerIo = playerIo; -+ // DivineMC - make configurable location of files start -+ USERBANLIST_FILE = (File) server.options.valueOf("banned-players"); -+ IPBANLIST_FILE = (File) server.options.valueOf("banned-ips"); -+ OPLIST_FILE = (File) server.options.valueOf("ops"); -+ WHITELIST_FILE = (File) server.options.valueOf("whitelist"); -+ -+ bans = new UserBanList(USERBANLIST_FILE); -+ ipBans = new IpBanList(IPBANLIST_FILE); -+ ops = new ServerOpList(OPLIST_FILE); -+ whitelist = new UserWhiteList(WHITELIST_FILE); -+ // DivineMC - make configurable location of files end - } - - abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor