From 86f8a541791a06788b873517b403d9eed983894b Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sat, 21 Mar 2020 17:29:35 +0100 Subject: [PATCH 01/11] Switch to Tuinity as base Fork --- .github/workflows/build.yml | 7 +- .gitmodules | 6 +- Paper | 1 - README.md | 4 +- Tuinity | 1 + current-paper => current-tuinity | 0 patches/api/0001-Modify-POM.patch | 22 +- .../api/0031-Add-GameProfileLookupEvent.patch | 8 +- patches/api/0032-Add-getLastTickMs-api.patch | 10 +- patches/server/0001-Modify-POM.patch | 42 ++-- patches/server/0002-Brandings.patch | 42 ++-- .../server/0004-EMC-PlayerUseItem-Event.patch | 12 +- ...Disable-UUID-conversion-Already-done.patch | 6 +- .../0015-EMC-EntityKnockbackEvent.patch | 6 +- patches/server/0017-EMC-Accept-the-EULA.patch | 6 +- .../server/0022-EMC-ServerReloadEvent.patch | 6 +- ...save-entities-with-player-passengers.patch | 8 +- ...-Purpur-Disable-outdated-build-check.patch | 6 +- ...0039-Don-t-save-Fireworks-and-Arrows.patch | 6 +- ... => 0040-Add-GameProfileLookupEvent.patch} | 10 +- ...dHandler-to-allow-custom-MainThreads.patch | 166 ------------- ...patch => 0041-Add-getLastTickMs-api.patch} | 16 +- ...ig-yapfa-command-and-basic-settings.patch} | 38 ++- ... 0043-Kill-the-vanilla-GameProfiler.patch} | 10 +- ...ite-the-PathfinderGoalSelector-class.patch | 138 ----------- ...educe-entity-tracker-updates-on-move.patch | 218 ------------------ scripts/apply.sh | 6 +- scripts/commitup.sh | 4 +- scripts/generatesources.sh | 10 +- scripts/importmcdev.sh | 16 +- scripts/push.sh | 2 +- scripts/rebuildpatches.sh | 4 +- scripts/upstream.sh | 28 +-- 33 files changed, 163 insertions(+), 702 deletions(-) delete mode 160000 Paper create mode 160000 Tuinity rename current-paper => current-tuinity (100%) rename patches/server/{0041-Add-GameProfileLookupEvent.patch => 0040-Add-GameProfileLookupEvent.patch} (91%) delete mode 100644 patches/server/0040-Add-MainThreadHandler-to-allow-custom-MainThreads.patch rename patches/server/{0042-Add-getLastTickMs-api.patch => 0041-Add-getLastTickMs-api.patch} (88%) rename patches/server/{0043-Add-config-yapfa-command-and-basic-settings.patch => 0042-Add-config-yapfa-command-and-basic-settings.patch} (93%) rename patches/server/{0044-Kill-the-vanilla-GameProfiler.patch => 0043-Kill-the-vanilla-GameProfiler.patch} (91%) delete mode 100644 patches/server/0045-Rewrite-the-PathfinderGoalSelector-class.patch delete mode 100644 patches/server/0046-PAPER-Reduce-entity-tracker-updates-on-move.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 761ff3bb..18bace52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,12 @@ jobs: - name: Build YAPFA run: | git submodule init - git submodule update + git submodule update --init --recursive git config --global user.email "ci@github.com" git config --global user.name "Github CI" - ./yapfa up + yapfaDir=`pwd` + cd Tuinity + ./tuinity jar + cd $yapfaDir ./yapfa patch ./yapfa build diff --git a/.gitmodules b/.gitmodules index fa984b51..73179f45 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "Paper"] - path = Paper - url = https://github.com/PaperMC/Paper +[submodule "Tuinity"] + path = Tuinity + url = https://github.com/Spottedleaf/Tuinity diff --git a/Paper b/Paper deleted file mode 160000 index 7bd0b6ab..00000000 --- a/Paper +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7bd0b6ab1ab2d7a17b20048dfc06daa1319c3506 diff --git a/README.md b/README.md index 00d2d4d5..68f3258f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # YAPFA -## (Yet another Paper fork attempt) +## (Yet another ~~Paper~~ Tuinity fork attempt) ## What ## -This Fork tries to import universal patches from [EMC](https://github.com/starlis/empirecraft) and [Purpur](https://github.com/pl3xgaming/Purpur), while adding a few more "extrem" patches that modify the basic minecraft server for more performance. +This Fork tries to import universal patches from [EMC](https://github.com/starlis/empirecraft) and [Purpur](https://github.com/pl3xgaming/Purpur), while adding a few more "extrem" patches that modify the basic minecraft server for more performance. This fork was based on Paper, but is now based on [Tuinity](https://github.com/Spottedleaf/Tuinity). ## Building and setting up Run the following commands in the root directory: diff --git a/Tuinity b/Tuinity new file mode 160000 index 00000000..d16b7882 --- /dev/null +++ b/Tuinity @@ -0,0 +1 @@ +Subproject commit d16b7882fc663ed975daf74091449c1927d0242a diff --git a/current-paper b/current-tuinity similarity index 100% rename from current-paper rename to current-tuinity diff --git a/patches/api/0001-Modify-POM.patch b/patches/api/0001-Modify-POM.patch index 1fde4617..382a11eb 100644 --- a/patches/api/0001-Modify-POM.patch +++ b/patches/api/0001-Modify-POM.patch @@ -1,36 +1,36 @@ -From e56e7c35b802814b62608f98517d2368cca70e47 Mon Sep 17 00:00:00 2001 +From 3f7f02d0d9e68b60c6c92144fc458afd99a64eb2 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 17:03:06 +0100 Subject: [PATCH] Modify POM --- - pom.xml | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) + pom.xml | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml -index 2cb97140..8103f6dd 100644 +index bab0b017..4bb7efe9 100644 --- a/pom.xml +++ b/pom.xml -@@ -3,18 +3,18 @@ +@@ -3,18 +3,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 -- com.destroystokyo.paper -- paper-parent +- com.tuinity +- tuinity-parent + de.tr7zw.yapfa + yapfa-parent dev-SNAPSHOT + ../pom.xml -- com.destroystokyo.paper -- paper-api +- tuinity-api + de.tr7zw.yapfa + yapfa-api 1.15.2-R0.1-SNAPSHOT jar -- Paper-API -- https://github.com/PaperMC/Paper +- Tuinity-API +- https://github.com/Spottedleaf/Tuinity + YAPFA-API + https://github.com/tr7zw/YAPFA An enhanced plugin API for Minecraft servers. diff --git a/patches/api/0031-Add-GameProfileLookupEvent.patch b/patches/api/0031-Add-GameProfileLookupEvent.patch index 15ce3ad0..8a08970c 100644 --- a/patches/api/0031-Add-GameProfileLookupEvent.patch +++ b/patches/api/0031-Add-GameProfileLookupEvent.patch @@ -1,4 +1,4 @@ -From d9c138fbfa962b5aafcc8b5387882523bab251dc Mon Sep 17 00:00:00 2001 +From 1c8f1bf377624c066e0d6300a3f684193eb1d0e9 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 22:21:14 +0100 Subject: [PATCH] Add GameProfileLookupEvent @@ -10,10 +10,10 @@ Subject: [PATCH] Add GameProfileLookupEvent create mode 100644 src/main/java/de/tr7zw/yapfa/events/GameProfileLookupEvent.java diff --git a/pom.xml b/pom.xml -index ca897873..3f97b2be 100644 +index 4bb7efe9..d9fb880f 100644 --- a/pom.xml +++ b/pom.xml -@@ -39,6 +39,10 @@ +@@ -40,6 +40,10 @@ sonatype https://oss.sonatype.org/content/groups/public/ @@ -24,7 +24,7 @@ index ca897873..3f97b2be 100644 -@@ -49,6 +53,13 @@ +@@ -50,6 +54,13 @@ diff --git a/patches/api/0032-Add-getLastTickMs-api.patch b/patches/api/0032-Add-getLastTickMs-api.patch index f2cd8c03..31f183f3 100644 --- a/patches/api/0032-Add-getLastTickMs-api.patch +++ b/patches/api/0032-Add-getLastTickMs-api.patch @@ -1,4 +1,4 @@ -From 8ad98f5fbf4542b3cb48d754448ff847bd45bab0 Mon Sep 17 00:00:00 2001 +From f729f3eb13144eb45278d3f0671f44339dd55552 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 21:13:14 +0100 Subject: [PATCH] Add getLastTickMs() api @@ -9,10 +9,10 @@ Subject: [PATCH] Add getLastTickMs() api 2 files changed, 19 insertions(+) diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 355bd2e2..f603f99f 100644 +index b9973406..610bd5b1 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -1618,6 +1618,14 @@ public final class Bukkit { +@@ -1662,6 +1662,14 @@ public final class Bukkit { return server.getCurrentTick(); } // Paper end @@ -28,10 +28,10 @@ index 355bd2e2..f603f99f 100644 @NotNull public static Server.Spigot spigot() { diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 98e7ba90..7cebe608 100644 +index 80f9abdc..7b6cbe71 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -1416,4 +1416,15 @@ public interface Server extends PluginMessageRecipient { +@@ -1456,4 +1456,15 @@ public interface Server extends PluginMessageRecipient { */ int getCurrentTick(); // Paper end diff --git a/patches/server/0001-Modify-POM.patch b/patches/server/0001-Modify-POM.patch index fd72d328..7f9823b1 100644 --- a/patches/server/0001-Modify-POM.patch +++ b/patches/server/0001-Modify-POM.patch @@ -1,37 +1,38 @@ -From 332de8cfc43e110aaf9c46ca3b9eef4ccf94c22d Mon Sep 17 00:00:00 2001 +From ddf4f73e653d81b5273acc1ad7cfc1ac00fd42e9 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 17:08:07 +0100 Subject: [PATCH] Modify POM --- - pom.xml | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) + pom.xml | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml -index 55679af9..7e166ce9 100644 +index 332a8a45..742e423c 100644 --- a/pom.xml +++ b/pom.xml -@@ -1,11 +1,11 @@ - 4.0.0 -- paper +- tuinity + yapfa jar 1.15.2-R0.1-SNAPSHOT -- Paper -- https://papermc.io +- Tuinity-Server +- https://github.com/Spottedleaf/Tuinity + YAPFA + https://github.com/tr7zw/YAPFA - ++ -@@ -21,16 +21,16 @@ + UTF-8 +@@ -20,16 +21,16 @@ -- com.destroystokyo.paper -- paper-parent +- com.tuinity +- tuinity-parent + de.tr7zw.yapfa + yapfa-parent dev-SNAPSHOT @@ -40,27 +41,28 @@ index 55679af9..7e166ce9 100644 -- com.destroystokyo.paper -- paper-api +- com.tuinity +- tuinity-api + de.tr7zw.yapfa + yapfa-api ${project.version} compile -@@ -143,7 +143,7 @@ +@@ -148,15 +149,15 @@ -- paper-${minecraft.version} +- tuinity-${minecraft.version} +- install + yapfa-${minecraft.version} - clean install ++ clean install -@@ -151,7 +151,7 @@ + com.lukegb.mojo gitdescribe-maven-plugin 1.3 -- git-Paper- +- git-Tuinity- + git-YAPFA- .. diff --git a/patches/server/0002-Brandings.patch b/patches/server/0002-Brandings.patch index fa596e3a..1636ae4b 100644 --- a/patches/server/0002-Brandings.patch +++ b/patches/server/0002-Brandings.patch @@ -1,47 +1,33 @@ -From 657c46021b893e6184415b1182fda23d7d9974d9 Mon Sep 17 00:00:00 2001 +From d1dfd7255c30123ed4d636bb4a6c2b1f03bac049 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 18:37:34 +0100 Subject: [PATCH] Brandings --- - .../paper/console/PaperConsole.java | 2 +- - .../paper/util/misc/AreaMap.java | 1 + + .../paper/console/PaperConsole.java | 1 + .../de/tr7zw/yapfa/YapfaVersionFetcher.java | 20 +++++++++++++++++++ .../net/minecraft/server/MinecraftServer.java | 2 +- .../org/bukkit/craftbukkit/CraftServer.java | 2 +- .../craftbukkit/util/CraftMagicNumbers.java | 2 +- .../bukkit/craftbukkit/util/Versioning.java | 2 +- - 7 files changed, 26 insertions(+), 5 deletions(-) + 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/main/java/de/tr7zw/yapfa/YapfaVersionFetcher.java diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java -index cd6e25923..24e852ebd 100644 +index cd6e2592..e3599d11 100644 --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java +++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java -@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole { - @Override +@@ -18,6 +18,7 @@ public final class PaperConsole extends SimpleTerminalConsole { protected LineReader buildReader(LineReaderBuilder builder) { return super.buildReader(builder -- .appName("Paper") -+ .appName("YAPFA") + .appName("Paper") ++ .appName("YAPFA") // YAPFA .completer(new ConsoleCommandCompleter(this.server)) ); } -diff --git a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java -index 5a44bc644..4bd88e5b3 100644 ---- a/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java -+++ b/src/main/java/com/destroystokyo/paper/util/misc/AreaMap.java -@@ -1,6 +1,7 @@ - package com.destroystokyo.paper.util.misc; - - import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; -+import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry; - import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; - import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; - import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; diff --git a/src/main/java/de/tr7zw/yapfa/YapfaVersionFetcher.java b/src/main/java/de/tr7zw/yapfa/YapfaVersionFetcher.java new file mode 100644 -index 000000000..4ca5fd338 +index 00000000..b7a73408 --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/YapfaVersionFetcher.java @@ -0,0 +1,20 @@ @@ -65,28 +51,28 @@ index 000000000..4ca5fd338 + } + +} +\ No newline at end of file diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c9deaffc4..b5bed4705 100644 +index 2acd6bf2..eec9a5b2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1484,7 +1484,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant // Spigot - Spigot > // CraftBukkit - cb > vanilla! -+ return "YAPFA"; //YAPFA - YAPFA > //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! +- return "Tuinity"; // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return "YAPFA"; // YAPFA // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! } public CrashReport b(CrashReport crashreport) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index b7dfda265..d6b06c06e 100644 +index 0b65cbb2..4b27af23 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -203,7 +203,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { -- private final String serverName = "Paper"; // Paper + private final String serverName = "YAPFA"; // YAPFA private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); diff --git a/patches/server/0004-EMC-PlayerUseItem-Event.patch b/patches/server/0004-EMC-PlayerUseItem-Event.patch index 1bca3e5c..5b677619 100644 --- a/patches/server/0004-EMC-PlayerUseItem-Event.patch +++ b/patches/server/0004-EMC-PlayerUseItem-Event.patch @@ -1,4 +1,4 @@ -From 1d76a3b9382672fb6f13dd9efb6b5e77e7962bcb Mon Sep 17 00:00:00 2001 +From 4421584fbbc1dfb981327ea61e8621616b60c3f1 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 22 Dec 2012 00:35:15 -0500 Subject: [PATCH] EMC PlayerUseItem Event @@ -23,10 +23,10 @@ index ad474500..671fa069 100644 this.setSlot(EnumItemSlot.MAINHAND, itemstack); } else { diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java -index ce4340a4..51e10cfc 100644 +index 1b60310b..3f358ec5 100644 --- a/src/main/java/net/minecraft/server/PlayerInteractManager.java +++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java -@@ -391,6 +391,15 @@ public class PlayerInteractManager { +@@ -412,6 +412,15 @@ public class PlayerInteractManager { } public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand) { @@ -42,7 +42,7 @@ index ce4340a4..51e10cfc 100644 if (this.gamemode == EnumGamemode.SPECTATOR) { return EnumInteractionResult.PASS; } else if (entityhuman.getCooldownTracker().hasCooldown(itemstack.getItem())) { -@@ -398,27 +407,53 @@ public class PlayerInteractManager { +@@ -419,27 +428,53 @@ public class PlayerInteractManager { } else { int i = itemstack.getCount(); int j = itemstack.getDamage(); @@ -102,7 +102,7 @@ index ce4340a4..51e10cfc 100644 ((EntityPlayer) entityhuman).updateInventory(entityhuman.defaultContainer); } -@@ -432,6 +467,7 @@ public class PlayerInteractManager { +@@ -453,6 +488,7 @@ public class PlayerInteractManager { public boolean firedInteract = false; public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); @@ -110,7 +110,7 @@ index ce4340a4..51e10cfc 100644 IBlockData iblockdata = world.getType(blockposition); EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; boolean cancelledBlock = false; -@@ -499,17 +535,45 @@ public class PlayerInteractManager { +@@ -520,17 +556,45 @@ public class PlayerInteractManager { } if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 diff --git a/patches/server/0013-EMC-Disable-UUID-conversion-Already-done.patch b/patches/server/0013-EMC-Disable-UUID-conversion-Already-done.patch index 5aaf4e05..525045d1 100644 --- a/patches/server/0013-EMC-Disable-UUID-conversion-Already-done.patch +++ b/patches/server/0013-EMC-Disable-UUID-conversion-Already-done.patch @@ -1,4 +1,4 @@ -From 89df9d7ca41b413ae9c3ac8193d8cedc89d68541 Mon Sep 17 00:00:00 2001 +From e1b72d3c45a36d430d4ef3b1bde43fbb6784bb5e Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 14 Apr 2014 20:44:38 -0400 Subject: [PATCH] EMC Disable UUID conversion - Already done @@ -9,10 +9,10 @@ Subject: [PATCH] EMC Disable UUID conversion - Already done 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 349a0ea2..8a241c28 100644 +index ede43693..610826c9 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java -@@ -249,7 +249,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer +@@ -250,7 +250,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } diff --git a/patches/server/0015-EMC-EntityKnockbackEvent.patch b/patches/server/0015-EMC-EntityKnockbackEvent.patch index c7a5902b..ff9dc7c8 100644 --- a/patches/server/0015-EMC-EntityKnockbackEvent.patch +++ b/patches/server/0015-EMC-EntityKnockbackEvent.patch @@ -1,4 +1,4 @@ -From 38cac2cc8d88fa416f879fa39ad554f2cde7c2a4 Mon Sep 17 00:00:00 2001 +From 360d20b06b9e2b1b8e68275a3ba054e1de3e7a65 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 16 Mar 2014 20:44:46 -0400 Subject: [PATCH] EMC EntityKnockbackEvent @@ -44,10 +44,10 @@ index 584166f2..9346fbf0 100644 if (this.isSprinting() && flag) { sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java -index 1991cee4..329f3685 100644 +index 27ef4760..0592e095 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java -@@ -1308,7 +1308,7 @@ public abstract class EntityInsentient extends EntityLiving { +@@ -1315,7 +1315,7 @@ public abstract class EntityInsentient extends EntityLiving { if (entity instanceof EntityLiving) { f += EnchantmentManager.a(this.getItemInMainHand(), ((EntityLiving) entity).getMonsterType()); diff --git a/patches/server/0017-EMC-Accept-the-EULA.patch b/patches/server/0017-EMC-Accept-the-EULA.patch index 9be3a70a..57f53889 100644 --- a/patches/server/0017-EMC-Accept-the-EULA.patch +++ b/patches/server/0017-EMC-Accept-the-EULA.patch @@ -1,4 +1,4 @@ -From f4e88ce690719daef8a3baac865262a070c43ea2 Mon Sep 17 00:00:00 2001 +From ec8804120c0877c9ed090ed7ed0e429eaffcab59 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 5 Sep 2014 23:04:54 -0400 Subject: [PATCH] EMC Accept the EULA @@ -9,10 +9,10 @@ Starlis LLC, the owner of Empire Minecraft, accepts the Minecraft EULA with this 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 32f1099a..b5bd0e38 100644 +index 15ceb83f..fa8a5f53 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1343,6 +1343,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant Date: Thu, 25 Jun 2015 21:00:09 -0400 Subject: [PATCH] EMC ServerReloadEvent @@ -8,10 +8,10 @@ Subject: [PATCH] EMC ServerReloadEvent 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index d6b06c06..9384c929 100644 +index 4b27af23..d3a0a917 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -761,6 +761,7 @@ public final class CraftServer implements Server { +@@ -771,6 +771,7 @@ public final class CraftServer implements Server { @Override public void reload() { org.spigotmc.WatchdogThread.hasStarted = false; // Paper - Disable watchdog early timeout on reload diff --git a/patches/server/0036-EMC-Do-not-save-entities-with-player-passengers.patch b/patches/server/0036-EMC-Do-not-save-entities-with-player-passengers.patch index b1025935..38a14913 100644 --- a/patches/server/0036-EMC-Do-not-save-entities-with-player-passengers.patch +++ b/patches/server/0036-EMC-Do-not-save-entities-with-player-passengers.patch @@ -1,4 +1,4 @@ -From b04e7fb704af33ef186743d10d773b5826e850ba Mon Sep 17 00:00:00 2001 +From 979580a2ffb58f7903fbddf2ef26203797535c79 Mon Sep 17 00:00:00 2001 From: chickeneer Date: Wed, 22 Jan 2020 01:22:34 -0600 Subject: [PATCH] EMC Do not save entities with player passengers @@ -8,10 +8,10 @@ Subject: [PATCH] EMC Do not save entities with player passengers 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -index 4349d22c..669eb9eb 100644 +index d529b795..1b2b73b8 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java -@@ -444,7 +444,7 @@ public class ChunkRegionLoader { +@@ -452,7 +452,7 @@ public class ChunkRegionLoader { if (asyncsavedata == null) toUpdate.add(entity); // todo fix this broken code, entityJoinedWorld wont work in this case! continue; } @@ -20,7 +20,7 @@ index 4349d22c..669eb9eb 100644 continue; } // Paper end -@@ -525,6 +525,20 @@ public class ChunkRegionLoader { +@@ -533,6 +533,20 @@ public class ChunkRegionLoader { return nbttagcompound; } diff --git a/patches/server/0037-Purpur-Disable-outdated-build-check.patch b/patches/server/0037-Purpur-Disable-outdated-build-check.patch index d756d886..d2cebead 100644 --- a/patches/server/0037-Purpur-Disable-outdated-build-check.patch +++ b/patches/server/0037-Purpur-Disable-outdated-build-check.patch @@ -1,4 +1,4 @@ -From 87a4ad5661fa6d92f8ead7f64e3c1548054d08ac Mon Sep 17 00:00:00 2001 +From 9339c992bd089a91513ff682736b5c44da787cd8 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 15 Dec 2019 12:53:59 -0600 Subject: [PATCH] Purpur Disable outdated build check @@ -8,10 +8,10 @@ Subject: [PATCH] Purpur Disable outdated build check 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 374e0450..d6aa0306 100644 +index 2666940e..a9f2229c 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -212,7 +212,7 @@ public class Main { +@@ -219,7 +219,7 @@ public class Main { System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper } diff --git a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch index 274daf94..2dd58af4 100644 --- a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch +++ b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch @@ -1,4 +1,4 @@ -From cc74d3456f0ffbd9abdbc0c6b740c6d17644a3fd Mon Sep 17 00:00:00 2001 +From 42b73c07d1ef71fd082f14c8eb6682817d33ea68 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 21:39:58 +0100 Subject: [PATCH] Don't save Fireworks and Arrows @@ -8,10 +8,10 @@ Subject: [PATCH] Don't save Fireworks and Arrows 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 8974c16b..bfcf4a9b 100644 +index 181f1742..d2a224a8 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1516,7 +1516,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -1616,7 +1616,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } public boolean c(NBTTagCompound nbttagcompound) { diff --git a/patches/server/0041-Add-GameProfileLookupEvent.patch b/patches/server/0040-Add-GameProfileLookupEvent.patch similarity index 91% rename from patches/server/0041-Add-GameProfileLookupEvent.patch rename to patches/server/0040-Add-GameProfileLookupEvent.patch index 3f742ab8..aa234ac2 100644 --- a/patches/server/0041-Add-GameProfileLookupEvent.patch +++ b/patches/server/0040-Add-GameProfileLookupEvent.patch @@ -1,4 +1,4 @@ -From 08c19476a6b5359ebc6fe21668c9a9dbb38e01c6 Mon Sep 17 00:00:00 2001 +From f3d5def9a1faac55232b4c258ec5f3c36ae81ede Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 22:22:02 +0100 Subject: [PATCH] Add GameProfileLookupEvent @@ -9,7 +9,7 @@ Subject: [PATCH] Add GameProfileLookupEvent 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java -index b151a13c1..9eacb3c43 100644 +index b151a13c..a37db9a5 100644 --- a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -5,8 +5,12 @@ import com.google.common.base.Charsets; @@ -34,7 +34,7 @@ index b151a13c1..9eacb3c43 100644 - this.profile = result; - } + // YAPFA start -+ GameProfileLookupEvent event = new GameProfileLookupEvent(!de.tr7zw.yapfa.MainThreadHandler.isMainThread(Thread.currentThread()), profile.getId(), profile.getName()); ++ GameProfileLookupEvent event = new GameProfileLookupEvent(!Bukkit.isPrimaryThread(), profile.getId(), profile.getName()); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.getGameProfile() != null) { + this.profile = event.getGameProfile(); @@ -49,7 +49,7 @@ index b151a13c1..9eacb3c43 100644 return profile.isComplete() && (!isOnlineMode || !textures || hasTextures()); } diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java -index 0882d82ce..8ed2c09ad 100644 +index 0882d82c..62607f49 100644 --- a/src/main/java/net/minecraft/server/TileEntitySkull.java +++ b/src/main/java/net/minecraft/server/TileEntitySkull.java @@ -4,9 +4,14 @@ import com.google.common.collect.Iterables; @@ -73,7 +73,7 @@ index 0882d82ce..8ed2c09ad 100644 { - profile = TileEntitySkull.sessionService.fillProfileProperties( profile, true ); + // YAPFA start -+ GameProfileLookupEvent event = new GameProfileLookupEvent(!de.tr7zw.yapfa.MainThreadHandler.isMainThread(Thread.currentThread()), profile.getId(), profile.getName()); ++ GameProfileLookupEvent event = new GameProfileLookupEvent(!Bukkit.isPrimaryThread(), profile.getId(), profile.getName()); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.getGameProfile() != null) { + profile = event.getGameProfile(); diff --git a/patches/server/0040-Add-MainThreadHandler-to-allow-custom-MainThreads.patch b/patches/server/0040-Add-MainThreadHandler-to-allow-custom-MainThreads.patch deleted file mode 100644 index a88cb3e0..00000000 --- a/patches/server/0040-Add-MainThreadHandler-to-allow-custom-MainThreads.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 8005dcac9b78f662be51bc0734b9d334a15d5a5a Mon Sep 17 00:00:00 2001 -From: tr7zw -Date: Thu, 5 Mar 2020 20:47:06 +0100 -Subject: [PATCH] Add MainThreadHandler to allow custom "MainThreads" - ---- - .../de/tr7zw/yapfa/MainThreadHandler.java | 24 +++++++++++++++++++ - .../minecraft/server/IAsyncTaskHandler.java | 5 +++- - .../java/net/minecraft/server/MCUtil.java | 6 +++-- - .../net/minecraft/server/MinecraftServer.java | 3 +++ - .../org/bukkit/craftbukkit/CraftServer.java | 4 +++- - src/main/java/org/spigotmc/AsyncCatcher.java | 4 ++-- - 6 files changed, 40 insertions(+), 6 deletions(-) - create mode 100644 src/main/java/de/tr7zw/yapfa/MainThreadHandler.java - -diff --git a/src/main/java/de/tr7zw/yapfa/MainThreadHandler.java b/src/main/java/de/tr7zw/yapfa/MainThreadHandler.java -new file mode 100644 -index 000000000..f66e15e76 ---- /dev/null -+++ b/src/main/java/de/tr7zw/yapfa/MainThreadHandler.java -@@ -0,0 +1,24 @@ -+package de.tr7zw.yapfa; -+ -+import org.bukkit.craftbukkit.util.WeakCollection; -+ -+/** -+ * All Threads that are stored in this Collection are considered "MainThread" -+ * for all intents and purposes. -+ * -+ * @author tr7zw -+ * -+ */ -+public class MainThreadHandler { -+ -+ private static WeakCollection weakMainThreads = new WeakCollection(); -+ -+ public static void registerThread(Thread thread) { -+ weakMainThreads.add(thread); -+ } -+ -+ public static boolean isMainThread(Thread thread) { -+ return weakMainThreads.contains(thread); -+ } -+ -+} -diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -index cfe43e882..9009705ee 100644 ---- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java -@@ -1,6 +1,9 @@ - package net.minecraft.server; - - import com.google.common.collect.Queues; -+ -+import de.tr7zw.yapfa.MainThreadHandler; -+ - import java.util.Queue; - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.Executor; -@@ -25,7 +28,7 @@ public abstract class IAsyncTaskHandler implements Mailbox T ensureMain(String reason, Supplier run) { -- if (AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread) { -+ if (AsyncCatcher.enabled && !MainThreadHandler.isMainThread(Thread.currentThread())) { // YAPFA - if (reason != null) { - new IllegalStateException("Asynchronous " + reason + "! Blocking thread until it returns ").printStackTrace(); - } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 816f4ff14..6ea3833fc 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2,6 +2,8 @@ package net.minecraft.server; - - import com.google.common.base.Splitter; - import co.aikar.timings.Timings; -+import de.tr7zw.yapfa.MainThreadHandler; -+ - import com.destroystokyo.paper.event.server.PaperServerListPingEvent; - import com.google.common.base.Stopwatch; - import com.google.common.collect.Lists; -@@ -132,6 +134,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { - MinecraftServer.LOGGER.error(throwable); - }); -+ MainThreadHandler.registerThread(thread); // YAPFA - }); - private long nextTick = SystemUtils.getMonotonicMillis(); - private long ab; final long getTickOversleepMaxTime() { return this.ab; } // Paper - OBFHELPER -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 9384c9292..19b74f3ca 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -14,6 +14,8 @@ import com.mojang.brigadier.StringReader; - import com.mojang.brigadier.exceptions.CommandSyntaxException; - import com.mojang.brigadier.tree.CommandNode; - import com.mojang.brigadier.tree.LiteralCommandNode; -+ -+import de.tr7zw.yapfa.MainThreadHandler; - import io.netty.buffer.ByteBuf; - import io.netty.buffer.ByteBufOutputStream; - import io.netty.buffer.Unpooled; -@@ -1684,7 +1686,7 @@ public final class CraftServer implements Server { - - @Override - public boolean isPrimaryThread() { -- return Thread.currentThread().equals(console.serverThread); // Paper - Fix issues with detecting main thread properly -+ return MainThreadHandler.isMainThread(Thread.currentThread()); // YAPFA // Paper - Fix issues with detecting main thread properly - } - - @Override -diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java -index 9f7d2ef93..f9fd9f603 100644 ---- a/src/main/java/org/spigotmc/AsyncCatcher.java -+++ b/src/main/java/org/spigotmc/AsyncCatcher.java -@@ -1,6 +1,6 @@ - package org.spigotmc; - --import net.minecraft.server.MinecraftServer; -+import de.tr7zw.yapfa.MainThreadHandler; - - public class AsyncCatcher - { -@@ -10,7 +10,7 @@ public class AsyncCatcher - - public static void catchOp(String reason) - { -- if ( enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread ) -+ if ( enabled && !MainThreadHandler.isMainThread(Thread.currentThread()) ) // YAPFA - { - throw new IllegalStateException( "Asynchronous " + reason + "!" ); - } --- -2.25.1.windows.1 - diff --git a/patches/server/0042-Add-getLastTickMs-api.patch b/patches/server/0041-Add-getLastTickMs-api.patch similarity index 88% rename from patches/server/0042-Add-getLastTickMs-api.patch rename to patches/server/0041-Add-getLastTickMs-api.patch index 20fa2abf..bed061da 100644 --- a/patches/server/0042-Add-getLastTickMs-api.patch +++ b/patches/server/0041-Add-getLastTickMs-api.patch @@ -1,4 +1,4 @@ -From 90e8bcd5384daf77b5d94744e1f40fbaf71526e5 Mon Sep 17 00:00:00 2001 +From 03a99f384fef93ce99164346e625053155eb7438 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 21:13:33 +0100 Subject: [PATCH] Add getLastTickMs() api @@ -10,10 +10,10 @@ Subject: [PATCH] Add getLastTickMs() api 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6ea3833fc..d5efea027 100644 +index 376cf955..0276abe1 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -886,6 +886,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant Date: Thu, 5 Mar 2020 22:31:50 +0100 Subject: [PATCH] Add config, yapfa command and basic settings @@ -8,14 +8,14 @@ Subject: [PATCH] Add config, yapfa command and basic settings src/main/java/de/tr7zw/yapfa/YapfaConfig.java | 219 ++++++++++++++++++ .../net/minecraft/server/DedicatedServer.java | 9 + .../java/net/minecraft/server/Entity.java | 3 +- - .../net/minecraft/server/EntityLiving.java | 9 +- - 5 files changed, 366 insertions(+), 3 deletions(-) + .../net/minecraft/server/EntityLiving.java | 6 +- + 5 files changed, 364 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/tr7zw/yapfa/YapfaCommand.java create mode 100644 src/main/java/de/tr7zw/yapfa/YapfaConfig.java diff --git a/src/main/java/de/tr7zw/yapfa/YapfaCommand.java b/src/main/java/de/tr7zw/yapfa/YapfaCommand.java new file mode 100644 -index 000000000..58ce1f826 +index 00000000..76d83f3d --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/YapfaCommand.java @@ -0,0 +1,129 @@ @@ -148,9 +148,10 @@ index 000000000..58ce1f826 + Command.broadcastCommandMessage(sender, ChatColor.GREEN + "YAPFA config reload complete."); + } +} +\ No newline at end of file diff --git a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java new file mode 100644 -index 000000000..71c04cf49 +index 00000000..9711cbc5 --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java @@ -0,0 +1,219 @@ @@ -373,8 +374,9 @@ index 000000000..71c04cf49 + } + +} +\ No newline at end of file diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 8a241c28a..c4006ff01 100644 +index 610826c9..2ed69f56 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -194,6 +194,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer @@ -390,14 +392,14 @@ index 8a241c28a..c4006ff01 100644 + } + de.tr7zw.yapfa.YapfaConfig.registerCommands(); + // YAPFA end + com.tuinity.tuinity.config.TuinityConfig.init((File) options.valueOf("tuinity-settings")); // Tuinity - Server Config this.setSpawnAnimals(dedicatedserverproperties.spawnAnimals); - this.setSpawnNPCs(dedicatedserverproperties.spawnNpcs); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index bfcf4a9b0..c27c1d5c2 100644 +index d2a224a8..45fdcee0 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -662,6 +662,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -761,6 +761,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke try { this.inLava = false; @@ -405,7 +407,7 @@ index bfcf4a9b0..c27c1d5c2 100644 this.checkBlockCollisions(); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); -@@ -786,7 +787,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -885,7 +886,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); VoxelShape voxelshape = this.world.getWorldBorder().a(); Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); @@ -415,10 +417,10 @@ index bfcf4a9b0..c27c1d5c2 100644 Vec3D vec3d1 = vec3d.g() == 0.0D ? vec3d : a(this, vec3d, axisalignedbb, this.world, voxelshapecollision, streamaccumulator); boolean flag = vec3d.x != vec3d1.x; diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 5b402690d..fa3affb54 100644 +index 5b402690..839b0f51 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java -@@ -246,10 +246,11 @@ public abstract class EntityLiving extends Entity { +@@ -246,6 +246,7 @@ public abstract class EntityLiving extends Entity { this.world.getMethodProfiler().enter("livingEntityBaseTick"); boolean flag = this instanceof EntityHuman; @@ -426,11 +428,6 @@ index 5b402690d..fa3affb54 100644 if (this.isAlive()) { if (this.inBlock()) { this.damageEntity(DamageSource.STUCK, 1.0F); -- } else if (flag && !this.world.getWorldBorder().a(this.getBoundingBox())) { -+ } else if (flag && !de.tr7zw.yapfa.YapfaConfig.disablePlayerOutOfWorldBorderCheck && !this.world.getWorldBorder().a(this.getBoundingBox())) { // YAPFA - double d0 = this.world.getWorldBorder().a((Entity) this) + this.world.getWorldBorder().getDamageBuffer(); - - if (d0 < 0.0D) { @@ -261,6 +262,7 @@ public abstract class EntityLiving extends Entity { } } @@ -455,7 +452,7 @@ index 5b402690d..fa3affb54 100644 if (!this.world.isClientSide) { BlockPosition blockposition = new BlockPosition(this); -@@ -2640,11 +2644,12 @@ public abstract class EntityLiving extends Entity { +@@ -2640,7 +2644,7 @@ public abstract class EntityLiving extends Entity { this.e(new Vec3D((double) this.aZ, (double) this.ba, (double) this.bb)); this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("push"); @@ -464,11 +461,6 @@ index 5b402690d..fa3affb54 100644 --this.bn; this.a(axisalignedbb, this.getBoundingBox()); } - -+ if(!de.tr7zw.yapfa.YapfaConfig.disableEntityCollisions) // YAPFA - this.collideNearby(); - this.world.getMethodProfiler().exit(); - } -- 2.25.1.windows.1 diff --git a/patches/server/0044-Kill-the-vanilla-GameProfiler.patch b/patches/server/0043-Kill-the-vanilla-GameProfiler.patch similarity index 91% rename from patches/server/0044-Kill-the-vanilla-GameProfiler.patch rename to patches/server/0043-Kill-the-vanilla-GameProfiler.patch index e19580db..44600c22 100644 --- a/patches/server/0044-Kill-the-vanilla-GameProfiler.patch +++ b/patches/server/0043-Kill-the-vanilla-GameProfiler.patch @@ -1,4 +1,4 @@ -From ead0f031e6ffc43a68ed0842ef4896bde0fd13ec Mon Sep 17 00:00:00 2001 +From 9ae232d05c7db4372c14cd33c9ef11e29770c731 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 23:08:01 +0100 Subject: [PATCH] Kill the vanilla "GameProfiler" @@ -11,7 +11,7 @@ Subject: [PATCH] Kill the vanilla "GameProfiler" diff --git a/src/main/java/de/tr7zw/yapfa/GameProfilerDisabled.java b/src/main/java/de/tr7zw/yapfa/GameProfilerDisabled.java new file mode 100644 -index 000000000..96a2270a8 +index 00000000..96a2270a --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/GameProfilerDisabled.java @@ -0,0 +1,51 @@ @@ -67,10 +67,10 @@ index 000000000..96a2270a8 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index d5efea027..692c0cac9 100644 +index 0276abe1..e803c968 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -82,7 +82,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant tickables = Lists.newArrayList(); @@ -79,7 +79,7 @@ index d5efea027..692c0cac9 100644 private ServerConnection serverConnection; public final WorldLoadListenerFactory worldLoadListenerFactory; private final ServerPing serverPing = new ServerPing(); -@@ -935,7 +935,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant -Date: Fri, 6 Mar 2020 20:28:47 +0100 -Subject: [PATCH] Rewrite the PathfinderGoalSelector class - ---- - .../server/PathfinderGoalSelector.java | 79 +++++++++++++++++-- - 1 file changed, 72 insertions(+), 7 deletions(-) - -diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java -index 935136771..8e5b944b2 100644 ---- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java -+++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java -@@ -1,9 +1,14 @@ - package net.minecraft.server; - - import com.google.common.collect.Sets; -+ -+import net.minecraft.server.PathfinderGoal.Type; -+ - import java.util.EnumMap; - import java.util.EnumSet; -+import java.util.Iterator; - import java.util.Map; -+import java.util.Map.Entry; - import java.util.Set; - import java.util.stream.Stream; - import org.apache.logging.log4j.LogManager; -@@ -58,9 +63,16 @@ public class PathfinderGoalSelector { - // Paper end - - public void a(PathfinderGoal pathfindergoal) { -- this.d.stream().filter((pathfindergoalwrapped) -> { -+ // YAPFA start -+ for(PathfinderGoalWrapped goal : this.d) { -+ if(goal.j() == pathfindergoal && goal.g()) { -+ goal.d(); -+ } -+ } -+ /*this.d.stream().filter((pathfindergoalwrapped) -> { - return pathfindergoalwrapped.j() == pathfindergoal; -- }).filter(PathfinderGoalWrapped::g).forEach(PathfinderGoalWrapped::d); -+ }).filter(PathfinderGoalWrapped::g).forEach(PathfinderGoalWrapped::d);*/ -+ // YAPFA end - this.d.removeIf((pathfindergoalwrapped) -> { - return pathfindergoalwrapped.j() == pathfindergoal; - }); -@@ -68,7 +80,24 @@ public class PathfinderGoalSelector { - - public void doTick() { - this.e.enter("goalCleanup"); -- this.c().filter((pathfindergoalwrapped) -> { -+ // YAPFA start -+ for (PathfinderGoalWrapped goal : this.d) { -+ if (goal.g() && !goal.b()) { -+ boolean flag = true; -+ -+ for(Type t : goal.i()) { -+ if(this.f.contains(t)) { -+ flag = false; -+ } -+ } -+ -+ if (flag) { -+ goal.d(); -+ } -+ } -+ } -+ this.c.entrySet().removeIf(ent -> !ent.getValue().g()); -+ /*this.c().filter((pathfindergoalwrapped) -> { - boolean flag; - - if (pathfindergoalwrapped.g()) { -@@ -90,10 +119,38 @@ public class PathfinderGoalSelector { - this.c.remove(pathfindergoal_type); - } - -- }); -+ });*/ -+ // YAPFA end - this.e.exit(); - this.e.enter("goalUpdate"); -- this.d.stream().filter((pathfindergoalwrapped) -> { -+ // YAPFA start -+ for(PathfinderGoalWrapped goal : this.d) { -+ if(!goal.g() && goal.a()) { -+ boolean noneMatch = true; -+ for(Type t : goal.i()) { -+ if(this.f.contains(t)) { -+ noneMatch = false; -+ } -+ } -+ if(noneMatch) { -+ boolean allMatch = true; -+ for(Type t : goal.i()) { -+ if(!this.c.getOrDefault(t, PathfinderGoalSelector.b).a(goal)){ -+ allMatch = false; -+ } -+ } -+ if(allMatch) { -+ for(Type t : goal.i()) { -+ PathfinderGoalWrapped pathfindergoalwrapped1 = (PathfinderGoalWrapped) this.c.getOrDefault(t, PathfinderGoalSelector.b); -+ pathfindergoalwrapped1.d(); -+ this.c.put(t, goal); -+ } -+ goal.c(); -+ } -+ } -+ } -+ } -+ /*this.d.stream().filter((pathfindergoalwrapped) -> { - return !pathfindergoalwrapped.g(); - }).filter((pathfindergoalwrapped) -> { - Stream stream = pathfindergoalwrapped.i().stream(); -@@ -113,10 +170,18 @@ public class PathfinderGoalSelector { - this.c.put(pathfindergoal_type, pathfindergoalwrapped); - }); - pathfindergoalwrapped.c(); -- }); -+ });*/ -+ // YAPFA end - this.e.exit(); - this.e.enter("goalTick"); -- this.c().forEach(PathfinderGoalWrapped::e); -+ // YAPFA start -+ for(PathfinderGoalWrapped goal : this.d) { -+ if(goal.g()) { -+ goal.e(); -+ } -+ } -+ //this.c().forEach(PathfinderGoalWrapped::e); -+ // YAPFA end - this.e.exit(); - } - --- -2.25.1.windows.1 - diff --git a/patches/server/0046-PAPER-Reduce-entity-tracker-updates-on-move.patch b/patches/server/0046-PAPER-Reduce-entity-tracker-updates-on-move.patch deleted file mode 100644 index bafe08a7..00000000 --- a/patches/server/0046-PAPER-Reduce-entity-tracker-updates-on-move.patch +++ /dev/null @@ -1,218 +0,0 @@ -From b8b3b931ccfa1f390db02deb97a830c537284652 Mon Sep 17 00:00:00 2001 -From: froobynooby -Date: Thu, 20 Feb 2020 15:50:49 +0930 -Subject: [PATCH] PAPER Reduce entity tracker updates on move - -With this patch, for each player we keep track of a set of -entities that the player is tracking. This is used to split -the entity tracker update logic in the movePlayer method in -PlayerChunkMap in to two parts: -* Full update: Run through all entity trackers and update them -* Partial update: Run through all entity trackers for entities -the player is already tracking and update them - -Partial updates will always take less time than full updates, -usually by a considerable amount if players and entities are -spread out over the map. Assuming they are evenly spread, -and given there are x many players, it would be expected to -take 1/x the time of a full update. - -Full updates are only run if the following conditions are met: -* It has been 20 ticks since the last full update -* The player has moved over set distance since the last full -update (distance is configurable) - -The motivation for the first condition is that the client -sends the server its position once a second, which calls -movePlayer, so at a minimum we want to be sending the player -an updated set of entities it can see every second. - -The motivation for the second condition is that looping -through every entity in world to check if it is now within -the tracking range after the player has moved 0.1 blocks is -largely unnecessary. Checking only after the player has moved -1 or 2 blocks is far better for performance, and very unlikely -to give any noticeable side effects. - -In testing, this has reduced the time taken for movement -packet processing by up to 4x. Packet processing for movement -packets often show up as a major contributor to TPS loss in -servers with large player counts ---- - .../destroystokyo/paper/PaperWorldConfig.java | 5 ++ - .../net/minecraft/server/EntityPlayer.java | 4 ++ - .../net/minecraft/server/PlayerChunkMap.java | 63 ++++++++++++++++++- - 3 files changed, 70 insertions(+), 2 deletions(-) - -diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 7d408542e..2ae44b230 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -658,4 +658,9 @@ public class PaperWorldConfig { - private void nerfNetherPortalPigmen() { - nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen); - } -+ -+ public double trackerUpdateDistance = 1; -+ private void trackeruUpdateDistance() { -+ trackerUpdateDistance = getDouble("tracker-update-distance", trackerUpdateDistance); -+ } - } -diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index e7bfbc330..43774bc9a 100644 ---- a/src/main/java/net/minecraft/server/EntityPlayer.java -+++ b/src/main/java/net/minecraft/server/EntityPlayer.java -@@ -86,6 +86,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { - public final int[] mobCounts = new int[ENUMCREATURETYPE_TOTAL_ENUMS]; // Paper - public final com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet cachedSingleMobDistanceMap; - // Paper end -+ // Paper start - Reduce entity tracker updates on move -+ public Vec3D lastTrackedPosition = new Vec3D(0, 0, 0); -+ public long lastTrackedTick; -+ // Paper end - - // CraftBukkit start - public String displayName; -diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 57bea926a..d971a4426 100644 ---- a/src/main/java/net/minecraft/server/PlayerChunkMap.java -+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java -@@ -133,6 +133,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - } - - -+ // Paper end -+ -+ // Paper start - Reduce entity tracker updates on move -+ private double trackerUpdateDistanceSquared; -+ private final Int2ObjectMap> playerTrackedEntities = new Int2ObjectOpenHashMap(); -+ private final Int2ObjectMap> playerTrackedEntitiesRemoveQueue = new Int2ObjectOpenHashMap(); -+ -+ void flushRemoveQueue(EntityPlayer entityplayer) { -+ Queue removeQueue = getPlayerTrackedEntityMapRemoveQueue(entityplayer.getId()); -+ Int2ObjectMap entityMap = getPlayerTrackedEntityMap(entityplayer.getId()); -+ for (Integer id = removeQueue.poll(); id != null; id = removeQueue.poll()) { -+ entityMap.remove(id); -+ } -+ } -+ -+ void flushRemoveQueues() { -+ for (Int2ObjectMap.Entry> entry : playerTrackedEntitiesRemoveQueue.int2ObjectEntrySet()) { -+ Int2ObjectMap entityMap = getPlayerTrackedEntityMap(entry.getKey()); -+ Queue removeQueue = entry.getValue(); -+ for (Integer id = removeQueue.poll(); id != null; id = removeQueue.poll()) { -+ entityMap.remove(id); -+ } -+ } -+ } -+ -+ Int2ObjectMap getPlayerTrackedEntityMap(int id) { -+ return playerTrackedEntities.computeIfAbsent(id, i -> new Int2ObjectOpenHashMap()); -+ } -+ -+ Queue getPlayerTrackedEntityMapRemoveQueue(int id) { -+ return playerTrackedEntitiesRemoveQueue.computeIfAbsent(id, i -> new java.util.ArrayDeque<>()); -+ } -+ - // Paper end - - public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i) { -@@ -167,6 +200,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - this.m = new VillagePlace(new File(this.w, "poi"), datafixer, this.world); // Paper - this.setViewDistance(i); - this.playerMobDistanceMap = this.world.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper -+ this.trackerUpdateDistanceSquared = Math.pow(this.world.paperConfig.trackerUpdateDistance, 2); // Paper - } - - public void updatePlayerMobTypeMap(Entity entity) { -@@ -1334,8 +1368,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - } - - public void movePlayer(EntityPlayer entityplayer) { -- ObjectIterator objectiterator = this.trackedEntities.values().iterator(); -+ // Paper start -+ // ObjectIterator objectiterator = this.trackedEntities.values().iterator(); -+ ObjectIterator objectiterator; - -+ if (MinecraftServer.currentTick - entityplayer.lastTrackedTick >= 20 -+ || entityplayer.lastTrackedPosition.distanceSquared(entityplayer.getPositionVector()) >= trackerUpdateDistanceSquared) { -+ entityplayer.lastTrackedPosition = entityplayer.getPositionVector(); -+ entityplayer.lastTrackedTick = MinecraftServer.currentTick; -+ objectiterator = this.trackedEntities.values().iterator(); // Update all entity trackers -+ } else { -+ objectiterator = getPlayerTrackedEntityMap(entityplayer.getId()).values().iterator(); // Only update entity trackers for already tracked entities -+ } -+ // Paper end - while (objectiterator.hasNext()) { - PlayerChunkMap.EntityTracker playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next(); - -@@ -1345,6 +1390,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - playerchunkmap_entitytracker.updatePlayer(entityplayer); - } - } -+ flushRemoveQueues(); // Paper - - int i = MathHelper.floor(entityplayer.locX()) >> 4; - int j = MathHelper.floor(entityplayer.locZ()) >> 4; -@@ -1486,12 +1532,21 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - - playerchunkmap_entitytracker.clear(entityplayer); - } -+ // Paper start -+ playerTrackedEntities.remove(entityplayer.getId()); -+ playerTrackedEntitiesRemoveQueue.remove(entityplayer.getId()); -+ // Paper end - } - - PlayerChunkMap.EntityTracker playerchunkmap_entitytracker1 = (PlayerChunkMap.EntityTracker) this.trackedEntities.remove(entity.getId()); - - if (playerchunkmap_entitytracker1 != null) { - playerchunkmap_entitytracker1.a(); -+ // Paper start -+ for (EntityPlayer player : playerchunkmap_entitytracker1.trackedPlayers) { -+ getPlayerTrackedEntityMap(player.getId()).remove(playerchunkmap_entitytracker1.tracker.getId()); -+ } -+ // Paper end - } - entity.tracker = null; // Paper - We're no longer tracked - } -@@ -1532,7 +1587,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - } - world.timings.tracker2.stopTiming(); // Paper - } -- -+ flushRemoveQueues(); // Paper - - } - -@@ -1581,6 +1636,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - } - } - } -+ flushRemoveQueue(entityplayer); // Paper - - Iterator iterator; - Entity entity1; -@@ -1677,6 +1733,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - org.spigotmc.AsyncCatcher.catchOp("player tracker clear"); // Spigot - if (this.trackedPlayers.remove(entityplayer)) { - this.trackerEntry.a(entityplayer); -+ getPlayerTrackedEntityMap(entityplayer.getId()).remove(this.tracker.getId()); // Paper - } - - } -@@ -1713,9 +1770,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { - - if (flag1 && this.trackedPlayerMap.putIfAbsent(entityplayer, true) == null) { // Paper - this.trackerEntry.b(entityplayer); -+ getPlayerTrackedEntityMap(entityplayer.getId()).put(this.tracker.getId(), this); // Paper - } - } else if (this.trackedPlayers.remove(entityplayer)) { - this.trackerEntry.a(entityplayer); -+ getPlayerTrackedEntityMapRemoveQueue(entityplayer.getId()).add(this.tracker.getId()); // Paper - } - - } --- -2.25.1.windows.1 - diff --git a/scripts/apply.sh b/scripts/apply.sh index 2a6a693c..0682a3a7 100755 --- a/scripts/apply.sh +++ b/scripts/apply.sh @@ -9,7 +9,7 @@ done . $(dirname $SOURCE)/init.sh PS1="$" -paperVer=$(cat current-paper) +tuinityVer=$(cat current-tuinity) gpgsign="$(git config commit.gpgsign || echo "false")" echo "Rebuilding Forked projects.... " @@ -69,8 +69,8 @@ function enableCommitSigningIfNeeded { } ( - (applyPatch Paper/Paper-API ${FORK_NAME}-API HEAD api $API_REPO && - applyPatch Paper/Paper-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1 + (applyPatch Tuinity/Tuinity-API ${FORK_NAME}-API HEAD api $API_REPO && + applyPatch Tuinity/Tuinity-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1 enableCommitSigningIfNeeded ) || ( echo "Failed to apply patches" diff --git a/scripts/commitup.sh b/scripts/commitup.sh index 222dc8ab..8919502c 100755 --- a/scripts/commitup.sh +++ b/scripts/commitup.sh @@ -7,9 +7,9 @@ function changelog() { base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1) cd $1 && git log --oneline ${base}...HEAD } -paper=$(changelog Paper) +tuinity=$(changelog Tuinity) -log="Updated Paper \n\nUpdating our baseline Paper reference\n\nPaper changes since last:\n$paper" +log="Updated Tuinity \n\nUpdating our baseline Tuinity reference\n\nTuinity changes since last:\n$tuinity" echo -e "$log" | git commit -F - diff --git a/scripts/generatesources.sh b/scripts/generatesources.sh index cb07c522..2eae5c94 100755 --- a/scripts/generatesources.sh +++ b/scripts/generatesources.sh @@ -10,10 +10,10 @@ done cd $basedir -paperVer=$(cat current-paper) +tuinityVer=$(cat current-tuinity) -minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -decompile="Paper/work/Minecraft/$minecraftversion/spigot" +minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +decompile="Tuinity/work/Minecraft/$minecraftversion/spigot" mkdir -p mc-dev/src/net/minecraft/server @@ -29,7 +29,7 @@ do done -base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server" +base="$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server" cd $basedir/mc-dev/src/net/minecraft/server/ for file in $(/bin/ls $base) do @@ -40,4 +40,4 @@ done cd $basedir/mc-dev git add . -A git commit . -m "mc-dev" -git tag -a "$paperVer" -m "$paperVer" 2>/dev/null +git tag -a "$tuinityVer" -m "$tuinityVer" 2>/dev/null diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index dc16dcf0..7b897312 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -8,8 +8,8 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done . $(dirname $SOURCE)/init.sh -workdir=$basedir/Paper/work -minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +workdir=$basedir/Tuinity/work +minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) decompiledir=$workdir/Minecraft/$minecraftversion/spigot nms="net/minecraft/server" @@ -18,13 +18,13 @@ cd $basedir export importedmcdev="" function import { - if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then + if [ -f "$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server/$1.java" ]; then echo "ALREADY IMPORTED $1" return 0 fi export importedmcdev="$importedmcdev $1" file="${1}.java" - target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file" + target="$basedir/Tuinity/Tuinity-Server/src/main/java/$nms/$file" base="$decompiledir/$nms/$file" if [[ ! -f "$target" ]]; then @@ -43,7 +43,7 @@ function importLibrary { shift 3 for file in "$@"; do file="$prefix/$file" - target="$basedir/Paper/Paper-Server/src/main/java/${file}" + target="$basedir/Tuinity/Tuinity-Server/src/main/java/${file}" targetdir=$(dirname "$target") mkdir -p "${targetdir}" base="$workdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file" @@ -57,7 +57,7 @@ function importLibrary { } ( - cd Paper/Paper-Server/ + cd Tuinity/Tuinity-Server/ lastlog=$(git log -1 --oneline) if [[ "$lastlog" = *"EMC-Extra mc-dev Imports"* ]]; then git reset --hard HEAD^ @@ -78,7 +78,7 @@ function containsElement { for f in $files; do containsElement "$f" ${nonnms[@]} if [ "$?" == "1" ]; then - if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then + if [ ! -f "$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server/$f.java" ]; then if [ ! -f "$decompiledir/$nms/$f.java" ]; then echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"; else @@ -111,7 +111,7 @@ done ######################################################## ######################################################## ( - cd Paper/Paper-Server/ + cd Tuinity/Tuinity-Server/ rm -rf nms-patches git add src -A echo -e "EMC-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F - diff --git a/scripts/push.sh b/scripts/push.sh index 651cb776..92d3646b 100755 --- a/scripts/push.sh +++ b/scripts/push.sh @@ -8,6 +8,6 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done . $(dirname $SOURCE)/init.sh -minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) basedir diff --git a/scripts/rebuildpatches.sh b/scripts/rebuildpatches.sh index ffc587e5..27ba16a4 100755 --- a/scripts/rebuildpatches.sh +++ b/scripts/rebuildpatches.sh @@ -40,9 +40,9 @@ function savePatches { savePatches ${FORK_NAME}-API api if [ -f "$basedir/${FORK_NAME}-API/.git/patch-apply-failed" ]; then - echo "$(bashColor 1 31)[[[ WARNING ]]] $(bashColor 1 33)- Not saving Paper-Server as it appears ${FORK_NAME}-API did not apply clean.$(bashColorReset)" + echo "$(bashColor 1 31)[[[ WARNING ]]] $(bashColor 1 33)- Not saving Tuinity-Server as it appears ${FORK_NAME}-API did not apply clean.$(bashColorReset)" echo "$(bashColor 1 33)If this is a mistake, delete $(bashColor 1 34)${FORK_NAME}-API/.git/patch-apply-failed$(bashColor 1 33) and run rebuild again.$(bashColorReset)" - echo "$(bashColor 1 33)Otherwise, rerun ./paper patch to have a clean Paper-API apply so the latest Paper-Server can build.$(bashColorReset)" + echo "$(bashColor 1 33)Otherwise, rerun ./tuinity patch to have a clean Tuinity-API apply so the latest Tuinity-Server can build.$(bashColorReset)" else savePatches ${FORK_NAME}-Server server ${basedir}/scripts/push.sh diff --git a/scripts/upstream.sh b/scripts/upstream.sh index 76049522..ef1c716b 100755 --- a/scripts/upstream.sh +++ b/scripts/upstream.sh @@ -10,33 +10,33 @@ done if [[ "$1" == up* ]]; then ( - cd "$basedir/Paper/" + cd "$basedir/Tuinity/" git fetch && git reset --hard origin/ver/1.14 cd ../ - git add Paper + git add Tuinity ) fi -paperVer=$(gethead Paper) -cd "$basedir/Paper/" +tuinityVer=$(gethead Tuinity) +cd "$basedir/Tuinity/" -./paper patch +./tuinity patch -cd "Paper-Server" +cd "Tuinity-Server" mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }') basedir . $basedir/scripts/importmcdev.sh -minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev") +minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +version=$(echo -e "Tuinity: $tuinityVer\nmc-dev:$importedmcdev") tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $1}')" -echo "$tag" > $basedir/current-paper -git add "$basedir/current-paper" +echo "$tag" > $basedir/current-tuinity +git add "$basedir/current-tuinity" $basedir/scripts/generatesources.sh -cd Paper/ +cd Tuinity/ function tag { ( @@ -51,10 +51,10 @@ echo "Tagging as $tag" echo -e "$version" forcetag=0 -if [ "$(cat $basedir/current-paper)" != "$tag" ]; then +if [ "$(cat $basedir/current-tuinity)" != "$tag" ]; then forcetag=1 fi -tag Paper-API $forcetag -tag Paper-Server $forcetag +tag Tuinity-API $forcetag +tag Tuinity-Server $forcetag From 6d36db0e828ad2f400e2145e51e60ba6e4a8f70c Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sat, 21 Mar 2020 17:30:03 +0100 Subject: [PATCH 02/11] Fix branding --- patches/server/0002-Brandings.patch | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/patches/server/0002-Brandings.patch b/patches/server/0002-Brandings.patch index 1636ae4b..ee025378 100644 --- a/patches/server/0002-Brandings.patch +++ b/patches/server/0002-Brandings.patch @@ -73,12 +73,13 @@ index 0b65cbb2..4b27af23 100644 import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { -+ private final String serverName = "YAPFA"; // YAPFA +- private final String serverName = "Tuinity"; // Paper // Tuinity ++ private final String serverName = "YAPFA"; // Paper // Tuinity // YAPFA private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 770375ed4..d88cc3383 100644 +index 770375ed..aefa51ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -306,7 +306,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -86,19 +87,19 @@ index 770375ed4..d88cc3383 100644 @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { - return new com.destroystokyo.paper.PaperVersionFetcher(); -+ return new de.tr7zw.yapfa.YapfaVersionFetcher();//YAPFA ++ return new de.tr7zw.yapfa.YapfaVersionFetcher(); //YAPFA } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 674096cab..e3c4ad3d3 100644 +index 001b1e51..e3c4ad3d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -11,7 +11,7 @@ public final class Versioning { public static String getBukkitVersion() { String result = "Unknown-Version"; -- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.destroystokyo.paper/paper-api/pom.properties"); +- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.tuinity/tuinity-api/pom.properties"); // Tuinity + InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/de.tr7zw.yapfa/yapfa-api/pom.properties"); // YAPFA Properties properties = new Properties(); From e5b6160903ce53ed4e1488718a038828b126a284 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sat, 21 Mar 2020 17:32:08 +0100 Subject: [PATCH 03/11] jdk11 --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18bace52..4b812276 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1.3.0 + with: + java-version: 11 - name: Build YAPFA run: | git submodule init From 55f4019aabf584fa563eeb5b7d1b7eafa5dc91b5 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 16:40:40 +0100 Subject: [PATCH 04/11] Update upstream --- Tuinity | 2 +- patches/api/0032-Add-getLastTickMs-api.patch | 6 +++--- .../0039-Don-t-save-Fireworks-and-Arrows.patch | 6 +++--- patches/server/0041-Add-getLastTickMs-api.patch | 10 +++++----- ...config-yapfa-command-and-basic-settings.patch | 16 ++++++++-------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Tuinity b/Tuinity index d16b7882..bf2a4dcb 160000 --- a/Tuinity +++ b/Tuinity @@ -1 +1 @@ -Subproject commit d16b7882fc663ed975daf74091449c1927d0242a +Subproject commit bf2a4dcb7c0050a33e59c3f10f83bf68074924fb diff --git a/patches/api/0032-Add-getLastTickMs-api.patch b/patches/api/0032-Add-getLastTickMs-api.patch index 31f183f3..307fbc17 100644 --- a/patches/api/0032-Add-getLastTickMs-api.patch +++ b/patches/api/0032-Add-getLastTickMs-api.patch @@ -1,4 +1,4 @@ -From f729f3eb13144eb45278d3f0671f44339dd55552 Mon Sep 17 00:00:00 2001 +From 60a34cc1a5fa232371cc3f2c6c4f530909e7c70b Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 21:13:14 +0100 Subject: [PATCH] Add getLastTickMs() api @@ -28,10 +28,10 @@ index b9973406..610bd5b1 100644 @NotNull public static Server.Spigot spigot() { diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 80f9abdc..7b6cbe71 100644 +index 55ec8d2d..ba7ef28b 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -1456,4 +1456,15 @@ public interface Server extends PluginMessageRecipient { +@@ -1464,4 +1464,15 @@ public interface Server extends PluginMessageRecipient { */ int getCurrentTick(); // Paper end diff --git a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch index 2dd58af4..c7662cd9 100644 --- a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch +++ b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch @@ -1,4 +1,4 @@ -From 42b73c07d1ef71fd082f14c8eb6682817d33ea68 Mon Sep 17 00:00:00 2001 +From 732cfeed9395bbcedcb3792517e6503172aa05ea Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 21:39:58 +0100 Subject: [PATCH] Don't save Fireworks and Arrows @@ -8,10 +8,10 @@ Subject: [PATCH] Don't save Fireworks and Arrows 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 181f1742..d2a224a8 100644 +index 3cdba5c42..429666193 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1616,7 +1616,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -1636,7 +1636,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } public boolean c(NBTTagCompound nbttagcompound) { diff --git a/patches/server/0041-Add-getLastTickMs-api.patch b/patches/server/0041-Add-getLastTickMs-api.patch index bed061da..492f9895 100644 --- a/patches/server/0041-Add-getLastTickMs-api.patch +++ b/patches/server/0041-Add-getLastTickMs-api.patch @@ -1,4 +1,4 @@ -From 03a99f384fef93ce99164346e625053155eb7438 Mon Sep 17 00:00:00 2001 +From fa0f4dd513ddbd9d30e04835d4ff83d0a94e882d Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 21:13:33 +0100 Subject: [PATCH] Add getLastTickMs() api @@ -10,7 +10,7 @@ Subject: [PATCH] Add getLastTickMs() api 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 376cf955..0276abe1 100644 +index 376cf9556..0276abe1c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -883,6 +883,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant Date: Thu, 5 Mar 2020 22:31:50 +0100 Subject: [PATCH] Add config, yapfa command and basic settings @@ -15,7 +15,7 @@ Subject: [PATCH] Add config, yapfa command and basic settings diff --git a/src/main/java/de/tr7zw/yapfa/YapfaCommand.java b/src/main/java/de/tr7zw/yapfa/YapfaCommand.java new file mode 100644 -index 00000000..76d83f3d +index 000000000..76d83f3db --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/YapfaCommand.java @@ -0,0 +1,129 @@ @@ -151,7 +151,7 @@ index 00000000..76d83f3d \ No newline at end of file diff --git a/src/main/java/de/tr7zw/yapfa/YapfaConfig.java b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java new file mode 100644 -index 00000000..9711cbc5 +index 000000000..9711cbc52 --- /dev/null +++ b/src/main/java/de/tr7zw/yapfa/YapfaConfig.java @@ -0,0 +1,219 @@ @@ -376,7 +376,7 @@ index 00000000..9711cbc5 +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index 610826c9..2ed69f56 100644 +index 610826c9e..2ed69f567 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -194,6 +194,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer @@ -396,10 +396,10 @@ index 610826c9..2ed69f56 100644 this.setSpawnAnimals(dedicatedserverproperties.spawnAnimals); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index d2a224a8..45fdcee0 100644 +index 429666193..2d97ecacb 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -761,6 +761,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -781,6 +781,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke try { this.inLava = false; @@ -407,7 +407,7 @@ index d2a224a8..45fdcee0 100644 this.checkBlockCollisions(); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); -@@ -885,7 +886,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -905,7 +906,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); VoxelShape voxelshape = this.world.getWorldBorder().a(); Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); @@ -417,7 +417,7 @@ index d2a224a8..45fdcee0 100644 Vec3D vec3d1 = vec3d.g() == 0.0D ? vec3d : a(this, vec3d, axisalignedbb, this.world, voxelshapecollision, streamaccumulator); boolean flag = vec3d.x != vec3d1.x; diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 5b402690..839b0f51 100644 +index 5b402690d..839b0f514 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -246,6 +246,7 @@ public abstract class EntityLiving extends Entity { From df3821322df427944a4a300672b7b11df80fc365 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 17:20:21 +0100 Subject: [PATCH 05/11] Add paperclip --- .github/workflows/build.yml | 6 ++++++ .gitignore | 1 + scripts/paperclip.sh | 25 +++++++++++++++++++++++++ yapfa | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100644 scripts/paperclip.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b812276..491ba006 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,3 +25,9 @@ jobs: cd $yapfaDir ./yapfa patch ./yapfa build + ./yapfa paperclip + - name: Upload Artifact + uses: actions/upload-artifact@v2-preview + with: + name: YAPFA + path: yapfa-paperclip.jar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0ef04d81..d245e5ce 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ mc-dev *.iml .settings/org.eclipse.m2e.core.prefs .project +yapfa-paperclip.jar diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh new file mode 100644 index 00000000..8622dfe2 --- /dev/null +++ b/scripts/paperclip.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Copied from https://github.com/PaperMC/Paper/blob/d54ce6c17fb7a35238d6b9f734d30a4289886773/scripts/paperclip.sh +# License from Paper applies to this file + +( +set -e +basedir="$(cd "$1" && pwd -P)" +workdir="$basedir/Tuinity/Paper/work" +mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +paperjar="$basedir/YAPFA-Server/target/yapfa-$mcver.jar" +vanillajar="$workdir/Minecraft/$mcver/$mcver.jar" + +( + cd "$workdir/Paperclip" + mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" +) +cp "$workdir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/yapfa-paperclip.jar" + +echo "" +echo "" +echo "" +echo "Build success!" +echo "Copied final jar to $(cd "$basedir" && pwd -P)/yapfa-paperclip.jar" +) || exit 1 diff --git a/yapfa b/yapfa index 22d3c0b2..a4b380d1 100755 --- a/yapfa +++ b/yapfa @@ -44,6 +44,13 @@ case "$1" in mvn clean install && cd ../${FORK_NAME}-Server && mvn clean install ) || failed=1 ;; + "jar" | "paperclip") + ( + basedir + cd "$basedir" + ./scripts/paperclip.sh + ) + ;; "d" | "de" | "deploy") ( basedir From 108b6efbec8840b2e9c0949924158ab33094bd1e Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 17:32:11 +0100 Subject: [PATCH 06/11] Exec flag --- scripts/paperclip.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/paperclip.sh diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh old mode 100644 new mode 100755 From 8ae1a4c13e9677a99e841316813b6bb1c7573a5d Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 19:13:15 +0100 Subject: [PATCH 07/11] Create 0044-Rewrite-Pathfinder-to-not-use-Streams.patch --- ...ewrite-Pathfinder-to-not-use-Streams.patch | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 patches/server/0044-Rewrite-Pathfinder-to-not-use-Streams.patch diff --git a/patches/server/0044-Rewrite-Pathfinder-to-not-use-Streams.patch b/patches/server/0044-Rewrite-Pathfinder-to-not-use-Streams.patch new file mode 100644 index 00000000..18f04fe3 --- /dev/null +++ b/patches/server/0044-Rewrite-Pathfinder-to-not-use-Streams.patch @@ -0,0 +1,92 @@ +From 811ff3fa87f91169e19575a7c5327feaf77f838d Mon Sep 17 00:00:00 2001 +From: tr7zw +Date: Sun, 22 Mar 2020 19:12:07 +0100 +Subject: [PATCH] Rewrite Pathfinder to not use Streams + +--- + .../java/net/minecraft/server/Pathfinder.java | 48 +++++++++++++++++-- + 1 file changed, 45 insertions(+), 3 deletions(-) + +diff --git a/src/main/java/net/minecraft/server/Pathfinder.java b/src/main/java/net/minecraft/server/Pathfinder.java +index 67c63cfe3..b0fa7dbf7 100644 +--- a/src/main/java/net/minecraft/server/Pathfinder.java ++++ b/src/main/java/net/minecraft/server/Pathfinder.java +@@ -2,7 +2,6 @@ package net.minecraft.server; + + import com.google.common.collect.Lists; + import com.google.common.collect.Sets; +-import java.util.Comparator; + import java.util.Iterator; + import java.util.List; + import java.util.Map; +@@ -10,7 +9,6 @@ import java.util.Optional; + import java.util.Set; + import java.util.function.Function; + import java.util.stream.Collectors; +-import java.util.stream.Stream; + import javax.annotation.Nullable; + + public class Pathfinder { +@@ -94,6 +92,48 @@ public class Pathfinder { + } + } + ++ // YAPFA start ++ ++ boolean anyMatch = false; ++ for(PathDestination path : set) { ++ if(path.f()) { ++ anyMatch = true; ++ break; ++ } ++ } ++ PathEntity lowest = null; ++ if(anyMatch) { ++ for(PathDestination path : set) { ++ if(path.f()) { ++ if(lowest == null) { ++ lowest = this.a(path.d(), (BlockPosition) map.get(path), true); ++ }else { ++ PathEntity dest = this.a(path.d(), (BlockPosition) map.get(path), true); ++ if(dest.e() < lowest.e()) { ++ lowest = dest; ++ } ++ } ++ } ++ } ++ } else { ++ for(PathDestination path : set) { ++ if(path.f()) { ++ if(lowest == null) { ++ lowest = this.a(path.d(), (BlockPosition) map.get(path), false); ++ }else { ++ PathEntity dest = this.a(path.d(), (BlockPosition) map.get(path), false); ++ if(dest.l() < lowest.l()) { ++ lowest = dest; ++ }else if(dest.l() == lowest.l() && dest.e() < lowest.e()) { ++ lowest = dest; ++ } ++ } ++ } ++ } ++ } ++ ++ Optional optional = Optional.ofNullable(lowest); ++ /* + Stream stream; + + if (set.stream().anyMatch(PathDestination::f)) { +@@ -107,7 +147,9 @@ public class Pathfinder { + } + + Optional optional = stream.findFirst(); +- ++ */ ++ // YAPFA end ++ + if (!optional.isPresent()) { + return null; + } else { +-- +2.25.1.windows.1 + From 0a582a786d72a5dc1468b95a98cb5db9b7c29f1a Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 20:44:02 +0100 Subject: [PATCH 08/11] Rewrite BehaviorController, add some utility to patch paper --- .github/workflows/build.yml | 1 + compile.sh | 41 --- patchPaper.sh | 1 + ...aviorController-with-99-less-Streams.patch | 270 ++++++++++++++++++ scripts/importmcdev.sh | 118 -------- scripts/importmcdev_paper.sh | 119 ++++++++ 6 files changed, 391 insertions(+), 159 deletions(-) delete mode 100644 compile.sh create mode 100644 patchPaper.sh create mode 100644 patches/server/0045-Rewrite-BehaviorController-with-99-less-Streams.patch delete mode 100755 scripts/importmcdev.sh create mode 100644 scripts/importmcdev_paper.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 491ba006..e5d97c26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,7 @@ jobs: git config --global user.email "ci@github.com" git config --global user.name "Github CI" yapfaDir=`pwd` + ./patchPaper.sh cd Tuinity ./tuinity jar cd $yapfaDir diff --git a/compile.sh b/compile.sh deleted file mode 100644 index 4d5f2740..00000000 --- a/compile.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -# get base dir regardless of execution location -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}") -basedir=$(dirname "$SOURCE") -cd "$basedir" -git pull -. scripts/init.sh -git submodule sync -git submodule update --init -( - cd Paper/ - git submodule update --init -) -mc=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) - -function update() { - cd $basedir - folder=${FORK_NAME}-$1 - if [ ! -d "$folder" ]; then - git clone "$2" $folder - fi - - cd $basedir/$folder - git fetch origin - git checkout master - git reset --hard origin/$mc -} -mvn clean install -N -update API "$API_REPO" -update Server "$SERVER_REPO" - -cd .. -if [ "$1" != "--nocompile" ]; then - mvn clean install -fi \ No newline at end of file diff --git a/patchPaper.sh b/patchPaper.sh new file mode 100644 index 00000000..2183b818 --- /dev/null +++ b/patchPaper.sh @@ -0,0 +1 @@ +cp -f ./scripts/importmcdev_paper.sh ./Tuinity/Paper/scripts/importmcdev.sh \ No newline at end of file diff --git a/patches/server/0045-Rewrite-BehaviorController-with-99-less-Streams.patch b/patches/server/0045-Rewrite-BehaviorController-with-99-less-Streams.patch new file mode 100644 index 00000000..0173edf6 --- /dev/null +++ b/patches/server/0045-Rewrite-BehaviorController-with-99-less-Streams.patch @@ -0,0 +1,270 @@ +From 698a03fe533c795e57b1f30f0099438699fc034b Mon Sep 17 00:00:00 2001 +From: tr7zw +Date: Sun, 22 Mar 2020 20:42:24 +0100 +Subject: [PATCH] Rewrite BehaviorController with 99% less Streams + +--- + .../minecraft/server/BehaviorController.java | 250 ++++++++++++++++++ + 1 file changed, 250 insertions(+) + create mode 100644 src/main/java/net/minecraft/server/BehaviorController.java + +diff --git a/src/main/java/net/minecraft/server/BehaviorController.java b/src/main/java/net/minecraft/server/BehaviorController.java +new file mode 100644 +index 000000000..1bb496b3e +--- /dev/null ++++ b/src/main/java/net/minecraft/server/BehaviorController.java +@@ -0,0 +1,250 @@ ++package net.minecraft.server; ++ ++import java.util.Collection; ++import java.util.HashMap; ++import java.util.Iterator; ++import java.util.Map; ++import java.util.Map.Entry; ++import java.util.Optional; ++import java.util.Set; ++import java.util.function.Function; ++import java.util.stream.Stream; ++ ++import javax.annotation.Nullable; ++ ++import com.google.common.collect.ImmutableList; ++import com.google.common.collect.ImmutableMap; ++import com.google.common.collect.ImmutableSet; ++import com.google.common.collect.Maps; ++import com.google.common.collect.Sets; ++import com.mojang.datafixers.Dynamic; ++import com.mojang.datafixers.types.DynamicOps; ++import com.mojang.datafixers.util.Pair; ++ ++import net.minecraft.server.Behavior.Status; ++ ++public class BehaviorController implements MinecraftSerializable { ++ private final Map, Optional> memories = Maps.newHashMap(); ++ private final Map>, Sensor> sensors = Maps.newLinkedHashMap(); ++ private final Map>>> c = Maps.newTreeMap(); ++ private Schedule schedule; ++ private final Map, MemoryStatus>>> e; ++ private Set f; ++ private final Set g; ++ private Activity h; ++ private long i; ++ ++ public BehaviorController(Collection> var0, ++ Collection>> var1, Dynamic var2) { ++ this.schedule = Schedule.EMPTY; ++ this.e = Maps.newHashMap(); ++ this.f = Sets.newHashSet(); ++ this.g = Sets.newHashSet(); ++ this.h = Activity.IDLE; ++ this.i = -9999L; ++ for(MemoryModuleType mem : var0) { ++ this.memories.put(mem, Optional.empty()); ++ } ++ for(SensorType> sensor : var1) { ++ this.sensors.put(sensor, sensor.a()); ++ } ++ for(Sensor sensor : sensors.values()) { ++ Iterator> var2x = sensor.a().iterator(); ++ ++ while (var2x.hasNext()) { ++ MemoryModuleType next = var2x.next(); ++ this.memories.put(next, Optional.empty()); ++ } ++ } ++ ++ Iterator, Dynamic>> var4 = var2.get("memories").asMap(Function.identity(), Function.identity()).entrySet().iterator(); ++ ++ while (var4.hasNext()) { ++ Entry, Dynamic> var5 = var4.next(); ++ this.a(IRegistry.MEMORY_MODULE_TYPE ++ .get(new MinecraftKey(( var5.getKey()).asString(""))), var5.getValue()); ++ } ++ ++ } ++ ++ public boolean hasMemory(MemoryModuleType var0) { ++ return this.a(var0, MemoryStatus.VALUE_PRESENT); ++ } ++ ++ private void a(MemoryModuleType var0, Dynamic var1) { ++ this.setMemory(var0, (U)((Function) var0.getSerializer().orElseThrow(RuntimeException::new)).apply(var1)); ++ } ++ ++ public void removeMemory(MemoryModuleType var0) { ++ this.setMemory(var0, Optional.empty()); ++ } ++ ++ public void setMemory(MemoryModuleType var0, @Nullable U var1) { ++ this.setMemory(var0, Optional.ofNullable(var1)); ++ } ++ ++ public void setMemory(MemoryModuleType var0, Optional var1) { ++ if (this.memories.containsKey(var0)) { ++ if (var1.isPresent() && this.a(var1.get())) { ++ this.removeMemory(var0); ++ } else { ++ this.memories.put(var0, var1); ++ } ++ } ++ ++ } ++ ++ public Optional getMemory(MemoryModuleType var0) { ++ return (Optional) this.memories.get(var0); ++ } ++ ++ public boolean a(MemoryModuleType var0, MemoryStatus var1) { ++ Optional var2 = this.memories.get(var0); ++ if (var2 == null) { ++ return false; ++ } else { ++ return var1 == MemoryStatus.REGISTERED || var1 == MemoryStatus.VALUE_PRESENT && var2.isPresent() ++ || var1 == MemoryStatus.VALUE_ABSENT && !var2.isPresent(); ++ } ++ } ++ ++ public Schedule getSchedule() { ++ return this.schedule; ++ } ++ ++ public void setSchedule(Schedule var0) { ++ this.schedule = var0; ++ } ++ ++ public void a(Set var0) { ++ this.f = var0; ++ } ++ ++ @Deprecated ++ public Stream> d() { ++ return this.c.values().stream().flatMap((var0) -> { ++ return var0.values().stream(); ++ }).flatMap(Collection::stream).filter((var0) -> { ++ return var0.a() == Status.RUNNING; ++ }); ++ } ++ ++ public void a(Activity var0) { ++ this.g.clear(); ++ this.g.addAll(this.f); ++ boolean var1 = this.e.keySet().contains(var0) && this.d(var0); ++ this.g.add(var1 ? var0 : this.h); ++ } ++ ++ public void a(long var0, long var2) { ++ if (var2 - this.i > 20L) { ++ this.i = var2; ++ Activity var4 = this.getSchedule().a((int) (var0 % 24000L)); ++ if (!this.g.contains(var4)) { ++ this.a(var4); ++ } ++ } ++ ++ } ++ ++ public void b(Activity var0) { ++ this.h = var0; ++ } ++ ++ public void a(Activity var0, ImmutableList>> var1) { ++ this.a((Activity) var0, var1, ImmutableSet.of()); ++ } ++ ++ public void a(Activity var0, ImmutableList>> var1, ++ Set, MemoryStatus>> var2) { ++ this.e.put(var0, var2); ++ for(Pair> var1x : var1) { ++ ((this.c.computeIfAbsent(var1x.getFirst(), (var0x) -> { ++ return Maps.newHashMap(); ++ })).computeIfAbsent(var0, (var0x) -> { ++ return Sets.newLinkedHashSet(); ++ })).add(var1x.getSecond()); ++ } ++ } ++ ++ public boolean c(Activity var0) { ++ return this.g.contains(var0); ++ } ++ ++ public BehaviorController f() { ++ BehaviorController var0 = new BehaviorController(this.memories.keySet(), this.sensors.keySet(), ++ new Dynamic<>(DynamicOpsNBT.a, new NBTTagCompound())); ++ for(Entry, Optional> entry : this.memories.entrySet()) { ++ entry.getValue().ifPresent((var2x) -> { ++ var0.memories.put(entry.getKey(), Optional.of(var2x)); ++ }); ++ } ++ return var0; ++ } ++ ++ public void a(WorldServer var0, E var1) { ++ this.c(var0, var1); ++ this.d(var0, var1); ++ this.e(var0, var1); ++ } ++ ++ public void b(WorldServer var0, E var1) { ++ long var2 = var1.world.getTime(); ++ this.d().forEach((var4) -> { ++ var4.e(var0, var1, var2); ++ }); ++ } ++ ++ public T a(DynamicOps var0) { ++ Map outMap = new HashMap(); ++ for(Entry, Optional> memory : this.memories.entrySet()) { ++ if((memory.getKey()).getSerializer().isPresent() && (memory.getValue()).isPresent()) { ++ outMap.put(var0.createString(IRegistry.MEMORY_MODULE_TYPE.getKey(memory.getKey()).toString()), ((MinecraftSerializable) (memory.getValue()).get()).a(var0)); ++ } ++ } ++ return var0.createMap(ImmutableMap.of(var0.createString("memories"), var0.createMap(outMap))); ++ } ++ ++ private void c(WorldServer var0, E var1) { ++ for(Sensor var2 : this.sensors.values()) { ++ var2.b(var0, var1); ++ } ++ } ++ ++ private void d(WorldServer var0, E var1) { ++ long var2 = var0.getTime(); ++ for(Map>> value : this.c.values()) { ++ for(Entry>> entry : value.entrySet()) { ++ if(this.g.contains(entry.getKey())) { ++ for(Behavior behavior : entry.getValue()) { ++ if(behavior.a() == Status.STOPPED) { ++ behavior.b(var0, var1, var2); ++ } ++ } ++ } ++ } ++ } ++ } ++ ++ private void e(WorldServer var0, E var1) { ++ long var2 = var0.getTime(); ++ this.d().forEach((var4) -> { ++ var4.c(var0, var1, var2); ++ }); ++ } ++ ++ private boolean d(Activity var0) { ++ for(Pair, MemoryStatus> entry : this.e.get(var0)) { ++ MemoryModuleType var1 = entry.getFirst(); ++ MemoryStatus var2 = entry.getSecond(); ++ if(!this.a(var1, var2)) { ++ return false; ++ } ++ } ++ return true; ++ } ++ ++ private boolean a(Object var0) { ++ return var0 instanceof Collection && ((Collection) var0).isEmpty(); ++ } ++} +\ No newline at end of file +-- +2.25.1.windows.1 + diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh deleted file mode 100755 index 7b897312..00000000 --- a/scripts/importmcdev.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash - -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -. $(dirname $SOURCE)/init.sh - -workdir=$basedir/Tuinity/work -minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -decompiledir=$workdir/Minecraft/$minecraftversion/spigot - -nms="net/minecraft/server" -export MODLOG="" -cd $basedir - -export importedmcdev="" -function import { - if [ -f "$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server/$1.java" ]; then - echo "ALREADY IMPORTED $1" - return 0 - fi - export importedmcdev="$importedmcdev $1" - file="${1}.java" - target="$basedir/Tuinity/Tuinity-Server/src/main/java/$nms/$file" - base="$decompiledir/$nms/$file" - - if [[ ! -f "$target" ]]; then - export MODLOG="$MODLOG Imported $file from mc-dev\n"; - echo "$(bashColor 1 32) Copying $(bashColor 1 34)$base $(bashColor 1 32)to$(bashColor 1 34) $target $(bashColorReset)" - cp "$base" "$target" - else - echo "$(bashColor 1 33) UN-NEEDED IMPORT STATEMENT:$(bashColor 1 34) $file $(bashColorReset)" - fi -} - -function importLibrary { - group=$1 - lib=$2 - prefix=$3 - shift 3 - for file in "$@"; do - file="$prefix/$file" - target="$basedir/Tuinity/Tuinity-Server/src/main/java/${file}" - targetdir=$(dirname "$target") - mkdir -p "${targetdir}" - base="$workdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file" - if [ ! -f "$base" ]; then - echo "Missing $base" - exit 1 - fi - export MODLOG="$MODLOG Imported $file from $lib\n"; - sed 's/\r$//' "$base" > "$target" || exit 1 - done -} - -( - cd Tuinity/Tuinity-Server/ - lastlog=$(git log -1 --oneline) - if [[ "$lastlog" = *"EMC-Extra mc-dev Imports"* ]]; then - git reset --hard HEAD^ - fi -) - - -files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') - -nonnms=$(cat patches/server/* | grep "create mode " | grep -Po "src/main/java/net/minecraft/server/(.*?).java" | sort | uniq | sed 's/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') -function containsElement { - local e - for e in "${@:2}"; do - [[ "$e" == "$1" ]] && return 0; - done - return 1 -} -for f in $files; do - containsElement "$f" ${nonnms[@]} - if [ "$?" == "1" ]; then - if [ ! -f "$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server/$f.java" ]; then - if [ ! -f "$decompiledir/$nms/$f.java" ]; then - echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"; - else - import $f - fi - fi - fi -done - -############################################################################################### -############################################################################################### -#################### ADD TEMPORARY ADDITIONS HERE ############################################# -############################################################################################### -############################################################################################### - -# import FileName - -######################################################## -######################################################## -######################################################## -# LIBRARY IMPORTS -# These must always be mapped manually, no automatic stuff -# -# importLibrary # group # lib # prefix # many files -# importLibrary com.mojang datafixerupper com/mojang/datafixers/types Type.java - -# dont forget \ at end of each line but last - -######################################################## -######################################################## -######################################################## -( - cd Tuinity/Tuinity-Server/ - rm -rf nms-patches - git add src -A - echo -e "EMC-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F - -) diff --git a/scripts/importmcdev_paper.sh b/scripts/importmcdev_paper.sh new file mode 100644 index 00000000..456dba84 --- /dev/null +++ b/scripts/importmcdev_paper.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +( +set -e +nms="net/minecraft/server" +export MODLOG="" +PS1="$" +basedir="$(cd "$1" && pwd -P)" +source "$basedir/scripts/functions.sh" +gitcmd="git -c commit.gpgsign=false" + +workdir="$basedir/work" +minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +decompiledir="$workdir/Minecraft/$minecraftversion/forge" +# replace for now +decompiledir="$workdir/Minecraft/$minecraftversion/spigot" +export importedmcdev="" +function import { + export importedmcdev="$importedmcdev $1" + file="${1}.java" + target="$workdir/Spigot/Spigot-Server/src/main/java/$nms/$file" + base="$decompiledir/$nms/$file" + + if [[ ! -f "$target" ]]; then + export MODLOG="$MODLOG Imported $file from mc-dev\n"; + #echo "Copying $base to $target" + cp "$base" "$target" || exit 1 + else + echo "UN-NEEDED IMPORT: $file" + fi +} + +function importLibrary { + group=$1 + lib=$2 + prefix=$3 + shift 3 + for file in "$@"; do + file="$prefix/$file" + target="$workdir/Spigot/Spigot-Server/src/main/java/${file}" + targetdir=$(dirname "$target") + mkdir -p "${targetdir}" + base="$workdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file" + if [ ! -f "$base" ]; then + echo "Missing $base" + exit 1 + fi + export MODLOG="$MODLOG Imported $file from $lib\n"; + sed 's/\r$//' "$base" > "$target" || exit 1 + done +} + +( + cd "$workdir/Spigot/Spigot-Server/" + lastlog=$($gitcmd log -1 --oneline) + if [[ "$lastlog" = *"mc-dev Imports"* ]]; then + $gitcmd reset --hard HEAD^ + fi +) + + + +files=$(cat "$basedir/Spigot-Server-Patches/"* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') + +nonnms=$(grep -R "new file mode" -B 1 "$basedir/Spigot-Server-Patches/" | grep -v "new file mode" | grep -oE "net\/minecraft\/server\/.*.java" | grep -oE "[A-Za-z]+?.java$" --color=none | sed 's/.java//g') +function containsElement { + local e + for e in "${@:2}"; do + [[ "$e" == "$1" ]] && return 0; + done + return 1 +} +set +e +for f in $files; do + containsElement "$f" ${nonnms[@]} + if [ "$?" == "1" ]; then + if [ ! -f "$workdir/Spigot/Spigot-Server/src/main/java/net/minecraft/server/$f.java" ]; then + if [ ! -f "$decompiledir/$nms/$f.java" ]; then + echo "$(color 1 31) ERROR!!! Missing NMS$(color 1 34) $f $(colorend)"; + else + import $f + fi + fi + fi +done + +######################################################## +######################################################## +######################################################## +# NMS IMPORTS +# Temporarily add new NMS dev imports here before you run paper patch +# but after you have paper rb'd your changes, remove the line from this file before committing. +# we do not need any lines added to this file for NMS + +#import BehaviorController + + + +######################################################## +######################################################## +######################################################## +# LIBRARY IMPORTS +# These must always be mapped manually, no automatic stuff +# +# # group # lib # prefix # many files + +# dont forget \ at end of each line but last +importLibrary com.mojang authlib com/mojang/authlib yggdrasil/YggdrasilGameProfileRepository.java +importLibrary com.mojang datafixerupper com/mojang/datafixers/util Either.java + +######################################################## +######################################################## +######################################################## +set -e +cd "$workdir/Spigot/Spigot-Server/" +rm -rf nms-patches applyPatches.sh makePatches.sh >/dev/null 2>&1 +$gitcmd add . -A >/dev/null 2>&1 +echo -e "mc-dev Imports\n\n$MODLOG" | $gitcmd commit . -F - +) From d476c59b91251e0ef1ac1a15c66dcdff726d5d76 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Sun, 22 Mar 2020 20:47:50 +0100 Subject: [PATCH 09/11] Fix flags --- patchPaper.sh | 0 scripts/importmcdev_paper.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 patchPaper.sh mode change 100644 => 100755 scripts/importmcdev_paper.sh diff --git a/patchPaper.sh b/patchPaper.sh old mode 100644 new mode 100755 diff --git a/scripts/importmcdev_paper.sh b/scripts/importmcdev_paper.sh old mode 100644 new mode 100755 From 9afd5b607d78d85ffd1f1f4e3686b03c956b9f47 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Mon, 23 Mar 2020 18:22:43 +0100 Subject: [PATCH 10/11] Create 0046-Remove-Stream-usage.patch --- patches/server/0046-Remove-Stream-usage.patch | 648 ++++++++++++++++++ 1 file changed, 648 insertions(+) create mode 100644 patches/server/0046-Remove-Stream-usage.patch diff --git a/patches/server/0046-Remove-Stream-usage.patch b/patches/server/0046-Remove-Stream-usage.patch new file mode 100644 index 00000000..e8923165 --- /dev/null +++ b/patches/server/0046-Remove-Stream-usage.patch @@ -0,0 +1,648 @@ +From 09fe7e940891f10e7eb8ace0ad12f1485f07ccf6 Mon Sep 17 00:00:00 2001 +From: tr7zw +Date: Mon, 23 Mar 2020 18:20:58 +0100 +Subject: [PATCH] Remove Stream usage + +This removes streams from the entity collision code, Crafting Manager and some other useless places. +--- + .../yapfa/collision/CollisionHelper.java | 123 +++++++++++++++ + .../server/BehaviorInteractDoor.java | 27 +++- + src/main/java/net/minecraft/server/Block.java | 2 +- + .../net/minecraft/server/BlockPosition.java | 2 +- + .../net/minecraft/server/CraftingManager.java | 57 +++++-- + .../java/net/minecraft/server/Entity.java | 145 ++++++++++++++++-- + .../net/minecraft/server/EntityLiving.java | 1 + + .../net/minecraft/server/VoxelShapes.java | 103 +++++++++++++ + 8 files changed, 424 insertions(+), 36 deletions(-) + create mode 100644 src/main/java/de/tr7zw/yapfa/collision/CollisionHelper.java + +diff --git a/src/main/java/de/tr7zw/yapfa/collision/CollisionHelper.java b/src/main/java/de/tr7zw/yapfa/collision/CollisionHelper.java +new file mode 100644 +index 000000000..d67753937 +--- /dev/null ++++ b/src/main/java/de/tr7zw/yapfa/collision/CollisionHelper.java +@@ -0,0 +1,123 @@ ++package de.tr7zw.yapfa.collision; ++ ++import java.util.List; ++import java.util.Spliterator; ++import java.util.Spliterators; ++import java.util.Spliterators.AbstractSpliterator; ++import java.util.function.Consumer; ++ ++import javax.annotation.Nullable; ++ ++import com.google.common.collect.Lists; ++ ++import net.minecraft.server.AxisAlignedBB; ++import net.minecraft.server.BlockPosition; ++import net.minecraft.server.BlockPosition.MutableBlockPosition; ++import net.minecraft.server.Blocks; ++import net.minecraft.server.CursorPosition; ++import net.minecraft.server.Entity; ++import net.minecraft.server.IBlockAccess; ++import net.minecraft.server.IBlockData; ++import net.minecraft.server.ICollisionAccess; ++import net.minecraft.server.MathHelper; ++import net.minecraft.server.OperatorBoolean; ++import net.minecraft.server.StreamAccumulator; ++import net.minecraft.server.VoxelShape; ++import net.minecraft.server.VoxelShapeCollision; ++import net.minecraft.server.VoxelShapes; ++ ++public class CollisionHelper { ++ ++ public static AbstractSpliterator b(ICollisionAccess collisionAccess, VoxelShape worldBorder, @Nullable Entity var0, AxisAlignedBB var1) { ++ int var2 = MathHelper.floor((double) (var1.minX - 1.0E-7)) - 1; ++ int var3 = MathHelper.floor((double) (var1.maxX + 1.0E-7)) + 1; ++ int var4 = MathHelper.floor((double) (var1.minY - 1.0E-7)) - 1; ++ int var5 = MathHelper.floor((double) (var1.maxY + 1.0E-7)) + 1; ++ int var6 = MathHelper.floor((double) (var1.minZ - 1.0E-7)) - 1; ++ int var7 = MathHelper.floor((double) (var1.maxZ + 1.0E-7)) + 1; ++ final VoxelShapeCollision var8 = var0 == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) var0); ++ final CursorPosition var9 = new CursorPosition(var2, var4, var6, var3, var5, var7); ++ final BlockPosition.MutableBlockPosition var10 = new BlockPosition.MutableBlockPosition(); ++ final VoxelShape var11 = VoxelShapes.a((AxisAlignedBB) var1); ++ return new Spliterators.AbstractSpliterator(Long.MAX_VALUE, 1280) { ++ boolean a; ++ { ++ ++ this.a = var0 == null; ++ } ++ ++ @Override ++ public boolean tryAdvance(Consumer var02) { ++ int var2; ++ int var3; ++ if (!this.a) { ++ this.a = true; ++ VoxelShape var1 = collisionAccess.getWorldBorder().a(); ++ var2 = VoxelShapes.c((VoxelShape) var1, ++ (VoxelShape) VoxelShapes.a((AxisAlignedBB) var0.getBoundingBox().shrink(1.0E-7)), ++ (OperatorBoolean) OperatorBoolean.AND) ? 1 : 0; ++ var3 = VoxelShapes.c((VoxelShape) var1, ++ (VoxelShape) VoxelShapes.a((AxisAlignedBB) var0.getBoundingBox().g(1.0E-7)), ++ (OperatorBoolean) OperatorBoolean.AND) ? 1 : 0; ++ if (var2 == 0 && var3 != 0) { ++ var02.accept((VoxelShape) var1); ++ return true; ++ } ++ } ++ while (var9.a()) { ++ IBlockAccess var7; ++ int var6; ++ int var5; ++ VoxelShape var92; ++ VoxelShape var102; ++ int var1 = var9.b(); ++ var2 = var9.c(); ++ var3 = var9.d(); ++ int var4 = var9.e(); ++ if (var4 == 3 || (var7 = collisionAccess.c(var5 = var1 >> 4, var6 = var3 >> 4)) == null) ++ continue; ++ var10.d(var1, var2, var3); ++ IBlockData var82 = var7.getType((BlockPosition) var10); ++ if (var4 == 1 && !var82.f() || var4 == 2 && var82.getBlock() != Blocks.MOVING_PISTON ++ || !VoxelShapes.c((VoxelShape) var11, ++ (VoxelShape) (var102 = (var92 = var82.b((IBlockAccess) collisionAccess, ++ (BlockPosition) var10, var8)).a((double) var1, (double) var2, ++ (double) var3)), ++ (OperatorBoolean) OperatorBoolean.AND)) ++ continue; ++ var02.accept((VoxelShape) var102); ++ return true; ++ } ++ return false; ++ } ++ }; ++ } ++ ++ public static class SpliteratorAccumulator { ++ private final List a = Lists.newArrayList(); ++ private final Spliterator b; ++ ++ public SpliteratorAccumulator(Spliterator var0) { ++ this.b = var0; ++ } ++ ++ public Spliterators.AbstractSpliterator a() { ++ return new Spliterators.AbstractSpliterator(Long.MAX_VALUE, 0) { ++ private int b; ++ ++ @Override ++ public boolean tryAdvance(Consumer var0) { ++ while (this.b >= SpliteratorAccumulator.this.a.size()) { ++ if (SpliteratorAccumulator.this.b.tryAdvance(SpliteratorAccumulator.this.a::add)) ++ continue; ++ return false; ++ } ++ var0.accept(SpliteratorAccumulator.this.a.get(this.b++)); ++ return true; ++ } ++ }; ++ } ++ ++ } ++ ++} +diff --git a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java +index 01d9c2d92..8c8be194e 100644 +--- a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java ++++ b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java +@@ -2,6 +2,9 @@ package net.minecraft.server; + + import com.google.common.collect.ImmutableMap; + import com.google.common.collect.Sets; ++ ++import java.util.ArrayList; ++import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Set; +@@ -19,9 +22,16 @@ public class BehaviorInteractDoor extends Behavior { + BehaviorController behaviorcontroller = entityliving.getBehaviorController(); + PathEntity pathentity = (PathEntity) behaviorcontroller.getMemory(MemoryModuleType.PATH).get(); + List list = (List) behaviorcontroller.getMemory(MemoryModuleType.INTERACTABLE_DOORS).get(); ++ // YAPFA start ++ List list1 = new ArrayList(); ++ for(PathPoint pathpoint : pathentity.d()) { ++ list1.add(new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c)); ++ } ++ /* + List list1 = (List) pathentity.d().stream().map((pathpoint) -> { + return new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c); + }).collect(Collectors.toList()); ++ */ // YAPFA end + Set set = this.a(worldserver, list, list1); + int j = pathentity.f() - 1; + +@@ -29,12 +39,25 @@ public class BehaviorInteractDoor extends Behavior { + } + + private Set a(WorldServer worldserver, List list, List list1) { +- Stream stream = list.stream().filter((globalpos) -> { ++ // YAPFA start ++ Set positions = new HashSet(); ++ for(GlobalPos globalpos : list) { ++ if(globalpos.getDimensionManager() == worldserver.getWorldProvider().getDimensionManager()) { ++ BlockPosition pos = globalpos.getBlockPosition(); ++ if(list1.contains(pos)) { ++ positions.add(pos); ++ } ++ } ++ } ++ return positions; ++ /* ++ Stream stream = list.stream().filter((globalpos) -> { + return globalpos.getDimensionManager() == worldserver.getWorldProvider().getDimensionManager(); + }).map(GlobalPos::getBlockPosition); +- ++ + list1.getClass(); + return (Set) stream.filter(list1::contains).collect(Collectors.toSet()); ++ */ // YAPFA end + } + + private void a(WorldServer worldserver, List list, Set set, int i, EntityLiving entityliving, BehaviorController behaviorcontroller) { +diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java +index e40375b67..2a5574be3 100644 +--- a/src/main/java/net/minecraft/server/Block.java ++++ b/src/main/java/net/minecraft/server/Block.java +@@ -92,7 +92,7 @@ public class Block implements IMaterial { + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); +- double d0 = VoxelShapes.a(EnumDirection.EnumAxis.Y, entity.getBoundingBox().d(0.0D, 1.0D, 0.0D), Stream.of(voxelshape), -1.0D); ++ double d0 = VoxelShapes.a(EnumDirection.EnumAxis.Y, entity.getBoundingBox().d(0.0D, 1.0D, 0.0D), voxelshape, -1.0D); // YAPFA + + entity.enderTeleportTo(entity.locX(), entity.locY() + 1.0D + d0, entity.locZ()); + } +diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java +index 2d07d350d..51a574184 100644 +--- a/src/main/java/net/minecraft/server/BlockPosition.java ++++ b/src/main/java/net/minecraft/server/BlockPosition.java +@@ -72,7 +72,7 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali + + @Override + public T a(DynamicOps dynamicops) { +- return dynamicops.createIntList(IntStream.of(new int[]{this.getX(), this.getY(), this.getZ()})); ++ return (T) new NBTTagIntArray(new int[]{this.getX(), this.getY(), this.getZ()}); // YAPFA + } + + public static long a(long i, EnumDirection enumdirection) { +diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java +index 6def3616e..e1338f809 100644 +--- a/src/main/java/net/minecraft/server/CraftingManager.java ++++ b/src/main/java/net/minecraft/server/CraftingManager.java +@@ -8,14 +8,18 @@ import com.google.gson.GsonBuilder; + import com.google.gson.JsonObject; + import com.google.gson.JsonParseException; + import com.google.gson.JsonSyntaxException; ++ ++import java.util.ArrayList; + import java.util.Collection; + import java.util.Collections; + import java.util.Comparator; ++import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Objects; + import java.util.Optional; ++import java.util.Set; + import java.util.Map.Entry; + import java.util.stream.Collectors; + import java.util.stream.Stream; +@@ -77,21 +81,30 @@ public class CraftingManager extends ResourceDataJson { + // CraftBukkit end + + public > Optional craft(Recipes recipes, C c0, World world) { +- // CraftBukkit start +- Optional recipe = this.a(recipes).values().stream().flatMap((irecipe) -> { +- return SystemUtils.a(recipes.a(irecipe, world, c0)); +- }).findFirst(); +- c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found +- // CraftBukkit end +- return recipe; ++ // YAPFA start ++ for(IRecipe rep : this.a(recipes).values()) { ++ Optional optional = recipes.a(rep, world, c0); ++ if(optional.isPresent()) { ++ return optional; ++ } ++ } ++ c0.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found ++ return Optional.empty(); ++ // YAPFA end + } + + public > List b(Recipes recipes, C c0, World world) { +- return (List) this.a(recipes).values().stream().flatMap((irecipe) -> { +- return SystemUtils.a(recipes.a(irecipe, world, c0)); +- }).sorted(Comparator.comparing((irecipe) -> { ++ // YAPFA start ++ List list = new ArrayList(); ++ for(IRecipe rec : this.a(recipes).values()) { ++ Optional optional = recipes.a(rec, world, c0); ++ optional.ifPresent(list::add); ++ } ++ list.sort(Comparator.comparing((irecipe) -> { + return irecipe.getResult().j(); +- })).collect(Collectors.toList()); ++ })); ++ return list; ++ // YAPFA end + } + + private > Map> a(Recipes recipes) { +@@ -115,15 +128,25 @@ public class CraftingManager extends ResourceDataJson { + } + + public Optional> a(MinecraftKey minecraftkey) { +- return this.recipes.values().stream().map((map) -> { +- return map.get(minecraftkey); // CraftBukkit - decompile error +- }).filter(Objects::nonNull).findFirst(); ++ // YAPFA start ++ for(Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { ++ IRecipe rec = map.get(minecraftkey); ++ if(rec != null) { ++ return Optional.of(rec); ++ } ++ } ++ return Optional.empty(); ++ // YAPFA end + } + + public Collection> b() { +- return (Collection) this.recipes.values().stream().flatMap((map) -> { +- return map.values().stream(); +- }).collect(Collectors.toSet()); ++ // YAPFA start ++ Set> recipes = new HashSet>(); ++ for(Object2ObjectLinkedOpenHashMap> map : this.recipes.values()) { ++ recipes.addAll(map.values()); ++ } ++ return recipes; ++ // YAPFA end + } + + public Stream c() { +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index 2d97ecacb..51b68de53 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -13,6 +13,7 @@ import java.util.Locale; + import java.util.Optional; + import java.util.Random; + import java.util.Set; ++import java.util.Spliterators.AbstractSpliterator; + import java.util.UUID; + import java.util.concurrent.atomic.AtomicInteger; + import java.util.stream.Stream; +@@ -904,31 +905,60 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + private Vec3D e(Vec3D vec3d) { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); +- VoxelShape voxelshape = this.world.getWorldBorder().a(); +- Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); +- Stream stream1 = de.tr7zw.yapfa.YapfaConfig.disableEntityCollisionboxes ? Stream.empty() : this.world.b(this, axisalignedbb.a(vec3d), (Set) ImmutableSet.of()); // YAPFA +- StreamAccumulator streamaccumulator = new StreamAccumulator<>(Stream.concat(stream1, stream)); +- Vec3D vec3d1 = vec3d.g() == 0.0D ? vec3d : a(this, vec3d, axisalignedbb, this.world, voxelshapecollision, streamaccumulator); ++ VoxelShape worldBorder = this.world.getWorldBorder().a(); ++ // YAPFA start ++ Vec3D vec3d1; ++ StreamAccumulator streamaccumulator = new StreamAccumulator<>(Stream.concat(Stream.empty(), Stream.empty())); ++ //boolean useVoxelShape = false; ++ if(de.tr7zw.yapfa.YapfaConfig.disableEntityCollisionboxes) { ++ //useVoxelShape = VoxelShapes.c(worldBorder, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND); ++ vec3d1 = vec3d.g() == 0.0D ? vec3d : aNonStream(this, vec3d, axisalignedbb, this.world, voxelshapecollision, worldBorder); ++ } else { ++ Stream stream = VoxelShapes.c(worldBorder, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(worldBorder); ++ Stream stream1 = this.world.b(this, axisalignedbb.a(vec3d), (Set) ImmutableSet.of()); ++ streamaccumulator = new StreamAccumulator<>(Stream.concat(stream1, stream)); ++ vec3d1 = vec3d.g() == 0.0D ? vec3d : a(this, vec3d, axisalignedbb, this.world, voxelshapecollision, streamaccumulator); ++ } + boolean flag = vec3d.x != vec3d1.x; + boolean flag1 = vec3d.y != vec3d1.y; + boolean flag2 = vec3d.z != vec3d1.z; + boolean flag3 = this.onGround || flag1 && vec3d.y < 0.0D; + + if (this.H > 0.0F && flag3 && (flag || flag2)) { +- Vec3D vec3d2 = a(this, new Vec3D(vec3d.x, (double) this.H, vec3d.z), axisalignedbb, this.world, voxelshapecollision, streamaccumulator); +- Vec3D vec3d3 = a(this, new Vec3D(0.0D, (double) this.H, 0.0D), axisalignedbb.b(vec3d.x, 0.0D, vec3d.z), this.world, voxelshapecollision, streamaccumulator); ++ if(de.tr7zw.yapfa.YapfaConfig.disableEntityCollisionboxes) { + +- if (vec3d3.y < (double) this.H) { +- Vec3D vec3d4 = a(this, new Vec3D(vec3d.x, 0.0D, vec3d.z), axisalignedbb.b(vec3d3), this.world, voxelshapecollision, streamaccumulator).e(vec3d3); ++ Vec3D vec3d2 = aNonStream(this, new Vec3D(vec3d.x, (double) this.H, vec3d.z), axisalignedbb, this.world, voxelshapecollision, worldBorder); ++ Vec3D vec3d3 = aNonStream(this, new Vec3D(0.0D, (double) this.H, 0.0D), axisalignedbb.b(vec3d.x, 0.0D, vec3d.z), this.world, voxelshapecollision, worldBorder); + +- if (b(vec3d4) > b(vec3d2)) { +- vec3d2 = vec3d4; ++ if (vec3d3.y < (double) this.H) { ++ Vec3D vec3d4 = aNonStream(this, new Vec3D(vec3d.x, 0.0D, vec3d.z), axisalignedbb.b(vec3d3), this.world, voxelshapecollision, worldBorder).e(vec3d3); ++ ++ if (b(vec3d4) > b(vec3d2)) { ++ vec3d2 = vec3d4; ++ } + } +- } + +- if (b(vec3d2) > b(vec3d1)) { +- return vec3d2.e(a(this, new Vec3D(0.0D, -vec3d2.y + vec3d.y, 0.0D), axisalignedbb.b(vec3d2), this.world, voxelshapecollision, streamaccumulator)); +- } ++ if (b(vec3d2) > b(vec3d1)) { ++ return vec3d2.e(aNonStream(this, new Vec3D(0.0D, -vec3d2.y + vec3d.y, 0.0D), axisalignedbb.b(vec3d2), this.world, voxelshapecollision, worldBorder)); ++ } ++ } else { ++ Vec3D vec3d2 = a(this, new Vec3D(vec3d.x, (double) this.H, vec3d.z), axisalignedbb, this.world, voxelshapecollision, streamaccumulator); ++ Vec3D vec3d3 = a(this, new Vec3D(0.0D, (double) this.H, 0.0D), axisalignedbb.b(vec3d.x, 0.0D, vec3d.z), this.world, voxelshapecollision, streamaccumulator); ++ ++ if (vec3d3.y < (double) this.H) { ++ Vec3D vec3d4 = a(this, new Vec3D(vec3d.x, 0.0D, vec3d.z), axisalignedbb.b(vec3d3), this.world, voxelshapecollision, streamaccumulator).e(vec3d3); ++ ++ if (b(vec3d4) > b(vec3d2)) { ++ vec3d2 = vec3d4; ++ } ++ } ++ ++ if (b(vec3d2) > b(vec3d1)) { ++ return vec3d2.e(a(this, new Vec3D(0.0D, -vec3d2.y + vec3d.y, 0.0D), axisalignedbb.b(vec3d2), this.world, voxelshapecollision, streamaccumulator)); ++ } ++ } ++ // YAPFA end ++ + } + + return vec3d1; +@@ -951,6 +981,91 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + return a(vec3d, axisalignedbb, world, voxelshapecollision, streamaccumulator); + } + } ++ ++ // YAPFA start ++ public static Vec3D aNonStream(@Nullable Entity entity, Vec3D vec3d, AxisAlignedBB axisalignedbb, World world, VoxelShapeCollision voxelshapecollision, VoxelShape worldBorder) { ++ boolean flag = vec3d.x == 0.0D; ++ boolean flag1 = vec3d.y == 0.0D; ++ boolean flag2 = vec3d.z == 0.0D; ++ ++ if ((!flag || !flag1) && (!flag || !flag2) && (!flag1 || !flag2)) { ++ return a(vec3d, axisalignedbb, de.tr7zw.yapfa.collision.CollisionHelper.b(world, worldBorder, entity, axisalignedbb.a(vec3d))); ++ } else { ++ return a(vec3d, axisalignedbb, world, voxelshapecollision, worldBorder); ++ } ++ } ++ ++ public static Vec3D a(Vec3D vec3d, AxisAlignedBB axisalignedbb, AbstractSpliterator split) { ++ double d0 = vec3d.x; ++ double d1 = vec3d.y; ++ double d2 = vec3d.z; ++ de.tr7zw.yapfa.collision.CollisionHelper.SpliteratorAccumulator acc = new de.tr7zw.yapfa.collision.CollisionHelper.SpliteratorAccumulator(split); ++ if (d1 != 0.0D) { ++ d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb, acc.a(), d1); ++ if (d1 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(0.0D, d1, 0.0D); ++ } ++ } ++ ++ boolean flag = Math.abs(d0) < Math.abs(d2); ++ ++ if (flag && d2 != 0.0D) { ++ d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb, acc.a(), d2); ++ if (d2 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(0.0D, 0.0D, d2); ++ } ++ } ++ ++ if (d0 != 0.0D) { ++ d0 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb, acc.a(), d0); ++ if (!flag && d0 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(d0, 0.0D, 0.0D); ++ } ++ } ++ ++ if (!flag && d2 != 0.0D) { ++ d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb, acc.a(), d2); ++ } ++ ++ return new Vec3D(d0, d1, d2); ++ } ++ ++ public static Vec3D a(Vec3D vec3d, AxisAlignedBB axisalignedbb, IWorldReader iworldreader, VoxelShapeCollision voxelshapecollision, VoxelShape voxelShape) { ++ double d0 = vec3d.x; ++ double d1 = vec3d.y; ++ double d2 = vec3d.z; ++ ++ if (d1 != 0.0D) { ++ d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb, iworldreader, d1, voxelshapecollision, voxelShape); ++ if (d1 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(0.0D, d1, 0.0D); ++ } ++ } ++ ++ boolean flag = Math.abs(d0) < Math.abs(d2); ++ ++ if (flag && d2 != 0.0D) { ++ d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb, iworldreader, d2, voxelshapecollision, voxelShape); ++ if (d2 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(0.0D, 0.0D, d2); ++ } ++ } ++ ++ if (d0 != 0.0D) { ++ d0 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb, iworldreader, d0, voxelshapecollision, voxelShape); ++ if (!flag && d0 != 0.0D) { ++ axisalignedbb = axisalignedbb.d(d0, 0.0D, 0.0D); ++ } ++ } ++ ++ if (!flag && d2 != 0.0D) { ++ d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb, iworldreader, d2, voxelshapecollision, voxelShape); ++ } ++ ++ return new Vec3D(d0, d1, d2); ++ } ++ ++ // YAPFA end + + public static Vec3D a(Vec3D vec3d, AxisAlignedBB axisalignedbb, StreamAccumulator streamaccumulator) { + double d0 = vec3d.x; +diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java +index 839b0f514..8ff6370d7 100644 +--- a/src/main/java/net/minecraft/server/EntityLiving.java ++++ b/src/main/java/net/minecraft/server/EntityLiving.java +@@ -2649,6 +2649,7 @@ public abstract class EntityLiving extends Entity { + this.a(axisalignedbb, this.getBoundingBox()); + } + ++ if(!de.tr7zw.yapfa.YapfaConfig.disableEntityCollisions) // YAPFA + this.collideNearby(); + this.world.getMethodProfiler().exit(); + } +diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java +index d5da9f582..afb8381a2 100644 +--- a/src/main/java/net/minecraft/server/VoxelShapes.java ++++ b/src/main/java/net/minecraft/server/VoxelShapes.java +@@ -5,9 +5,12 @@ import com.google.common.math.DoubleMath; + import com.google.common.math.IntMath; + import it.unimi.dsi.fastutil.doubles.DoubleArrayList; + import it.unimi.dsi.fastutil.doubles.DoubleList; ++ + import java.util.Arrays; + import java.util.Iterator; + import java.util.Objects; ++import java.util.Spliterators; ++import java.util.Spliterators.AbstractSpliterator; + import java.util.stream.Stream; + + public final class VoxelShapes { +@@ -183,6 +186,106 @@ public final class VoxelShapes { + + return d0; + } ++ ++ // YAPFA start ++ ++ public static double a(EnumDirection.EnumAxis enumdirection_enumaxis, AxisAlignedBB axisalignedbb, VoxelShape voxel, double d0) { ++ d0 = voxel.a(enumdirection_enumaxis, axisalignedbb, d0); ++ if (Math.abs(d0) < 1.0E-7D) { ++ return 0.0D; ++ } ++ ++ return d0; ++ } ++ ++ public static double a(EnumDirection.EnumAxis enumdirection_enumaxis, AxisAlignedBB axisalignedbb, AbstractSpliterator stream, double d0) { ++ for (Iterator iterator = Spliterators.iterator(stream); iterator.hasNext(); d0 = ((VoxelShape) iterator.next()).a(enumdirection_enumaxis, axisalignedbb, d0)) { ++ if (Math.abs(d0) < 1.0E-7D) { ++ return 0.0D; ++ } ++ } ++ ++ return d0; ++ } ++ ++ public static double a(EnumDirection.EnumAxis enumdirection_enumaxis, AxisAlignedBB axisalignedbb, IWorldReader iworldreader, double d0, VoxelShapeCollision voxelshapecollision, VoxelShape voxel) { ++ return a(axisalignedbb, iworldreader, d0, voxelshapecollision, EnumAxisCycle.a(enumdirection_enumaxis, EnumDirection.EnumAxis.Z), voxel); ++ } ++ ++ private static double a(AxisAlignedBB axisalignedbb, IWorldReader iworldreader, double d0, VoxelShapeCollision voxelshapecollision, EnumAxisCycle enumaxiscycle, VoxelShape voxelshape) { ++ if (axisalignedbb.b() >= 1.0E-6D && axisalignedbb.c() >= 1.0E-6D && axisalignedbb.d() >= 1.0E-6D) { ++ if (Math.abs(d0) < 1.0E-7D) { ++ return 0.0D; ++ } else { ++ EnumAxisCycle enumaxiscycle1 = enumaxiscycle.a(); ++ EnumDirection.EnumAxis enumdirection_enumaxis = enumaxiscycle1.a(EnumDirection.EnumAxis.X); ++ EnumDirection.EnumAxis enumdirection_enumaxis1 = enumaxiscycle1.a(EnumDirection.EnumAxis.Y); ++ EnumDirection.EnumAxis enumdirection_enumaxis2 = enumaxiscycle1.a(EnumDirection.EnumAxis.Z); ++ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); ++ int i = MathHelper.floor(axisalignedbb.a(enumdirection_enumaxis) - 1.0E-7D) - 1; ++ int j = MathHelper.floor(axisalignedbb.b(enumdirection_enumaxis) + 1.0E-7D) + 1; ++ int k = MathHelper.floor(axisalignedbb.a(enumdirection_enumaxis1) - 1.0E-7D) - 1; ++ int l = MathHelper.floor(axisalignedbb.b(enumdirection_enumaxis1) + 1.0E-7D) + 1; ++ double d1 = axisalignedbb.a(enumdirection_enumaxis2) - 1.0E-7D; ++ double d2 = axisalignedbb.b(enumdirection_enumaxis2) + 1.0E-7D; ++ boolean flag = d0 > 0.0D; ++ int i1 = flag ? MathHelper.floor(axisalignedbb.b(enumdirection_enumaxis2) - 1.0E-7D) - 1 : MathHelper.floor(axisalignedbb.a(enumdirection_enumaxis2) + 1.0E-7D) + 1; ++ int j1 = a(d0, d1, d2); ++ int k1 = flag ? 1 : -1; ++ int l1 = i1; ++ ++ while (true) { ++ if (flag) { ++ if (l1 > j1) { ++ break; ++ } ++ } else if (l1 < j1) { ++ break; ++ } ++ ++ for (int i2 = i; i2 <= j; ++i2) { ++ for (int j2 = k; j2 <= l; ++j2) { ++ int k2 = 0; ++ ++ if (i2 == i || i2 == j) { ++ ++k2; ++ } ++ ++ if (j2 == k || j2 == l) { ++ ++k2; ++ } ++ ++ if (l1 == i1 || l1 == j1) { ++ ++k2; ++ } ++ ++ if (k2 < 3) { ++ blockposition_mutableblockposition.a(enumaxiscycle1, i2, j2, l1); ++ IBlockData iblockdata = iworldreader.getType(blockposition_mutableblockposition); ++ ++ if ((k2 != 1 || iblockdata.f()) && (k2 != 2 || iblockdata.getBlock() == Blocks.MOVING_PISTON)) { ++ d0 = iblockdata.b((IBlockAccess) iworldreader, blockposition_mutableblockposition, voxelshapecollision).a(enumdirection_enumaxis2, axisalignedbb.d((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), d0); ++ if (Math.abs(d0) < 1.0E-7D) { ++ return 0.0D; ++ } ++ ++ j1 = a(d0, d1, d2); ++ } ++ } ++ } ++ } ++ ++ l1 += k1; ++ } ++ ++ return voxelshape.a(enumdirection_enumaxis2, axisalignedbb, d0); ++ } ++ } else { ++ return d0; ++ } ++ } ++ ++ // YAPFA end + + public static double a(EnumDirection.EnumAxis enumdirection_enumaxis, AxisAlignedBB axisalignedbb, IWorldReader iworldreader, double d0, VoxelShapeCollision voxelshapecollision, Stream stream) { + return a(axisalignedbb, iworldreader, d0, voxelshapecollision, EnumAxisCycle.a(enumdirection_enumaxis, EnumDirection.EnumAxis.Z), stream); +-- +2.25.1.windows.1 + From 471d61213117d188143fdb5d64cd8abd0f9d75a5 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Mon, 23 Mar 2020 21:46:28 +0100 Subject: [PATCH 11/11] Update upstream --- Tuinity | 2 +- patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch | 6 +++--- ...0042-Add-config-yapfa-command-and-basic-settings.patch | 8 ++++---- patches/server/0046-Remove-Stream-usage.patch | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tuinity b/Tuinity index bf2a4dcb..6316c976 160000 --- a/Tuinity +++ b/Tuinity @@ -1 +1 @@ -Subproject commit bf2a4dcb7c0050a33e59c3f10f83bf68074924fb +Subproject commit 6316c9761bd7f95c9d3d4ec6cbb31baf88347529 diff --git a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch index c7662cd9..f2be8933 100644 --- a/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch +++ b/patches/server/0039-Don-t-save-Fireworks-and-Arrows.patch @@ -1,4 +1,4 @@ -From 732cfeed9395bbcedcb3792517e6503172aa05ea Mon Sep 17 00:00:00 2001 +From 9fbb1e47f53612dc3648fdfc97da351a6e2396da Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 26 Feb 2020 21:39:58 +0100 Subject: [PATCH] Don't save Fireworks and Arrows @@ -8,10 +8,10 @@ Subject: [PATCH] Don't save Fireworks and Arrows 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 3cdba5c42..429666193 100644 +index 223ad3965..fa1fb7a40 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -1636,7 +1636,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -1653,7 +1653,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke } public boolean c(NBTTagCompound nbttagcompound) { diff --git a/patches/server/0042-Add-config-yapfa-command-and-basic-settings.patch b/patches/server/0042-Add-config-yapfa-command-and-basic-settings.patch index 49aef0dd..2df62376 100644 --- a/patches/server/0042-Add-config-yapfa-command-and-basic-settings.patch +++ b/patches/server/0042-Add-config-yapfa-command-and-basic-settings.patch @@ -1,4 +1,4 @@ -From 0c2f4b89cf11f58387baa7bd964aaa84e3fefd23 Mon Sep 17 00:00:00 2001 +From fdc9dd192f39efb4e2a22b8ea93c272c08c56c67 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Thu, 5 Mar 2020 22:31:50 +0100 Subject: [PATCH] Add config, yapfa command and basic settings @@ -396,10 +396,10 @@ index 610826c9e..2ed69f567 100644 this.setSpawnAnimals(dedicatedserverproperties.spawnAnimals); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 429666193..2d97ecacb 100644 +index fa1fb7a40..8c21a1e73 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java -@@ -781,6 +781,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -798,6 +798,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke try { this.inLava = false; @@ -407,7 +407,7 @@ index 429666193..2d97ecacb 100644 this.checkBlockCollisions(); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); -@@ -905,7 +906,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -922,7 +923,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); VoxelShape voxelshape = this.world.getWorldBorder().a(); Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); diff --git a/patches/server/0046-Remove-Stream-usage.patch b/patches/server/0046-Remove-Stream-usage.patch index e8923165..f5a2fa5f 100644 --- a/patches/server/0046-Remove-Stream-usage.patch +++ b/patches/server/0046-Remove-Stream-usage.patch @@ -1,4 +1,4 @@ -From 09fe7e940891f10e7eb8ace0ad12f1485f07ccf6 Mon Sep 17 00:00:00 2001 +From 89cd52730b413447c2756ce9981038d36e33f293 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Mon, 23 Mar 2020 18:20:58 +0100 Subject: [PATCH] Remove Stream usage @@ -328,7 +328,7 @@ index 6def3616e..e1338f809 100644 public Stream c() { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 2d97ecacb..51b68de53 100644 +index 8c21a1e73..184a3843d 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -13,6 +13,7 @@ import java.util.Locale; @@ -339,7 +339,7 @@ index 2d97ecacb..51b68de53 100644 import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; -@@ -904,31 +905,60 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -921,31 +922,60 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke private Vec3D e(Vec3D vec3d) { AxisAlignedBB axisalignedbb = this.getBoundingBox(); VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); @@ -415,7 +415,7 @@ index 2d97ecacb..51b68de53 100644 } return vec3d1; -@@ -951,6 +981,91 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke +@@ -968,6 +998,91 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke return a(vec3d, axisalignedbb, world, voxelshapecollision, streamaccumulator); } }