diff --git a/patches/server/0016-Configurable-max-bees-in-hive.patch b/patches/server/0016-Configurable-max-bees-in-hive.patch index e0a3643..e557b95 100644 --- a/patches/server/0016-Configurable-max-bees-in-hive.patch +++ b/patches/server/0016-Configurable-max-bees-in-hive.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable max bees in hive diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index 5c784e1155c16dbbe1b75bb5bcb3d73793d146a3..8eabe7113822d35ff53390e981ea69ad5f07d67d 100644 +index b05ac56823feaf062b1418c9e6dbe4268225f00f..2d981971497c3f06a3bae7a15679af462f489b6f 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java @@ -43,7 +43,7 @@ public class BeehiveBlockEntity extends BlockEntity { @@ -18,10 +18,10 @@ index 5c784e1155c16dbbe1b75bb5bcb3d73793d146a3..8eabe7113822d35ff53390e981ea69ad public BeehiveBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.BEEHIVE, pos, state); diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java -index 9f775115d5120d3fc514d9c0cea98272feecbb49..458d7aedfd8279f0e581415f350e867672718027 100644 +index 63d750d5858d20304b9608697ae618eb97cb6eb6..667eaabe95e9b44cad64dd5aba5ac693f4d726ed 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java -@@ -194,6 +194,9 @@ public class MiraiConfig { +@@ -189,6 +189,9 @@ public class MiraiConfig { logPlayerLoginLoc = getBoolean("log-player-login-location", logPlayerLoginLoc); } diff --git a/patches/server/0017-Remove-TickTask.patch b/patches/server/0017-Remove-TickTask.patch index 307bb97..b5446c1 100644 --- a/patches/server/0017-Remove-TickTask.patch +++ b/patches/server/0017-Remove-TickTask.patch @@ -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/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 98bebaab40390418681b2ee42af0dd4b14df6330..66b67c42d223dab3daf98e9088f1277b17342ac5 100644 +index 1e02e916815e14bce466bd02d9ffe664d456cfbc..ff048b48ab243513967572872220176d826659fe 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -186,7 +186,7 @@ import org.bukkit.event.server.ServerLoadEvent; @@ -19,7 +19,7 @@ index 98bebaab40390418681b2ee42af0dd4b14df6330..66b67c42d223dab3daf98e9088f1277b private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogManager.getLogger(); -@@ -1368,19 +1368,21 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { return BlockEntityType.TRAPPED_CHEST; 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 02a3e1ced592784b9c66927c76376c7ab413367d..7070dabb09347b98570b7460da712a3b7e621bf7 100644 +index a4344bf2267112e3c1e31c07c9f6b8eae9666947..09159965c77dea23aa11bf5524ac7bffcebd7cc6 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java @@ -26,8 +26,22 @@ import net.minecraft.world.level.gameevent.GameEvent; @@ -2631,10 +2631,10 @@ index 02a3e1ced592784b9c66927c76376c7ab413367d..7070dabb09347b98570b7460da712a3b public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public static final BooleanProperty POWERED = BlockStateProperties.POWERED; diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java -index 58fedd73583f5c8d1c3d3971d994156f67ae082c..b5e0254f043e2d25bcbb98885558c117e2c72c44 100644 +index 726c0fdb46619e0e0c57b7b5a65be4270acdd0eb..4a6ece60ec3084409577e50486dda9707c23e935 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java -@@ -242,4 +242,9 @@ public class MiraiConfig { +@@ -237,4 +237,9 @@ public class MiraiConfig { signAllowColors = getBoolean("sign.allow-colors", signAllowColors); } diff --git a/patches/server/0079-Configurable-enchanting-table-tick.patch b/patches/server/0079-Configurable-enchanting-table-tick.patch index e2d5935..4b5b868 100644 --- a/patches/server/0079-Configurable-enchanting-table-tick.patch +++ b/patches/server/0079-Configurable-enchanting-table-tick.patch @@ -19,10 +19,10 @@ index b03621ebd0a94ab2dceb9006aee43fd5320094e3..7afa4bd52d3816ffd5eba1afeec26abb blockEntity.oRot = blockEntity.rot; Player player = world.getNearestPlayer((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 3.0D, false); diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java -index b5e0254f043e2d25bcbb98885558c117e2c72c44..55a16321d86d7b0c149f799d8f16404455bb30d5 100644 +index 4a6ece60ec3084409577e50486dda9707c23e935..c13fc3c014c6f558c0582aedb221c9236ad0031d 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java -@@ -247,4 +247,9 @@ public class MiraiConfig { +@@ -242,4 +242,9 @@ public class MiraiConfig { alternateCurrent = getBoolean("enable-alternate-current", alternateCurrent); } diff --git a/patches/server/0088-Configurable-server-metrics.patch b/patches/server/0088-Configurable-server-metrics.patch index c70684b..923adc0 100644 --- a/patches/server/0088-Configurable-server-metrics.patch +++ b/patches/server/0088-Configurable-server-metrics.patch @@ -18,10 +18,10 @@ index 2a19037d3ad734d1cf746d02b72926dd702fd23a..0297e176e2e4b29b4aeeaee30d43653b metricsStarted = true; } diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java -index 55a16321d86d7b0c149f799d8f16404455bb30d5..a41334314a731e8ec6dc3efa77aa564446d26ef8 100644 +index c13fc3c014c6f558c0582aedb221c9236ad0031d..a8d9ef7a7fcdfcab468594664d352702ee25406e 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java -@@ -252,4 +252,9 @@ public class MiraiConfig { +@@ -247,4 +247,9 @@ public class MiraiConfig { shouldTickEnchantingTables = getBoolean("tick-enchanting-tables", shouldTickEnchantingTables); } diff --git a/patches/server/0089-Configurable-FastMath.round.patch b/patches/server/0089-Configurable-FastMath.round.patch index 127aff9..309df2b 100644 --- a/patches/server/0089-Configurable-FastMath.round.patch +++ b/patches/server/0089-Configurable-FastMath.round.patch @@ -8,10 +8,10 @@ You can find the original code on https://github.com/fxmorin/carpet-fixes diff --git a/src/main/java/carpetfixes/helpers/FastMath.java b/src/main/java/carpetfixes/helpers/FastMath.java new file mode 100644 -index 0000000000000000000000000000000000000000..265bffa41a748c9d5684973af7309ed7fa37064c +index 0000000000000000000000000000000000000000..da81a142d2b072f846f9905a0d5b8e293763284a --- /dev/null +++ b/src/main/java/carpetfixes/helpers/FastMath.java -@@ -0,0 +1,20 @@ +@@ -0,0 +1,28 @@ +package carpetfixes.helpers; + +public class FastMath { @@ -21,7 +21,11 @@ index 0000000000000000000000000000000000000000..265bffa41a748c9d5684973af7309ed7 + * ~1.25x faster than {@link Math#round(float)} + */ + public static int round(float a) { -+ return a > 0F ? (int)(a + .5F) : (int)(a - .5F); ++ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { ++ return a > 0F ? (int)(a + .5F) : (int)(a - .5F); ++ } else { ++ return Math.round(a); ++ } + } + + /** @@ -29,366 +33,217 @@ index 0000000000000000000000000000000000000000..265bffa41a748c9d5684973af7309ed7 + * ~1.28x faster than {@link Math#round(double)} + */ + public static long round(double a) { -+ return a > 0D ? (long)(a + .5D) : (long)(a - .5D); ++ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { ++ return a > 0D ? (long)(a + .5D) : (long)(a - .5D); ++ } else { ++ return Math.round(a); ++ } + } +} \ 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 7764b1f86aca33dc227bf4357c20839b8820eb67..3f8860e456bd8b841dbe5f624dace4f7d48a235b 100644 +index 7764b1f86aca33dc227bf4357c20839b8820eb67..2e141e7b85ef54a084698b5a920b85212271fce8 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java -@@ -723,14 +723,30 @@ public class PaperCommand extends Command { - lightengine.relight(chunks, - (ChunkPos chunkPos) -> { +@@ -725,12 +725,12 @@ public class PaperCommand extends Command { ++relitChunks[0]; -- sender.getBukkitEntity().sendMessage( -- ChatColor.BLUE + "Relit chunk " + ChatColor.DARK_AQUA + chunkPos + ChatColor.BLUE + + sender.getBukkitEntity().sendMessage( + ChatColor.BLUE + "Relit chunk " + ChatColor.DARK_AQUA + chunkPos + ChatColor.BLUE + - ", progress: " + ChatColor.DARK_AQUA + (int)(Math.round(100.0 * (double)(relitChunks[0])/(double)pending[0])) + "%" -- ); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ sender.getBukkitEntity().sendMessage( -+ ChatColor.BLUE + "Relit chunk " + ChatColor.DARK_AQUA + chunkPos + ChatColor.BLUE + -+ ", progress: " + ChatColor.DARK_AQUA + (int)(carpetfixes.helpers.FastMath.round(100.0 * (double)(relitChunks[0])/(double)pending[0])) + "%" -+ ); -+ } else { -+ sender.getBukkitEntity().sendMessage( -+ ChatColor.BLUE + "Relit chunk " + ChatColor.DARK_AQUA + chunkPos + ChatColor.BLUE + -+ ", progress: " + ChatColor.DARK_AQUA + (int)(Math.round(100.0 * (double)(relitChunks[0])/(double)pending[0])) + "%" -+ ); -+ } -+ // Mirai end ++ ", progress: " + ChatColor.DARK_AQUA + (int)(carpetfixes.helpers.FastMath.round(100.0 * (double)(relitChunks[0])/(double)pending[0])) + "%" + ); }, (int totalRelit) -> { final long end = System.nanoTime(); - final long diff = Math.round(1.0e-6*(end - start)); -+ // Mirai start -+ final long diff; -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ diff = carpetfixes.helpers.FastMath.round(1.0e-6*(end - start)); -+ } else { -+ diff = Math.round(1.0e-6*(end - start)); -+ } -+ // Mirai end ++ final long diff = carpetfixes.helpers.FastMath.round(1.0e-6*(end - start)); sender.getBukkitEntity().sendMessage( ChatColor.BLUE + "Relit " + ChatColor.DARK_AQUA + totalRelit + ChatColor.BLUE + " chunks. Took " + ChatColor.DARK_AQUA + 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..d87ba2e05870ad9ebb7dd8374b7206bdb4c4e4cb 100644 +index f9251183df72ddc56662fd3f02acf21641a2200c..ea1bad145e529ac36bf335cf4d5339b2d88b282f 100644 --- a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java +++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java -@@ -81,6 +81,12 @@ public class RAMDetails extends JList { +@@ -81,6 +81,6 @@ public class RAMDetails extends JList { } private static String format(double tps) { - return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( carpetfixes.helpers.FastMath.round( tps * 100.0 ) / 100.0, 20.0 ); -+ } else { -+ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); -+ } -+ // Mirai end ++ return ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( carpetfixes.helpers.FastMath.round( tps * 100.0 ) / 100.0, 20.0 ); } } diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java -index c3e54da4ab6440811aab2f9dd1e218802ac13285..abaee3564a6187dd3ddb5fe63ae4689469474ae7 100644 +index c3e54da4ab6440811aab2f9dd1e218802ac13285..2a38ea32f2d4a01be556fdf11254d5910c54f997 100644 --- a/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java +++ b/src/main/java/com/destroystokyo/paper/gui/RAMGraph.java -@@ -127,9 +127,17 @@ public class RAMGraph extends JComponent { - graphics.drawOval(m.x - 2, 100 - used - 2, 5, 5); +@@ -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("Used: %s mb (%s%%)
%s", + setToolTipText(String.format("Used: %s mb (%s%%)
%s", - Math.round(data.getUsedMem() / 1024F / 1024F), -- used, getTime(m.x))); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ setToolTipText(String.format("Used: %s mb (%s%%)
%s", -+ carpetfixes.helpers.FastMath.round(data.getUsedMem() / 1024F / 1024F), -+ used, getTime(m.x))); -+ } else { -+ setToolTipText(String.format("Used: %s mb (%s%%)
%s", -+ Math.round(data.getUsedMem() / 1024F / 1024F), -+ used, getTime(m.x))); -+ } -+ // Mirai end ++ carpetfixes.helpers.FastMath.round(data.getUsedMem() / 1024F / 1024F), + 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..c087b864ca193eb5ecf232b63da30349cf08d61d 100644 +index 40447d00aefb5ffedb8a2ee87155a04088f0649f..31cc0a29e89e79f616b3ee329a5528961edaa2de 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,14 @@ public class TPSCollector extends LiveCollector { +@@ -25,7 +25,7 @@ public class TPSCollector extends LiveCollector { long[] times = MinecraftServer.getServer().tickTimes5s.getTimes(); double mspt = ((double) Arrays.stream(times).sum() / (double) times.length) * 1.0E-6D; - this.report(TPS, Math.min(20D, Math.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d)); - this.report(MSPT, (double) Math.round(mspt * 100d) / 100d); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ 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); -+ } else { -+ this.report(TPS, Math.min(20D, Math.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d)); -+ this.report(MSPT, (double) Math.round(mspt * 100d) / 100d); -+ } -+ // Mirai end ++ 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); } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0f69380a5c6d4a2ac1aed2185122ec11c2ed4720..cbed49b6bdc251388579cbdfe2d1c911283c3212 100644 +index 744b39a86ab02350e36b16036cf3f82d0be1dd86..4f8c0c69a7492ba183f436d4062df177d9c7a9ec 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -393,7 +393,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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 -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ 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 -+ } else { -+ 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 -+ } -+ // Mirai end ++ 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 } // Paper end } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index fcf6606d7fde0a9f93a2bd1a8e20f8f6ddb9374b..9f33aeeedd03746cdc26709cd3593f9e4078aad8 100644 +index fcf6606d7fde0a9f93a2bd1a8e20f8f6ddb9374b..9373e4ce1061d5cb3a2d22272671c668614dd4a8 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1473,7 +1473,13 @@ public abstract class LivingEntity extends Entity { +@@ -1473,7 +1473,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); -+ } else { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(f2 * 10.0F)); -+ } -+ // Mirai end ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); } } -@@ -1985,11 +1991,21 @@ public abstract class LivingEntity extends Entity { - float f3 = f2 - amount; +@@ -1986,9 +1986,9 @@ public abstract class LivingEntity extends Entity { if (f3 > 0.0F && f3 < 3.4028235E37F) { -- if (this instanceof ServerPlayer) { + if (this instanceof ServerPlayer) { - ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); -- } else if (source.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); + } else if (source.getEntity() instanceof ServerPlayer) { - ((ServerPlayer) source.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); -+ } else if (source.getEntity() instanceof ServerPlayer) { -+ ((ServerPlayer) source.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); -+ } -+ } else { -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); -+ } 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 end } } - -@@ -2097,11 +2113,21 @@ public abstract class LivingEntity extends Entity { - if (event.getDamage(DamageModifier.RESISTANCE) < 0) { +@@ -2098,9 +2098,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) { + if (this instanceof ServerPlayer) { - ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); -- } else if (damagesource.getEntity() instanceof ServerPlayer) { ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); + } else if (damagesource.getEntity() instanceof ServerPlayer) { - ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); -+ } else if (damagesource.getEntity() instanceof ServerPlayer) { -+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_RESISTED, carpetfixes.helpers.FastMath.round(f3 * 10.0F)); -+ } -+ } else { -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_RESISTED, Math.round(f3 * 10.0F)); -+ } 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 end } } - -@@ -2132,10 +2158,22 @@ public abstract class LivingEntity extends Entity { +@@ -2132,10 +2132,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); -+ } else { -+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); -+ } -+ // Mirai end ++ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); } if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof ServerPlayer) { - ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); -+ } else { -+ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); -+ } -+ // Mirai end ++ ((ServerPlayer) damagesource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); } if (f > 0 || !human) { -@@ -2143,7 +2181,13 @@ public abstract class LivingEntity extends Entity { +@@ -2143,7 +2143,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); -+ } else { -+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, Math.round(f * 10.0F)); -+ } -+ // Mirai end ++ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); } } // CraftBukkit end -@@ -2165,7 +2209,13 @@ public abstract class LivingEntity extends Entity { +@@ -2165,7 +2165,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(originalDamage * 10.0F)); -+ } else { -+ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); -+ } -+ // Mirai end ++ ((ServerPlayer) this).awardStat(Stats.DAMAGE_BLOCKED_BY_SHIELD, carpetfixes.helpers.FastMath.round(originalDamage * 10.0F)); } } 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 b871d89d16e0bb08cc8ce87e74ced974734be418..fda2f91ef20542cc11037c9bf74f71bd17061d49 100644 +index b871d89d16e0bb08cc8ce87e74ced974734be418..87689c468b8e4d2498584fca90738f82fa46d78a 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1026,7 +1026,13 @@ public abstract class Player extends LivingEntity { +@@ -1026,7 +1026,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ this.awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); -+ } else { -+ this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); -+ } -+ // Mirai end ++ this.awardStat(Stats.DAMAGE_ABSORBED, carpetfixes.helpers.FastMath.round(f2 * 10.0F)); } if (f != 0.0F) { -@@ -1036,7 +1042,13 @@ public abstract class Player extends LivingEntity { +@@ -1036,7 +1036,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ this.awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); -+ } else { -+ this.awardStat(Stats.DAMAGE_TAKEN, Math.round(f * 10.0F)); -+ } -+ // Mirai end ++ this.awardStat(Stats.DAMAGE_TAKEN, carpetfixes.helpers.FastMath.round(f * 10.0F)); } } -@@ -1362,7 +1374,13 @@ public abstract class Player extends LivingEntity { +@@ -1362,7 +1362,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ this.awardStat(Stats.DAMAGE_DEALT, carpetfixes.helpers.FastMath.round(f5 * 10.0F)); -+ } else { -+ this.awardStat(Stats.DAMAGE_DEALT, Math.round(f5 * 10.0F)); -+ } -+ // Mirai end ++ this.awardStat(Stats.DAMAGE_DEALT, carpetfixes.helpers.FastMath.round(f5 * 10.0F)); 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); -@@ -1626,29 +1644,59 @@ public abstract class Player extends LivingEntity { +@@ -1626,29 +1626,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); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); 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); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); 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); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); 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 @@ -396,190 +251,118 @@ index b871d89d16e0bb08cc8ce87e74ced974734be418..fda2f91ef20542cc11037c9bf74f71bd } else if (this.onClimbable()) { if (dy > 0.0D) { - this.awardStat(Stats.CLIMB_ONE_CM, (int) Math.round(dy * 100.0D)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ this.awardStat(Stats.CLIMB_ONE_CM, (int) carpetfixes.helpers.FastMath.round(dy * 100.0D)); -+ } else { -+ this.awardStat(Stats.CLIMB_ONE_CM, (int) Math.round(dy * 100.0D)); -+ } -+ // Mirai end ++ this.awardStat(Stats.CLIMB_ONE_CM, (int) carpetfixes.helpers.FastMath.round(dy * 100.0D)); } } else if (this.onGround) { - i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); if (i > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, i); -@@ -1662,10 +1710,22 @@ public abstract class Player extends LivingEntity { +@@ -1662,10 +1662,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); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); this.awardStat(Stats.AVIATE_ONE_CM, i); } else { - i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dz * dz) * 100.0F); if (i > 25) { this.awardStat(Stats.FLY_ONE_CM, i); } -@@ -1676,7 +1736,14 @@ public abstract class Player extends LivingEntity { +@@ -1676,7 +1676,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); -+ // Mirai start -+ int i; -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } else { -+ i = Math.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); -+ } -+ // Mirai end ++ int i = carpetfixes.helpers.FastMath.round((float) Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (i > 0) { Entity entity = this.getVehicle(); -@@ -1703,7 +1770,13 @@ public abstract class Player extends LivingEntity { +@@ -1703,7 +1703,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)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ this.awardStat(Stats.FALL_ONE_CM, (int) carpetfixes.helpers.FastMath.round((double) fallDistance * 100.0D)); -+ } else { -+ this.awardStat(Stats.FALL_ONE_CM, (int) Math.round((double) fallDistance * 100.0D)); -+ } -+ // Mirai end ++ this.awardStat(Stats.FALL_ONE_CM, (int) carpetfixes.helpers.FastMath.round((double) fallDistance * 100.0D)); } return super.causeFallDamage(fallDistance, damageMultiplier, damageSource); 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 7bc5aa35b52de0027cf58a6127a9903464ccaf47..f34fe699ecfbe1531ba793a0baede5fc49591c48 100644 +index 7bc5aa35b52de0027cf58a6127a9903464ccaf47..eee325b78f92070acac95d40ce01e13383ba9fde 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -@@ -345,7 +345,13 @@ public class EnchantmentHelper { +@@ -345,7 +345,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); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ level = Mth.clamp(carpetfixes.helpers.FastMath.round((float)level + (float)level * f), 1, Integer.MAX_VALUE); -+ } else { -+ level = Mth.clamp(Math.round((float)level + (float)level * f), 1, Integer.MAX_VALUE); -+ } -+ // Mirai end ++ level = Mth.clamp(carpetfixes.helpers.FastMath.round((float)level + (float)level * f), 1, Integer.MAX_VALUE); List 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 d212774a4e7c578683394fb4a6c90ce5ce875711..89288c924fd1a024e2eab5119ce7888f6693dc25 100644 +index d212774a4e7c578683394fb4a6c90ce5ce875711..9d2c7ee01d73f54fc24bd7c2b8dc7629c417c3e5 100644 --- a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java -@@ -69,7 +69,13 @@ public class DaylightDetectorBlock extends BaseEntityBlock implements IBlock { +@@ -69,7 +69,7 @@ public class DaylightDetectorBlock extends BaseEntityBlock implements IBlock { float f1 = f < 3.1415927F ? 0.0F : 6.2831855F; f += (f1 - f) * 0.2F; - i = Math.round((float) i * Mth.cos(f)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ i = carpetfixes.helpers.FastMath.round((float) i * Mth.cos(f)); -+ } else { -+ i = Math.round((float) i * Mth.cos(f)); -+ } -+ // Mirai end ++ i = carpetfixes.helpers.FastMath.round((float) i * Mth.cos(f)); } i = Mth.clamp(i, (int) 0, (int) 15); 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..58ca673fb7b9c87ccea67631e3b808da9718330e 100644 +index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..f512f1e0c46b96f831fdea3073e57c6bfd9c69eb 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,13 @@ public class LootingEnchantFunction extends LootItemConditionalFunction { +@@ -61,7 +61,7 @@ public class LootingEnchantFunction extends LootItemConditionalFunction { float f = (float) i * this.value.getFloat(context); - stack.grow(Math.round(f)); -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ stack.grow(carpetfixes.helpers.FastMath.round(f)); -+ } else { -+ stack.grow(Math.round(f)); -+ } -+ // Mirai end ++ stack.grow(carpetfixes.helpers.FastMath.round(f)); 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..7a44d9905523d21bb13ebd2edf177175b66a7e52 100644 +index 731c7dd15f131dc124be6af8f342b122cb89491b..3ca1a2599a211374cb95e73fdc8c8b3069496660 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,17 @@ public final class Shapes { +@@ -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; -+ // Mirai start -+ boolean bl; -+ boolean bl2; -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ bl = Math.abs(d - (double)carpetfixes.helpers.FastMath.round(d)) < 1.0E-7D * (double)j; -+ bl2 = Math.abs(e - (double)carpetfixes.helpers.FastMath.round(e)) < 1.0E-7D * (double)j; -+ } else { -+ bl = Math.abs(d - (double)Math.round(d)) < 1.0E-7D * (double)j; -+ bl2 = Math.abs(e - (double)Math.round(e)) < 1.0E-7D * (double)j; -+ } -+ // Mirai end ++ 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; 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..4ca3e92765426e9d80796c97d1af7c14fbe1f1c3 100644 +index 0ecac76577eb440a0c3104ef4603acec826c474d..4813bd6de894d0566e8631d8c71915c38c1da0f8 100644 --- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java +++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java -@@ -51,8 +51,15 @@ public class TicksPerSecondCommand extends Command - private boolean hasShownMemoryWarning; // Paper +@@ -52,7 +52,7 @@ 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() + 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 -+ // Mirai start -+ if (wtf.etil.mirai.MiraiConfig.riskyMathRoundOpt) { -+ return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString() -+ + ( ( 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 -+ } else { -+ 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 -+ } -+ // Mirai end ++ + ( ( 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 } // 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 a41334314a731e8ec6dc3efa77aa564446d26ef8..f4e4ace7dbad9fcbda2537dc024377d1f0770ebc 100644 +index a8d9ef7a7fcdfcab468594664d352702ee25406e..3da87aeb0ea91096a00c9acd19ca8cbb4c209d53 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java -@@ -257,4 +257,9 @@ public class MiraiConfig { +@@ -252,4 +252,9 @@ public class MiraiConfig { serverMetrics = getBoolean("enable-server-metrics", serverMetrics); } diff --git a/patches/server/0090-lithium-tag.patch b/patches/server/0090-lithium-tag.patch deleted file mode 100644 index e0bdc52..0000000 --- a/patches/server/0090-lithium-tag.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: JellySquid -Date: Wed, 23 Sep 2020 16:33:58 +0200 -Subject: [PATCH] lithium: tag - -Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0 -You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) - -diff --git a/src/main/java/net/minecraft/tags/SetTag.java b/src/main/java/net/minecraft/tags/SetTag.java -index d0c4a1dd2b11cfdbd3972dec5b5622e2f013ab48..9444e3dcdf3fa307c93adb2f790876fcd9ad88e7 100644 ---- a/src/main/java/net/minecraft/tags/SetTag.java -+++ b/src/main/java/net/minecraft/tags/SetTag.java -@@ -3,6 +3,8 @@ package net.minecraft.tags; - import com.google.common.annotations.VisibleForTesting; - import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableSet; -+import it.unimi.dsi.fastutil.objects.ReferenceArraySet; // Mirai -+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // Mirai - import java.util.List; - import java.util.Set; - -@@ -14,8 +16,14 @@ public class SetTag implements Tag { - - protected SetTag(Set values, Class type) { - this.closestCommonSuperType = type; -- this.values = values; - this.valuesList = ImmutableList.copyOf(values); -+ // Mirai start -+ if (values.size() <= 3) { -+ this.values = new ReferenceArraySet<>(values); -+ } else { -+ this.values = new ReferenceOpenHashSet<>(values); -+ } -+ // Mirai end - } - - public static SetTag empty() {