From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 19 Jan 2022 16:55:38 -0700 Subject: [PATCH] Fast speed check Original code by NFT-Worlds, licensed under GNU General Public License v3.0 You can find the original code on https://github.com/NFT-Worlds/Server etil2jz's note: NFT-Worlds is related to Stellar devs, known for countless paid forks mostly taking open source patches, doing questionable/buggy ones, and claiming breathtaking performance improvements. Never ever pay for any of those Spigot forks! diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 6bc313aa05d572236f05d0960fde0f27b9f93d50..9bdcad2b05367a8dcb519a2db8c4efea94a4d21c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1205,7 +1205,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } this.tryCheckInsideBlocks(); - float f2 = this.getBlockSpeedFactor(); + // NFT-Worlds start + float f2; + if (wtf.etil.mirai.MiraiConfig.fastSpeedCheck) { + if (this.getDeltaMovement().x == 0 && this.getDeltaMovement().z == 0) { + f2 = 1; + } else { + f2 = this.getBlockSpeedFactor(); + } + } else { + f2 = this.getBlockSpeedFactor(); + } + // NFT-Worlds stop 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 c12ab155bdd4a1bad7bb428ecddc20a7999f91f5..b9351994ac2b9865ca39fdb76625983cf7c63cdb 100644 --- a/src/main/java/wtf/etil/mirai/MiraiConfig.java +++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java @@ -221,4 +221,11 @@ public class MiraiConfig { "Whether or not server should listen to location triggers."); } + public static boolean fastSpeedCheck; + private static void speedCheck() { + fastSpeedCheck = getBoolean("fast-speed-check", true, + "Whether or not server should use a faster method", + "to check when entity delta movement is null."); + } + } \ No newline at end of file