Faster Sheep.getOffspringColor

This commit is contained in:
Arthur Blanchot
2022-06-29 03:01:17 +02:00
parent 0750e5fe34
commit 64a31b5b50
42 changed files with 245 additions and 96 deletions

View File

@@ -4,7 +4,7 @@ plugins {
java
`maven-publish`
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("io.papermc.paperweight.patcher") version "1.3.8-SNAPSHOT"
id("io.papermc.paperweight.patcher") version "1.3.9-SNAPSHOT"
}
repositories {

View File

@@ -7,7 +7,7 @@ Original code by CaffeineMC, licensed under GNU Lesser General Public License v3
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a42f5e16e18586d4a72cdfd517e7796728701d6c..0968f6b6d32760ceb5717c5f8fc100377f4c2d7d 100644
index f6af6dc1c686d477212cd68031d4983f85234a7f..de9b209597bad45ac1ea918b43745dc92b085082 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3422,6 +3422,8 @@ public abstract class LivingEntity extends Entity {

View File

@@ -7,7 +7,7 @@ Original code by CaffeineMC, licensed under GNU Lesser General Public License v3
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0968f6b6d32760ceb5717c5f8fc100377f4c2d7d..15fc1ccef371bf8b2b27238193f9d6b57e521b4e 100644
index de9b209597bad45ac1ea918b43745dc92b085082..9e71182c927dec5ede91d7e7c6a842e69b10db6a 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2463,6 +2463,8 @@ public abstract class LivingEntity extends Entity {

View File

@@ -7,7 +7,7 @@ Original code by CaffeineMC, licensed under GNU Lesser General Public License v3
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 15fc1ccef371bf8b2b27238193f9d6b57e521b4e..c096b4e83d82518f0cee143496b648e010b72754 100644
index 9e71182c927dec5ede91d7e7c6a842e69b10db6a..858ccbfd456777a61e9579beb997abb568d5b75e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -569,11 +569,11 @@ public abstract class LivingEntity extends Entity {

View File

@@ -42,11 +42,11 @@ index f5aca2054dcad52301b9b99e44fbd3723aabdad7..f120e10679d38f3db22315f16a00622a
// CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
if (this.oldLevel == -1) {
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index 2cd6f76c378f3666617e33a0b7dca439316aa325..e86875be3f0e723d3242c9809cd05e767ee49ea4 100644
index 4ef25b6203371b9c22275e1015ea75d870acf8da..4ace3c19551ea1cc5079d0570f5f0e70f1cae6a5 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -249,4 +249,13 @@ public class MiraiConfig {
riskyMathRoundOpt = getBoolean("use-risky-mathround-opt", riskyMathRoundOpt);
@@ -244,4 +244,13 @@ public class MiraiConfig {
serverMetrics = getBoolean("enable-server-metrics", serverMetrics);
}
+ public static boolean criterionTriggerEnterBlock = true;

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 fc01e48c0e2c7f4e56379cb8b89c78e7a874c053..8f0bc485597167caef4ed01e787181fff0bd2598 100644
index b22e4068407f3012b62683abd060509829e61c62..da94849a59825b6b2ca886df3080d026e1720418 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -283,19 +283,21 @@ public abstract class Player extends LivingEntity {

View File

@@ -34,10 +34,10 @@ index 9fc77dc845fc993ebb9d96f9af107f7e1e8e8a39..6b4370f8dffdaebb861ec59d0dad3fe5
this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2));
// Paper start - remove expensive streams from here
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index e86875be3f0e723d3242c9809cd05e767ee49ea4..e2d86b2845cbc17ef418d4421bde71134f407ae5 100644
index 4ace3c19551ea1cc5079d0570f5f0e70f1cae6a5..4da53712474506e80c265ee38e1e1e88f51e3ec9 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -258,4 +258,9 @@ public class MiraiConfig {
@@ -253,4 +253,9 @@ public class MiraiConfig {
criterionTriggerLocation = getBoolean("criterion-trigger.location", criterionTriggerLocation);
}

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] PaperPR Stop large look changes from crashing the server
Taken from https://github.com/PaperMC/Paper/pull/7459
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index c096b4e83d82518f0cee143496b648e010b72754..a03930ebdb3ebc766db4414eee38c6aa4c39fc56 100644
index 858ccbfd456777a61e9579beb997abb568d5b75e..4a0ef94baec5b16ca0eee8d971851a08038b1825 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3006,37 +3006,12 @@ public abstract class LivingEntity extends Entity {

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] PaperPR Add more collision code skipping logic
Taken from https://github.com/PaperMC/Paper/pull/7581
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a03930ebdb3ebc766db4414eee38c6aa4c39fc56..08e50fb20be2f1a4266c1bfe59eb8fe83c6942ab 100644
index 4a0ef94baec5b16ca0eee8d971851a08038b1825..10fe0a33e7d2663e27413b3affe035e91de37255 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3439,6 +3439,10 @@ public abstract class LivingEntity extends Entity {

View File

@@ -27,10 +27,10 @@ index 67b88da702b780f79c0496cb17f1e6f1f8dd6c2b..712707da510977bfa1ce4b991fd8a8f5
// CraftBukkit start
java.util.Collection<MapDecoration> icons = new java.util.ArrayList<MapDecoration>();
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index e2d86b2845cbc17ef418d4421bde71134f407ae5..02b630ed8ac8ad07b9571dc15d4c18165b7062d6 100644
index 4da53712474506e80c265ee38e1e1e88f51e3ec9..ea398d72cdbec80add81971f3cf34b750e9448ae 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -263,4 +263,9 @@ public class MiraiConfig {
@@ -258,4 +258,9 @@ public class MiraiConfig {
fastSpeedCheck = getBoolean("fast-speed-check", fastSpeedCheck);
}

View File

@@ -8,7 +8,7 @@ the displayed hunger bar never goes down. Hunger (or any related value, includin
should not go down on peaceful. See https://bugs.mojang.com/browse/MC-31819.
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 8f0bc485597167caef4ed01e787181fff0bd2598..4e520a7c5bdf0eb3830905859ea106396fa79653 100644
index da94849a59825b6b2ca886df3080d026e1720418..8d465c3ca7af2a804a4c178f054063d6a1a5ddad 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1911,6 +1911,7 @@ public abstract class Player extends LivingEntity {

View File

@@ -3,6 +3,8 @@ From: Arthur Blanchot <blanchot.arthur@protonmail.ch>
Date: Fri, 24 Jun 2022 21:17:05 +0200
Subject: [PATCH] lithium: world.tick_scheduler
Original license: GPLv3
Original project: https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/world/scheduler/OrderedTickQueue.java b/src/main/java/me/jellysquid/mods/lithium/common/world/scheduler/OrderedTickQueue.java
new file mode 100644

View File

@@ -1,31 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: FX - PR0CESS <fx.e.morin@gmail.com>
Date: Wed, 22 Dec 2021 18:39:21 +0100
Subject: [PATCH] Faster Math.round implementation
From: Arthur Blanchot <blanchot.arthur@protonmail.ch>
Date: Wed, 29 Jun 2022 02:17:00 +0200
Subject: [PATCH] Optimize `Math.round` and `Math.hypot` functions
Original code by fxmorin, licensed under MIT
You can find the original code on https://github.com/fxmorin/carpet-fixes
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..da81a142d2b072f846f9905a0d5b8e293763284a
index 0000000000000000000000000000000000000000..409475deb22ae19d77c9125531ede823997bb452
--- /dev/null
+++ b/src/main/java/carpetfixes/helpers/FastMath.java
@@ -0,0 +1,28 @@
@@ -0,0 +1,59 @@
+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) {
+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) {
+ return a > 0F ? (int)(a + .5F) : (int)(a - .5F);
+ } else {
+ return Math.round(a);
+ }
+ if (wtf.etil.mirai.MiraiConfig.optimizedRound) return a > 0F ? (int)(a + .5F) : (int)(a - .5F);
+ return Math.round(a);
+ }
+
+ /**
@@ -33,16 +35,46 @@ index 0000000000000000000000000000000000000000..da81a142d2b072f846f9905a0d5b8e29
+ * ~1.28x faster than {@link Math#round(double)}
+ */
+ public static long round(double a) {
+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) {
+ return a > 0D ? (long)(a + .5D) : (long)(a - .5D);
+ if (wtf.etil.mirai.MiraiConfig.optimizedRound) return a > 0D ? (long)(a + .5D) : (long)(a - .5D);
+ return Math.round(a);
+ }
+
+ /**
+ * @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 {
+ return Math.round(a);
+ 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/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index bb220f27f5d472514d9a1620a40ed50fcb31ae16..a1aa0265ce807e6f40575094fd84b8aedf2be793 100644
index bb220f27f5d472514d9a1620a40ed50fcb31ae16..9ec0d9c79413654436082aef93c416e7d7fb9125 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -734,12 +734,12 @@ public class PaperCommand extends Command {
@@ -50,18 +82,18 @@ index bb220f27f5d472514d9a1620a40ed50fcb31ae16..a1aa0265ce807e6f40575094fd84b8ae
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])) + "%")
+ text(", progress: ", BLUE), text((int)(carpetfixes.helpers.FastMath.round(100.0 * (double)(relitChunks[0])/(double)pending[0])) + "%") // Mirai
));
},
(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));
+ 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/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
index f9251183df72ddc56662fd3f02acf21641a2200c..ea1bad145e529ac36bf335cf4d5339b2d88b282f 100644
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> {
@@ -69,11 +101,11 @@ index f9251183df72ddc56662fd3f02acf21641a2200c..ea1bad145e529ac36bf335cf4d5339b2
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 );
+ 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..2a38ea32f2d4a01be556fdf11254d5910c54f997 100644
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 {
@@ -81,12 +113,12 @@ index c3e54da4ab6440811aab2f9dd1e218802ac13285..2a38ea32f2d4a01be556fdf11254d591
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),
+ carpetfixes.helpers.FastMath.round(data.getUsedMem() / 1024F / 1024F), // Mirai
used, getTime(m.x)));
}
}
diff --git a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java
index 40447d00aefb5ffedb8a2ee87155a04088f0649f..31cc0a29e89e79f616b3ee329a5528961edaa2de 100644
index 40447d00aefb5ffedb8a2ee87155a04088f0649f..633a6e313174244cf13ed89b53893ea5900e2828 100644
--- a/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java
+++ b/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java
@@ -25,7 +25,7 @@ public class TPSCollector extends LiveCollector {
@@ -95,12 +127,12 @@ index 40447d00aefb5ffedb8a2ee87155a04088f0649f..31cc0a29e89e79f616b3ee329a552896
- this.report(TPS, Math.min(20D, Math.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d));
- this.report(MSPT, (double) Math.round(mspt * 100d) / 100d);
+ this.report(TPS, Math.min(20D, carpetfixes.helpers.FastMath.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d));
+ this.report(MSPT, (double) carpetfixes.helpers.FastMath.round(mspt * 100d) / 100d);
+ this.report(TPS, Math.min(20D, carpetfixes.helpers.FastMath.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d)); // Mirai
+ this.report(MSPT, (double) carpetfixes.helpers.FastMath.round(mspt * 100d) / 100d); // Mirai
}
}
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
index b53402903eb6845df361daf6b05a668608ad7b63..df60ee5ec4f98e815499dd1dfe94a0b62d1f1fbf 100644
index b53402903eb6845df361daf6b05a668608ad7b63..0d43afcdd5db346d0ddf82e06bad5b219721715c 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 {
@@ -108,17 +140,17 @@ index b53402903eb6845df361daf6b05a668608ad7b63..df60ee5ec4f98e815499dd1dfe94a0b6
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);
+ 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);
+ 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/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a578b872a357b19236ef1217344d3cdeffc64f9b..d43aac359f49c0c7e83954277d2eb0871491810d 100644
index a578b872a357b19236ef1217344d3cdeffc64f9b..d565a12648d92b1d446a3b8b38b1e92520954254 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2749,7 +2749,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<Runnab
@@ -126,12 +158,12 @@ index a578b872a357b19236ef1217344d3cdeffc64f9b..d43aac359f49c0c7e83954277d2eb087
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);
+ 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..df2c8dffd626eab0e03b1b62940a52fa83f6edaf 100644
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 {
@@ -139,12 +171,24 @@ index 88f10d729aa1e0a01790521821d691a0ecd373a2..df2c8dffd626eab0e03b1b62940a52fa
// 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
+ 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 a4a6885bea59210192e8a2ce8834372275e7ceb3..6fb805ba6afa000e215e4b7c8da29bf5d8ba7399 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -791,6 +791,7 @@ public class Mth {
}
public static double length(double a, double b) {
+ if (wtf.etil.mirai.MiraiConfig.optimizedHypot) return carpetfixes.helpers.FastMath.hypot(a, b); // Mirai
return Math.sqrt(lengthSquared(a, b));
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e7796728701d6c 100644
index 10fe0a33e7d2663e27413b3affe035e91de37255..64f268e7b0d7029c330036817db4ce086bd336a6 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1496,7 +1496,7 @@ public abstract class LivingEntity extends Entity {
@@ -152,7 +196,7 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
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));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
}
@@ -161,10 +205,10 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
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));
+ ((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));
+ ((ServerPlayer) source.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
}
}
}
@@ -173,10 +217,10 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
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));
+ ((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));
+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); // Mirai
}
}
}
@@ -185,11 +229,11 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
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));
+ ((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));
+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
if (f > 0 || !human) {
@@ -198,7 +242,7 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
((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));
+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); // Mirai
}
}
// CraftBukkit end
@@ -207,61 +251,78 @@ index f6af6dc1c686d477212cd68031d4983f85234a7f..a42f5e16e18586d4a72cdfd517e77967
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));
+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(originalDamage * 10.0F)); // Mirai
}
}
@@ -3007,10 +3007,12 @@ public abstract class LivingEntity extends Entity {
this.level.getProfiler().push("rangeChecks");
// 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.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F;
- this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F;
- this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
+ // Mirai start
+ this.yRotO += carpetfixes.helpers.FastMath.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
+ this.yBodyRotO += carpetfixes.helpers.FastMath.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F;
+ this.xRotO += carpetfixes.helpers.FastMath.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F;
+ this.yHeadRotO += carpetfixes.helpers.FastMath.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
+ // Mirai end
// Paper end
this.level.getProfiler().pop();
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 b22e4068407f3012b62683abd060509829e61c62..fc01e48c0e2c7f4e56379cb8b89c78e7a874c053 100644
index 8d465c3ca7af2a804a4c178f054063d6a1a5ddad..c8fb4679d11c1e046bbe5483f72a7b74f0a36713 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1084,7 +1084,7 @@ public abstract class Player extends LivingEntity {
@@ -1086,7 +1086,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));
+ this.awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); // Mirai
}
if (f != 0.0F) {
@@ -1094,7 +1094,7 @@ public abstract class Player extends LivingEntity {
@@ -1096,7 +1096,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));
+ this.awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); // Mirai
}
}
@@ -1420,7 +1420,7 @@ public abstract class Player extends LivingEntity {
@@ -1422,7 +1422,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));
+ 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);
@@ -1689,29 +1689,29 @@ public abstract class Player extends LivingEntity {
@@ -1691,29 +1691,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);
+ 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);
+ 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);
+ 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
@@ -269,47 +330,47 @@ index b22e4068407f3012b62683abd060509829e61c62..fc01e48c0e2c7f4e56379cb8b89c78e7
} 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));
+ 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);
+ 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);
@@ -1725,10 +1725,10 @@ public abstract class Player extends LivingEntity {
@@ -1727,10 +1727,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);
+ 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);
+ 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);
}
@@ -1739,7 +1739,7 @@ public abstract class Player extends LivingEntity {
@@ -1741,7 +1741,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);
+ 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();
@@ -1766,7 +1766,7 @@ public abstract class Player extends LivingEntity {
@@ -1768,7 +1768,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));
+ 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/level/block/DaylightDetectorBlock.java b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java
index 16504b8be08064e61b013fa943f692816612cbd0..c5b39234822626b4ff948464409ca415250619e9 100644
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 {
@@ -317,12 +378,12 @@ index 16504b8be08064e61b013fa943f692816612cbd0..c5b39234822626b4ff948464409ca415
f += (f1 - f) * 0.2F;
- i = Math.round((float) i * Mth.cos(f));
+ i = carpetfixes.helpers.FastMath.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 264ca51c2f2a5ff69688372b71ad7355366bac1a..01fcbe8445de6d024b17c205d9363faa6b2dfa39 100644
index 264ca51c2f2a5ff69688372b71ad7355366bac1a..22114707a850079e4adcc31775824ccb33c456b1 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -249,8 +249,8 @@ public abstract class ChunkGenerator {
@@ -331,13 +392,13 @@ index 264ca51c2f2a5ff69688372b71ad7355366bac1a..01fcbe8445de6d024b17c205d9363faa
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);
+ int l1 = (int) carpetfixes.helpers.FastMath.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/storage/loot/functions/LootingEnchantFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..f512f1e0c46b96f831fdea3073e57c6bfd9c69eb 100644
index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..fe0bcd4295e96556d1c5282d6acc426980697675 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
@@ -61,7 +61,7 @@ public class LootingEnchantFunction extends LootItemConditionalFunction {
@@ -345,12 +406,12 @@ index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..f512f1e0c46b96f831fdea3073e57c6b
float f = (float) i * this.value.getFloat(context);
- stack.grow(Math.round(f));
+ stack.grow(carpetfixes.helpers.FastMath.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/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 731c7dd15f131dc124be6af8f342b122cb89491b..3ca1a2599a211374cb95e73fdc8c8b3069496660 100644
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 {
@@ -359,13 +420,13 @@ index 731c7dd15f131dc124be6af8f342b122cb89491b..3ca1a2599a211374cb95e73fdc8c8b30
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;
+ boolean bl2 = Math.abs(e - (double)carpetfixes.helpers.FastMath.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 0ecac76577eb440a0c3104ef4603acec826c474d..4813bd6de894d0566e8631d8c71915c38c1da0f8 100644
index 0ecac76577eb440a0c3104ef4603acec826c474d..26ff7f68dacad945095d794c1def4752e0775abb 100644
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
@@ -52,7 +52,7 @@ public class TicksPerSecondCommand extends Command
@@ -373,21 +434,23 @@ index 0ecac76577eb440a0c3104ef4603acec826c474d..4813bd6de894d0566e8631d8c71915c3
{
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
+ + ( ( 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
}
// Yatopia start - Last tick time API
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index 4ef25b6203371b9c22275e1015ea75d870acf8da..2cd6f76c378f3666617e33a0b7dca439316aa325 100644
index ea398d72cdbec80add81971f3cf34b750e9448ae..db805105fd2a9befb1f4e4fd4b917207ca7d82e5 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -244,4 +244,9 @@ public class MiraiConfig {
serverMetrics = getBoolean("enable-server-metrics", serverMetrics);
@@ -263,4 +263,11 @@ public class MiraiConfig {
mapUpdateInterval = getInt("map-update-interval", mapUpdateInterval);
}
+ public static boolean riskyMathRoundOpt = true;
+ private static void fastMathRound() {
+ riskyMathRoundOpt = getBoolean("use-risky-mathround-opt", riskyMathRoundOpt);
+ public static boolean optimizedRound = true;
+ public static boolean optimizedHypot = true;
+ private static void fastMath() {
+ optimizedRound = getBoolean("optimize-math-round", optimizedRound);
+ optimizedHypot = getBoolean("optimize-math-hypot", optimizedHypot);
+ }
+
}

View File

@@ -0,0 +1,84 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Arthur Blanchot <blanchot.arthur@protonmail.ch>
Date: Wed, 29 Jun 2022 02:49:45 +0200
Subject: [PATCH] Faster Sheep.getOffspringColor
Original license: MIT
Original project: https://github.com/fxmorin/carpet-fixes
Copyright (c) 2020 Fx Morin
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 ed289bdc0455e737c79e8630e1cdfdeb957e2c03..4215ff3e536da3384f75cabbcecb82da81ce4d65 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
@@ -367,21 +367,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) {