From 2549f7a39629ccbb7f9839696a8183da36307280 Mon Sep 17 00:00:00 2001 From: nostalgic853 Date: Mon, 24 Oct 2022 11:14:25 +0800 Subject: [PATCH] Faster Sheep.getOffspringColor method --- ...ches.patch => 0004-JettPack-patches.patch} | 0 ...-Patches.patch => 0005-Suki-Patches.patch} | 10 +- ...patch => 0006-Lithium-optimizations.patch} | 4 +- ...h => 0007-CarpetFixes-optimizations.patch} | 107 ++++++++++++++++-- ...ns.patch => 0008-C2ME-optimizations.patch} | 0 ...09-Use-our-logo-instead-of-Purpur-s.patch} | 0 ... => 0010-Smarter-statistics-ticking.patch} | 2 +- ...orts.patch => 0011-Smooth-Teleports.patch} | 0 ...heck.patch => 0012-Fast-speed-check.patch} | 0 ...ch => 0013-PaperPR-Optimize-VarInts.patch} | 0 ...s.patch => 0014-Options-of-warnings.patch} | 6 +- 11 files changed, 106 insertions(+), 23 deletions(-) rename patches/server/{0006-JettPack-patches.patch => 0004-JettPack-patches.patch} (100%) rename patches/server/{0014-Suki-Patches.patch => 0005-Suki-Patches.patch} (99%) rename patches/server/{0004-Lithium-optimizations.patch => 0006-Lithium-optimizations.patch} (99%) rename patches/server/{0010-Optimize-Math.round-and-Math.hypot-functions.patch => 0007-CarpetFixes-optimizations.patch} (86%) rename patches/server/{0007-C2ME-optimizations.patch => 0008-C2ME-optimizations.patch} (100%) rename patches/server/{0005-Use-our-logo-instead-of-Purpur-s.patch => 0009-Use-our-logo-instead-of-Purpur-s.patch} (100%) rename patches/server/{0008-Smarter-statistics-ticking.patch => 0010-Smarter-statistics-ticking.patch} (95%) rename patches/server/{0009-Smooth-Teleports.patch => 0011-Smooth-Teleports.patch} (100%) rename patches/server/{0011-Fast-speed-check.patch => 0012-Fast-speed-check.patch} (100%) rename patches/server/{0012-PaperPR-Optimize-VarInts.patch => 0013-PaperPR-Optimize-VarInts.patch} (100%) rename patches/server/{0013-Options-of-warnings.patch => 0014-Options-of-warnings.patch} (95%) diff --git a/patches/server/0006-JettPack-patches.patch b/patches/server/0004-JettPack-patches.patch similarity index 100% rename from patches/server/0006-JettPack-patches.patch rename to patches/server/0004-JettPack-patches.patch diff --git a/patches/server/0014-Suki-Patches.patch b/patches/server/0005-Suki-Patches.patch similarity index 99% rename from patches/server/0014-Suki-Patches.patch rename to patches/server/0005-Suki-Patches.patch index 8ab035a..9cebb93 100644 --- a/patches/server/0014-Suki-Patches.patch +++ b/patches/server/0005-Suki-Patches.patch @@ -340,7 +340,7 @@ index 5962f7a2b185d7d54a0f9e341a4fdf6e6f1c1ec5..8c80520396bc7e34bac25354c1fcdb38 worldUpgrader.convert(); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index a444c8c57a2ab16eba45b0379841a69ff60a5586..ede16b015b9dde07a7346e0bffde53082145798b 100644 +index 13c9cddf7ac0af16676050e3bcdf22b7475a0387..74d361e7e96708653378b27d5c81a11c46033bc2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -294,6 +294,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { // Holder holder = worlddimension.typeHolder(); // CraftBukkit - decompile error // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error @@ -497,7 +497,7 @@ index c9def2202d7c2a523858ec124df2beaf994d9888..3a7bcee2e4b1c4ef2ba303b0200ae846 } 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/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 9f0126aedb94f74d01dc47112496160cc4e1f02c..dc3f2b26e19619adf80827d26b95209ded973c2a 100644 +index cf8693d02de53f1e02d55936f889c5724889e3f5..a6c58a6f2a69c4783570c29d300dd996c01c014e 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -172,7 +172,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { diff --git a/patches/server/0004-Lithium-optimizations.patch b/patches/server/0006-Lithium-optimizations.patch similarity index 99% rename from patches/server/0004-Lithium-optimizations.patch rename to patches/server/0006-Lithium-optimizations.patch index a8bfb5f..adbe0d1 100644 --- a/patches/server/0004-Lithium-optimizations.patch +++ b/patches/server/0006-Lithium-optimizations.patch @@ -1083,7 +1083,7 @@ index 6c27b22dd1d497687c0f4d3835e34149bcf952c1..445f21c3764d148de937f558e3f087ae public static Direction getNearest(double x, double y, double z) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 92e7ba78e18efb8263475ecc076bc49e88b85e84..2a9219e0139670674319a7cf17ad664582b42715 100644 +index f13170b77f69c3ef31fb145ec244b112600b8a45..ba95c8ba2fdcb73065c2fc219f94528239751f33 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -227,6 +227,13 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1662,7 +1662,7 @@ index 17e869074b8cf29a8c3280499a27e95179896750..97a5aec7da267b8b9f6d191c871316cc // Pufferfish start int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index cf8693d02de53f1e02d55936f889c5724889e3f5..9f0126aedb94f74d01dc47112496160cc4e1f02c 100644 +index a6c58a6f2a69c4783570c29d300dd996c01c014e..dc3f2b26e19619adf80827d26b95209ded973c2a 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 { diff --git a/patches/server/0010-Optimize-Math.round-and-Math.hypot-functions.patch b/patches/server/0007-CarpetFixes-optimizations.patch similarity index 86% rename from patches/server/0010-Optimize-Math.round-and-Math.hypot-functions.patch rename to patches/server/0007-CarpetFixes-optimizations.patch index fb0e3eb..d9fa101 100644 --- a/patches/server/0010-Optimize-Math.round-and-Math.hypot-functions.patch +++ b/patches/server/0007-CarpetFixes-optimizations.patch @@ -1,7 +1,16 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: etil2jz <81570777+etil2jz@users.noreply.github.com> -Date: Wed, 29 Jun 2022 02:17:00 +0200 -Subject: [PATCH] Optimize `Math.round` and `Math.hypot` functions +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 @@ -148,10 +157,10 @@ index e3e80db89c18588322ffdaa0f9fd85e398cb1471..d947011b80ee14e7aaf74af3d9081fc7 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 13c9cddf7ac0af16676050e3bcdf22b7475a0387..a444c8c57a2ab16eba45b0379841a69ff60a5586 100644 +index 74d361e7e96708653378b27d5c81a11c46033bc2..ede16b015b9dde07a7346e0bffde53082145798b 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 { ++ 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 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 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a334f3a7030 100644 +index e87a436711e179a4384630de41188c09a75a7f0d..5668e6fa7f560199c352dbed629dbc6897d468a7 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1128,7 +1128,7 @@ public abstract class Player extends LivingEntity { +@@ -1126,7 +1126,7 @@ public abstract class Player extends LivingEntity { float f2 = f1 - f; if (f2 > 0.0F && f2 < 3.4028235E37F) { @@ -285,7 +368,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 } if (f != 0.0F) { -@@ -1138,7 +1138,7 @@ public abstract class Player extends LivingEntity { +@@ -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) { @@ -294,7 +377,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 } } -@@ -1464,7 +1464,7 @@ public abstract class Player extends LivingEntity { +@@ -1462,7 +1462,7 @@ public abstract class Player extends LivingEntity { if (target instanceof LivingEntity) { float f5 = f3 - ((LivingEntity) target).getHealth(); @@ -303,7 +386,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 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); -@@ -1737,29 +1737,29 @@ public abstract class Player extends LivingEntity { +@@ -1735,29 +1735,29 @@ public abstract class Player extends LivingEntity { int i; if (this.isSwimming()) { @@ -338,7 +421,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 if (i > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, i); -@@ -1773,10 +1773,10 @@ public abstract class Player extends LivingEntity { +@@ -1771,10 +1771,10 @@ public abstract class Player extends LivingEntity { } } } else if (this.isFallFlying()) { @@ -351,7 +434,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 if (i > 25) { this.awardStat(Stats.FLY_ONE_CM, i); } -@@ -1787,7 +1787,7 @@ public abstract class Player extends LivingEntity { +@@ -1785,7 +1785,7 @@ public abstract class Player extends LivingEntity { public void checkRidingStatistics(double dx, double dy, double dz) { if (this.isPassenger()) { @@ -360,7 +443,7 @@ index 97668eee40bff129c0a983a6596d0415ddb97b4b..5a17c5df95390120bdd36c86dcd14a33 if (i > 0) { Entity entity = this.getVehicle(); -@@ -1814,7 +1814,7 @@ public abstract class Player extends LivingEntity { +@@ -1812,7 +1812,7 @@ public abstract class Player extends LivingEntity { return false; } else { if (fallDistance >= 2.0F) { diff --git a/patches/server/0007-C2ME-optimizations.patch b/patches/server/0008-C2ME-optimizations.patch similarity index 100% rename from patches/server/0007-C2ME-optimizations.patch rename to patches/server/0008-C2ME-optimizations.patch diff --git a/patches/server/0005-Use-our-logo-instead-of-Purpur-s.patch b/patches/server/0009-Use-our-logo-instead-of-Purpur-s.patch similarity index 100% rename from patches/server/0005-Use-our-logo-instead-of-Purpur-s.patch rename to patches/server/0009-Use-our-logo-instead-of-Purpur-s.patch diff --git a/patches/server/0008-Smarter-statistics-ticking.patch b/patches/server/0010-Smarter-statistics-ticking.patch similarity index 95% rename from patches/server/0008-Smarter-statistics-ticking.patch rename to patches/server/0010-Smarter-statistics-ticking.patch index b1c42bc..c647bb2 100644 --- a/patches/server/0008-Smarter-statistics-ticking.patch +++ b/patches/server/0010-Smarter-statistics-ticking.patch @@ -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 e87a436711e179a4384630de41188c09a75a7f0d..97668eee40bff129c0a983a6596d0415ddb97b4b 100644 +index 5668e6fa7f560199c352dbed629dbc6897d468a7..5a17c5df95390120bdd36c86dcd14a334f3a7030 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 { diff --git a/patches/server/0009-Smooth-Teleports.patch b/patches/server/0011-Smooth-Teleports.patch similarity index 100% rename from patches/server/0009-Smooth-Teleports.patch rename to patches/server/0011-Smooth-Teleports.patch diff --git a/patches/server/0011-Fast-speed-check.patch b/patches/server/0012-Fast-speed-check.patch similarity index 100% rename from patches/server/0011-Fast-speed-check.patch rename to patches/server/0012-Fast-speed-check.patch diff --git a/patches/server/0012-PaperPR-Optimize-VarInts.patch b/patches/server/0013-PaperPR-Optimize-VarInts.patch similarity index 100% rename from patches/server/0012-PaperPR-Optimize-VarInts.patch rename to patches/server/0013-PaperPR-Optimize-VarInts.patch diff --git a/patches/server/0013-Options-of-warnings.patch b/patches/server/0014-Options-of-warnings.patch similarity index 95% rename from patches/server/0013-Options-of-warnings.patch rename to patches/server/0014-Options-of-warnings.patch index c2b978a..c556136 100644 --- a/patches/server/0013-Options-of-warnings.patch +++ b/patches/server/0014-Options-of-warnings.patch @@ -30,7 +30,7 @@ index bc9403d002ef24e71be67a962d099f5d73db9540..5582c15a37fbbf74d2039ba15d67684f } \ 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 ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a0032156203cdf9c9 100644 +index 9227cff62d675703785ad2eaebf6dcbb5adfbaa7..3e7dd41555263e8361db08d1380c767fe0ba8886 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -185,7 +185,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -42,7 +42,7 @@ index ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a00321562 DedicatedServer.LOGGER.warn("****************************"); DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); -@@ -326,10 +326,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -330,10 +330,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // CraftBukkit end if (!this.usesAuthentication()) { @@ -61,7 +61,7 @@ index ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a00321562 DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord or Velocity, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); // Purpur DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information."); } else { -@@ -337,7 +342,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -341,7 +346,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.warn("You will not be offered any support as long as the server allows offline-mode players to join."); // Purpur } // Spigot end