From db8e9122cb2330cb75850492faf90c341241cf64 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Fri, 19 Jan 2024 20:45:37 +0900 Subject: [PATCH] it builds!!! --- .github/workflows/release.yml | 2 +- ...15-Completely-remove-Mojang-Profiler.patch | 501 ++++++++++++++++++ .../0017-Reduce-create-random-instance.patch | 4 +- .../0023-Implement-No-Chat-Reports.patch | 22 +- patches/server/0034-Reduce-allocations.patch | 32 +- .../0038-Async-PathProcessing.patch | 0 6 files changed, 551 insertions(+), 10 deletions(-) rename patches/{server => unapplied}/0038-Async-PathProcessing.patch (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3494e73..09b52f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,7 +53,7 @@ jobs: run: ./gradlew applyPatches --stacktrace - name: Build - run: ./gradlew build --no-rebuild --stacktrace + run: ./gradlew build --stacktrace - name: Create Reobf Jar run: ./gradlew createReobfPaperclipJar --no-rebuild --stacktrace diff --git a/patches/server/0015-Completely-remove-Mojang-Profiler.patch b/patches/server/0015-Completely-remove-Mojang-Profiler.patch index 32f6919..d914b83 100644 --- a/patches/server/0015-Completely-remove-Mojang-Profiler.patch +++ b/patches/server/0015-Completely-remove-Mojang-Profiler.patch @@ -4,6 +4,66 @@ Date: Wed, 27 Sep 2023 17:52:52 +0900 Subject: [PATCH] Completely remove Mojang Profiler +diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java +index 35563a94879fe77f98d43d97cc6ba57b24906c23..1ecbd34e4066dd33047d2a0d081eb257e3409222 100644 +--- a/src/main/java/net/minecraft/commands/Commands.java ++++ b/src/main/java/net/minecraft/commands/Commands.java +@@ -435,7 +435,7 @@ public class Commands { + int j = minecraftserver.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT); + + try { +- ExecutionContext executioncontext1 = new ExecutionContext<>(i, j, minecraftserver.getProfiler()); ++ ExecutionContext executioncontext1 = new ExecutionContext<>(i, j/*, minecraftserver.getProfiler()*/); // Plazma - Completely remove profiler + + try { + Commands.CURRENT_EXECUTION_CONTEXT.set(executioncontext1); +diff --git a/src/main/java/net/minecraft/commands/execution/ExecutionContext.java b/src/main/java/net/minecraft/commands/execution/ExecutionContext.java +index 38854a047c6da7e2551f206478d17628e765168d..2f72549549d4d79251baaf1339dbb482703ab2c9 100644 +--- a/src/main/java/net/minecraft/commands/execution/ExecutionContext.java ++++ b/src/main/java/net/minecraft/commands/execution/ExecutionContext.java +@@ -12,7 +12,7 @@ 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 net.minecraft.util.profiling.ProfilerFiller; // Plazma - Completely remove profiler + import org.slf4j.Logger; + + public class ExecutionContext implements AutoCloseable { +@@ -20,7 +20,7 @@ public class ExecutionContext implements AutoCloseable { + private static final Logger LOGGER = LogUtils.getLogger(); + private final int commandLimit; + private final int forkLimit; +- private final ProfilerFiller profiler; ++ //private final ProfilerFiller profiler; // Plazma - Completely remove profiler + @Nullable + private TraceCallbacks tracer; + private int commandQuota; +@@ -29,10 +29,10 @@ public class ExecutionContext implements AutoCloseable { + private final List> newTopCommands = new ObjectArrayList<>(); + private int currentFrameDepth; + +- public ExecutionContext(int maxCommandChainLength, int maxCommandForkCount, ProfilerFiller profiler) { ++ public ExecutionContext(int maxCommandChainLength, int maxCommandForkCount/*, ProfilerFiller profiler*/) { // Plazma - Completely remove profiler + this.commandLimit = maxCommandChainLength; + this.forkLimit = maxCommandForkCount; +- this.profiler = profiler; ++ //this.profiler = profiler; // Plazma - Completely remove profiler + this.commandQuota = maxCommandChainLength; + } + +@@ -127,9 +127,11 @@ public class ExecutionContext implements AutoCloseable { + return this.tracer; + } + ++ /* // Plazma - Completely remove profiler + public ProfilerFiller profiler() { + return this.profiler; + } ++ */ // Plazma - Completely remove profiler + + public int forkLimit() { + return this.forkLimit; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index b0c8943b3ad6c2d29b46ce387d349f91acc899f1..6b98e5140e946b4d728c281417cc37dc60413ba1 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java @@ -529,6 +589,47 @@ index c6c30d99399c5cde2b0ec2f320d81d952b422d78..00000000000000000000000000000000 - } - } -} +diff --git a/src/main/java/net/minecraft/util/profiling/ContinuousProfiler.java b/src/main/java/net/minecraft/util/profiling/ContinuousProfiler.java +deleted file mode 100644 +index 4424bca7effa4fef26453afcd06d86e6a30d7b8f..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/ContinuousProfiler.java ++++ /dev/null +@@ -1,35 +0,0 @@ +-package net.minecraft.util.profiling; +- +-import java.util.function.IntSupplier; +-import java.util.function.LongSupplier; +- +-public class ContinuousProfiler { +- private final LongSupplier realTime; +- private final IntSupplier tickCount; +- private ProfileCollector profiler = InactiveProfiler.INSTANCE; +- +- public ContinuousProfiler(LongSupplier timeGetter, IntSupplier tickGetter) { +- this.realTime = timeGetter; +- this.tickCount = tickGetter; +- } +- +- 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, true); +- } +- +- public ProfilerFiller getFiller() { +- return this.profiler; +- } +- +- public ProfileResults getResults() { +- return this.profiler.getResults(); +- } +-} diff --git a/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java b/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java deleted file mode 100644 index 863343a87fe34d72f04af89d75268b477b2adc7a..0000000000000000000000000000000000000000 @@ -651,6 +752,406 @@ index 863343a87fe34d72f04af89d75268b477b2adc7a..00000000000000000000000000000000 - } - } -} +diff --git a/src/main/java/net/minecraft/util/profiling/SingleTickProfiler.java b/src/main/java/net/minecraft/util/profiling/SingleTickProfiler.java +deleted file mode 100644 +index 38c9b686212c0f78eb702b1897d491e450267ca7..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/SingleTickProfiler.java ++++ /dev/null +@@ -1,53 +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.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 timeGetter, String filename, long overtime) { +- this.realTime = timeGetter; +- this.location = new File("debug", filename); +- this.saveThreshold = overtime; +- } +- +- public ProfilerFiller startTick() { +- this.profiler = new ActiveProfiler(this.realTime, () -> { +- return this.tick; +- }, false); +- ++this.tick; +- return this.profiler; +- } +- +- public void endTick() { +- if (this.profiler != InactiveProfiler.INSTANCE) { +- ProfileResults profileResults = this.profiler.getResults(); +- this.profiler = InactiveProfiler.INSTANCE; +- if (profileResults.getNanoDuration() >= this.saveThreshold) { +- File file = new File(this.location, "tick-results-" + Util.getFilenameFormattedDateTime() + ".txt"); +- profileResults.saveResults(file.toPath()); +- LOGGER.info("Recorded long tick -- wrote info to: {}", (Object)file.getAbsolutePath()); +- } +- +- } +- } +- +- @Nullable +- public static SingleTickProfiler createTickProfiler(String name) { +- return null; +- } +- +- public static ProfilerFiller decorateFiller(ProfilerFiller profiler, @Nullable SingleTickProfiler monitor) { +- return monitor != null ? ProfilerFiller.tee(monitor.startTick(), profiler) : profiler; +- } +-} +diff --git a/src/main/java/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java +deleted file mode 100644 +index 157e6562bc2fa0946ea6be825cd740d067b4e84f..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java ++++ /dev/null +@@ -1,164 +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 samplerSource, LongSupplier timeGetter, Executor dumpExecutor, MetricsPersister dumper, Consumer resultConsumer, Consumer dumpConsumer) { +- this.metricsSamplerProvider = samplerSource; +- this.wallTimeSource = timeGetter; +- this.taskProfiler = new ContinuousProfiler(timeGetter, () -> { +- return this.currentTick; +- }); +- this.ioExecutor = dumpExecutor; +- this.metricsPersister = dumper; +- this.onProfilingEnd = resultConsumer; +- this.onReportFinished = globalOnReportFinished == null ? dumpConsumer : dumpConsumer.andThen(globalOnReportFinished); +- this.deadlineNano = timeGetter.getAsLong() + TimeUnit.NANOSECONDS.convert(10L, TimeUnit.SECONDS); +- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> { +- return this.currentTick; +- }, false); +- this.taskProfiler.enable(); +- } +- +- public static ActiveMetricsRecorder createStarted(MetricsSamplerProvider source, LongSupplier timeGetter, Executor dumpExecutor, MetricsPersister dumper, Consumer resultConsumer, Consumer dumpConsumer) { +- return new ActiveMetricsRecorder(source, timeGetter, dumpExecutor, dumper, resultConsumer, dumpConsumer); +- } +- +- @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(() -> { +- return 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, (s) -> { +- return Lists.newArrayList(); +- }).add(recordedDeviation); +- } +- } +- +- if (!this.killSwitch && this.wallTimeSource.getAsLong() <= this.deadlineNano) { +- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> { +- return this.currentTick; +- }, false); +- } else { +- this.killSwitch = false; +- ProfileResults profileResults = this.taskProfiler.getResults(); +- this.singleTickProfiler = InactiveProfiler.INSTANCE; +- this.onProfilingEnd.accept(profileResults); +- this.scheduleSaveResults(profileResults); +- } +- } +- } +- +- @Override +- public boolean isRecording() { +- return this.taskProfiler.isEnabled(); +- } +- +- @Override +- public ProfilerFiller getProfiler() { +- return ProfilerFiller.tee(this.taskProfiler.getFiller(), this.singleTickProfiler); +- } +- +- private void verifyStarted() { +- if (!this.isRecording()) { +- throw new IllegalStateException("Not started!"); +- } +- } +- +- private void scheduleSaveResults(ProfileResults result) { +- HashSet hashSet = new HashSet<>(this.thisTickSamplers); +- this.ioExecutor.execute(() -> { +- Path path = this.metricsPersister.saveReports(hashSet, this.deviationsBySampler, result); +- this.cleanup(hashSet); +- 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 consumer) { +- globalOnReportFinished = consumer; +- } +-} +diff --git a/src/main/java/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java +deleted file mode 100644 +index 12d7b7c86115b667bd8f940206985d9ed4b837d4..0000000000000000000000000000000000000000 +--- a/src/main/java/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/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java +deleted file mode 100644 +index 48e7211e01691a677c52cf1f5982b0c179eaf83b..0000000000000000000000000000000000000000 +--- a/src/main/java/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/src/main/java/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java b/src/main/java/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java +deleted file mode 100644 +index 42fc60456bc651345c5f6e13b975c7874532231e..0000000000000000000000000000000000000000 +--- a/src/main/java/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java ++++ /dev/null +@@ -1,102 +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.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.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 nanoTimeSupplier, boolean includeSystem) { +- this.samplers.add(tickTimeSampler(nanoTimeSupplier)); +- if (includeSystem) { +- this.samplers.addAll(runtimeIndependentSamplers()); +- } +- +- } +- +- public static Set runtimeIndependentSamplers() { +- ImmutableSet.Builder builder = ImmutableSet.builder(); +- +- try { +- ServerMetricsSamplersProvider.CpuStats cpuStats = new ServerMetricsSamplersProvider.CpuStats(); +- IntStream.range(0, cpuStats.nrOfCpus).mapToObj((index) -> { +- return MetricSampler.create("cpu#" + index, MetricCategory.CPU, () -> { +- return cpuStats.loadForCpu(index); +- }); +- }).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, () -> { +- return (double)((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576.0F); +- })); +- builder.addAll(MetricsRegistry.INSTANCE.getRegisteredSamplers()); +- return builder.build(); +- } +- +- @Override +- public Set samplers(Supplier profilerSupplier) { +- this.samplers.addAll(this.samplerFactory.newSamplersFoundInProfiler(profilerSupplier)); +- return this.samplers; +- } +- +- public static MetricSampler tickTimeSampler(final LongSupplier nanoTimeSupplier) { +- Stopwatch stopwatch = Stopwatch.createUnstarted(new Ticker() { +- @Override +- public long read() { +- return nanoTimeSupplier.getAsLong(); +- } +- }); +- ToDoubleFunction toDoubleFunction = (watch) -> { +- if (watch.isRunning()) { +- watch.stop(); +- } +- +- long l = watch.elapsed(TimeUnit.NANOSECONDS); +- watch.reset(); +- return (double)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.0D; +- } +- } +-} diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java index 4c0d710d20e074ad4a0fdd1cd4c0c3d3383b68a5..2d5568ac864a7f557bc5a21ad796206c25caf028 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/patches/server/0017-Reduce-create-random-instance.patch b/patches/server/0017-Reduce-create-random-instance.patch index 37aaab6..9afe264 100644 --- a/patches/server/0017-Reduce-create-random-instance.patch +++ b/patches/server/0017-Reduce-create-random-instance.patch @@ -78,7 +78,7 @@ index 1ef089dbf83de35d875c00efdf468c397be56978..832c3fa9f6f6706c48d5744e15d3c748 } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java -index 731ef21dbbd25d6924717de42f4569a9b5935643..22c1698a4728e5d9bf9576f9f5db07b68cd33f89 100644 +index 731ef21dbbd25d6924717de42f4569a9b5935643..54b0ecc7c88c0ec7bbb4862f31f80a706e5ab46a 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java @@ -15,7 +15,7 @@ import net.minecraft.util.RandomSource; @@ -86,7 +86,7 @@ index 731ef21dbbd25d6924717de42f4569a9b5935643..22c1698a4728e5d9bf9576f9f5db07b6 public class ShufflingList implements Iterable { protected final List> entries; - private final RandomSource random = RandomSource.create(); -+ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.getServer().random() : RandomSource.create(); // Plazma ++ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceRandom ? net.minecraft.server.MinecraftServer.getServer().random() : RandomSource.create(); // Plazma - Reduce create random instance private final boolean isUnsafe; // Paper public ShufflingList() { diff --git a/patches/server/0023-Implement-No-Chat-Reports.patch b/patches/server/0023-Implement-No-Chat-Reports.patch index 3bf31d5..a6c4445 100644 --- a/patches/server/0023-Implement-No-Chat-Reports.patch +++ b/patches/server/0023-Implement-No-Chat-Reports.patch @@ -94,17 +94,33 @@ index 5c897d11e6ae17d8feaeedc7edf7ede02571a207..05dd190de9d45e245eb9f67ccec6b5c2 // Paper start - Add setting for proxy online mode status diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index da499e0b21eba40d24d95047e3a9220567d4bae7..96d406c79e501971b5b4086abdeb6fdd70d8e1f7 100644 +index da499e0b21eba40d24d95047e3a9220567d4bae7..ef706612c7dd4ab703e442a488264244008b6227 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -275,6 +275,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -271,10 +271,29 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } + + public void send(Packet packet) { ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().noChatReports.convertToSystemMessage() ++ && this instanceof ServerGamePacketListenerImpl impl ++ && packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket p) { ++ impl.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket( ++ p.chatType().resolve(impl.player.level().registryAccess()) ++ .orElseThrow().decorate(p.unsignedContent() != null ? p.unsignedContent() : Component.literal(p.body().content())), ++ false ++ )); ++ return; ++ } + this.send(packet, (PacketSendListener) null); } public void send(Packet packet, @Nullable PacketSendListener callbacks) { + // Plazma start - Implement No Chat Reports + if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().noChatReports.convertToSystemMessage() ++ && callbacks != null ++ && this instanceof ServerGamePacketListenerImpl impl + && packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket p) { -+ this.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(null, Component.Serializer.toJson(p.chatType().resolve(this.player.level().registryAccess()).get().decorate(p.unsignedContent() != null ? p.unsignedContent() : Component.literal(p.body().content()))), false), null); ++ impl.send(p); + return; + } + // Plazma end diff --git a/patches/server/0034-Reduce-allocations.patch b/patches/server/0034-Reduce-allocations.patch index 2b941f5..918d48d 100644 --- a/patches/server/0034-Reduce-allocations.patch +++ b/patches/server/0034-Reduce-allocations.patch @@ -310,6 +310,19 @@ index 3604e22f593275140d706c296355ee06ca8ec888..6974ca1efbef05c845dc41e643bfed6d } @Override +diff --git a/src/main/java/net/minecraft/nbt/NbtIo.java b/src/main/java/net/minecraft/nbt/NbtIo.java +index c2044d2e8ce2d4747aa73ba90e5b975b1b7d2c19..b4e043379ece86ce39eacd4c1eb9114a2b6727ca 100644 +--- a/src/main/java/net/minecraft/nbt/NbtIo.java ++++ b/src/main/java/net/minecraft/nbt/NbtIo.java +@@ -249,7 +249,7 @@ public class NbtIo { + + @Nullable + public static CompoundTag read(Path path) throws IOException { +- if (!Files.exists(path, new LinkOption[0])) { ++ if (!Files.exists(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations + return null; + } else { + InputStream inputstream = Files.newInputStream(path); diff --git a/src/main/java/net/minecraft/network/CipherBase.java b/src/main/java/net/minecraft/network/CipherBase.java index a2920b8a9eff77d9c5d1d7f70ad3abdacba8f0fa..70d776d5cfdb0612f65d92333d6f872afedc2207 100644 --- a/src/main/java/net/minecraft/network/CipherBase.java @@ -361,7 +374,7 @@ index d3a80d0a23be762c05931ae8001d98e43cab2b4a..a94feef330b1836a2fc009405c529455 static MutableComponent translatableWithFallback(String key, @Nullable String fallback, Object... args) { diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -index d45e39bc009281c298f3dfae113dc87f2b3b1fbd..1a33c6bb361b9bb0e4e98b74e85fc966931bb334 100644 +index d45e39bc009281c298f3dfae113dc87f2b3b1fbd..d9deb14896c62c35ccc5758df1419e5307702a2d 100644 --- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java @@ -28,7 +28,7 @@ import net.minecraft.util.ExtraCodecs; @@ -373,6 +386,17 @@ index d45e39bc009281c298f3dfae113dc87f2b3b1fbd..1a33c6bb361b9bb0e4e98b74e85fc966 private static final Codec PRIMITIVE_ARG_CODEC = ExtraCodecs.validate(ExtraCodecs.JAVA, TranslatableContents::filterAllowedArguments); private static final Codec ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC).xmap((either) -> { return either.map((object) -> { +@@ -83,8 +83,8 @@ public class TranslatableContents implements ComponentContents { + + private static Object[] adjustArgs(Optional> args) { + return args.map((list) -> { +- return list.isEmpty() ? NO_ARGS : list.toArray(); +- }).orElse(NO_ARGS); ++ return list.isEmpty() ? org.plazmamc.plazma.constants.Empty.OBJECT : list.toArray(); ++ }).orElse(org.plazmamc.plazma.constants.Empty.OBJECT); + } + + private static TranslatableContents create(String key, Optional fallback, Optional> args) { diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java index e3f355c85eb7cc8c1683e3009502c10a5ed32daa..838f07692c8e34c21c5a93611ab0f01b5059ab5e 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java @@ -900,7 +924,7 @@ index c68736b023127c7b395835f4fa82d9062110697b..71ca67be643254b49afa963068b5813c @Override diff --git a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -index 399da9d43aefbb95897df4697860d5bce5317152..6a6a562a147d3c6e945dcedbd70df966b63c5088 100644 +index 399da9d43aefbb95897df4697860d5bce5317152..df7816c1c5f069d89a22dbd876a2d663ba68949f 100644 --- a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java @@ -110,7 +110,7 @@ public class LevelStorageSource { @@ -953,7 +977,7 @@ index 399da9d43aefbb95897df4697860d5bce5317152..6a6a562a147d3c6e945dcedbd70df966 public boolean levelExists(String name) { try { - return Files.isDirectory(this.getLevelPath(name), new LinkOption[0]); -+ return Files.isDirectory(this.getLevelPath(name)/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations ++ return Files.isDirectory(this.getLevelPath(name)/*, new LinkOption[0]*/); // Plazma - Reduce allocations } catch (InvalidPathException invalidpathexception) { return false; } @@ -962,7 +986,7 @@ index 399da9d43aefbb95897df4697860d5bce5317152..6a6a562a147d3c6e945dcedbd70df966 public boolean hasWorldData() { - return Files.exists(this.levelDirectory.dataFile(), new LinkOption[0]) || Files.exists(this.levelDirectory.oldDataFile(), new LinkOption[0]); -+ return Files.exists(this.levelDirectory.dataFile()/*, new LinkOption[0])*/ || Files.exists(this.levelDirectory.oldDataFile()/*, new LinkOption[0]*/); // Plazma - Reduce allocations ++ return Files.exists(this.levelDirectory.dataFile()/*, new LinkOption[0]*/) || Files.exists(this.levelDirectory.oldDataFile()/*, new LinkOption[0]*/); // Plazma - Reduce allocations } public void close() throws IOException { diff --git a/patches/server/0038-Async-PathProcessing.patch b/patches/unapplied/0038-Async-PathProcessing.patch similarity index 100% rename from patches/server/0038-Async-PathProcessing.patch rename to patches/unapplied/0038-Async-PathProcessing.patch