Merge pull request #1 from tr7zw/tuinity

Tuinity
This commit is contained in:
tr7zw 2020-03-23 22:37:54 +01:00 committed by GitHub
commit 2bdf917089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 1334 additions and 857 deletions

View File

@ -9,12 +9,26 @@ 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
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`
./patchPaper.sh
cd Tuinity
./tuinity jar
cd $yapfaDir
./yapfa patch
./yapfa build
./yapfa paperclip
- name: Upload Artifact
uses: actions/upload-artifact@v2-preview
with:
name: YAPFA
path: yapfa-paperclip.jar

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ mc-dev
*.iml
.settings/org.eclipse.m2e.core.prefs
.project
yapfa-paperclip.jar

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "Paper"]
path = Paper
url = https://github.com/PaperMC/Paper
[submodule "Tuinity"]
path = Tuinity
url = https://github.com/Spottedleaf/Tuinity

1
Paper

@ -1 +0,0 @@
Subproject commit 7bd0b6ab1ab2d7a17b20048dfc06daa1319c3506

View File

@ -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:

1
Tuinity Submodule

@ -0,0 +1 @@
Subproject commit 6316c9761bd7f95c9d3d4ec6cbb31baf88347529

View File

@ -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

1
patchPaper.sh Executable file
View File

@ -0,0 +1 @@
cp -f ./scripts/importmcdev_paper.sh ./Tuinity/Paper/scripts/importmcdev.sh

View File

@ -1,36 +1,36 @@
From e56e7c35b802814b62608f98517d2368cca70e47 Mon Sep 17 00:00:00 2001
From 3f7f02d0d9e68b60c6c92144fc458afd99a64eb2 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>com.destroystokyo.paper</groupId>
- <artifactId>paper-parent</artifactId>
- <groupId>com.tuinity</groupId>
- <artifactId>tuinity-parent</artifactId>
+ <groupId>de.tr7zw.yapfa</groupId>
+ <artifactId>yapfa-parent</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>com.destroystokyo.paper</groupId>
- <artifactId>paper-api</artifactId>
- <artifactId>tuinity-api</artifactId>
+ <groupId>de.tr7zw.yapfa</groupId>
+ <artifactId>yapfa-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>Paper-API</name>
- <url>https://github.com/PaperMC/Paper</url>
- <name>Tuinity-API</name>
- <url>https://github.com/Spottedleaf/Tuinity</url>
+ <name>YAPFA-API</name>
+ <url>https://github.com/tr7zw/YAPFA</url>
<description>An enhanced plugin API for Minecraft servers.</description>

View File

@ -1,4 +1,4 @@
From d9c138fbfa962b5aafcc8b5387882523bab251dc Mon Sep 17 00:00:00 2001
From 1c8f1bf377624c066e0d6300a3f684193eb1d0e9 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
@ -24,7 +24,7 @@ index ca897873..3f97b2be 100644
</repositories>
<pluginRepositories>
@@ -49,6 +53,13 @@
@@ -50,6 +54,13 @@
</pluginRepositories>
<dependencies>

View File

@ -1,4 +1,4 @@
From 8ad98f5fbf4542b3cb48d754448ff847bd45bab0 Mon Sep 17 00:00:00 2001
From 60a34cc1a5fa232371cc3f2c6c4f530909e7c70b Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 55ec8d2d..ba7ef28b 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 {
@@ -1464,4 +1464,15 @@ public interface Server extends PluginMessageRecipient {
*/
int getCurrentTick();
// Paper end

View File

@ -1,37 +1,38 @@
From 332de8cfc43e110aaf9c46ca3b9eef4ccf94c22d Mon Sep 17 00:00:00 2001
From ddf4f73e653d81b5273acc1ad7cfc1ac00fd42e9 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -1,11 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>paper</artifactId>
- <artifactId>tuinity</artifactId>
+ <artifactId>yapfa</artifactId>
<packaging>jar</packaging>
<version>1.15.2-R0.1-SNAPSHOT</version>
- <name>Paper</name>
- <url>https://papermc.io</url>
- <name>Tuinity-Server</name>
- <url>https://github.com/Spottedleaf/Tuinity</url>
+ <name>YAPFA</name>
+ <url>https://github.com/tr7zw/YAPFA</url>
+
<properties>
<!-- <skipTests>true</skipTests> Paper - This [was] not going to end well -->
@@ -21,16 +21,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -20,16 +21,16 @@
</properties>
<parent>
- <groupId>com.destroystokyo.paper</groupId>
- <artifactId>paper-parent</artifactId>
- <groupId>com.tuinity</groupId>
- <artifactId>tuinity-parent</artifactId>
+ <groupId>de.tr7zw.yapfa</groupId>
+ <artifactId>yapfa-parent</artifactId>
<version>dev-SNAPSHOT</version>
@ -40,27 +41,28 @@ index 55679af9..7e166ce9 100644
<dependencies>
<dependency>
- <groupId>com.destroystokyo.paper</groupId>
- <artifactId>paper-api</artifactId>
- <groupId>com.tuinity</groupId>
- <artifactId>tuinity-api</artifactId>
+ <groupId>de.tr7zw.yapfa</groupId>
+ <artifactId>yapfa-api</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
@@ -143,7 +143,7 @@
@@ -148,15 +149,15 @@
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
<build>
- <finalName>paper-${minecraft.version}</finalName>
- <finalName>tuinity-${minecraft.version}</finalName>
- <defaultGoal>install</defaultGoal> <!-- Paper -->
+ <finalName>yapfa-${minecraft.version}</finalName>
<defaultGoal>clean install</defaultGoal> <!-- Paper -->
+ <defaultGoal>clean install</defaultGoal> <!-- Paper -->
<plugins>
<plugin>
@@ -151,7 +151,7 @@
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
- <outputPrefix>git-Paper-</outputPrefix>
- <outputPrefix>git-Tuinity-</outputPrefix> <!-- Tuinity -->
+ <outputPrefix>git-YAPFA-</outputPrefix>
<scmDirectory>..</scmDirectory>
</configuration>

View File

@ -1,47 +1,33 @@
From 657c46021b893e6184415b1182fda23d7d9974d9 Mon Sep 17 00:00:00 2001
From d1dfd7255c30123ed4d636bb4a6c2b1f03bac049 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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,34 +51,35 @@ 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<TickTas
@@ -1482,7 +1482,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
public String getServerModName() {
- return "Paper"; //Paper - Paper > // 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 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 {
@ -100,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();

View File

@ -1,4 +1,4 @@
From 1d76a3b9382672fb6f13dd9efb6b5e77e7962bcb Mon Sep 17 00:00:00 2001
From 4421584fbbc1dfb981327ea61e8621616b60c3f1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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

View File

@ -1,4 +1,4 @@
From 89df9d7ca41b413ae9c3ac8193d8cedc89d68541 Mon Sep 17 00:00:00 2001
From e1b72d3c45a36d430d4ef3b1bde43fbb6784bb5e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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.");
}

View File

@ -1,4 +1,4 @@
From 38cac2cc8d88fa416f879fa39ad554f2cde7c2a4 Mon Sep 17 00:00:00 2001
From 360d20b06b9e2b1b8e68275a3ba054e1de3e7a65 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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());

View File

@ -1,4 +1,4 @@
From f4e88ce690719daef8a3baac865262a070c43ea2 Mon Sep 17 00:00:00 2001
From ec8804120c0877c9ed090ed7ed0e429eaffcab59 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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<TickTas
@@ -1341,6 +1341,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
System.err.println( "If you do not agree to the above EULA please stop your server and remove this flag immediately." );
}
// Spigot End

View File

@ -1,4 +1,4 @@
From 8459ee7038d25c28284c47b244442a98d44d4cf9 Mon Sep 17 00:00:00 2001
From 0d60368fc67b5a475b1285d0484c517b3565332f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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

View File

@ -1,4 +1,4 @@
From b04e7fb704af33ef186743d10d773b5826e850ba Mon Sep 17 00:00:00 2001
From 979580a2ffb58f7903fbddf2ef26203797535c79 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
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;
}

View File

@ -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 <Blake.Galbreath@GMail.com>
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
}

View File

@ -1,4 +1,4 @@
From cc74d3456f0ffbd9abdbc0c6b740c6d17644a3fd Mon Sep 17 00:00:00 2001
From 9fbb1e47f53612dc3648fdfc97da351a6e2396da Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 223ad3965..fa1fb7a40 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
@@ -1653,7 +1653,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public boolean c(NBTTagCompound nbttagcompound) {

View File

@ -1,4 +1,4 @@
From 08c19476a6b5359ebc6fe21668c9a9dbb38e01c6 Mon Sep 17 00:00:00 2001
From f3d5def9a1faac55232b4c258ec5f3c36ae81ede Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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();

View File

@ -1,166 +0,0 @@
From 8005dcac9b78f662be51bc0734b9d334a15d5a5a Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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<Thread> weakMainThreads = new WeakCollection<Thread>();
+
+ 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<R extends Runnable> implements Mailbox<R
protected abstract boolean canExecute(R r0);
public boolean isMainThread() {
- return Thread.currentThread() == this.getThread();
+ return MainThreadHandler.isMainThread(Thread.currentThread()); // YAPFA
}
protected abstract Thread getThread();
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index bcd5cc9f2..f1310bf57 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -10,6 +10,8 @@ import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonWriter;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Either;
+
+import de.tr7zw.yapfa.MainThreadHandler;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Location;
@@ -195,7 +197,7 @@ public final class MCUtil {
* @return
*/
public static void ensureMain(String reason, Runnable run) {
- if (AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread) {
+ if (AsyncCatcher.enabled && !MainThreadHandler.isMainThread(Thread.currentThread())) { // YAPFA
if (reason != null) {
new IllegalStateException("Asynchronous " + reason + "!").printStackTrace();
}
@@ -220,7 +222,7 @@ public final class MCUtil {
* @return
*/
public static <T> T ensureMain(String reason, Supplier<T> 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<TickTas
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
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

View File

@ -1,4 +1,4 @@
From 90e8bcd5384daf77b5d94744e1f40fbaf71526e5 Mon Sep 17 00:00:00 2001
From fa0f4dd513ddbd9d30e04835d4ff83d0a94e882d Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 376cf9556..0276abe1c 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<TickTas
@@ -883,6 +883,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
// Paper End
// Spigot End
@ -22,7 +22,7 @@ index 6ea3833fc..d5efea027 100644
public void run() {
try {
@@ -936,9 +938,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -933,9 +935,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.d().d();
}
@ -36,7 +36,7 @@ index 6ea3833fc..d5efea027 100644
this.methodProfiler.exitEnter("nextTickWait");
this.ac = true;
this.ab = Math.max(SystemUtils.getMonotonicMillis() + 50L, this.nextTick);
@@ -946,6 +952,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -943,6 +949,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.exit();
this.methodProfiler.b();
this.hasTicked = true;
@ -45,10 +45,10 @@ index 6ea3833fc..d5efea027 100644
} else {
this.a((CrashReport) null);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 19b74f3ca..e9c5bb9dd 100644
index ad80aeb83..022a82e56 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2189,4 +2189,13 @@ public final class CraftServer implements Server {
@@ -2222,4 +2222,13 @@ public final class CraftServer implements Server {
return net.minecraft.server.MinecraftServer.currentTick;
}
// Paper end

View File

@ -1,4 +1,4 @@
From 9bb528c0c5db42ba279c5e6189e6dc6670d7c384 Mon Sep 17 00:00:00 2001
From fdc9dd192f39efb4e2a22b8ea93c272c08c56c67 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 000000000..76d83f3db
--- /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 000000000..9711cbc52
--- /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 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
@ -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 fa1fb7a40..8c21a1e73 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
@@ -798,6 +798,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
@@ -922,7 +923,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this);
VoxelShape voxelshape = this.world.getWorldBorder().a();
Stream<VoxelShape> 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 5b402690d..839b0f514 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

View File

@ -1,4 +1,4 @@
From ead0f031e6ffc43a68ed0842ef4896bde0fd13ec Mon Sep 17 00:00:00 2001
From 9ae232d05c7db4372c14cd33c9ef11e29770c731 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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<TickTas
@@ -80,7 +80,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private final MojangStatisticsGenerator snooper = new MojangStatisticsGenerator("server", this, SystemUtils.getMonotonicMillis());
public File universe;
private final List<Runnable> 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<TickTas
@@ -932,7 +932,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.nextTick += 50L;
if (this.T) {
this.T = false;

View File

@ -0,0 +1,92 @@
From 811ff3fa87f91169e19575a7c5327feaf77f838d Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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<PathEntity> optional = Optional.ofNullable(lowest);
+ /*
Stream stream;
if (set.stream().anyMatch(PathDestination::f)) {
@@ -107,7 +147,9 @@ public class Pathfinder {
}
Optional<PathEntity> optional = stream.findFirst();
-
+ */
+ // YAPFA end
+
if (!optional.isPresent()) {
return null;
} else {
--
2.25.1.windows.1

View File

@ -0,0 +1,270 @@
From 698a03fe533c795e57b1f30f0099438699fc034b Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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<E extends EntityLiving> implements MinecraftSerializable {
+ private final Map<MemoryModuleType<?>, Optional<?>> memories = Maps.newHashMap();
+ private final Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors = Maps.newLinkedHashMap();
+ private final Map<Integer, Map<Activity, Set<Behavior<? super E>>>> c = Maps.newTreeMap();
+ private Schedule schedule;
+ private final Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> e;
+ private Set<Activity> f;
+ private final Set<Activity> g;
+ private Activity h;
+ private long i;
+
+ public <T> BehaviorController(Collection<MemoryModuleType<?>> var0,
+ Collection<SensorType<? extends Sensor<? super E>>> var1, Dynamic<T> 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<? extends Sensor<? super E>> sensor : var1) {
+ this.sensors.put(sensor, sensor.a());
+ }
+ for(Sensor<? super E> sensor : sensors.values()) {
+ Iterator<MemoryModuleType<?>> var2x = sensor.a().iterator();
+
+ while (var2x.hasNext()) {
+ MemoryModuleType<?> next = var2x.next();
+ this.memories.put(next, Optional.empty());
+ }
+ }
+
+ Iterator<Entry<Dynamic<T>, Dynamic<T>>> var4 = var2.get("memories").asMap(Function.identity(), Function.identity()).entrySet().iterator();
+
+ while (var4.hasNext()) {
+ Entry<Dynamic<T>, Dynamic<T>> 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 <T, U> void a(MemoryModuleType<U> var0, Dynamic<T> var1) {
+ this.setMemory(var0, (U)((Function) var0.getSerializer().orElseThrow(RuntimeException::new)).apply(var1));
+ }
+
+ public <U> void removeMemory(MemoryModuleType<U> var0) {
+ this.setMemory(var0, Optional.empty());
+ }
+
+ public <U> void setMemory(MemoryModuleType<U> var0, @Nullable U var1) {
+ this.setMemory(var0, Optional.ofNullable(var1));
+ }
+
+ public <U> void setMemory(MemoryModuleType<U> var0, Optional<U> var1) {
+ if (this.memories.containsKey(var0)) {
+ if (var1.isPresent() && this.a(var1.get())) {
+ this.removeMemory(var0);
+ } else {
+ this.memories.put(var0, var1);
+ }
+ }
+
+ }
+
+ public <U> Optional<U> getMemory(MemoryModuleType<U> var0) {
+ return (Optional<U>) 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<Activity> var0) {
+ this.f = var0;
+ }
+
+ @Deprecated
+ public Stream<Behavior<? super E>> 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<Pair<Integer, ? extends Behavior<? super E>>> var1) {
+ this.a((Activity) var0, var1, ImmutableSet.of());
+ }
+
+ public void a(Activity var0, ImmutableList<Pair<Integer, ? extends Behavior<? super E>>> var1,
+ Set<Pair<MemoryModuleType<?>, MemoryStatus>> var2) {
+ this.e.put(var0, var2);
+ for(Pair<Integer, ? extends Behavior<? super E>> 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<E> f() {
+ BehaviorController<E> var0 = new BehaviorController<E>(this.memories.keySet(), this.sensors.keySet(),
+ new Dynamic<>(DynamicOpsNBT.a, new NBTTagCompound()));
+ for(Entry<MemoryModuleType<?>, 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> T a(DynamicOps<T> var0) {
+ Map<T, T> outMap = new HashMap<T, T>();
+ for(Entry<MemoryModuleType<?>, 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<? super E> var2 : this.sensors.values()) {
+ var2.b(var0, var1);
+ }
+ }
+
+ private void d(WorldServer var0, E var1) {
+ long var2 = var0.getTime();
+ for(Map<Activity, Set<Behavior<? super E>>> value : this.c.values()) {
+ for(Entry<Activity, Set<Behavior<? super E>>> entry : value.entrySet()) {
+ if(this.g.contains(entry.getKey())) {
+ for(Behavior<? super E> 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<MemoryModuleType<?>, 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

View File

@ -1,138 +0,0 @@
From af216c33212a285dbcb0b6255c568d005d91de43 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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

View File

@ -1,218 +0,0 @@
From b8b3b931ccfa1f390db02deb97a830c537284652 Mon Sep 17 00:00:00 2001
From: froobynooby <froobynooby@froobworld.com>
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<EntityPlayer> 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<Int2ObjectMap<PlayerChunkMap.EntityTracker>> playerTrackedEntities = new Int2ObjectOpenHashMap();
+ private final Int2ObjectMap<Queue<Integer>> playerTrackedEntitiesRemoveQueue = new Int2ObjectOpenHashMap();
+
+ void flushRemoveQueue(EntityPlayer entityplayer) {
+ Queue<Integer> removeQueue = getPlayerTrackedEntityMapRemoveQueue(entityplayer.getId());
+ Int2ObjectMap<PlayerChunkMap.EntityTracker> entityMap = getPlayerTrackedEntityMap(entityplayer.getId());
+ for (Integer id = removeQueue.poll(); id != null; id = removeQueue.poll()) {
+ entityMap.remove(id);
+ }
+ }
+
+ void flushRemoveQueues() {
+ for (Int2ObjectMap.Entry<Queue<Integer>> entry : playerTrackedEntitiesRemoveQueue.int2ObjectEntrySet()) {
+ Int2ObjectMap entityMap = getPlayerTrackedEntityMap(entry.getKey());
+ Queue<Integer> 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<Integer> 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<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator<?> chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> 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

View File

@ -0,0 +1,648 @@
From 89cd52730b413447c2756ce9981038d36e33f293 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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<VoxelShape> 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<VoxelShape>(Long.MAX_VALUE, 1280) {
+ boolean a;
+ {
+
+ this.a = var0 == null;
+ }
+
+ @Override
+ public boolean tryAdvance(Consumer<? super VoxelShape> 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<T> {
+ private final List<T> a = Lists.newArrayList();
+ private final Spliterator<T> b;
+
+ public SpliteratorAccumulator(Spliterator<T> var0) {
+ this.b = var0;
+ }
+
+ public Spliterators.AbstractSpliterator<T> a() {
+ return new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, 0) {
+ private int b;
+
+ @Override
+ public boolean tryAdvance(Consumer<? super T> 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<EntityLiving> {
BehaviorController<?> behaviorcontroller = entityliving.getBehaviorController();
PathEntity pathentity = (PathEntity) behaviorcontroller.getMemory(MemoryModuleType.PATH).get();
List<GlobalPos> list = (List) behaviorcontroller.getMemory(MemoryModuleType.INTERACTABLE_DOORS).get();
+ // YAPFA start
+ List<BlockPosition> list1 = new ArrayList<BlockPosition>();
+ for(PathPoint pathpoint : pathentity.d()) {
+ list1.add(new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c));
+ }
+ /*
List<BlockPosition> list1 = (List) pathentity.d().stream().map((pathpoint) -> {
return new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c);
}).collect(Collectors.toList());
+ */ // YAPFA end
Set<BlockPosition> set = this.a(worldserver, list, list1);
int j = pathentity.f() - 1;
@@ -29,12 +39,25 @@ public class BehaviorInteractDoor extends Behavior<EntityLiving> {
}
private Set<BlockPosition> a(WorldServer worldserver, List<GlobalPos> list, List<BlockPosition> list1) {
- Stream stream = list.stream().filter((globalpos) -> {
+ // YAPFA start
+ Set<BlockPosition> positions = new HashSet<BlockPosition>();
+ 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<BlockPosition> list, Set<BlockPosition> 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> T a(DynamicOps<T> 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 <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
- // CraftBukkit start
- Optional<T> 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<C> rep : this.a(recipes).values()) {
+ Optional<T> 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 <C extends IInventory, T extends IRecipe<C>> List<T> b(Recipes<T> 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<T> list = new ArrayList<T>();
+ for(IRecipe<C> rec : this.a(recipes).values()) {
+ Optional<T> 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 <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> a(Recipes<T> recipes) {
@@ -115,15 +128,25 @@ public class CraftingManager extends ResourceDataJson {
}
public Optional<? extends IRecipe<?>> 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<MinecraftKey, IRecipe<?>> map : this.recipes.values()) {
+ IRecipe<?> rec = map.get(minecraftkey);
+ if(rec != null) {
+ return Optional.of(rec);
+ }
+ }
+ return Optional.empty();
+ // YAPFA end
}
public Collection<IRecipe<?>> b() {
- return (Collection) this.recipes.values().stream().flatMap((map) -> {
- return map.values().stream();
- }).collect(Collectors.toSet());
+ // YAPFA start
+ Set<IRecipe<?>> recipes = new HashSet<IRecipe<?>>();
+ for(Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map : this.recipes.values()) {
+ recipes.addAll(map.values());
+ }
+ return recipes;
+ // YAPFA end
}
public Stream<MinecraftKey> c() {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
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;
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;
@@ -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);
- VoxelShape voxelshape = this.world.getWorldBorder().a();
- Stream<VoxelShape> stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape);
- Stream<VoxelShape> stream1 = de.tr7zw.yapfa.YapfaConfig.disableEntityCollisionboxes ? Stream.empty() : this.world.b(this, axisalignedbb.a(vec3d), (Set) ImmutableSet.of()); // YAPFA
- StreamAccumulator<VoxelShape> 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<VoxelShape> 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<VoxelShape> stream = VoxelShapes.c(worldBorder, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(worldBorder);
+ Stream<VoxelShape> 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;
@@ -968,6 +998,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<VoxelShape> split) {
+ double d0 = vec3d.x;
+ double d1 = vec3d.y;
+ double d2 = vec3d.z;
+ de.tr7zw.yapfa.collision.CollisionHelper.SpliteratorAccumulator<VoxelShape> acc = new de.tr7zw.yapfa.collision.CollisionHelper.SpliteratorAccumulator<VoxelShape>(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<VoxelShape> 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<VoxelShape> 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<VoxelShape> stream) {
return a(axisalignedbb, iworldreader, d0, voxelshapecollision, EnumAxisCycle.a(enumdirection_enumaxis, EnumDirection.EnumAxis.Z), stream);
--
2.25.1.windows.1

View File

@ -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"

View File

@ -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 -

View File

@ -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

View File

@ -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/Paper/work
minecraftversion=$(cat $basedir/Paper/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/Paper/Paper-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"
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/Paper/Paper-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 Paper/Paper-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/Paper/Paper-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 Paper/Paper-Server/
rm -rf nms-patches
git add src -A
echo -e "EMC-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F -
)

119
scripts/importmcdev_paper.sh Executable file
View File

@ -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 -
)

25
scripts/paperclip.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

7
yapfa
View File

@ -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