More works

This commit is contained in:
nostalgic853
2022-11-18 23:42:32 +08:00
parent 269817cf9a
commit fef567e45d
25 changed files with 79 additions and 151 deletions

View File

@@ -1,206 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Simon Gardling <titaniumtown@gmail.com>
Date: Thu, 8 Jul 2021 15:03:15 -0400
Subject: [PATCH] JettPack patches
Use LinkedBlockingDeque in IAsyncTaskHandler
Original license: GPLv3
Original project: https://gitlab.com/Titaniumtown/JettPack
Use MCUtil.asyncExecutor for MAIN_WORKER_EXECUTOR in SystemUtils
Original code by Titaniumtown, licensed under GNU General Public License v3.0
You can find the original code on https://gitlab.com/Titaniumtown/JettPack
diff --git a/src/main/java/me/titaniumtown/ServerWorkerWrapper.java b/src/main/java/me/titaniumtown/ServerWorkerWrapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..7bd88761137b2a68c04fbaa920a9ea9ce1f9e873
--- /dev/null
+++ b/src/main/java/me/titaniumtown/ServerWorkerWrapper.java
@@ -0,0 +1,24 @@
+package me.titaniumtown;
+
+import com.google.common.base.Preconditions;
+import net.minecraft.Util;
+
+public final class ServerWorkerWrapper implements Runnable {
+ private final Runnable internalRunnable;
+
+ public ServerWorkerWrapper(Runnable runnable) {
+ this.internalRunnable = Preconditions.checkNotNull(runnable, "internalRunnable");
+ }
+
+ @Override
+ public final void run() {
+ try {
+ this.internalRunnable.run();
+ return;
+ }
+ catch (Throwable throwable) {
+ Util.onThreadException(Thread.currentThread(), throwable);
+ return;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 6b7943e8348b0a41ca69fb56ccfd5f1c1484eb07..b2860114d52c52360e1e559d0c2c5ee4789dee97 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -73,6 +73,12 @@ import net.minecraft.util.TimeSource;
import net.minecraft.util.datafix.DataFixers;
import net.minecraft.world.level.block.state.properties.Property;
import org.slf4j.Logger;
+// JettPack start
+import java.util.concurrent.AbstractExecutorService;
+import me.titaniumtown.ServerWorkerWrapper;
+import io.papermc.paper.util.MCUtil;
+import java.util.Collections;
+// JettPack end
public class Util {
static final Logger LOGGER = LogUtils.getLogger();
@@ -165,7 +171,47 @@ public class Util {
if (i <= 0) {
executorService = MoreExecutors.newDirectExecutorService();
} else {
- executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
+
+ //executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new net.minecraft.server.ServerWorkerThread(target, s, priorityModifier)); // JettPack
+ // JettPack start
+ executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new AbstractExecutorService(){
+ private volatile boolean shutdown = false;
+
+ @Override
+ public final List<Runnable> shutdownNow() {
+ this.shutdown = true;
+ return Collections.emptyList();
+ }
+
+ @Override
+ public final void shutdown() {
+ this.shutdown = true;
+ }
+
+ @Override
+ public final boolean isShutdown() {
+ return this.shutdown;
+ }
+
+ @Override
+ public final boolean isTerminated() {
+ return this.shutdown;
+ }
+
+ @Override
+ public final boolean awaitTermination(long l2, TimeUnit timeUnit) throws InterruptedException {
+ if (!this.shutdown) {
+ throw new UnsupportedOperationException();
+ }
+ return true;
+ }
+
+ @Override
+ public final void execute(Runnable runnable) {
+ MCUtil.asyncExecutor.execute(new ServerWorkerWrapper(runnable));
+ }
+ };
+ // JettPack end
}
/*
@Override
diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java
index 7a4ade1a4190bf4fbb048919ae2be230f7b80fff..5edd42d22c320e126ef377f7a9ce6fee97b2c19f 100644
--- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java
+++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java
@@ -1,13 +1,13 @@
package net.minecraft.util.thread;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Queues;
+//import com.google.common.collect.Queues; // JettPack
import com.mojang.logging.LogUtils;
import java.util.List;
-import java.util.Queue;
+//import java.util.Queue; // JettPack
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
-import java.util.concurrent.locks.LockSupport;
+//import java.util.concurrent.locks.LockSupport; // JettPack
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
import net.minecraft.util.profiling.metrics.MetricCategory;
@@ -15,12 +15,15 @@ import net.minecraft.util.profiling.metrics.MetricSampler;
import net.minecraft.util.profiling.metrics.MetricsRegistry;
import net.minecraft.util.profiling.metrics.ProfilerMeasured;
import org.slf4j.Logger;
+import java.util.concurrent.LinkedBlockingDeque; // JettPack
+import java.util.concurrent.TimeUnit; // JettPack
public abstract class BlockableEventLoop<R extends Runnable> implements ProfilerMeasured, ProcessorHandle<R>, Executor {
private final String name;
private static final Logger LOGGER = LogUtils.getLogger();
- private final Queue<R> pendingRunnables = Queues.newConcurrentLinkedQueue();
+ private final LinkedBlockingDeque<R> pendingRunnables = new LinkedBlockingDeque(); // JettPack
private int blockingCount;
+ private R next = null; // JettPack
protected BlockableEventLoop(String name) {
this.name = name;
@@ -89,7 +92,7 @@ public abstract class BlockableEventLoop<R extends Runnable> implements Profiler
@Override
public void tell(R runnable) {
this.pendingRunnables.add(runnable);
- LockSupport.unpark(this.getRunningThread());
+ //LockSupport.unpark(this.getRunningThread()); // JettPack
}
@Override
@@ -117,15 +120,20 @@ public abstract class BlockableEventLoop<R extends Runnable> implements Profiler
}
public boolean pollTask() {
- R runnable = this.pendingRunnables.peek();
- if (runnable == null) {
- return false;
- } else if (this.blockingCount == 0 && !this.shouldRun(runnable)) {
+ // JettPack start
+ if (this.next == null && !this.pendingRunnables.isEmpty()) {
+ this.waitForTasks();
+ }
+
+ if (this.next == null) {
return false;
} else {
- this.doRunTask(this.pendingRunnables.remove());
+ R r2 = this.next;
+ this.next = null;
+ this.doRunTask(r2);
return true;
}
+ // JettPack end
}
public void managedBlock(BooleanSupplier stopCondition) {
@@ -144,8 +152,18 @@ public abstract class BlockableEventLoop<R extends Runnable> implements Profiler
}
protected void waitForTasks() {
- Thread.yield();
- LockSupport.parkNanos("waiting for tasks", 100000L);
+ // JettPack start
+ if (this.next != null) {
+ throw new IllegalStateException("next != null");
+ }
+ try {
+ this.next = this.pendingRunnables.poll(100L, TimeUnit.MICROSECONDS);
+ return;
+ }
+ catch (InterruptedException interruptedException) {
+ return;
+ }
+ // JettPack end
}
protected void doRunTask(R task) {

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 5668e6fa7f560199c352dbed629dbc6897d468a7..5a17c5df95390120bdd36c86dcd14a334f3a7030 100644
index 1b7e38538881ba00ffdbe9226952627151532c5c..119e26e32654c834ff1158836ce56ba8985c09e8 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -315,19 +315,21 @@ public abstract class Player extends LivingEntity {

View File

@@ -1,586 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: etil2jz <81570777+etil2jz@users.noreply.github.com>
Date: Wed, 29 Jun 2022 02:49:45 +0200
Subject: [PATCH] CarpetFixes optimizations
Faster Sheep.getOffspringColor
Original license: MIT
Original project: https://github.com/fxmorin/carpet-fixes
Copyright (c) 2020 Fx Morin
Optimize `Math.round` and `Math.hypot` functions
Original license: MIT
Original project: https://github.com/fxmorin/carpet-fixes
Copyright (c) 2020 Fx Morin
diff --git a/src/main/java/carpetfixes/helpers/FastMath.java b/src/main/java/carpetfixes/helpers/FastMath.java
new file mode 100644
index 0000000000000000000000000000000000000000..1563b21eac06ba0cc57336a639a2d83accb511c9
--- /dev/null
+++ b/src/main/java/carpetfixes/helpers/FastMath.java
@@ -0,0 +1,57 @@
+package carpetfixes.helpers;
+
+public class FastMath {
+
+ private static final double HYPOT_MAX_MAG = 2^511;
+ private static final double HYPOT_FACTOR = 2^750;
+
+ /**
+ * @author FX - PR0CESS
+ * ~1.25x faster than {@link Math#round(float)}
+ */
+ public static int round(float a) {
+ return a > 0F ? (int)(a + .5F) : (int)(a - .5F);
+ }
+
+ /**
+ * @author FX - PR0CESS
+ * ~1.28x faster than {@link Math#round(double)}
+ */
+ public static long round(double a) {
+ return a > 0D ? (long)(a + .5D) : (long)(a - .5D);
+ }
+
+ /**
+ * @author FX - PR0CESS
+ * Hypot implementation from the jafama library. Not 100% accurate! (3E-14%, 15 is perfectly accurate)
+ * ~1.6x faster than {@link Math#hypot(double,double)}
+ */
+ public static double hypot(double x, double y) {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ if (y < x) { // Ensuring x <= y
+ final double a = x;
+ x = y;
+ y = a;
+ } else if (!(y >= x)) { // Testing if we have some NaN
+ return x == Double.POSITIVE_INFINITY ? Double.POSITIVE_INFINITY : Double.NaN;
+ }
+ if (y-x == y) { // x too small to subtract from y
+ return y;
+ } else {
+ double factor;
+ if (y > HYPOT_MAX_MAG) { // y is too large: scaling down
+ x *= (1/HYPOT_FACTOR);
+ y *= (1/HYPOT_FACTOR);
+ factor = HYPOT_FACTOR;
+ } else if (x < (1/HYPOT_MAX_MAG)) { // x is too small: scaling up
+ x *= HYPOT_FACTOR;
+ y *= HYPOT_FACTOR;
+ factor = (1/HYPOT_FACTOR);
+ } else {
+ factor = 1.0;
+ }
+ return factor * Math.sqrt(x*x+y*y);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
index f9251183df72ddc56662fd3f02acf21641a2200c..525bbe1a07025179cb32d9182fdde1d472b5852e 100644
--- a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
@@ -81,6 +81,6 @@ public class RAMDetails extends JList<String> {
}
private static String format(double tps) {
- return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( carpetfixes.helpers.FastMath.round( tps * 100.0 ) / 100.0, 20.0 ); // Mirai
}
}
diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java
index c3e54da4ab6440811aab2f9dd1e218802ac13285..db1319c51a5410ee106d023fce759f1e390872e2 100644
--- a/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java
@@ -128,7 +128,7 @@ public class RAMGraph extends JComponent {
graphics.setColor(data.getLineColor());
graphics.fillOval(m.x - 2, 100 - used - 2, 5, 5);
setToolTipText(String.format("<html><body>Used: %s mb (%s%%)<br/>%s</body></html>",
- Math.round(data.getUsedMem() / 1024F / 1024F),
+ carpetfixes.helpers.FastMath.round(data.getUsedMem() / 1024F / 1024F), // Mirai
used, getTime(m.x)));
}
}
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
index 0b060183429f4c72ec767075538477b4302bbf0d..75e7d181a8dff7247c6db8448cbf5f22772eab4b 100644
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
@@ -387,11 +387,11 @@ public final class PlayerChunkLoader {
}
protected long getTargetSendPerPlayerAddend() {
- return GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate);
+ return GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate <= 1.0 ? 0L : (long)carpetfixes.helpers.FastMath.round(1.0e9 / GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate); // Mirai
}
protected long getMaxSendAddend() {
- return GlobalConfiguration.get().chunkLoading.globalMaxChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / GlobalConfiguration.get().chunkLoading.globalMaxChunkSendRate);
+ return GlobalConfiguration.get().chunkLoading.globalMaxChunkSendRate <= 1.0 ? 0L : (long)carpetfixes.helpers.FastMath.round(1.0e9 / GlobalConfiguration.get().chunkLoading.globalMaxChunkSendRate); // Mirai
}
public void onChunkPlayerTickReady(final int chunkX, final int chunkZ) {
diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
index 7784d72ddd6db00c674e22759c00c430222c4b85..0f180d11774f6dec2667b3a3f6a63d1127bac869 100644
--- a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
+++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
@@ -95,12 +95,12 @@ public final class FixLightCommand implements PaperSubcommand {
++relitChunks[0];
sender.getBukkitEntity().sendMessage(text().color(DARK_AQUA).append(
text("Relit chunk ", BLUE), text(chunkPos.toString()),
- text(", progress: ", BLUE), text((int) (Math.round(100.0 * (double) (relitChunks[0]) / (double) pending[0])) + "%")
+ text(", progress: ", BLUE), text((int) (carpetfixes.helpers.FastMath.round(100.0 * (double) (relitChunks[0]) / (double) pending[0])) + "%") // Mirai
));
},
(final int totalRelit) -> {
final long end = System.nanoTime();
- final long diff = Math.round(1.0e-6 * (end - start));
+ final long diff = carpetfixes.helpers.FastMath.round(1.0e-6 * (end - start)); // Mirai
sender.getBukkitEntity().sendMessage(text().color(DARK_AQUA).append(
text("Relit ", BLUE), text(totalRelit),
text(" chunks. Took ", BLUE), text(diff + "ms")
diff --git a/src/main/java/net/minecraft/commands/arguments/TimeArgument.java b/src/main/java/net/minecraft/commands/arguments/TimeArgument.java
index e3e80db89c18588322ffdaa0f9fd85e398cb1471..d947011b80ee14e7aaf74af3d9081fc78e8cb4c3 100644
--- a/src/main/java/net/minecraft/commands/arguments/TimeArgument.java
+++ b/src/main/java/net/minecraft/commands/arguments/TimeArgument.java
@@ -35,7 +35,7 @@ public class TimeArgument implements ArgumentType<Integer> {
if (i == 0) {
throw ERROR_INVALID_UNIT.create();
} else {
- int j = Math.round(f * (float)i);
+ int j = carpetfixes.helpers.FastMath.round(f * (float)i); // Mirai
if (j < 0) {
throw ERROR_INVALID_TICK_COUNT.create(j);
} else {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 735e01c550d561aa21c3c8f7f34a495ec3a0ab67..795c631bb5edc696a4e52703b1819fcddfb800e2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2786,7 +2786,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
double overuseCount = (double)overuse/(double)MAX_CHUNK_EXEC_TIME;
- long extraSleep = (long)Math.round(overuseCount*CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME);
+ long extraSleep = (long)carpetfixes.helpers.FastMath.round(overuseCount*CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME); // Mirai
lastMidTickExecute = currTime + extraSleep;
return;
diff --git a/src/main/java/net/minecraft/server/gui/StatsComponent.java b/src/main/java/net/minecraft/server/gui/StatsComponent.java
index 88f10d729aa1e0a01790521821d691a0ecd373a2..45b2aa542969798a5a3b73af78de21ccc57bcca1 100644
--- a/src/main/java/net/minecraft/server/gui/StatsComponent.java
+++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java
@@ -88,7 +88,7 @@ public class StatsComponent extends JComponent {
// Paper - start Add tps entry
private static String format(double tps) {
- return (( tps > 21.0 ) ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
+ return (( tps > 21.0 ) ? "*" : "") + Math.min(carpetfixes.helpers.FastMath.round(tps * 100.0) / 100.0, 20.0); // only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise // Mirai
}
// Paper end
}
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index c852331f0c9dddbfe29e88e2dca1dceb2d7cee44..67ca2a39236ecfaeb54294b8b6b9fdb109b54513 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -792,7 +792,7 @@ public class Mth {
}
public static double length(double a, double b) {
- return Math.sqrt(lengthSquared(a, b));
+ return carpetfixes.helpers.FastMath.hypot(a, b); // Mirai
}
public static double lengthSquared(double a, double b, double c) {
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 219c7dcbe6bee5054aff0640a80d620eded812c0..87655d7c3dfbbd6bf348d693445c71d5601ed9c3 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1529,7 +1529,7 @@ public abstract class LivingEntity extends Entity {
if (this instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer) this, source, f1, amount, flag);
if (f2 > 0.0F && f2 < 3.4028235E37F) {
- ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(f2 * 10.0F));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
}
@@ -2097,9 +2097,9 @@ public abstract class LivingEntity extends Entity {
if (f3 > 0.0F && f3 < 3.4028235E37F) {
if (this instanceof ServerPlayer) {
- ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
} else if (source.getEntity() instanceof ServerPlayer) {
- ((ServerPlayer) source.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
+ ((ServerPlayer) source.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
}
}
}
@@ -2211,9 +2211,9 @@ public abstract class LivingEntity extends Entity {
float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
if (f3 > 0.0F && f3 < 3.4028235E37F) {
if (this instanceof ServerPlayer) {
- ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
} else if (damagesource.getEntity() instanceof ServerPlayer) {
- ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
}
}
}
@@ -2245,10 +2245,10 @@ public abstract class LivingEntity extends Entity {
float f2 = absorptionModifier;
if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof net.minecraft.world.entity.player.Player) {
- ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof ServerPlayer) {
- ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
// Purpur start
@@ -2270,7 +2270,7 @@ public abstract class LivingEntity extends Entity {
// PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
((net.minecraft.world.entity.player.Player) this).causeFoodExhaustion(damagesource.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
if (f < 3.4028235E37F) {
- ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, Math.round(f * 10.0F));
+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); // Mirai
}
}
// CraftBukkit end
@@ -2292,7 +2292,7 @@ public abstract class LivingEntity extends Entity {
CriteriaTriggers.ENTITY_HURT_PLAYER.trigger((ServerPlayer) this, damagesource, f, originalDamage, true);
f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
if (f2 > 0.0F && f2 < 3.4028235E37F) {
- ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(originalDamage * 10.0F)); // Mirai
}
}
@@ -3097,13 +3097,13 @@ public abstract class LivingEntity extends Entity {
//this.level.getProfiler().push("rangeChecks"); // Purpur
// Paper start - stop large pitch and yaw changes from crashing the server
- this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
+ this.yRotO += carpetfixes.helpers.FastMath.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; // Mirai
- this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F;
+ this.yBodyRotO += carpetfixes.helpers.FastMath.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F; // Mirai
- this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F;
+ this.xRotO += carpetfixes.helpers.FastMath.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; // Mirai
- this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
+ this.yHeadRotO += carpetfixes.helpers.FastMath.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; // Mirai
// Paper end
//this.level.getProfiler().pop(); // Purpur
diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
index 954a12c23da96a07cd175f6f2eb28e8c5d2a8c3d..e5bef70e9a5abfec859757bc47b003d24a0dd171 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
@@ -406,21 +406,56 @@ public class Sheep extends Animal implements Shearable {
return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
}
+ // Mirai start
+ private static DyeColor properDye(DyeColor firstColor, DyeColor secondColor) {
+ if (firstColor.equals(secondColor)) return firstColor;
+ switch(firstColor) {
+ case WHITE -> {
+ switch(secondColor) {
+ case BLUE -> {return DyeColor.LIGHT_BLUE;}
+ case GRAY -> {return DyeColor.LIGHT_GRAY;}
+ case BLACK -> {return DyeColor.GRAY;}
+ case GREEN -> {return DyeColor.LIME;}
+ case RED -> {return DyeColor.PINK;}
+ }
+ }
+ case BLUE -> {
+ switch(secondColor) {
+ case WHITE -> {return DyeColor.LIGHT_BLUE;}
+ case GREEN -> {return DyeColor.CYAN;}
+ case RED -> {return DyeColor.PURPLE;}
+ }
+ }
+ case RED -> {
+ switch(secondColor) {
+ case YELLOW -> {return DyeColor.ORANGE;}
+ case WHITE -> {return DyeColor.PINK;}
+ case BLUE -> {return DyeColor.PURPLE;}
+ }
+ }
+ case GREEN -> {
+ switch(secondColor) {
+ case BLUE -> {return DyeColor.CYAN;}
+ case WHITE -> {return DyeColor.LIME;}
+ }
+ }
+ case YELLOW -> {if (secondColor.equals(DyeColor.RED)) return DyeColor.ORANGE;}
+ case PURPLE -> {if (secondColor.equals(DyeColor.PINK)) return DyeColor.MAGENTA;}
+ case PINK -> {if (secondColor.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;}
+ case GRAY -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;}
+ case BLACK -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.GRAY;}
+ }
+ return null;
+ }
+
private DyeColor getOffspringColor(Animal firstParent, Animal secondParent) {
- DyeColor enumcolor = ((Sheep) firstParent).getColor();
- DyeColor enumcolor1 = ((Sheep) secondParent).getColor();
- CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1);
- Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error
- return recipecrafting.assemble(inventorycrafting);
- }).map(ItemStack::getItem);
-
- Objects.requireNonNull(DyeItem.class);
- optional = optional.filter(DyeItem.class::isInstance);
- Objects.requireNonNull(DyeItem.class);
- return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
- return this.level.random.nextBoolean() ? enumcolor : enumcolor1;
- });
+ DyeColor firstColor = ((Sheep)firstParent).getColor();
+ DyeColor secondColor = ((Sheep)secondParent).getColor();
+ DyeColor col = properDye(firstColor,secondColor);
+ if (col == null) col = this.level.random.nextBoolean() ? firstColor : secondColor;
+ return col;
}
+ // Mirai end
private static CraftingContainer makeContainer(DyeColor firstColor, DyeColor secondColor) {
CraftingContainer inventorycrafting = new CraftingContainer(new AbstractContainerMenu((MenuType) null, -1) {
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 1b7e38538881ba00ffdbe9226952627151532c5c..ff57940690dd9a1f43dab16d5b26432210659cc4 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1126,7 +1126,7 @@ public abstract class Player extends LivingEntity {
float f2 = f1 - f;
if (f2 > 0.0F && f2 < 3.4028235E37F) {
- this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
+ this.awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
if (f != 0.0F) {
@@ -1136,7 +1136,7 @@ public abstract class Player extends LivingEntity {
this.setHealth(this.getHealth() - f);
this.getCombatTracker().recordDamage(damagesource, f3, f);
if (f < 3.4028235E37F) {
- this.awardStat(Stats.DAMAGE_TAKEN, Math.round(f * 10.0F));
+ this.awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); // Mirai
}
}
@@ -1471,7 +1471,7 @@ public abstract class Player extends LivingEntity {
if (target instanceof LivingEntity) {
float f5 = f3 - ((LivingEntity) target).getHealth();
- this.awardStat(Stats.DAMAGE_DEALT, Math.round(f5 * 10.0F));
+ this.awardStat(Stats.DAMAGE_DEALT, carpetfixes.helpers.FastMath.round(f5 * 10.0F)); // Mirai
if (j > 0) {
// CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), target.getBukkitEntity(), j * 4);
@@ -1744,29 +1744,29 @@ public abstract class Player extends LivingEntity {
int i;
if (this.isSwimming()) {
- i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); // Mirai
if (i > 0) {
this.awardStat(Stats.SWIM_ONE_CM, i);
this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent // Spigot
}
} else if (this.isEyeInFluid(FluidTags.WATER)) {
- i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); // Mirai
if (i > 0) {
this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, i);
this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent // Spigot
}
} else if (this.isInWater()) {
- i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); // Mirai
if (i > 0) {
this.awardStat(Stats.WALK_ON_WATER_ONE_CM, i);
this.causeFoodExhaustion(level.spigotConfig.swimMultiplier * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent // Spigot
}
} else if (this.onClimbable()) {
if (dy > 0.0D) {
- this.awardStat(Stats.CLIMB_ONE_CM, (int) Math.round(dy * 100.0D));
+ this.awardStat(Stats.CLIMB_ONE_CM, (int) carpetfixes.helpers.FastMath.round(dy * 100.0D)); // Mirai
}
} else if (this.onGround) {
- i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); // Mirai
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(Stats.SPRINT_ONE_CM, i);
@@ -1780,10 +1780,10 @@ public abstract class Player extends LivingEntity {
}
}
} else if (this.isFallFlying()) {
- i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); // Mirai
this.awardStat(Stats.AVIATE_ONE_CM, i);
} else {
- i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F);
+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); // Mirai
if (i > 25) {
this.awardStat(Stats.FLY_ONE_CM, i);
}
@@ -1794,7 +1794,7 @@ public abstract class Player extends LivingEntity {
public void checkRidingStatistics(double dx, double dy, double dz) {
if (this.isPassenger()) {
- int i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
+ int i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); // Mirai
if (i > 0) {
Entity entity = this.getVehicle();
@@ -1821,7 +1821,7 @@ public abstract class Player extends LivingEntity {
return false;
} else {
if (fallDistance >= 2.0F) {
- this.awardStat(Stats.FALL_ONE_CM, (int) Math.round((double) fallDistance * 100.0D));
+ this.awardStat(Stats.FALL_ONE_CM, (int) carpetfixes.helpers.FastMath.round((double) fallDistance * 100.0D)); // Mirai
}
return super.causeFallDamage(fallDistance, damageMultiplier, damageSource);
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
index 8b250dab8f3cb788ae1cfad43737afda31b72c0f..7e57163c82f7a4f9df0774f049f724c9b201e023 100644
--- a/src/main/java/net/minecraft/world/item/Item.java
+++ b/src/main/java/net/minecraft/world/item/Item.java
@@ -166,7 +166,7 @@ public class Item implements ItemLike {
}
public int getBarWidth(ItemStack stack) {
- return Math.round(13.0F - (float)stack.getDamageValue() * 13.0F / (float)this.maxDamage);
+ return carpetfixes.helpers.FastMath.round(13.0F - (float)stack.getDamageValue() * 13.0F / (float)this.maxDamage); // Mirai
}
public int getBarColor(ItemStack stack) {
diff --git a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
index 1d79da7f8405f7dff3b2e10022a564a9cf2609eb..1d697e31e4bf5a94341f8044b8d580da019e94d7 100644
--- a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
+++ b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
@@ -369,7 +369,7 @@ public class EnchantmentHelper {
} else {
level += 1 + random.nextInt(i / 4 + 1) + random.nextInt(i / 4 + 1);
float f = (random.nextFloat() + random.nextFloat() - 1.0F) * 0.15F;
- level = Mth.clamp(Math.round((float)level + (float)level * f), 1, Integer.MAX_VALUE);
+ level = Mth.clamp(carpetfixes.helpers.FastMath.round((float)level + (float)level * f), 1, Integer.MAX_VALUE); // Mirai
List<EnchantmentInstance> list2 = getAvailableEnchantmentResults(level, stack, treasureAllowed);
if (!list2.isEmpty()) {
WeightedRandom.getRandomItem(random, list2).ifPresent(list::add);
diff --git a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java
index 16504b8be08064e61b013fa943f692816612cbd0..38f6759501dcc2a0adb9608a9f639c2411acf277 100644
--- a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java
@@ -62,7 +62,7 @@ public class DaylightDetectorBlock extends BaseEntityBlock {
float f1 = f < 3.1415927F ? 0.0F : 6.2831855F;
f += (f1 - f) * 0.2F;
- i = Math.round((float) i * Mth.cos(f));
+ i = carpetfixes.helpers.FastMath.round((float) i * Mth.cos(f)); // Mirai
}
i = Mth.clamp(i, (int) 0, (int) 15);
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
index 9579889e4c7dedefc4f901ccac6157c425740481..7904e80ff9476221ffac153494c1ecbd9b9cd9d9 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -254,8 +254,8 @@ public abstract class ChunkGenerator {
for (int j1 = 0; j1 < j; ++j1) {
double d1 = (double) (4 * i + i * i1 * 6) + (randomsource.nextDouble() - 0.5D) * (double) i * 2.5D;
- int k1 = (int) Math.round(Math.cos(d0) * d1);
- int l1 = (int) Math.round(Math.sin(d0) * d1);
+ int k1 = (int) carpetfixes.helpers.FastMath.round(Math.cos(d0) * d1); // Mirai
+ int l1 = (int) carpetfixes.helpers.FastMath.round(Math.sin(d0) * d1); // Mirai
BiomeSource worldchunkmanager = this.biomeSource;
int i2 = SectionPos.sectionToBlockCoord(k1, 8);
int j2 = SectionPos.sectionToBlockCoord(l1, 8);
diff --git a/src/main/java/net/minecraft/world/level/levelgen/SurfaceSystem.java b/src/main/java/net/minecraft/world/level/levelgen/SurfaceSystem.java
index b20ba0b10b5b1682bb5435d9d0bbe4aad25e8062..22a23580ccd861d14031f46b72f309cca6584d3b 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/SurfaceSystem.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/SurfaceSystem.java
@@ -300,7 +300,7 @@ public class SurfaceSystem {
}
protected BlockState getBand(int x, int y, int z) {
- int i = (int)Math.round(this.clayBandsOffsetNoise.getValue((double)x, 0.0D, (double)z) * 4.0D);
+ int i = (int)carpetfixes.helpers.FastMath.round(this.clayBandsOffsetNoise.getValue((double)x, 0.0D, (double)z) * 4.0D); // Mirai
return this.clayBands[(y + i + this.clayBands.length) % this.clayBands.length];
}
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/ScatteredOreFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/ScatteredOreFeature.java
index 06f27fc8eda9ec160c54759ec95fdade19876d29..567d653469c964922dc5662e48c45dc289222bc2 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/ScatteredOreFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/ScatteredOreFeature.java
@@ -46,6 +46,6 @@ public class ScatteredOreFeature extends Feature<OreConfiguration> {
}
private int getRandomPlacementInOneAxisRelativeToOrigin(RandomSource randomSource, int spread) {
- return Math.round((randomSource.nextFloat() - randomSource.nextFloat()) * (float)spread);
+ return carpetfixes.helpers.FastMath.round((randomSource.nextFloat() - randomSource.nextFloat()) * (float)spread); // Mirai
}
}
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
index 15d8e9261a89da30529ac347462c520920ca4e7d..477003d735548ef2f8152681a31fef3354e1f949 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
@@ -68,7 +68,7 @@ public class LootingEnchantFunction extends LootItemConditionalFunction {
float f = (float) i * this.value.getFloat(context);
- stack.grow(Math.round(f));
+ stack.grow(carpetfixes.helpers.FastMath.round(f)); // Mirai
if (this.hasLimit() && stack.getCount() > this.limit) {
stack.setCount(this.limit);
}
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/providers/number/NumberProvider.java b/src/main/java/net/minecraft/world/level/storage/loot/providers/number/NumberProvider.java
index 2a7c75ea447b179ea1ab9db56e8a39d03faa0bce..53ca87c7659a4fff9e99d21217d1ad08c8765836 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/providers/number/NumberProvider.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/providers/number/NumberProvider.java
@@ -7,7 +7,7 @@ public interface NumberProvider extends LootContextUser {
float getFloat(LootContext context);
default int getInt(LootContext context) {
- return Math.round(this.getFloat(context));
+ return carpetfixes.helpers.FastMath.round(this.getFloat(context)); // Mirai
}
LootNumberProviderType getType();
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 731c7dd15f131dc124be6af8f342b122cb89491b..24a82111a5485da1e3903977d0519e9ed502f34d 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
@@ -59,8 +59,8 @@ public final class Shapes {
int j = 1 << i;
double d = min * (double)j;
double e = max * (double)j;
- boolean bl = Math.abs(d - (double)Math.round(d)) < 1.0E-7D * (double)j;
- boolean bl2 = Math.abs(e - (double)Math.round(e)) < 1.0E-7D * (double)j;
+ boolean bl = Math.abs(d - (double)carpetfixes.helpers.FastMath.round(d)) < 1.0E-7D * (double)j; // Mirai
+ boolean bl2 = Math.abs(e - (double)carpetfixes.helpers.FastMath.round(e)) < 1.0E-7D * (double)j; // Mirai
if (bl && bl2) {
return i;
}
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
index 088239d17aa8178cf8af09ec23cfd4deaaf2bbb6..6a02c713c9e5b0a2fb4f8d2a47a62344af12ef95 100644
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
@@ -48,6 +48,6 @@ public class TicksPerSecondCommand extends Command
private static String format(double tps) // Paper - Made static
{
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
- + ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
+ + ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( carpetfixes.helpers.FastMath.round( tps * 100.0 ) / 100.0, 20.0 ); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise // Mirai
}
}

View File

@@ -9,7 +9,7 @@ Original license: MIT
Original project: https://github.com/Cryptite/Slice
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 467f60dcbed645d773e7e3e042d2bbbd8f5bb589..89f2bffb6d3458f885e6098ea770c46867f6419d 100644
index 14b2c36049c91a8abfc545e2fb5e3d6f908370e8..77c00de9b94531f8136469e04e535a43829c0a60 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -271,6 +271,7 @@ public class ServerPlayer extends Player {

View File

@@ -14,7 +14,7 @@ doing questionable/buggy ones, and claiming breathtaking performance improvement
any of those Spigot forks!
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6f2518ec1be9af4fa00d719c50cbe64e4e57fcbc..9701a89149cc2bd7330b23c441b51677be0bdc18 100644
index 193b6621d6506a04bc1f9f23571aeb2e635d562c..7ef574008f413008427d075860c9eb5debeef4f4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1195,7 +1195,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

View File

@@ -1,301 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MartijnMuijsers <martijnmuijsers@live.nl>
Date: Thu, 13 Oct 2022 18:09:28 +0200
Subject: [PATCH] Suki Patches
Original code by SuCraft, licensed under GPL-3.0.
You can find the original code on https://github.com/SuCraft/Suki
0012-Only-refresh-lootables-for-players.patch
0013-Optimize-harmless-explosions.patch
0016-Send-more-packets-immediately.patch
0017-Flush-after-more-packets.patch
0018-Do-not-relocate-corrupted-chunks.patch
0015-Multithreading environment variables.patch
diff --git a/src/main/java/cc/keyimc/keyi/KeyiConfig.java b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
index bc9403d002ef24e71be67a962d099f5d73db9540..8b9a2f06b0a61cfdd493eeddde512f0abd17f49e 100644
--- a/src/main/java/cc/keyimc/keyi/KeyiConfig.java
+++ b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
@@ -132,4 +132,22 @@ public final class KeyiConfig {
public static void reload() {
KeyiConfig.init((File) MinecraftServer.getServer().options.valueOf("keyi-settings"));
}
+
+ // Suki start - only refresh lootables for players
+
+ public static boolean onlyRefreshForPlayers = false;
+ private static void lootables() {
+ onlyRefreshForPlayers = getBoolean("suki.onlyRefreshForPlayers", onlyRefreshForPlayers);
+ }
+
+ // Suki end - only refresh lootables for players
+
+ // Suki start - do not relocate corrupted chunks
+
+ public static boolean RelocateCorruptedChunks = true;
+ private static void RelocateCorruptedChunks() {
+ RelocateCorruptedChunks = getBoolean("suki.RelocateCorruptedChunks", RelocateCorruptedChunks);
+ }
+
+ // Suki end - do not relocated corrupted chunks
}
\ No newline at end of file
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
index c8f7aa9e0794713724e1053581c220aa95f1bc90..f24193a13563bbfbe0f0677ec8f645b122937996 100644
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
@@ -56,8 +56,8 @@ import java.util.function.Supplier;
public final class MCUtil {
public static final ThreadPoolExecutor asyncExecutor = new ThreadPoolExecutor(
- 0, 2, 60L, TimeUnit.SECONDS,
- new LinkedBlockingQueue<>(),
+ Integer.getInteger("suki.threads.asyncexecutor", 4), Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, // JettPack // Suki - multithreading environment variables
+ new LinkedBlockingQueue<>(),
new ThreadFactoryBuilder()
.setNameFormat("Paper Async Task Handler Thread - %1$d")
.setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(MinecraftServer.LOGGER))
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index b2860114d52c52360e1e559d0c2c5ee4789dee97..8c09bdc0bd0af7ab9c5b3cad4067e1e0067c5502 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -27,7 +27,6 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.spi.FileSystemProvider;
-import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.time.Duration;
@@ -151,9 +150,15 @@ public class Util {
}
private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
+ // Suki start - multithreading environment variables
+ return makeExecutor(s, priorityModifier, -1);
+ }
+
+ public static ExecutorService makeExecutor(String s, int priorityModifier, int specificThreads) {
+ // Suki end - multithreading environment variables
// Paper start - use simpler thread pool that allows 1 thread
// Paper start - also try to avoid suffocating the system with the worldgen workers
- int cpus = Runtime.getRuntime().availableProcessors() / 2;
+ int cpus = Integer.getInteger("suki.systemcpus.forexecutors", Runtime.getRuntime().availableProcessors() / 2); // Suki - multithreading environment variables
int i;
if (cpus <= 4) {
i = cpus <= 2 ? 1 : 2;
@@ -166,6 +171,11 @@ public class Util {
i = Math.min(8, i);
// Paper end - also try to avoid suffocating the system with the worldgen workers
i = Integer.getInteger("Paper.WorkerThreadCount", i);
+ // Suki start - multithreading environment variables
+ if (specificThreads > 0) {
+ i = specificThreads;
+ }
+ // Suki end - multithreading environment variables
ExecutorService executorService;
if (i <= 0) {
@@ -174,7 +184,7 @@ public class Util {
//executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new net.minecraft.server.ServerWorkerThread(target, s, priorityModifier)); // JettPack
// JettPack start
- executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new AbstractExecutorService(){
+ executorService = new AbstractExecutorService(){ // Suki - multithreading environment variables
private volatile boolean shutdown = false;
@Override
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 2a71c8e6901944af90c4ad4dfa39dba7fafc0126..2e79bc8218454d1714dc878b6f07d3ed289fed68 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -356,7 +356,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
packet instanceof net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket ||
packet instanceof net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket ||
packet instanceof net.minecraft.network.protocol.game.ClientboundClearTitlesPacket ||
- packet instanceof net.minecraft.network.protocol.game.ClientboundBossEventPacket;
+ // Suki start - send more packets immediately
+ packet instanceof net.minecraft.network.protocol.game.ClientboundBossEventPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
+ // Suki end - send more packets immediately
}
// Paper end
}
@@ -407,7 +411,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, Boolean flushConditional) {
this.packetWrites.getAndIncrement(); // must be befeore using canFlush
boolean effectiveFlush = flushConditional == null ? this.canFlush : flushConditional.booleanValue();
- final boolean flush = effectiveFlush || packet instanceof net.minecraft.network.protocol.game.ClientboundKeepAlivePacket || packet instanceof ClientboundDisconnectPacket; // no delay for certain packets
+ // Suki start - flush after more packets
+ final boolean flush = effectiveFlush ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundKeepAlivePacket ||
+ packet instanceof ClientboundDisconnectPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundForgetLevelChunkPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket ||
+ packet instanceof net.minecraft.network.protocol.game.ClientboundMapItemDataPacket; // no delay for certain packets
+ // Suki end - flush after more packets
// Paper end - add flush parameter
ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet);
ConnectionProtocol enumprotocol1 = this.getCurrentProtocol();
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
index 0066b1abc008d245825abf1d256cb87fa9c2d877..5efe002efcfa43b2cdd90f2dc127fee89b25b82b 100644
--- a/src/main/java/net/minecraft/server/Main.java
+++ b/src/main/java/net/minecraft/server/Main.java
@@ -330,7 +330,7 @@ public class Main {
// Paper start - fix and optimise world upgrading
public static void convertWorldButItWorks(net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimensionType, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession,
DataFixer dataFixer, Optional<net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator>>> generatorKey, boolean removeCaches) {
- int threads = Runtime.getRuntime().availableProcessors() * 3 / 8;
+ int threads = Integer.getInteger("suki.threads.upgradeworld", Integer.getInteger("suki.systemcpus.forupgradeworld", Runtime.getRuntime().availableProcessors()) * 3 / 8); // Suki - multithreading environment variables
final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldSession.getLevelId(), worldSession.levelDirectory.path().toFile(), threads, dataFixer, generatorKey, removeCaches);
worldUpgrader.convert();
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 795c631bb5edc696a4e52703b1819fcddfb800e2..cb2fc1a77d8170772ec4595642d317b04652b293 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -313,8 +313,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
MinecraftServer.LOGGER.error("Uncaught exception in server thread", throwable);
});
- if (Runtime.getRuntime().availableProcessors() > 4) {
- thread.setPriority(8);
+ // Suki start - multithreading environment variables
+ if (Integer.getInteger("suki.mainthreadpriority", -1) != -1 || Runtime.getRuntime().availableProcessors() > 4) {
+ thread.setPriority(Integer.getInteger("suki.mainthreadpriority", 8));
+ // Suki end - multithreading environment variables
}
S s0 = serverFactory.apply(thread); // CraftBukkit - decompile error
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index c9def2202d7c2a523858ec124df2beaf994d9888..3a7bcee2e4b1c4ef2ba303b0200ae846357c5982 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -152,6 +152,7 @@ public class Explosion {
int i;
int j;
+ if (this.fire || this.blockInteraction != BlockInteraction.NONE) { // Suki - optimize explosions - don't run block processing if neither flag is set
for (int k = 0; k < 16; ++k) {
for (i = 0; i < 16; ++i) {
for (j = 0; j < 16; ++j) {
@@ -191,8 +192,8 @@ public class Explosion {
if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) {
BlockEntity extension = this.level.getBlockEntity(blockposition);
if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) {
- net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
- set.add(blockposition.relative(direction.getOpposite()));
+ net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
+ set.add(blockposition.relative(direction.getOpposite()));
}
}
// Paper end
@@ -206,6 +207,7 @@ public class Explosion {
}
}
}
+ } // Suki - optimize explosions - don't run block processing if neither flag is set
this.toBlow.addAll(set);
float f2 = this.radius * 2.0F;
@@ -296,7 +298,7 @@ public class Explosion {
boolean flag1 = this.blockInteraction != Explosion.BlockInteraction.NONE;
if (particles) {
- if (this.radius >= 2.0F && flag1) {
+ if (this.radius >= 2.0F) {
this.level.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
} else {
this.level.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 13e749a3c40f0b2cc002f13675a9a56eedbefdac..2995d5f80dd2e9b4b8fbbafe3567a6f2847a1187 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
@@ -1,6 +1,8 @@
package net.minecraft.world.level.block.entity;
import javax.annotation.Nullable;
+
+import cc.keyimc.keyi.KeyiConfig;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
@@ -69,6 +71,15 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
}
public void unpackLootTable(@Nullable Player player) {
+ // Suki start - only refresh lootables for players
+ if (this.level.getServer() != null) {
+ if (KeyiConfig.onlyRefreshForPlayers) {
+ if (player == null) {
+ return;
+ }
+ }
+ }
+ // Suki end - only refresh lootables for players
if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
LootTable lootTable = this.level.getServer().getLootTables().get(this.lootTable);
if (player instanceof ServerPlayer) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
index 577eefd0990b0d6ae237dd685976975d3532d7fa..1ef21e74e353f178d9031ef253765593147263bb 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.chunk.storage;
+import cc.keyimc.keyi.KeyiConfig;
import com.google.common.collect.Maps;
import com.mojang.logging.LogUtils;
import com.mojang.serialization.Codec;
@@ -30,6 +31,7 @@ import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.ShortTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ThreadedLevelLightEngine;
@@ -157,7 +159,14 @@ public class ChunkSerializer {
ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
- ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
+ // Suki start - do not relocate corrupted chunks
+ if (KeyiConfig.RelocateCorruptedChunks) {
+ ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
+ } else {
+ ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; stopping the server. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1});
+ MinecraftServer.getServer().stopServer();
+ }
+ // Suki end - do not relocate corrupted chunks
}
UpgradeData chunkconverter = nbt.contains("UpgradeData", 10) ? new UpgradeData(nbt.getCompound("UpgradeData"), world) : UpgradeData.EMPTY;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 3a67aaa39daf1fb86938f53e129aadfb686583b0..a57d633c439f66cb27209f56abf391e84bbb52c5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -242,6 +242,7 @@ import org.jetbrains.annotations.NotNull;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.error.MarkedYAMLException;
+import net.minecraft.Util; // KeYi
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
@@ -1295,9 +1296,11 @@ public final class CraftServer implements Server {
worldKey = ResourceKey.create(net.minecraft.core.Registry.DIMENSION_REGISTRY, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
}
- ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11),
+ // Suki start - multithreading environment variables
+ int levelExecutorThreads = Integer.getInteger("suki.threads.levelexecutor", -1);
+ ServerLevel internal = (ServerLevel) new ServerLevel(this.console, levelExecutorThreads > 0 ? Util.makeExecutor(name, -1, levelExecutorThreads) : console.executor, worldSession, worlddata, worldKey, worlddimension, this.getServer().progressListenerFactory.create(11),
worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
-
+ // Suki end - multithreading environment variables
if (!(this.worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
return null;
}

View File

@@ -1,525 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ishland <ishlandmc@yeah.net>
Date: Tue, 21 Sep 2021 10:37:34 +0200
Subject: [PATCH] C2ME optimizations
c2me: opts math
Copyright (c) 2021-2022 ishland
Original code by RelativityMC, licensed under MIT
You can find the original code on https://github.com/RelativityMC/C2ME-fabric (Yarn mappings)
c2me: reduce_allocs
Copyright (c) 2021-2022 ishland
Original code by RelativityMC, licensed under MIT
You can find the original code on https://github.com/RelativityMC/C2ME-fabric (Yarn mappings)
diff --git a/src/main/java/com/ishland/c2me/opts/allocs/common/ObjectCachingUtils.java b/src/main/java/com/ishland/c2me/opts/allocs/common/ObjectCachingUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1229bae2e74d22065c723c6d3eaf9a97d572b04
--- /dev/null
+++ b/src/main/java/com/ishland/c2me/opts/allocs/common/ObjectCachingUtils.java
@@ -0,0 +1,23 @@
+package com.ishland.c2me.opts.allocs.common;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+
+import java.util.BitSet;
+import java.util.function.IntFunction;
+
+public class ObjectCachingUtils {
+
+ private static final IntFunction<BitSet> bitSetConstructor = BitSet::new;
+
+ public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
+
+ private ObjectCachingUtils() {
+ }
+
+ public static BitSet getCachedOrNewBitSet(int bits) {
+ final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
+ bitSet.clear();
+ return bitSet;
+ }
+
+}
diff --git a/src/main/java/com/ishland/c2me/opts/allocs/common/PooledFeatureContext.java b/src/main/java/com/ishland/c2me/opts/allocs/common/PooledFeatureContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..4c84006c90bda4849b27879d5218f98e6d98f1dc
--- /dev/null
+++ b/src/main/java/com/ishland/c2me/opts/allocs/common/PooledFeatureContext.java
@@ -0,0 +1,68 @@
+package com.ishland.c2me.opts.allocs.common;
+
+import java.util.Optional;
+import net.minecraft.core.BlockPos;
+import net.minecraft.util.RandomSource;
+import net.minecraft.world.level.WorldGenLevel;
+import net.minecraft.world.level.chunk.ChunkGenerator;
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
+import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
+
+public class PooledFeatureContext<FC extends FeatureConfiguration> extends FeaturePlaceContext<FC> {
+
+ public static final ThreadLocal<SimpleObjectPool<PooledFeatureContext<?>>> POOL = ThreadLocal.withInitial(() -> new SimpleObjectPool<>(unused -> new PooledFeatureContext<>(), unused -> {}, 2048));
+
+ private Optional<ConfiguredFeature<?, ?>> feature;
+ private WorldGenLevel world;
+ private ChunkGenerator generator;
+ private RandomSource random;
+ private BlockPos origin;
+ private FC config;
+
+ public PooledFeatureContext() {
+ super(null, null, null, null, null, null);
+ }
+
+ public void reInit(Optional<ConfiguredFeature<?, ?>> feature, WorldGenLevel world, ChunkGenerator generator, RandomSource random, BlockPos origin, FC config) {
+ this.feature = feature;
+ this.world = world;
+ this.generator = generator;
+ this.random = random;
+ this.origin = origin;
+ this.config = config;
+ }
+
+ public void reInit() {
+ this.feature = null;
+ this.world = null;
+ this.generator = null;
+ this.random = null;
+ this.origin = null;
+ this.config = null;
+ }
+
+ public WorldGenLevel level() {
+ return this.world;
+ }
+
+ public ChunkGenerator chunkGenerator() {
+ return this.generator;
+ }
+
+ public RandomSource random() {
+ return this.random;
+ }
+
+ public BlockPos origin() {
+ return this.origin;
+ }
+
+ public FC config() {
+ return this.config;
+ }
+
+ public Optional<ConfiguredFeature<?, ?>> topFeature() {
+ return this.feature;
+ }
+}
diff --git a/src/main/java/com/ishland/c2me/opts/allocs/common/SimpleObjectPool.java b/src/main/java/com/ishland/c2me/opts/allocs/common/SimpleObjectPool.java
new file mode 100644
index 0000000000000000000000000000000000000000..b989019847f73ba3af57f7428699c9c869d6332f
--- /dev/null
+++ b/src/main/java/com/ishland/c2me/opts/allocs/common/SimpleObjectPool.java
@@ -0,0 +1,57 @@
+package com.ishland.c2me.opts.allocs.common;
+
+import com.google.common.base.Preconditions;
+
+import java.util.Objects;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+public class SimpleObjectPool<T> {
+
+ private final Function<SimpleObjectPool<T>, T> constructor;
+ private final Consumer<T> initializer;
+ private final int size;
+
+ private final Object[] cachedObjects;
+ private int allocatedCount = 0;
+
+ public SimpleObjectPool(Function<SimpleObjectPool<T>, T> constructor, Consumer<T> initializer, int size) {
+ this.constructor = Objects.requireNonNull(constructor);
+ this.initializer = Objects.requireNonNull(initializer);
+ Preconditions.checkArgument(size > 0);
+ this.cachedObjects = new Object[size];
+ this.size = size;
+
+ for (int i = 0; i < size; i++) {
+ final T object = constructor.apply(this);
+ this.cachedObjects[i] = object;
+ }
+ }
+
+ public T alloc() {
+ final T object;
+ synchronized (this) {
+ if (this.allocatedCount >= this.size) { // oversized, falling back to normal alloc
+ object = this.constructor.apply(this);
+ return object;
+ }
+
+ // get an object from the array
+ final int ordinal = this.allocatedCount++;
+ object = (T) this.cachedObjects[ordinal];
+ this.cachedObjects[ordinal] = null;
+ }
+
+ this.initializer.accept(object); // initialize the object
+
+ return object;
+ }
+
+ public void release(T object) {
+ synchronized (this) {
+ if (this.allocatedCount == 0) return; // pool is full
+ this.cachedObjects[--this.allocatedCount] = object; // store the object into the pool
+ }
+ }
+
+}
diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java
index 7017dd42f832d928f1008a05f01701667d951644..4e767dd8f9594e8a8f5d71e2bfd8c976c0032f98 100644
--- a/src/main/java/net/minecraft/resources/ResourceLocation.java
+++ b/src/main/java/net/minecraft/resources/ResourceLocation.java
@@ -27,6 +27,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> {
public static final String REALMS_NAMESPACE = "realms";
protected final String namespace;
protected final String path;
+ private String cachedString = null; // Mirai - c2me: opts allocs
protected ResourceLocation(String[] id) {
this.namespace = StringUtils.isEmpty(id[0]) ? "minecraft" : id[0];
@@ -99,7 +100,16 @@ public class ResourceLocation implements Comparable<ResourceLocation> {
@Override
public String toString() {
- return this.namespace + ":" + this.path;
+ // Mirai start - c2me: opts allocs
+ /**
+ * @author ishland
+ * @reason cache toString
+ */
+ if (this.cachedString != null) return this.cachedString;
+ final String s = this.namespace + ":" + this.path;
+ this.cachedString = s;
+ return s;
+ // Mirai end
}
@Override
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredFeature.java
index 2f67705132df06ae6231dd1b89a4f61a90616ef5..1013df19df55316200169f6c3deec8876ea4686a 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredFeature.java
@@ -12,6 +12,10 @@ import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
+// Mirai start - c2me: opts allocs
+import com.ishland.c2me.opts.allocs.common.PooledFeatureContext;
+import com.ishland.c2me.opts.allocs.common.SimpleObjectPool;
+// Mirai end
public record ConfiguredFeature<FC extends FeatureConfiguration, F extends Feature<FC>>(F feature, FC config) {
public static final Codec<ConfiguredFeature<?, ?>> DIRECT_CODEC = Registry.FEATURE.byNameCodec().dispatch((configuredFeature) -> {
@@ -21,7 +25,22 @@ public record ConfiguredFeature<FC extends FeatureConfiguration, F extends Featu
public static final Codec<HolderSet<ConfiguredFeature<?, ?>>> LIST_CODEC = RegistryCodecs.homogeneousList(Registry.CONFIGURED_FEATURE_REGISTRY, DIRECT_CODEC);
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, RandomSource random, BlockPos origin) {
- return this.feature.place(this.config, world, chunkGenerator, random, origin);
+ // Mirai start - c2me: opts allocs
+ /**
+ * @author ishland
+ * @reason pool FeatureContext
+ */
+ if (!world.ensureCanWrite(origin)) return false;
+ final SimpleObjectPool<PooledFeatureContext<?>> pool = PooledFeatureContext.POOL.get();
+ final PooledFeatureContext<FC> context = (PooledFeatureContext<FC>) pool.alloc();
+ try {
+ context.reInit(java.util.Optional.empty(), world, chunkGenerator, random, origin, this.config);
+ return this.feature.place(context);
+ } finally {
+ context.reInit();
+ pool.release(context);
+ }
+ // Mirai end
}
public Stream<ConfiguredFeature<?, ?>> getFeatures() {
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
index b2f36a998437e2a63a3cbc6c3aa95b1402bff2f1..d69a57f67eeb99f3db4f80d13b9f0276ce4603af 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
@@ -54,7 +54,7 @@ public class OreFeature extends Feature<OreConfiguration> {
protected boolean doPlace(WorldGenLevel world, RandomSource randomSource, OreConfiguration config, double startX, double endX, double startZ, double endZ, double startY, double endY, int x, int y, int z, int horizontalSize, int verticalSize) {
int i = 0;
- BitSet bitSet = new BitSet(horizontalSize * verticalSize * horizontalSize);
+ BitSet bitSet = com.ishland.c2me.opts.allocs.common.ObjectCachingUtils.getCachedOrNewBitSet(horizontalSize * verticalSize * horizontalSize); // Mirai - c2me: opts allocs
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
int j = config.size;
double[] ds = new double[j * 4];
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
index fb84d703b4461343d50510d7c9be32fc1f09ed22..3da6b30febc98e5392e42d39c5bd69a82116dc2d 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java
@@ -11,6 +11,27 @@ public final class ImprovedNoise {
public final double yo;
public final double zo;
+ // Mirai start - c2me: opts math
+ private static final double[] FLAT_SIMPLEX_GRAD = new double[]{
+ 1, 1, 0, 0,
+ -1, 1, 0, 0,
+ 1, -1, 0, 0,
+ -1, -1, 0, 0,
+ 1, 0, 1, 0,
+ -1, 0, 1, 0,
+ 1, 0, -1, 0,
+ -1, 0, -1, 0,
+ 0, 1, 1, 0,
+ 0, -1, 1, 0,
+ 0, 1, -1, 0,
+ 0, -1, -1, 0,
+ 1, 1, 0, 0,
+ 0, -1, 1, 0,
+ -1, 1, 0, 0,
+ 0, -1, -1, 0,
+ };
+ // Mirai end
+
public ImprovedNoise(RandomSource random) {
this.xo = random.nextDouble() * 256.0D;
this.yo = random.nextDouble() * 256.0D;
@@ -34,34 +55,38 @@ public final class ImprovedNoise {
return this.noise(x, y, z, 0.0D, 0.0D);
}
+ // Mirai start - c2me: opts math
+ /**
+ * @author ishland
+ * @reason optimize: remove frequent type conversions
+ */
/** @deprecated */
@Deprecated
public double noise(double x, double y, double z, double yScale, double yMax) {
double d = x + this.xo;
double e = y + this.yo;
double f = z + this.zo;
- int i = Mth.floor(d);
- int j = Mth.floor(e);
- int k = Mth.floor(f);
- double g = d - (double)i;
- double h = e - (double)j;
- double l = f - (double)k;
- double o;
- if (yScale != 0.0D) {
+ double i = Mth.floor(d);
+ double j = Mth.floor(e);
+ double k = Mth.floor(f);
+ double g = d - i;
+ double h = e - j;
+ double l = f - k;
+ double o = 0.0D;
+ if (yScale != 0.0) {
double m;
- if (yMax >= 0.0D && yMax < h) {
+ if (yMax >= 0.0 && yMax < h) {
m = yMax;
} else {
m = h;
}
- o = (double)Mth.floor(m / yScale + (double)1.0E-7F) * yScale;
- } else {
- o = 0.0D;
+ o = Mth.floor(m / yScale + 1.0E-7F) * yScale;
}
- return this.sampleAndLerp(i, j, k, g, h - o, l, h);
+ return this.sampleAndLerp((int) i, (int) j, (int) k, g, h - o, l, h);
}
+ // Mirai end
public double noiseWithDerivative(double x, double y, double z, double[] ds) {
double d = x + this.xo;
@@ -84,26 +109,76 @@ public final class ImprovedNoise {
return this.p[input & 255] & 255;
}
- private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalY) {
- int i = this.p(sectionX);
- int j = this.p(sectionX + 1);
- int k = this.p(i + sectionY);
- int l = this.p(i + sectionY + 1);
- int m = this.p(j + sectionY);
- int n = this.p(j + sectionY + 1);
- double d = gradDot(this.p(k + sectionZ), localX, localY, localZ);
- double e = gradDot(this.p(m + sectionZ), localX - 1.0D, localY, localZ);
- double f = gradDot(this.p(l + sectionZ), localX, localY - 1.0D, localZ);
- double g = gradDot(this.p(n + sectionZ), localX - 1.0D, localY - 1.0D, localZ);
- double h = gradDot(this.p(k + sectionZ + 1), localX, localY, localZ - 1.0D);
- double o = gradDot(this.p(m + sectionZ + 1), localX - 1.0D, localY, localZ - 1.0D);
- double p = gradDot(this.p(l + sectionZ + 1), localX, localY - 1.0D, localZ - 1.0D);
- double q = gradDot(this.p(n + sectionZ + 1), localX - 1.0D, localY - 1.0D, localZ - 1.0D);
- double r = Mth.smoothstep(localX);
- double s = Mth.smoothstep(fadeLocalY);
- double t = Mth.smoothstep(localZ);
- return Mth.lerp3(r, s, t, d, e, f, g, h, o, p, q);
+ // Mirai start - c2me: opts math
+ /**
+ * @author ishland
+ * @reason inline math & small optimization: remove frequent type conversions and redundant ops
+ */
+ private double sampleAndLerp(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double fadeLocalX) {
+ // TODO [VanillaCopy] but optimized
+ final int var0 = sectionX & 0xFF;
+ final int var1 = (sectionX + 1) & 0xFF;
+ final int var2 = this.p[var0] & 0xFF;
+ final int var3 = this.p[var1] & 0xFF;
+ final int var4 = (var2 + sectionY) & 0xFF;
+ final int var5 = (var3 + sectionY) & 0xFF;
+ final int var6 = (var2 + sectionY + 1) & 0xFF;
+ final int var7 = (var3 + sectionY + 1) & 0xFF;
+ final int var8 = this.p[var4] & 0xFF;
+ final int var9 = this.p[var5] & 0xFF;
+ final int var10 = this.p[var6] & 0xFF;
+ final int var11 = this.p[var7] & 0xFF;
+
+ final int var12 = (var8 + sectionZ) & 0xFF;
+ final int var13 = (var9 + sectionZ) & 0xFF;
+ final int var14 = (var10 + sectionZ) & 0xFF;
+ final int var15 = (var11 + sectionZ) & 0xFF;
+ final int var16 = (var8 + sectionZ + 1) & 0xFF;
+ final int var17 = (var9 + sectionZ + 1) & 0xFF;
+ final int var18 = (var10 + sectionZ + 1) & 0xFF;
+ final int var19 = (var11 + sectionZ + 1) & 0xFF;
+ final int var20 = (this.p[var12] & 15) << 2;
+ final int var21 = (this.p[var13] & 15) << 2;
+ final int var22 = (this.p[var14] & 15) << 2;
+ final int var23 = (this.p[var15] & 15) << 2;
+ final int var24 = (this.p[var16] & 15) << 2;
+ final int var25 = (this.p[var17] & 15) << 2;
+ final int var26 = (this.p[var18] & 15) << 2;
+ final int var27 = (this.p[var19] & 15) << 2;
+ final double var60 = localX - 1.0;
+ final double var61 = localY - 1.0;
+ final double var62 = localZ - 1.0;
+ final double var87 = FLAT_SIMPLEX_GRAD[(var20) | 0] * localX + FLAT_SIMPLEX_GRAD[(var20) | 1] * localY + FLAT_SIMPLEX_GRAD[(var20) | 2] * localZ;
+ final double var88 = FLAT_SIMPLEX_GRAD[(var21) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var21) | 1] * localY + FLAT_SIMPLEX_GRAD[(var21) | 2] * localZ;
+ final double var89 = FLAT_SIMPLEX_GRAD[(var22) | 0] * localX + FLAT_SIMPLEX_GRAD[(var22) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var22) | 2] * localZ;
+ final double var90 = FLAT_SIMPLEX_GRAD[(var23) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var23) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var23) | 2] * localZ;
+ final double var91 = FLAT_SIMPLEX_GRAD[(var24) | 0] * localX + FLAT_SIMPLEX_GRAD[(var24) | 1] * localY + FLAT_SIMPLEX_GRAD[(var24) | 2] * var62;
+ final double var92 = FLAT_SIMPLEX_GRAD[(var25) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var25) | 1] * localY + FLAT_SIMPLEX_GRAD[(var25) | 2] * var62;
+ final double var93 = FLAT_SIMPLEX_GRAD[(var26) | 0] * localX + FLAT_SIMPLEX_GRAD[(var26) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var26) | 2] * var62;
+ final double var94 = FLAT_SIMPLEX_GRAD[(var27) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var27) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var27) | 2] * var62;
+
+ final double var95 = localX * 6.0 - 15.0;
+ final double var96 = fadeLocalX * 6.0 - 15.0;
+ final double var97 = localZ * 6.0 - 15.0;
+ final double var98 = localX * var95 + 10.0;
+ final double var99 = fadeLocalX * var96 + 10.0;
+ final double var100 = localZ * var97 + 10.0;
+ final double var101 = localX * localX * localX * var98;
+ final double var102 = fadeLocalX * fadeLocalX * fadeLocalX * var99;
+ final double var103 = localZ * localZ * localZ * var100;
+
+ final double var113 = var87 + var101 * (var88 - var87);
+ final double var114 = var93 + var101 * (var94 - var93);
+ final double var115 = var91 + var101 * (var92 - var91);
+ final double var116 = var89 + var101 * (var90 - var89);
+ final double var117 = var114 - var115;
+ final double var118 = var102 * (var116 - var113);
+ final double var119 = var102 * var117;
+ final double var120 = var113 + var118;
+ final double var121 = var115 + var119;
+ return var120 + (var103 * (var121 - var120));
}
+ // Mirai end
private double sampleWithDerivative(int sectionX, int sectionY, int sectionZ, double localX, double localY, double localZ, double[] ds) {
int i = this.p(sectionX);
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
index 03c752e4abfe9e1f27c79024af48b31f7e90e555..125ae55681212e902e6e1ed3f82990180d1a56c4 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinNoise.java
@@ -26,6 +26,10 @@ public class PerlinNoise {
private final double lowestFreqValueFactor;
private final double lowestFreqInputFactor;
private final double maxValue;
+ // Mirai start - c2me: opts math
+ private int octaveSamplersCount = 0;
+ private double[] amplitudesArray = null;
+ // Mirai end
/** @deprecated */
@Deprecated
@@ -131,6 +135,10 @@ public class PerlinNoise {
this.lowestFreqInputFactor = Math.pow(2.0D, (double)(-j));
this.lowestFreqValueFactor = Math.pow(2.0D, (double)(i - 1)) / (Math.pow(2.0D, (double)i) - 1.0D);
this.maxValue = this.edgeValue(2.0D);
+ // Mirai start - c2me: opts math
+ this.octaveSamplersCount = this.noiseLevels.length;
+ this.amplitudesArray = this.amplitudes.toDoubleArray();
+ // Mirai end
}
protected double maxValue() {
@@ -141,9 +149,33 @@ public class PerlinNoise {
random.consumeCount(262);
}
+ // Mirai start - c2me: opts math
+ /**
+ * @author ishland
+ * @reason optimize for common cases
+ */
public double getValue(double x, double y, double z) {
- return this.getValue(x, y, z, 0.0D, 0.0D, false);
+ double d = 0.0;
+ double e = this.lowestFreqInputFactor;
+ double f = this.lowestFreqValueFactor;
+
+ for(int i = 0; i < this.octaveSamplersCount; ++i) {
+ ImprovedNoise perlinNoiseSampler = this.noiseLevels[i];
+ if (perlinNoiseSampler != null) {
+ @SuppressWarnings("deprecation")
+ double g = perlinNoiseSampler.noise(
+ wrap(x * e), wrap(y * e), wrap(z * e), 0.0, 0.0
+ );
+ d += this.amplitudesArray[i] * g * f;
+ }
+
+ e *= 2.0;
+ f /= 2.0;
+ }
+
+ return d;
}
+ // Mirai end
/** @deprecated */
@Deprecated
@@ -191,9 +223,15 @@ public class PerlinNoise {
return this.noiseLevels[this.noiseLevels.length - 1 - octave];
}
+ // Mirai start - c2me: opts math
+ /**
+ * @author ishland
+ * @reason remove frequent type conversion
+ */
public static double wrap(double value) {
- return value - (double)Mth.lfloor(value / 3.3554432E7D + 0.5D) * 3.3554432E7D;
+ return value - Mth.lfloor(value / 3.3554432E7 + 0.5) * 3.3554432E7;
}
+ // Mirai end
protected int firstOctave() {
return this.firstOctave;

View File

@@ -10,13 +10,14 @@ Let users decide if we should warn while running in offline mode
Let users decide if we should warn while running in proxy mode
diff --git a/src/main/java/cc/keyimc/keyi/KeyiConfig.java b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
index 8b9a2f06b0a61cfdd493eeddde512f0abd17f49e..98705c4206906404fed31c87fb03737fe3771b0a 100644
index bc9403d002ef24e71be67a962d099f5d73db9540..5582c15a37fbbf74d2039ba15d67684f5294a46d 100644
--- a/src/main/java/cc/keyimc/keyi/KeyiConfig.java
+++ b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
@@ -133,6 +133,16 @@ public final class KeyiConfig {
@@ -132,4 +132,14 @@ public final class KeyiConfig {
public static void reload() {
KeyiConfig.init((File) MinecraftServer.getServer().options.valueOf("keyi-settings"));
}
+
+ public static boolean enableRootUserWarning = true;
+ public static boolean enableOfflineModeWarning = true;
+ public static boolean enableProxyUnsafeWarning = true;
@@ -26,10 +27,8 @@ index 8b9a2f06b0a61cfdd493eeddde512f0abd17f49e..98705c4206906404fed31c87fb03737f
+ enableOfflineModeWarning = getBoolean("misc.enable-offline-mode-warning", enableOfflineModeWarning);
+ enableProxyUnsafeWarning = getBoolean("misc.enable-proxy-unsafe-warning", enableProxyUnsafeWarning);
+ }
+
// Suki start - only refresh lootables for players
public static boolean onlyRefreshForPlayers = false;
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index a9c4f1192f53fea55b2f5edc8a91b6911489e2d3..5420915b21bbd17eeaba2ba45e08399a3abe6952 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java

View File

@@ -5,22 +5,21 @@ Subject: [PATCH] Add an option for tripwire duping
diff --git a/src/main/java/cc/keyimc/keyi/KeyiConfig.java b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
index 98705c4206906404fed31c87fb03737fe3771b0a..c93bb951fd456af9e8f030b6f5c7989925c3556f 100644
index 5582c15a37fbbf74d2039ba15d67684f5294a46d..8884a2471b4b7c5cabf1c0c767710ba69c7ae4ec 100644
--- a/src/main/java/cc/keyimc/keyi/KeyiConfig.java
+++ b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
@@ -143,6 +143,12 @@ public final class KeyiConfig {
@@ -142,4 +142,10 @@ public final class KeyiConfig {
enableOfflineModeWarning = getBoolean("misc.enable-offline-mode-warning", enableOfflineModeWarning);
enableProxyUnsafeWarning = getBoolean("misc.enable-proxy-unsafe-warning", enableProxyUnsafeWarning);
}
+
+ public static boolean fixTripwireDuping = true;
+
+ private static void fixes() {
+ fixTripwireDuping = getBoolean("fixes.fix-tripwire-duping", fixTripwireDuping);
+ }
+
// Suki start - only refresh lootables for players
public static boolean onlyRefreshForPlayers = false;
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
index 004dce26ff073f1de52a84cd425c4f60fdab5e50..b37a5d643dc07eaa0808b972f43281f2e24d3394 100644
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java

View File

@@ -5,22 +5,21 @@ Subject: [PATCH] Add an option for spigot item merging mechanism
diff --git a/src/main/java/cc/keyimc/keyi/KeyiConfig.java b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
index c93bb951fd456af9e8f030b6f5c7989925c3556f..2ccee00d230f4801c4ed4b80b8415a249e933133 100644
index 8884a2471b4b7c5cabf1c0c767710ba69c7ae4ec..4f08f2e40f5bc3bc5a87bf3a34945afdec65f288 100644
--- a/src/main/java/cc/keyimc/keyi/KeyiConfig.java
+++ b/src/main/java/cc/keyimc/keyi/KeyiConfig.java
@@ -149,6 +149,12 @@ public final class KeyiConfig {
@@ -148,4 +148,10 @@ public final class KeyiConfig {
private static void fixes() {
fixTripwireDuping = getBoolean("fixes.fix-tripwire-duping", fixTripwireDuping);
}
+
+ public static boolean useSpigotItemMergingMechanism = true;
+
+ private static void performance() {
+ useSpigotItemMergingMechanism = getBoolean("performance.use-spigot-item-merging-mechanism", useSpigotItemMergingMechanism);
+ }
+
// Suki start - only refresh lootables for players
public static boolean onlyRefreshForPlayers = false;
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index aa1c929d948cea8f6212330f922eb5f1d9b9bb97..bb72741300cedd1c37fc5611c6472292bdf245a1 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Disable arrow despawn counter by default
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index daa437f3aaebed4d917fde65d75a8a941755a764..576a50c0279f5336d606b53aeb2ed76785e1d538 100644
index bb352ed86e4047e38ad27900f72fc0ddb741bf71..2cc8eeedfd5729fd324b10cb4b2a6298dad39e9d 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -116,7 +116,7 @@ public class PurpurWorldConfig {

View File

@@ -7,7 +7,7 @@ Original code by PatinaMC, licensed under GNU General Public License v3.0
You can find the original code on https://github.com/PatinaMC/Patina
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 882512d766bdd52fc6ada18db61d0e7e243ab039..a79aedc82328492629c1347b7154ab087e46d14a 100644
index 77c00de9b94531f8136469e04e535a43829c0a60..e633be38543a6eb4b2e0e1d834996400762b2536 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -387,7 +387,7 @@ public class ServerPlayer extends Player {

View File

@@ -9,7 +9,7 @@ Original code by RelativityMC, licensed under MIT
You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9701a89149cc2bd7330b23c441b51677be0bdc18..0032bd550a398c330e16db8081b8dc8ba21333d2 100644
index 7ef574008f413008427d075860c9eb5debeef4f4..83eece9c61f8316221a304f3dd69a7fe3cce3727 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -399,6 +399,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -34,7 +34,7 @@ index 9701a89149cc2bd7330b23c441b51677be0bdc18..0032bd550a398c330e16db8081b8dc8b
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
synchronized (this.posLock) {
@@ -3821,6 +3829,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3796,6 +3804,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public final void setBoundingBox(AABB boundingBox) {

View File

@@ -89,10 +89,10 @@ index e8efbbeece7e866c6c4d7489677d2d9e15fea4d0..8bc0cb9ad5bb4e76d962ff54305e2c08
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11a61ec29b 100644
index 735e01c550d561aa21c3c8f7f34a495ec3a0ab67..13d86c1fba2377808a5ef1e2820db445383af156 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -330,13 +330,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -328,13 +328,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public MinecraftServer(OptionSet options, DataPackConfig datapackconfiguration, DynamicOps<Tag> registryreadops, Thread thread, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, ChunkProgressListenerFactory worldloadlistenerfactory) {
super("Server");
SERVER = this; // Paper - better singleton
@@ -112,7 +112,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
this.status = new ServerStatus();
this.random = RandomSource.create();
this.port = -1;
@@ -938,9 +938,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -936,9 +936,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
// Paper end
// CraftBukkit end
@@ -124,7 +124,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
MinecraftServer.LOGGER.info("Stopping server");
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Shutdown and don't bother finishing
@@ -1183,18 +1183,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1181,18 +1181,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
// Spigot end
@@ -148,7 +148,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
this.mayHaveDelayedTasks = true;
// Purpur start - tps catchup
if (org.purpurmc.purpur.PurpurConfig.tpsCatchup) {
@@ -1204,8 +1204,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1202,8 +1202,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
// Purpur end - tps catchup
this.waitUntilNextTick();
@@ -159,7 +159,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
this.isReady = true;
JvmProfiler.INSTANCE.onServerTick(this.averageTickTime);
}
@@ -1366,7 +1366,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1364,7 +1364,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error
@@ -168,7 +168,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
super.doRunTask(ticktask);
}
@@ -1410,15 +1410,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1408,15 +1408,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public void onServerExit() {}
public void tickServer(BooleanSupplier shouldKeepTicking) {
@@ -187,7 +187,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
// Paper end
new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper
@@ -1451,7 +1451,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1449,7 +1449,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (playerSaveInterval < 0) {
playerSaveInterval = autosavePeriod;
}
@@ -196,7 +196,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
final boolean fullSave = autosavePeriod > 0 && this.tickCount % autosavePeriod == 0;
try {
this.isSaving = true;
@@ -1466,20 +1466,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1464,20 +1464,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} finally {
this.isSaving = false;
}
@@ -221,7 +221,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
long l = this.tickTimes[this.tickCount % 100] = Util.getNanos() - i;
this.averageTickTime = this.averageTickTime * 0.8F + (float) l / 1000000.0F * 0.19999999F;
@@ -1492,31 +1492,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1490,31 +1490,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper end
this.frameTimer.logFrameDuration(i1 - i);
@@ -264,7 +264,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
// Send time updates to everyone, it will get the right time from the world the player is in.
// Paper start - optimize time updates
for (final ServerLevel world : this.getAllLevels()) {
@@ -1536,10 +1536,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1534,10 +1534,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
// Paper end
@@ -276,7 +276,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
Iterator iterator = this.getAllLevels().iterator(); // Paper - move down
while (iterator.hasNext()) {
ServerLevel worldserver = (ServerLevel) iterator.next();
@@ -1548,28 +1547,28 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1546,28 +1545,28 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.hasRidableMoveEvent = org.purpurmc.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
@@ -312,7 +312,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
} catch (Throwable throwable) {
// Spigot Start
CrashReport crashreport;
@@ -1585,33 +1584,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1583,33 +1582,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
throw new ReportedException(crashreport);
}
@@ -358,7 +358,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
}
public boolean isNetherEnabled() {
@@ -2259,7 +2258,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2257,7 +2256,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
public ProfilerFiller getProfiler() {
@@ -367,7 +367,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
return this.profiler;
}
@@ -2499,7 +2498,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2497,7 +2496,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// CraftBukkit end
private void startMetricsRecordingTick() {
@@ -376,7 +376,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
this.executeBlocking(() -> {
this.saveDebugReport(path.resolve("server"));
@@ -2509,40 +2508,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2507,40 +2506,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.willStartRecordingMetrics = false;
}
@@ -429,7 +429,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
}
public Path getWorldPath(LevelResource worldSavePath) {
@@ -2587,15 +2586,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2585,15 +2584,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
public boolean isTimeProfilerRunning() {
@@ -448,7 +448,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
return EmptyProfileResults.EMPTY;
} else {
ProfileResults methodprofilerresults = this.debugCommandProfiler.stop(Util.getNanos(), this.tickCount);
@@ -2768,7 +2767,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2766,7 +2765,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
return;
}
@@ -457,15 +457,7 @@ index cb2fc1a77d8170772ec4595642d317b04652b293..04a8cc1ec44b474e1048ccb06b4a7c11
try {
for (;;) {
boolean moreTasks = this.tickMidTickTasks();
@@ -2788,14 +2787,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
double overuseCount = (double)overuse/(double)MAX_CHUNK_EXEC_TIME;
- long extraSleep = (long)carpetfixes.helpers.FastMath.round(overuseCount*CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME); // Mirai
+ long extraSleep = (long)Math.round(overuseCount*CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME);
lastMidTickExecute = currTime + extraSleep;
return;
@@ -2793,7 +2792,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
} finally {
@@ -797,24 +789,10 @@ index 9d13ef8c597b9ca11280ad1d3249d13bbab4ac6f..0b75caca3f77980505d0689601d920fb
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e3557647c41c210 100644
index c888e654ab9449bfdc7dfe16078eb0786ae6c15e..71ff2cfc4aba6da71911ea717e3557647c41c210 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -229,13 +229,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
return thr;
}
- // Mirai start
- @Override
- public ProfilerFiller getProfiler() {
- return this.getServer().getProfiler();
- }
- // Mirai end
-
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper
}
@@ -660,12 +653,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -653,12 +653,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
// Paper end - optimise checkDespawn
@@ -830,7 +808,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
this.advanceWeatherCycle();
int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
long j;
@@ -692,32 +685,32 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -685,32 +685,32 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.updateSkyBrightness();
this.tickTime();
@@ -879,7 +857,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
if (flag) {
@@ -725,24 +718,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -718,24 +718,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
if (flag || this.emptyTime++ < 300) {
@@ -911,7 +889,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
if (true || this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(entity.chunkPosition().toLong())) { // Paper - now always true if in the ticking list
Entity entity1 = entity.getVehicle();
@@ -754,7 +747,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -747,7 +747,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
entity.stopRiding();
}
@@ -920,7 +898,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
// Pufferfish start - copied from this.guardEntityTick
try {
this.tickNonPassenger(entity); // Pufferfish - changed
@@ -769,22 +762,22 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -762,22 +762,22 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Paper end
}
// Pufferfish end
@@ -950,7 +928,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
}
@Override
@@ -866,9 +859,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -859,9 +859,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
boolean flag = this.isRaining();
int j = chunkcoordintpair.getMinBlockX();
int k = chunkcoordintpair.getMinBlockZ();
@@ -962,7 +940,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change
if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Pufferfish - replace random with shouldDoLightning
@@ -900,7 +893,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -893,7 +893,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
@@ -971,7 +949,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking // Pufferfish - optimize further random ticking
// Paper start - optimise chunk ticking
this.getRandomBlockPosition(j, 0, k, 15, blockposition);
@@ -936,8 +929,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -929,8 +929,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
// Paper start - optimise random block ticking
@@ -982,7 +960,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
if (randomTickSpeed > 0) {
LevelChunkSection[] sections = chunk.getSections();
int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this);
@@ -971,8 +964,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -964,8 +964,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
// Paper end - optimise random block ticking
@@ -993,7 +971,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
}
public Optional<BlockPos> findLightningRod(BlockPos pos) {
@@ -1264,24 +1257,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1257,24 +1257,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Spigot end
// Paper start- timings
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity);
@@ -1026,7 +1004,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
Iterator iterator = entity.getPassengers().iterator();
while (iterator.hasNext()) {
@@ -1304,17 +1297,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1297,17 +1297,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (passenger instanceof Player || this.entityTickList.contains(passenger)) {
// Paper - EAR 2
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
@@ -1050,7 +1028,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
// Paper start - EAR 2
if (isActive) {
passenger.rideTick();
@@ -1326,7 +1319,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1319,7 +1319,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
vehicle.positionRider(passenger);
}
// Paper end - EAR 2
@@ -1059,7 +1037,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
Iterator iterator = passenger.getPassengers().iterator();
while (iterator.hasNext()) {
@@ -1335,7 +1328,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1328,7 +1328,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(passenger, entity2);
}
@@ -1068,7 +1046,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
}
} else {
passenger.stopRiding();
@@ -1355,14 +1348,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1348,14 +1348,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld()));
}
@@ -1086,7 +1064,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
// Copied from save()
// CraftBukkit start - moved from MinecraftServer.saveChunks
@@ -1374,7 +1367,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1367,7 +1367,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.convertable.saveDataTag(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
}
// CraftBukkit end
@@ -1095,7 +1073,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
}
// Paper end
@@ -1388,7 +1381,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1381,7 +1381,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (!savingDisabled) {
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
@@ -1104,7 +1082,7 @@ index 00fe84ae4fee41b365223f836c82e1688fe322ee..71ff2cfc4aba6da71911ea717e355764
if (progressListener != null) {
progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel"));
}
@@ -1398,11 +1391,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1391,11 +1391,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
progressListener.progressStage(Component.translatable("menu.savingChunks"));
}
@@ -1222,21 +1200,9 @@ index 7094701d213c73ba47ace806962244c10fdf4dda..fcdb9bde8e1605e30dde3e580491522d
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index aa27ab72d30f917ea41045db16b6f59f1442ea77..09ae98db728bade8121587e9ded6f3ab98f3bb30 100644
index 0bb14272d024af90e7aef40f2f694e184af607d3..09ae98db728bade8121587e9ded6f3ab98f3bb30 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -117,9 +117,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public static final int TICKS_PER_DAY = 24000;
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
- protected final List<TickingBlockEntity> blockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedReferenceList.wrapper(Lists.newArrayList()); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper // Jettpack - lithium: HashedReferenceList
+ protected final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper
protected final NeighborUpdater neighborUpdater;
- private final List<TickingBlockEntity> pendingBlockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedReferenceList.wrapper(Lists.newArrayList()); // Jettpack - lithium: HashedReferenceList
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
private boolean tickingBlockEntities;
public final Thread thread;
private final boolean isDebug;
@@ -712,9 +712,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
BlockState iblockdata2 = this.getBlockState(pos);
@@ -1349,33 +1315,19 @@ index 50712b2222703fff01378e2ececb0fc0dba60b65..a182b3c804cf56855e15290f826fdebd
if (entityhuman != null) {
double d2 = entityhuman.distanceToSqr(d0, (double) i, d1);
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 7249fe1d53c22d4164c68cb89b8df95e92873d1b..e0e4a924e926b086699998095a1abddd01d8c002 100644
index 2877441927de3aeba28f5c3dd876e2ae4c15797c..e0e4a924e926b086699998095a1abddd01d8c002 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -53,10 +53,6 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.ticks.LevelChunkTicks;
import net.minecraft.world.ticks.TickContainerAccess;
import org.slf4j.Logger;
-// KeYi start
-import cc.keyimc.keyi.utils.FastRandom;
-import java.util.Random; // KeYi
-// KeYi end
public class LevelChunk extends ChunkAccess {
@@ -934,9 +930,9 @@ public class LevelChunk extends ChunkAccess {
@@ -930,7 +930,7 @@ public class LevelChunk extends ChunkAccess {
this.chunkHolder.getEntityChunk().callEntitiesLoadEvent(); // Paper - rewrite chunk system
if (this.needsDecoration) {
- //try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper // Purpur
+ try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper
this.needsDecoration = false;
- Random random = new FastRandom();
+ java.util.Random random = new java.util.Random();
java.util.Random random = new java.util.Random();
random.setSeed(this.level.getSeed());
long xRand = random.nextLong() / 2L * 2L + 1L;
long zRand = random.nextLong() / 2L * 2L + 1L;
@@ -954,7 +950,7 @@ public class LevelChunk extends ChunkAccess {
@@ -950,7 +950,7 @@ public class LevelChunk extends ChunkAccess {
}
}
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(this.bukkitChunk));
@@ -1384,7 +1336,7 @@ index 7249fe1d53c22d4164c68cb89b8df95e92873d1b..e0e4a924e926b086699998095a1abddd
}
}
}
@@ -1313,10 +1309,10 @@ public class LevelChunk extends ChunkAccess {
@@ -1309,10 +1309,10 @@ public class LevelChunk extends ChunkAccess {
if (LevelChunk.this.isTicking(blockposition)) {
try {
@@ -1398,7 +1350,7 @@ index 7249fe1d53c22d4164c68cb89b8df95e92873d1b..e0e4a924e926b086699998095a1abddd
BlockState iblockdata = LevelChunk.this.getBlockState(blockposition);
if (this.blockEntity.getType().isValid(iblockdata)) {
@@ -1327,7 +1323,7 @@ public class LevelChunk extends ChunkAccess {
@@ -1323,7 +1323,7 @@ public class LevelChunk extends ChunkAccess {
LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), iblockdata});
}
@@ -1407,7 +1359,7 @@ index 7249fe1d53c22d4164c68cb89b8df95e92873d1b..e0e4a924e926b086699998095a1abddd
} catch (Throwable throwable) {
if (throwable instanceof ThreadDeath) throw throwable; // Paper
// Paper start - Prevent tile entity and entity crashes
@@ -1338,7 +1334,7 @@ public class LevelChunk extends ChunkAccess {
@@ -1334,7 +1334,7 @@ public class LevelChunk extends ChunkAccess {
// Paper end
// Spigot start
} finally {
@@ -1417,10 +1369,10 @@ index 7249fe1d53c22d4164c68cb89b8df95e92873d1b..e0e4a924e926b086699998095a1abddd
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index a57d633c439f66cb27209f56abf391e84bbb52c5..ef0f8c37308dc2fa97bff437319a850526e660c2 100644
index 3a67aaa39daf1fb86938f53e129aadfb686583b0..33accb56fbc00560e2f253a2150991331e515858 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -436,38 +436,7 @@ public final class CraftServer implements Server {
@@ -435,38 +435,7 @@ public final class CraftServer implements Server {
if (!pluginFolder.exists()) {
pluginFolder.mkdirs();
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Use cached pool for mob spawning executor
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 04a8cc1ec44b474e1048ccb06b4a7c11a61ec29b..66843d7ca82c4be7f45b7b830f0d45d925a3d504 100644
index 13d86c1fba2377808a5ef1e2820db445383af156..ae95e3af64811f6f149a01b9715d8fdd2c2583fa 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -43,6 +43,7 @@ import java.util.Optional;

View File

@@ -1,12 +1,12 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalgic853 <yuu8583@proton.me>
Date: Mon, 24 Oct 2022 10:52:07 +0800
Date: Fri, 18 Nov 2022 23:39:13 +0800
Subject: [PATCH] Use a faster random implementation
diff --git a/src/main/java/cc/keyimc/keyi/utils/FastRandom.java b/src/main/java/cc/keyimc/keyi/utils/FastRandom.java
new file mode 100644
index 0000000000000000000000000000000000000000..a9b3a467e7dbfdc78c11f04e6bb5a9642c20470c
index 0000000000000000000000000000000000000000..ca75a84c2fe0b163f5618f408372b38e048ae2cd
--- /dev/null
+++ b/src/main/java/cc/keyimc/keyi/utils/FastRandom.java
@@ -0,0 +1,395 @@
@@ -423,29 +423,8 @@ index e5ea9f27a1936ed9e329e74317c91c5df89b9fbd..89a41d396162a1c2eb2df5192b0d888b
private long lastFill = -1;
private long nextRefill = -1;
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/cached_blockpos_iteration/IterateOutwardsCache.java b/src/main/java/me/jellysquid/mods/lithium/common/cached_blockpos_iteration/IterateOutwardsCache.java
index a5d3aa309d3fdaab9e0fea2dfb91a080a3ac1193..384733b2b0bc7c5108ebdc725c0d13548bd349a3 100644
--- a/src/main/java/me/jellysquid/mods/lithium/common/cached_blockpos_iteration/IterateOutwardsCache.java
+++ b/src/main/java/me/jellysquid/mods/lithium/common/cached_blockpos_iteration/IterateOutwardsCache.java
@@ -6,6 +6,7 @@ import java.util.Iterator;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.core.BlockPos;
+import cc.keyimc.keyi.utils.FastRandom; // KeYi
/**
* @author 2No2Name, original implemenation by SuperCoder7979 and Gegy1000
@@ -22,7 +23,7 @@ public class IterateOutwardsCache {
public IterateOutwardsCache(int capacity) {
this.capacity = capacity;
this.table = new ConcurrentHashMap<>(31);
- this.random = new Random();
+ this.random = new FastRandom(); // KeYi - use a faster random
}
private void fillPositionsWithIterateOutwards(LongList entry, int xRange, int yRange, int zRange) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 620173eef4c2f30a97a4c2f8049ea01fcc60d0b2..1ef5f03a332e832817be132bbbf3ac1021f085d1 100644
index e0e4a924e926b086699998095a1abddd01d8c002..f55584f7255012599fdce018b85e2e21e4660849 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -53,6 +53,10 @@ import net.minecraft.world.level.material.Fluids;
@@ -461,7 +440,7 @@ index 620173eef4c2f30a97a4c2f8049ea01fcc60d0b2..1ef5f03a332e832817be132bbbf3ac10
@@ -932,7 +936,7 @@ public class LevelChunk extends ChunkAccess {
if (this.needsDecoration) {
//try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper // Purpur
try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper
this.needsDecoration = false;
- java.util.Random random = new java.util.Random();
+ Random random = new FastRandom();
@@ -469,7 +448,7 @@ index 620173eef4c2f30a97a4c2f8049ea01fcc60d0b2..1ef5f03a332e832817be132bbbf3ac10
long xRand = random.nextLong() / 2L * 2L + 1L;
long zRand = random.nextLong() / 2L * 2L + 1L;
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index fc3442b4c7e1f22080fe6bf36d4fade162d6709e..7de2b353db5b76089c10cba826898bcd228f4ad9 100644
index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..ef8909c9c13c8f46ec6d452f0d14c9a1119e0edf 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -26,6 +26,7 @@ import net.minecraft.nbt.CompoundTag;
@@ -490,7 +469,7 @@ index fc3442b4c7e1f22080fe6bf36d4fade162d6709e..7de2b353db5b76089c10cba826898bcd
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index dabf1649f5bf14ec17dad6d43dcd7e2b7df255d3..ed754df76d3f86e2230c88ebb45125fe6af1e507 100644
index 41fafd4a1583e748d763439e8838739ec1ff8e1d..48c35afdbb8b08dbc1279bc57ea44bccb65b2a8a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -135,6 +135,7 @@ import org.bukkit.util.Consumer;