diff --git a/patches/server/0001-Tuinity-Server-Changes.patch b/patches/server/0001-Tuinity-Server-Changes.patch
index 5ea981b30..166fec33d 100644
--- a/patches/server/0001-Tuinity-Server-Changes.patch
+++ b/patches/server/0001-Tuinity-Server-Changes.patch
@@ -454,12 +454,12 @@ index 9ba379b7e3ee3bc8c6d2c8ec46213c404c73d682..e83e4241a56fe131a75fe21cc1518992
- https://papermc.io
+ Tuinity-Server
+ https://github.com/Spottedleaf/Tuinity
-
+
@@ -19,16 +19,16 @@
-
+
- com.destroystokyo.paper
- paper-parent
@@ -468,7 +468,7 @@ index 9ba379b7e3ee3bc8c6d2c8ec46213c404c73d682..e83e4241a56fe131a75fe21cc1518992
dev-SNAPSHOT
../pom.xml
-
+
- com.destroystokyo.paper
@@ -517,10 +517,10 @@ index 9ba379b7e3ee3bc8c6d2c8ec46213c404c73d682..e83e4241a56fe131a75fe21cc1518992
+ compile
+
-
+
@@ -173,15 +183,15 @@
-
+
- paper-${minecraft.version}
@@ -545,12 +545,12 @@ index 884b59d478aa7de49906520e77866a7949bed19d..68ab5ccb2fcfe1de0503c9336572f28e
@@ -43,6 +43,9 @@ public final class MinecraftTimings {
public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
-
+
+ public static final Timing scoreboardScoreSearch = Timings.ofSafe("Scoreboard score search"); // Tuinity - add timings for scoreboard search
+ public static final Timing distanceManagerTick = Timings.ofSafe("Distance Manager Tick"); // Tuinity - add timings for distance manager
+
private static final Map, String> taskNameCache = new MapMaker().weakKeys().makeMap();
-
+
private MinecraftTimings() {}
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index e33e889c291d37a821a4fbd40d9aac7bb079de0d..5dfa0658838c4801cdf260eae8b98163f729e5af 100644
@@ -564,7 +564,7 @@ index e33e889c291d37a821a4fbd40d9aac7bb079de0d..5dfa0658838c4801cdf260eae8b98163
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Tuinity - add config to timings report
+ pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)) // Tuinity - add config to timings report
));
-
+
new TimingsExport(listeners, parent, history).start();
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
index dee00aac05f1acf050f05d4db557a08dd0f301c8..52c0ab1ce46e1f3233ef746d9bc699356fa9fae4 100644
@@ -576,16 +576,16 @@ index dee00aac05f1acf050f05d4db557a08dd0f301c8..52c0ab1ce46e1f3233ef746d9bc69935
if (config.getBoolean("enabled", true)) {
- Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger());
+ Metrics metrics = new Metrics("Tuinity", serverUUID, logFailedRequests, Bukkit.getLogger()); // Tuinity - we have our own bstats page
-
+
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
String minecraftVersion = Bukkit.getVersion();
@@ -603,7 +603,7 @@ public class Metrics {
-
+
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() || PaperConfig.isProxyOnlineMode() ? "online" : "offline"));
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
+ metrics.addCustomChart(new Metrics.SimplePie("tuinity_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Tuinity - we have our own bstats page
-
+
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
Map> map = new HashMap<>();
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -595,7 +595,7 @@ index 0abfe19e204d20af0f8dedbeedb0ef98dfe9d3c8..1a876336384198bad2a25c018be5f241
@@ -186,6 +186,44 @@ public class PaperCommand extends Command {
}
}
-
+
+ private void starlightFixLight(EntityPlayer sender, WorldServer world, LightEngineThreaded lightengine, int radius) {
+ long start = System.nanoTime();
+ LinkedHashSet chunks = new LinkedHashSet<>(MCUtil.getSpiralOutChunks(sender.getChunkCoordinates(), radius)); // getChunkCoordinates is actually just bad mappings, this function rets position as blockpos
@@ -649,7 +649,7 @@ index 0abfe19e204d20af0f8dedbeedb0ef98dfe9d3c8..1a876336384198bad2a25c018be5f241
@@ -207,6 +245,13 @@ public class PaperCommand extends Command {
net.minecraft.server.WorldServer world = (WorldServer) handle.world;
LightEngineThreaded lightengine = world.getChunkProvider().getLightEngine();
-
+
+ // Tuinity start - rewrite light engine
+ if (com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine) {
+ this.starlightFixLight(handle, world, lightengine, radius);
@@ -673,10 +673,10 @@ index 49a38c6608b652ff48ef4eaca0dd3ccb1ba570e3..255bbd6e48b95c70fad02ba692c64c75
+ String[] parts = serverVersion.substring("git-Tuinity-".length()).split("[-\\s]"); // Tuinity
+ String updateMessage = getUpdateStatusMessage("Spottedleaf/Tuinity", GITHUB_BRANCH_NAME, parts[0]); // Tuinity
String history = getHistory();
-
+
return history != null ? history + "\n" + updateMessage : updateMessage;
@@ -49,13 +49,10 @@ public class PaperVersionFetcher implements VersionFetcher {
-
+
private static String getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
int distance;
- try {
@@ -688,7 +688,7 @@ index 49a38c6608b652ff48ef4eaca0dd3ccb1ba570e3..255bbd6e48b95c70fad02ba692c64c75
distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
- }
+ // Tuinity - we don't have jenkins setup
-
+
switch (distance) {
case -1:
diff --git a/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java
@@ -697,14 +697,14 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
+++ b/src/main/java/com/destroystokyo/paper/server/ticklist/PaperTickList.java
@@ -186,6 +186,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
}
-
+
public void onChunkSetTicking(final int chunkX, final int chunkZ) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list chunk ticking update"); // Tuinity - soft async catcher
final ArrayList> pending = this.pendingChunkTickLoad.remove(MCUtil.getCoordinateKey(chunkX, chunkZ));
if (pending == null) {
return;
@@ -268,6 +269,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
protected void nextTick() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list tick"); // Tuinity - soft async catcher
@@ -712,12 +712,12 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
if (this.currentTick != this.world.getTime()) {
if (!this.warnedAboutDesync) {
@@ -280,6 +282,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public void tick() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list tick"); // Tuinity - soft async catcher
final ChunkProviderServer chunkProvider = this.world.getChunkProvider();
-
+
this.world.getMethodProfiler().enter("cleaning");
@@ -307,6 +310,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
if (toTick.tickState == STATE_TICKING) {
@@ -729,14 +729,14 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
toTick.tickState = STATE_SCHEDULED;
@@ -424,6 +428,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
}
-
+
public void schedule(final BlockPosition pos, final T data, final long targetTick, final TickListPriority priority) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list schedule"); // Tuinity - soft async catcher
final NextTickListEntry entry = new NextTickListEntry<>(pos, data, targetTick, priority);
if (this.excludeFromScheduling.test(entry.getData())) {
return;
@@ -479,6 +484,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public List> getEntriesInBoundingBox(final StructureBoundingBox structureboundingbox, final boolean removeReturned, final boolean excludeTicked) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list get in bounding box"); // Tuinity - soft async catcher
@@ -744,7 +744,7 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
return Collections.emptyList(); // vanilla behaviour, check isBlockInSortof above
}
@@ -535,6 +541,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public void copy(StructureBoundingBox structureboundingbox, BlockPosition blockposition) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list copy"); // Tuinity - soft async catcher
@@ -752,7 +752,7 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
List> list = this.getEntriesInBoundingBox(structureboundingbox, false, false);
Iterator> iterator = list.iterator();
@@ -554,6 +561,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public List> getEntriesInChunk(ChunkCoordIntPair chunkPos, boolean removeReturned, boolean excludeTicked) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list get"); // Tuinity - soft async catcher
@@ -760,21 +760,21 @@ index e7624948ea4aa1a07d84ed3d295cfe2dd354fd14..77df6888803093ad9527d276033f2ed7
// not at ticking status, and ticking status requires neighbours loaded
// so with this method we will reduce scheduler churning
@@ -585,6 +593,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public NBTTagList serialize(ChunkCoordIntPair chunkcoordintpair) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list serialize"); // Tuinity - soft async catcher
// start copy from TickListServer // TODO check on update
List> list = this.getEntriesInChunk(chunkcoordintpair, false, true);
-
+
@@ -594,6 +603,7 @@ public final class PaperTickList extends TickListServer { // extend to avo
-
+
@Override
public int getTotalScheduledEntries() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("async tick list get size"); // Tuinity - soft async catcher
// good thing this is only used in debug reports // TODO check on update
int ret = 0;
-
+
diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
index 103576715ef6ae4df4b216ae9ae31b6fb1086bd5..e8fdbe7b8d8192a3247d98534e78ede7a7314a91 100644
--- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java
@@ -797,7 +797,7 @@ index cb993ca102402d9c19ea9fa04e5db09c21205896..849686f7b2a8b0044f7cd14c8c2e401e
--- a/src/main/java/com/mojang/brigadier/arguments/BoolArgumentType.java
+++ b/src/main/java/com/mojang/brigadier/arguments/BoolArgumentType.java
@@ -34,10 +34,10 @@ public class BoolArgumentType implements ArgumentType {
-
+
@Override
public CompletableFuture listSuggestions(final CommandContext context, final SuggestionsBuilder builder) {
- if ("true".startsWith(builder.getRemaining().toLowerCase())) {
@@ -819,7 +819,7 @@ index bc0024adb804ac055a4f8afb7f85d00ec13931e9..0343f6663c450c3f0d9c57d817eef9c9
private final String remaining;
+ private String remainingLowercase; public final String getRemainingLowercase() { return this.remainingLowercase == null ? this.remainingLowercase = this.remaining.toLowerCase() : this.remainingLowercase; } // Tuinity
private final List result = new ArrayList<>();
-
+
public SuggestionsBuilder(final String input, final int start) {
+ // Tuinity start
+ this(input, start, null);
@@ -836,20 +836,20 @@ index 7720578796e28d28e8c0c9aa40155cd205c17d54..e5db29d4cadb5702c7d06b0b6e2d0558
+++ b/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java
@@ -20,11 +20,11 @@ import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
-
+
public class LiteralCommandNode extends CommandNode {
- private final String literal;
+ private final String literal; private final String literalLower; // Tuinity
-
+
public LiteralCommandNode(final String literal, final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final boolean forks) {
super(command, requirement, redirect, modifier, forks);
- this.literal = literal;
+ this.literal = literal; this.literalLower = this.literal.toLowerCase(); // Tuinity
}
-
+
public String getLiteral() {
@@ -66,7 +66,7 @@ public class LiteralCommandNode extends CommandNode {
-
+
@Override
public CompletableFuture listSuggestions(final CommandContext context, final SuggestionsBuilder builder) {
- if (literal.toLowerCase().startsWith(builder.getRemaining().toLowerCase())) {
@@ -5271,7 +5271,7 @@ index 0000000000000000000000000000000000000000..63dfad42c372a33b35c585aaa7ed24d8
+ tickWorldsInParallel = TuinityConfig.getBoolean("tick-worlds-in-parallel", false);
+ tickThreads = TuinityConfig.getInt("server-tick-threads", 1); // will be 4 in the future
+ }*/
-+
++
+ public static int delayChunkUnloadsBy;
+
+ private static void delayChunkUnloadsBy() {
@@ -7726,7 +7726,7 @@ index ed9b2f9adfecdc6d1b9925579ec510657adde11f..5c3d5b22b833d9f835e17803295b8789
@@ -13,6 +13,157 @@ public class AxisAlignedBB {
public final double maxY;
public final double maxZ;
-
+
+ // Tuinity start
+ public final boolean isEmpty() {
+ return (this.maxX - this.minX) < MCUtil.COLLISION_EPSILON && (this.maxY - this.minY) < MCUtil.COLLISION_EPSILON && (this.maxZ - this.minZ) < MCUtil.COLLISION_EPSILON;
@@ -7884,7 +7884,7 @@ index ed9b2f9adfecdc6d1b9925579ec510657adde11f..5c3d5b22b833d9f835e17803295b8789
@@ -185,6 +336,7 @@ public class AxisAlignedBB {
return new AxisAlignedBB(d0, d1, d2, d3, d4, d5);
}
-
+
+ public final AxisAlignedBB offset(double d0, double d1, double d2) { return this.d(d0, d1, d2); } // Tuinity - OBFHELPER
public AxisAlignedBB d(double d0, double d1, double d2) {
return new AxisAlignedBB(this.minX + d0, this.minY + d1, this.minZ + d2, this.maxX + d0, this.maxY + d1, this.maxZ + d2);
@@ -7892,7 +7892,7 @@ index ed9b2f9adfecdc6d1b9925579ec510657adde11f..5c3d5b22b833d9f835e17803295b8789
@@ -193,6 +345,7 @@ public class AxisAlignedBB {
return new AxisAlignedBB(this.minX + (double) blockposition.getX(), this.minY + (double) blockposition.getY(), this.minZ + (double) blockposition.getZ(), this.maxX + (double) blockposition.getX(), this.maxY + (double) blockposition.getY(), this.maxZ + (double) blockposition.getZ());
}
-
+
+ public final AxisAlignedBB offset(Vec3D vec3d) { return this.b(vec3d); } // Tuinity - OBFHELPER
public AxisAlignedBB c(Vec3D vec3d) {
return this.d(vec3d.x, vec3d.y, vec3d.z);
@@ -7900,7 +7900,7 @@ index ed9b2f9adfecdc6d1b9925579ec510657adde11f..5c3d5b22b833d9f835e17803295b8789
@@ -212,6 +365,7 @@ public class AxisAlignedBB {
return this.e(vec3d.x, vec3d.y, vec3d.z);
}
-
+
+ public final boolean contains(double d0, double d1, double d2) { return this.e(d0, d1, d2); } // Tuinity - OBFHELPER
public boolean e(double d0, double d1, double d2) {
return d0 >= this.minX && d0 < this.maxX && d1 >= this.minY && d1 < this.maxY && d2 >= this.minZ && d2 < this.maxZ;
@@ -7919,35 +7919,35 @@ index 6b655b744d31d9660c7521ab596b27bcd92f4d58..e811295b4d6afcd920f60e0ce5440e43
+ protected int a; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the x coordinate - Also revert the decision to expose set on an immutable type
+ protected int b; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the y coordinate - Also revert the decision to expose set on an immutable type
+ protected int e; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the z coordinate - Also revert the decision to expose set on an immutable type
-
+
// Paper start
public boolean isValidLocation() {
@@ -71,15 +71,15 @@ public class BaseBlockPosition implements Comparable {
return this.e;
}
-
+
- public void o(int i) { // Paper - protected -> public
+ protected void o_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
this.a = i;
}
-
+
- public void p(int i) { // Paper - protected -> public
+ protected void p_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
this.b = i;
}
-
+
- public void q(int i) { // Paper - protected -> public
+ protected void q_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
this.e = i;
}
-
+
diff --git a/src/main/java/net/minecraft/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java
index 65af976527133ee5c2f52e411e19c4f7f06df3ef..0b9d469a92decfb0632805791868ef7faa88c535 100644
--- a/src/main/java/net/minecraft/server/Behavior.java
+++ b/src/main/java/net/minecraft/server/Behavior.java
@@ -7,7 +7,7 @@ import java.util.Map.Entry;
public abstract class Behavior {
-
+
protected final Map, MemoryStatus> a;
- private Behavior.Status b;
+ private Behavior.Status b; public final Behavior.Status getStatus() { return this.b; } // Tuinity - OBFHELPER
@@ -7961,7 +7961,7 @@ index 63a761ebef80d4af09cdc2682e496d78492c4a3a..8d445e9c0875db6cf45e4d8bcfce7cd3
@@ -55,6 +55,227 @@ public class BehaviorFindPosition extends Behavior {
}
}
-
+
+ // Tuinity - remove streams entirely for poi search
+ // the only intentional vanilla diff is that this function will NOT load in poi data, anything else is a bug!
+ protected static Set findNearestPoi(VillagePlace poiStorage,
@@ -8193,7 +8193,7 @@ index 63a761ebef80d4af09cdc2682e496d78492c4a3a..8d445e9c0875db6cf45e4d8bcfce7cd3
- Set set = (Set) villageplace.b(this.b.c(), predicate, entitycreature.getChunkCoordinates(), 48, VillagePlace.Occupancy.HAS_SPACE).limit(5L).collect(Collectors.toSet());
+ Set set = findNearestPoi(villageplace, this.b.c(), predicate, entitycreature.getChunkCoordinates(), 48, VillagePlace.Occupancy.HAS_SPACE, 5); // Tuinity - remove streams entirely for poi search
PathEntity pathentity = entitycreature.getNavigation().a(set, this.b.d());
-
+
if (pathentity != null && pathentity.j()) {
@@ -84,7 +305,7 @@ public class BehaviorFindPosition extends Behavior {
villageplace.a(this.b.c(), (blockposition1) -> {
@@ -8214,11 +8214,11 @@ index 46e910581210421c8699637431804dc2f43eb4a6..fb967bc03f58fab8cec2732b1890108f
private final BehaviorGate.Execution d;
- private final WeightedList> e = new WeightedList<>(false); // Paper - don't use a clone
+ private final WeightedList> e = new WeightedList<>(false); protected final WeightedList> getList() { return this.e; } // Paper - don't use a clone // Tuinity - OBFHELPER
-
+
public BehaviorGate(Map, MemoryStatus> map, Set> set, BehaviorGate.Order behaviorgate_order, BehaviorGate.Execution behaviorgate_execution, List, Integer>> list) {
super(map);
@@ -26,11 +26,17 @@ public class BehaviorGate extends Behavior {
-
+
@Override
protected boolean b(WorldServer worldserver, E e0, long i) {
- return this.e.c().filter((behavior) -> {
@@ -8238,10 +8238,10 @@ index 46e910581210421c8699637431804dc2f43eb4a6..fb967bc03f58fab8cec2732b1890108f
+ return false;
+ // Tuinity end - remove streams
}
-
+
@Override
@@ -46,20 +52,28 @@ public class BehaviorGate extends Behavior {
-
+
@Override
protected void d(WorldServer worldserver, E e0, long i) {
- this.e.c().filter((behavior) -> {
@@ -8259,7 +8259,7 @@ index 46e910581210421c8699637431804dc2f43eb4a6..fb967bc03f58fab8cec2732b1890108f
+ }
+ // Tuinity end - remove streams
}
-
+
@Override
protected void c(WorldServer worldserver, E e0, long i) {
- this.e.c().filter((behavior) -> {
@@ -8277,7 +8277,7 @@ index 46e910581210421c8699637431804dc2f43eb4a6..fb967bc03f58fab8cec2732b1890108f
+ }
+ // Tuinity end - remove streams
BehaviorController behaviorcontroller = e0.getBehaviorController();
-
+
this.b.forEach(behaviorcontroller::removeMemory); // Paper - decomp fix
@@ -79,21 +93,29 @@ public class BehaviorGate extends Behavior {
RUN_ONE {
@@ -8318,22 +8318,22 @@ index 46e910581210421c8699637431804dc2f43eb4a6..fb967bc03f58fab8cec2732b1890108f
+ // Tuinity end - remove streams
}
};
-
+
diff --git a/src/main/java/net/minecraft/server/BehaviorLookInteract.java b/src/main/java/net/minecraft/server/BehaviorLookInteract.java
index a33303c31881b6391723e16a06d7841d48679958..ce57e6a4acac97d6da82202094306e7e91f1c87e 100644
--- a/src/main/java/net/minecraft/server/BehaviorLookInteract.java
+++ b/src/main/java/net/minecraft/server/BehaviorLookInteract.java
@@ -7,7 +7,7 @@ import java.util.function.Predicate;
public class BehaviorLookInteract extends Behavior {
-
+
private final EntityTypes> b;
- private final int c;
+ private final int c; private final int getMaxRange() { return this.c; } // Tuinity - OBFHELPER
private final Predicate d;
private final Predicate e;
-
+
@@ -29,7 +29,20 @@ public class BehaviorLookInteract extends Behavior {
-
+
@Override
public boolean a(WorldServer worldserver, EntityLiving entityliving) {
- return this.e.test(entityliving) && this.b(entityliving).stream().anyMatch(this::a);
@@ -8352,12 +8352,12 @@ index a33303c31881b6391723e16a06d7841d48679958..ce57e6a4acac97d6da82202094306e7e
+ return false;
+ // Tuinity end - remove streams
}
-
+
@Override
@@ -37,16 +50,28 @@ public class BehaviorLookInteract extends Behavior {
super.a(worldserver, entityliving, i);
BehaviorController> behaviorcontroller = entityliving.getBehaviorController();
-
+
- behaviorcontroller.getMemory(MemoryModuleType.VISIBLE_MOBS).ifPresent((list) -> {
- list.stream().filter((entityliving1) -> {
- return entityliving1.h((Entity) entityliving) <= (double) this.c;
@@ -8386,7 +8386,7 @@ index a33303c31881b6391723e16a06d7841d48679958..ce57e6a4acac97d6da82202094306e7e
+ }
+ // Tuinity end - remove streams
}
-
+
+ private final boolean canTarget(EntityLiving entityliving) { return this.a(entityliving); } // Tuinity - OBFHELPER
private boolean a(EntityLiving entityliving) {
return this.b.equals(entityliving.getEntityType()) && this.d.test(entityliving);
@@ -8396,9 +8396,9 @@ index 1f334d63282bd5c23dc3b275a220f09e60c34537..829d4a7508e1656dbdc912096b7eafcf
--- a/src/main/java/net/minecraft/server/BlockBase.java
+++ b/src/main/java/net/minecraft/server/BlockBase.java
@@ -295,21 +295,23 @@ public abstract class BlockBase {
-
+
public abstract static class BlockData extends IBlockDataHolder {
-
+
- private final int b;
- private final boolean e;
+ private final int b; public final int getEmittedLight() { return this.b; } // Tuinity - OBFHELPER
@@ -8420,7 +8420,7 @@ index 1f334d63282bd5c23dc3b275a220f09e60c34537..829d4a7508e1656dbdc912096b7eafcf
+ protected BlockBase.BlockData.Cache a; protected final BlockBase.BlockData.Cache getShapeCache() { return this.a; } // Tuinity - OBFHELPER
+ public PathType staticPathType; // Tuinity - cache static path types
+ public PathType neighbourOverridePathType; // Tuinity - cache static path types
-
+
protected BlockData(Block block, ImmutableMap, Comparable>> immutablemap, MapCodec mapcodec) {
super(block, immutablemap, mapcodec);
@@ -328,6 +330,7 @@ public abstract class BlockBase {
@@ -8434,7 +8434,7 @@ index 1f334d63282bd5c23dc3b275a220f09e60c34537..829d4a7508e1656dbdc912096b7eafcf
@@ -343,12 +346,62 @@ public abstract class BlockBase {
protected Fluid fluid;
// Paper end
-
+
+ // Tuinity start - micro the hell out of this call
+ protected boolean shapeExceedsCube = true;
+ public final boolean shapeExceedsCube() {
@@ -8491,30 +8491,30 @@ index 1f334d63282bd5c23dc3b275a220f09e60c34537..829d4a7508e1656dbdc912096b7eafcf
+ }
+ }
+ // Tuinity end - optimise culling shape cache for light
-
+
}
-
+
@@ -372,10 +425,12 @@ public abstract class BlockBase {
return this.a != null ? this.a.g : this.getBlock().b(this.p(), iblockaccess, blockposition);
}
-
+
+ public final int getOpacity(IBlockAccess iblockaccess, BlockPosition blockposition) { return this.b(iblockaccess, blockposition); } // Tuinity - OBFHELPER
public int b(IBlockAccess iblockaccess, BlockPosition blockposition) {
return this.a != null ? this.a.h : this.getBlock().f(this.p(), iblockaccess, blockposition);
}
-
+
+ public final VoxelShape getCullingFace(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) { return this.a(iblockaccess, blockposition, enumdirection); } // Tuinity - OBFHELPER
public VoxelShape a(IBlockAccess iblockaccess, BlockPosition blockposition, EnumDirection enumdirection) {
return this.a != null && this.a.i != null ? this.a.i[enumdirection.ordinal()] : VoxelShapes.a(this.c(iblockaccess, blockposition), enumdirection);
}
@@ -385,7 +440,7 @@ public abstract class BlockBase {
}
-
+
public final boolean d() { // Paper
- return this.a == null || this.a.c;
+ return this.shapeExceedsCube; // Tuinity - moved into shape cache init
}
-
+
public final boolean e() { // Paper
@@ -675,9 +730,9 @@ public abstract class BlockBase {
private static final int f = EnumBlockSupport.values().length;
@@ -8534,7 +8534,7 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -449,10 +449,10 @@ public class BlockPosition extends BaseBlockPosition {
}
-
+
public final BlockPosition.MutableBlockPosition setValues(int i, int j, int k) { return d(i, j, k);} // Paper - OBFHELPER
- public BlockPosition.MutableBlockPosition d(int i, int j, int k) {
- this.o(i);
@@ -8546,10 +8546,10 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ ((BaseBlockPosition)this).e = k; // Tuinity - force inline
return this;
}
-
+
@@ -462,12 +462,18 @@ public class BlockPosition extends BaseBlockPosition {
}
-
+
public final BlockPosition.MutableBlockPosition setValues(final BaseBlockPosition baseblockposition) { return this.g(baseblockposition); } // Paper - OBFHELPER
- public BlockPosition.MutableBlockPosition g(BaseBlockPosition baseblockposition) {
- return this.d(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
@@ -8559,7 +8559,7 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ ((BaseBlockPosition)this).e = baseblockposition.e; // Tuinity - force inline
+ return this;
}
-
+
- public BlockPosition.MutableBlockPosition g(long i) {
- return this.d(b(i), c(i), d(i));
+ public final BlockPosition.MutableBlockPosition g(long i) { // Tuinity
@@ -8568,12 +8568,12 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ ((BaseBlockPosition)this).e = (int)((i << 26) >> 38); // Tuinity - force inline
+ return this;
}
-
+
public BlockPosition.MutableBlockPosition a(EnumAxisCycle enumaxiscycle, int i, int j, int k) {
@@ -482,8 +488,11 @@ public class BlockPosition extends BaseBlockPosition {
return this.d(baseblockposition.getX() + i, baseblockposition.getY() + j, baseblockposition.getZ() + k);
}
-
+
- public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection) {
- return this.c(enumdirection, 1);
+ public final BlockPosition.MutableBlockPosition c(EnumDirection enumdirection) { // Tuinity
@@ -8582,12 +8582,12 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ ((BaseBlockPosition)this).e += enumdirection.getAdjacentZ(); // Tuinity - force inline
+ return this;
}
-
+
public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection, int i) {
@@ -511,21 +520,30 @@ public class BlockPosition extends BaseBlockPosition {
}
}
-
+
- /* // Paper start - comment out useless overrides @Override
- @Override
- public void o(int i) {
@@ -8603,7 +8603,7 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ public final void setZ(int value) {
+ ((BaseBlockPosition)this).e = value;
}
-
+
- @Override
- public void p(int i) {
- super.p(i);
@@ -8614,7 +8614,7 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
+ public final void p(int i) {
+ ((BaseBlockPosition)this).b = i;
}
-
+
- public void q(int i) {
- super.q(i);
+ public final void q(int i) {
@@ -8622,7 +8622,7 @@ index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd
}
- */ // Paper end
+ // Tuinity end
-
+
@Override
public BlockPosition immutableCopy() {
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
@@ -8632,7 +8632,7 @@ index 3bcd63a754538ccfc5965207a8fc79faa31925c0..68d6fb69a0c1b98b3c11b6d80783faaa
@@ -91,6 +91,197 @@ public class Chunk implements IChunkAccess {
private final int[] inventoryEntityCounts = new int[16];
// Paper end
-
+
+ // Tuinity start - optimise hard collision handling
+ final com.destroystokyo.paper.util.maplist.EntityList[] hardCollidingEntities = new com.destroystokyo.paper.util.maplist.EntityList[16];
+
@@ -8828,7 +8828,7 @@ index 3bcd63a754538ccfc5965207a8fc79faa31925c0..68d6fb69a0c1b98b3c11b6d80783faaa
this.sections = new ChunkSection[16];
this.e = Maps.newHashMap();
@@ -298,6 +489,12 @@ public class Chunk implements IChunkAccess {
-
+
public Chunk(World world, ProtoChunk protochunk) {
this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.getInhabitedTime(), protochunk.getSections(), (Consumer) null);
+ // Tuinity start - copy over protochunk light
@@ -8838,7 +8838,7 @@ index 3bcd63a754538ccfc5965207a8fc79faa31925c0..68d6fb69a0c1b98b3c11b6d80783faaa
+ this.setBlockEmptinessMap(protochunk.getBlockEmptinessMap());
+ // Tuinity end - copy over protochunk light
Iterator iterator = protochunk.y().iterator();
-
+
while (iterator.hasNext()) {
@@ -594,8 +791,8 @@ public class Chunk implements IChunkAccess {
entity.chunkX = this.loc.x;
@@ -8861,9 +8861,9 @@ index 3bcd63a754538ccfc5965207a8fc79faa31925c0..68d6fb69a0c1b98b3c11b6d80783faaa
}
if (entity instanceof EntityItem) {
@@ -946,6 +1143,7 @@ public class Chunk implements IChunkAccess {
-
+
}
-
+
+ public final void getEntities(Class extends T> oclass, AxisAlignedBB axisalignedbb, List list, @Nullable Predicate super T> predicate) { this.a(oclass, axisalignedbb, list, predicate); } // Tuinity - OBFHELPER
public void a(Class extends T> oclass, AxisAlignedBB axisalignedbb, List list, @Nullable Predicate super T> predicate) {
org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot
@@ -8874,7 +8874,7 @@ index 8eecdcde510661ec3a13a25a04ba394f6b6dc012..ab1085091fefea3a3fa15f7028bec050
+++ b/src/main/java/net/minecraft/server/ChunkCache.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
-
+
+import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -8882,7 +8882,7 @@ index 8eecdcde510661ec3a13a25a04ba394f6b6dc012..ab1085091fefea3a3fa15f7028bec050
@@ -12,6 +13,156 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
protected boolean d;
protected final World e; protected final World getWorld() { return e; } // Paper - OBFHELPER
-
+
+ // Tuinity start - optimise pathfinder collision detection
+ @Override
+ public boolean getCubes(Entity entity) {
@@ -9063,9 +9063,9 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
private final ChunkMapDistance.c g = new ChunkMapDistance.c(33);
// Paper start use a queue, but still keep unique requirement
@@ -53,6 +53,47 @@ public abstract class ChunkMapDistance {
-
+
PlayerChunkMap chunkMap; // Paper
-
+
+ // Tuinity start - delay chunk unloads
+ private long nextUnloadId; // delay chunk unloads
+ private final Long2ObjectOpenHashMap> delayedChunks = new Long2ObjectOpenHashMap<>();
@@ -9112,12 +9112,12 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
Mailbox mailbox = Mailbox.a("player ticket throttler", executor1::execute);
@@ -65,21 +106,45 @@ public abstract class ChunkMapDistance {
}
-
+
protected void purgeTickets() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async purge tickets"); // Tuinity
++this.currentTick;
ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator();
-
+
+ // Tuinity start - delay chunk unloads
+ int[] tempLevel = new int[] { PlayerChunkMap.GOLDEN_TICKET + 1 };
+ Entry>>[] entryPass = new Entry[1];
@@ -9139,7 +9139,7 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
while (objectiterator.hasNext()) {
- Entry>> entry = (Entry) objectiterator.next();
+ Entry>> entry = (Entry) objectiterator.next(); entryPass[0] = entry; // Tuinity - only allocate lambda once
-
+
- if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
- return ticket.b(this.currentTick);
- })) {
@@ -9151,18 +9151,18 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
+ // Tuinity end - delay chunk unloads
this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
}
-
+
if (((ArraySetSorted) entry.getValue()).isEmpty()) {
objectiterator.remove();
}
+
+ tempLevel[0] = PlayerChunkMap.GOLDEN_TICKET + 1; // Tuinity - reset
}
-
+
}
@@ -98,6 +163,7 @@ public abstract class ChunkMapDistance {
protected abstract PlayerChunk a(long i, int j, @Nullable PlayerChunk playerchunk, int k);
-
+
public boolean a(PlayerChunkMap playerchunkmap) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot tick ChunkMapDistance off of the main-thread");// Tuinity
//this.f.a(); // Paper - no longer used
@@ -9198,11 +9198,11 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
- // Paper end
+ // Tuinity end - delay chunk unloads
}
-
+
if (arraysetsorted.isEmpty()) {
@@ -370,6 +420,7 @@ public abstract class ChunkMapDistance {
}
-
+
private ArraySetSorted> e(long i) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async tickets compute"); // Tuinity
return (ArraySetSorted) this.tickets.computeIfAbsent(i, (j) -> {
@@ -9210,27 +9210,27 @@ index 76f9bb728def91744910d0b680b73e753f1a2b26..7f3887b0894aca0f972922f434382646
});
@@ -387,6 +438,7 @@ public abstract class ChunkMapDistance {
}
-
+
public void a(SectionPosition sectionposition, EntityPlayer entityplayer) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async player add"); // Tuinity
long i = sectionposition.r().pair();
-
+
((ObjectSet) this.c.computeIfAbsent(i, (j) -> {
@@ -397,6 +449,7 @@ public abstract class ChunkMapDistance {
}
-
+
public void b(SectionPosition sectionposition, EntityPlayer entityplayer) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async player remove"); // Tuinity
long i = sectionposition.r().pair();
ObjectSet objectset = (ObjectSet) this.c.get(i);
if (objectset == null) return; // CraftBukkit - SPIGOT-6208
@@ -447,6 +500,7 @@ public abstract class ChunkMapDistance {
-
+
// CraftBukkit start
public void removeAllTicketsFor(TicketType ticketType, int ticketLevel, T ticketIdentifier) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async ticket remove"); // Tuinity
Ticket target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier);
-
+
for (java.util.Iterator>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) {
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112bccfa8c3 100644
@@ -9239,7 +9239,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
@@ -22,6 +22,12 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-
+
+// Tuinity start
+import it.unimi.dsi.fastutil.objects.Object2BooleanLinkedOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator;
@@ -9247,19 +9247,19 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
+// Tuinity end
+
public class ChunkProviderServer extends IChunkProvider {
-
+
private static final List b = ChunkStatus.a(); static final List getPossibleChunkStatuses() { return ChunkProviderServer.b; } // Paper - OBFHELPER
@@ -112,7 +118,7 @@ public class ChunkProviderServer extends IChunkProvider {
return (Chunk)this.getChunkAt(x, z, ChunkStatus.FULL, true);
}
-
+
- private long chunkFutureAwaitCounter;
+ long chunkFutureAwaitCounter; // Tuinity - private -> package private
-
+
public void getEntityTickingChunkAsync(int x, int z, java.util.function.Consumer onLoad) {
if (Thread.currentThread() != this.serverThread) {
@@ -174,9 +180,9 @@ public class ChunkProviderServer extends IChunkProvider {
-
+
try {
if (onLoad != null) {
- playerChunkMap.callbackExecutor.execute(() -> {
@@ -9273,7 +9273,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
@@ -201,6 +207,165 @@ public class ChunkProviderServer extends IChunkProvider {
}
// Paper end - rewrite ticklistserver
-
+
+ // Tuinity start
+ // this will try to avoid chunk neighbours for lighting
+ public final IChunkAccess getFullStatusChunkAt(int chunkX, int chunkZ) {
@@ -9439,7 +9439,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
@@ -544,6 +709,8 @@ public class ChunkProviderServer extends IChunkProvider {
Arrays.fill(this.cacheChunk, (Object) null);
}
-
+
+ private long syncLoadCounter; // Tuinity - prevent plugin unloads from removing our ticket
+
private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag) {
@@ -9483,30 +9483,30 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
@@ -599,8 +777,8 @@ public class ChunkProviderServer extends IChunkProvider {
return !this.a(playerchunk, k);
}
-
+
- @Override
- public IBlockAccess c(int i, int j) {
+ public final IBlockAccess getFeaturesReadyChunk(int x, int z) { return this.c(x, z); } // Tuinity - OBFHELPER
+ @Override public IBlockAccess c(int i, int j) { // Tuinity - OBFHELPER
long k = ChunkCoordIntPair.pair(i, j);
PlayerChunk playerchunk = this.getChunk(k);
-
+
@@ -637,6 +815,8 @@ public class ChunkProviderServer extends IChunkProvider {
-
+
public boolean tickDistanceManager() { // Paper - private -> public
if (chunkMapDistance.delayDistanceManagerTick) return false; // Paper
+ if (this.playerChunkMap.unloadingPlayerChunk) { MinecraftServer.LOGGER.fatal("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Tuinity
+ co.aikar.timings.MinecraftTimings.distanceManagerTick.startTiming(); try { // Tuinity - add timings for distance manager
boolean flag = this.chunkMapDistance.a(this.playerChunkMap);
boolean flag1 = this.playerChunkMap.b();
-
+
@@ -646,6 +826,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.clearCache();
return true;
}
+ } finally { co.aikar.timings.MinecraftTimings.distanceManagerTick.stopTiming(); } // Tuinity - add timings for distance manager
}
-
+
public final boolean isInEntityTickingChunk(Entity entity) { return this.a(entity); } // Paper - OBFHELPER
@@ -734,7 +915,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().enter("purge");
@@ -9550,13 +9550,13 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
this.world.getMethodProfiler().exit();
- Optional optional1 = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
+ // Tuinity
-
+
- if (optional1.isPresent()) {
- Chunk chunk = (Chunk) optional1.get();
+ if (true) { // Tuinity
+ // Tuinity
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
-
+
if (!this.playerChunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, false)) { // Paper - optimise isOutsideOfRange
@@ -845,11 +1030,15 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
@@ -9579,7 +9579,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
@@ -861,7 +1050,25 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
}
-
+
+ // Tuinity start - controlled flush for entity tracker packets
+ List disabledFlushes = new java.util.ArrayList<>(this.world.getPlayers().size());
+ for (EntityPlayer player : this.world.getPlayers()) {
@@ -9600,7 +9600,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
+ }
+ // Tuinity end - controlled flush for entity tracker packets
}
-
+
private void a(long i, Consumer consumer) {
@@ -1001,51 +1208,18 @@ public class ChunkProviderServer extends IChunkProvider {
ChunkProviderServer.this.world.getMethodProfiler().c("runTask");
@@ -9642,7 +9642,7 @@ index 0ea1b25bf98d71c251351807fa92d4d08eb6b06e..fdbf984e64f135abfdee465d76eb1112
- }
- // Paper end
+ // Tuinity - replace logic
-
+
@Override
protected boolean executeNext() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot execute chunk tasks off-main thread");// Tuinity
@@ -9662,9 +9662,9 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -24,6 +24,14 @@ public class ChunkRegionLoader {
-
+
private static final Logger LOGGER = LogManager.getLogger();
-
+
+ // Tuinity start
+ // TODO: Check on update
+ public static long getLastWorldSaveTime(NBTTagCompound chunkData) {
@@ -9679,7 +9679,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
@@ -56,6 +64,13 @@ public class ChunkRegionLoader {
private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion");
// Paper end
-
+
+ // Tuinity start - rewrite light engine
+ private static final int STARLIGHT_LIGHT_VERSION = 4;
+
@@ -9706,11 +9706,11 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
+ com.tuinity.tuinity.chunk.light.SWMRNibbleArray[] skyNibbles = com.tuinity.tuinity.chunk.light.StarLightEngine.getFilledEmptyLight(worldserver); // Tuinity - replace light impl
+ final int minSection = com.tuinity.tuinity.util.WorldUtil.getMinLightSection(worldserver);
+ final int maxSection = com.tuinity.tuinity.util.WorldUtil.getMaxLightSection(worldserver);
-
+
if (flag) {
tasksToExecuteOnMain.add(() -> { // Paper - delay this task since we're executing off-main
@@ -119,6 +138,7 @@ public class ChunkRegionLoader {
-
+
if (flag) {
if (nbttagcompound2.hasKeyOfType("BlockLight", 7)) {
+ if (com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine && canUseBlockLight) blockNibbles[b0 - minSection] = new com.tuinity.tuinity.chunk.light.SWMRNibbleArray(nbttagcompound2.getByteArray("BlockLight").clone()); // Tuinity - replace light impl
@@ -9719,7 +9719,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
tasksToExecuteOnMain.add(() -> {
@@ -128,13 +148,14 @@ public class ChunkRegionLoader {
}
-
+
if (flag2 && nbttagcompound2.hasKeyOfType("SkyLight", 7)) {
+ if (com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine && canUseSkyLight) skyNibbles[b0 - minSection] = new com.tuinity.tuinity.chunk.light.SWMRNibbleArray(nbttagcompound2.getByteArray("SkyLight").clone()); // Tuinity - replace light impl
// Paper start - delay this task since we're executing off-main
@@ -9732,7 +9732,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
+ } else if (flag2 && nbttagcompound2.getBoolean(UNINITIALISED_SKYLIGHT_TAG)) skyNibbles[b0 - minSection] = new com.tuinity.tuinity.chunk.light.SWMRNibbleArray(); // Tuinity - replace light impl
}
}
-
+
@@ -173,8 +194,12 @@ public class ChunkRegionLoader {
object = new Chunk(worldserver.getMinecraftWorld(), chunkcoordintpair, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, j, achunksection, // Paper start - fix massive nbt memory leak due to lambda. move lambda into a container method to not leak scope. Only clone needed NBT keys.
createLoadEntitiesConsumer(new SafeNBTCopy(nbttagcompound1, "TileEntities", "Entities", "ChunkBukkitValues")) // Paper - move CB Chunk PDC into here
@@ -9743,13 +9743,13 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); // Paper - Anti-Xray - Add parameter
+ protochunk.setBlockNibbles(blockNibbles); // Tuinity - replace light impl
+ protochunk.setSkyNibbles(skyNibbles); // Tuinity - replace light impl
-
+
protochunk.a(biomestorage);
object = protochunk;
@@ -353,15 +378,20 @@ public class ChunkRegionLoader {
NibbleArray[] blockLight = new NibbleArray[17 - (-1)];
NibbleArray[] skyLight = new NibbleArray[17 - (-1)];
-
+
+ // Tuinity start - rewrite light impl
+ final int minSection = com.tuinity.tuinity.util.WorldUtil.getMinLightSection(world);
+ final int maxSection = com.tuinity.tuinity.util.WorldUtil.getMaxLightSection(world);
@@ -9760,7 +9760,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
- NibbleArray skyArray = lightenginethreaded.a(EnumSkyBlock.SKY).a(SectionPosition.a(chunkPos, i));
+ NibbleArray blockArray = com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? (!lightenginethreaded.hasBlockLight ? null : (chunk.getBlockNibbles()[i - minSection].isAllZero() ? new NibbleArray() : chunk.getBlockNibbles()[i - minSection].toVanillaNibble())) : lightenginethreaded.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(chunkPos, i)); // Tuinity - chunk might not be loaded
+ NibbleArray skyArray = com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? (!lightenginethreaded.hasSkyLight ? null : (chunk.getSkyNibbles()[i - minSection].isAllZero() ? new NibbleArray() : chunk.getSkyNibbles()[i - minSection].toVanillaNibble())) : lightenginethreaded.a(EnumSkyBlock.SKY).a(SectionPosition.a(chunkPos, i)); // Tuinity - chunk might not be loaded
-
+
// copy data for safety
- if (blockArray != null) {
+ if (!com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine && blockArray != null) { // Tuinity - data already copied
@@ -9770,7 +9770,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
+ if (!com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine && skyArray != null) { // Tuinity - data already copied
skyArray = skyArray.copy();
}
-
+
@@ -396,15 +426,19 @@ public class ChunkRegionLoader {
}
public static NBTTagCompound saveChunk(WorldServer worldserver, IChunkAccess ichunkaccess, AsyncSaveData asyncsavedata) {
@@ -9782,7 +9782,7 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
-
+
nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion());
- nbttagcompound.set("Level", nbttagcompound1);
+ nbttagcompound.set("Level", nbttagcompound1); // Tuinity - diff on change
@@ -9806,28 +9806,28 @@ index f51bf71c8d6eef3c054ac64765709794fcfad5ee..076d6c1e1cc049dd312ecb30518e7b25
nibblearray1 = asyncsavedata.skyLight[i + 1]; // +1 to offset the -1 starting index
@@ -444,12 +478,12 @@ public class ChunkRegionLoader {
}
-
+
if (nibblearray != null && !nibblearray.c()) {
- nbttagcompound2.setByteArray("BlockLight", nibblearray.asBytesPoolSafe().clone()); // Paper
+ nbttagcompound2.setByteArray("BlockLight", com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? nibblearray.asBytes() : nibblearray.asBytesPoolSafe().clone()); // Paper // Tuinity - data is already cloned
}
-
+
if (nibblearray1 != null && !nibblearray1.c()) {
- nbttagcompound2.setByteArray("SkyLight", nibblearray1.asBytesPoolSafe().clone()); // Paper
- }
+ nbttagcompound2.setByteArray("SkyLight", com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? nibblearray1.asBytes() : nibblearray1.asBytesPoolSafe().clone()); // Paper // Tuinity - data is already cloned
+ } else if (nibblearray1 != null && com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine) nbttagcompound2.setBoolean(UNINITIALISED_SKYLIGHT_TAG, true); // Tuinity - store uninitialised tags
-
+
nbttaglist.add(nbttagcompound2);
}
@@ -457,7 +491,7 @@ public class ChunkRegionLoader {
-
+
nbttagcompound1.set("Sections", nbttaglist);
if (flag) {
- nbttagcompound1.setBoolean("isLightOn", true);
+ nbttagcompound1.setBoolean("isLightOn", com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? false : true); if (com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine) nbttagcompound1.setInt(STARLIGHT_VERSION_TAG, STARLIGHT_LIGHT_VERSION); // Tuinity
}
-
+
BiomeStorage biomestorage = ichunkaccess.getBiomeIndex();
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
index e52df8096e399c84ff8a2637fdd65ea57d9001d0..33b8f4e0f09fdc41c8ea48b6ed77af199136ab92 100644
@@ -9839,13 +9839,13 @@ index e52df8096e399c84ff8a2637fdd65ea57d9001d0..33b8f4e0f09fdc41c8ea48b6ed77af19
private short e;
- final DataPaletteBlock blockIds; // Paper - package-private
+ public final DataPaletteBlock blockIds; // Paper - package-private // Tuinity - public
-
+
final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
-
+
@@ -96,6 +96,7 @@ public class ChunkSection {
return iblockdata1;
}
-
+
+ public final boolean isFullOfAir() { return this.c(); } // Tuinity - OBFHELPER
public boolean c() {
return this.nonEmptyBlockCount == 0;
@@ -9860,7 +9860,7 @@ index f6c9bdbf52d773d7aa601125b887b347163f9328..51ea295d66312c95685b9fe4ee502a02
private final ChunkStatus.Type y;
- private final EnumSet z;
+ private final EnumSet z; public final HeightMap.Type[] heightMaps; // Tuinity
-
+
private static CompletableFuture> a(ChunkStatus chunkstatus, LightEngineThreaded lightenginethreaded, IChunkAccess ichunkaccess) {
boolean flag = a(chunkstatus, ichunkaccess);
@@ -171,7 +171,7 @@ public class ChunkStatus {
@@ -9871,7 +9871,7 @@ index f6c9bdbf52d773d7aa601125b887b347163f9328..51ea295d66312c95685b9fe4ee502a02
+ this.z = enumset; this.heightMaps = new java.util.ArrayList<>(this.z).toArray(new HeightMap.Type[0]); // Tuinity
this.t = chunkstatus == null ? 0 : chunkstatus.c() + 1;
}
-
+
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
index 95ef96286855624590b72d69514b0fc0e08fddba..73163b417af7e522a4509bf9c1ab56d6499be622 100644
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
@@ -9879,11 +9879,11 @@ index 95ef96286855624590b72d69514b0fc0e08fddba..73163b417af7e522a4509bf9c1ab56d6
@@ -163,6 +163,7 @@ public class DataPaletteBlock implements DataPaletteExpandable {
return this.a(j << 8 | k << 4 | i); // Paper - inline
}
-
+
+ public final T rawGet(int index) { return this.a(index); } // Tuinity - OBFHELPER
protected T a(int i) {
T t0 = this.h.a(this.a.a(i));
-
+
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 5504facd2e453238caa71d98743be5416d4dd4fe..ecff0657e5666ddc2e6a5c3111bfb2b8dd2b78d3 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -9893,17 +9893,17 @@ index 5504facd2e453238caa71d98743be5416d4dd4fe..ecff0657e5666ddc2e6a5c3111bfb2b8
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
// Paper end
+ com.tuinity.tuinity.config.TuinityConfig.init((java.io.File) options.valueOf("tuinity-settings")); // Tuinity - Server Config
-
+
this.setPVP(dedicatedserverproperties.pvp);
this.setAllowFlight(dedicatedserverproperties.allowFlight);
@@ -357,7 +358,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
-
+
if (this.q != null) {
- this.q.b();
+ //this.q.b(); // Tuinity - do not wait for AWT, causes deadlock with sigint handler (AWT shutdown will properly clear our resources anyways)
}
-
+
if (this.remoteControlListener != null) {
diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java
index 550232cb3819138b3bae0fa1c51429485e8bc593..229c3b0f0c650b501f31147adaa17194af57fedd 100644
@@ -9911,7 +9911,7 @@ index 550232cb3819138b3bae0fa1c51429485e8bc593..229c3b0f0c650b501f31147adaa17194
+++ b/src/main/java/net/minecraft/server/EULA.java
@@ -70,7 +70,7 @@ public class EULA {
Properties properties = new Properties();
-
+
properties.setProperty("eula", "false");
- properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\nYou also agree that tacos are tasty, and the best food in the world."); // Paper - fix lag;
+ properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); // Paper - fix lag; // Tuinity - Tacos are disgusting
@@ -9934,7 +9934,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
@@ -207,6 +207,14 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// CraftBukkit end
-
+
+ // Tuinity start
+ public final AxisAlignedBB getBoundingBoxAt(double x, double y, double z) {
+ double widthHalf = (double)this.size.width / 2.0;
@@ -9945,11 +9945,11 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
+
// Paper start - optimise entity tracking
final org.spigotmc.TrackingRange.TrackingRangeType trackingRangeType = org.spigotmc.TrackingRange.getTrackingRangeType(this);
-
+
@@ -222,6 +230,41 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// Paper end - optimise entity tracking
-
+
+ // Tuinity start
+ /**
+ * Overriding this field will cause memory leaks.
@@ -9991,7 +9991,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
@@ -591,7 +634,39 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.onGround;
}
-
+
+ // Tuinity start - detailed watchdog information
+ private Vec3D moveVector;
+ private double moveStartX;
@@ -10030,16 +10030,16 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
this.recalcPosition();
@@ -619,7 +694,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// Paper end
-
+
vec3d = this.a(vec3d, enummovetype);
- Vec3D vec3d1 = this.g(vec3d);
+ Vec3D vec3d1 = this.performCollision(vec3d); // Tuinity - optimise collisions
-
+
if (vec3d1.g() > 1.0E-7D) {
this.a(this.getBoundingBox().c(vec3d1));
@@ -710,7 +785,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
-
+
try {
- this.checkBlockCollisions();
+ this.checkBlockCollisions(this.fireTicks <= 0); // Tuinity - move fire checking into method here
@@ -10048,7 +10048,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision");
@@ -722,11 +797,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
float f2 = this.getBlockSpeedFactor();
-
+
this.setMot(this.getMot().d((double) f2, 1.0D, (double) f2));
- if (this.world.c(this.getBoundingBox().shrink(0.001D)).noneMatch((iblockdata1) -> {
- return iblockdata1.a((Tag) TagsBlock.FIRE) || iblockdata1.a(Blocks.LAVA);
@@ -10056,11 +10056,11 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
- this.setFireTicks(-this.getMaxFireTicks());
- }
+ // Tuinity - move into checkBlockCollisions
-
+
if (this.aG() && this.isBurning()) {
this.playSound(SoundEffects.ENTITY_GENERIC_EXTINGUISH_FIRE, 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
@@ -735,6 +806,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
-
+
this.world.getMethodProfiler().exit();
}
+ // Tuinity start - detailed watchdog information
@@ -10071,12 +10071,12 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
+ }
+ // Tuinity end - detailed watchdog information
}
-
+
protected BlockPosition ap() {
@@ -815,6 +893,137 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return d0;
}
-
+
+ // Tuinity start - optimise entity movement
+ private static double performCollisionsX(AxisAlignedBB currentBoundingBox, double value, List potentialCollisions) {
+ for (int i = 0, len = potentialCollisions.size(); i < len; ++i) {
@@ -10214,14 +10214,14 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
@@ -850,6 +1059,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return vec3d1;
}
-
+
+ public static double getXZSquared(Vec3D vec3d) { return Entity.c(vec3d); } // Tuinity - OBFHELPER
public static double c(Vec3D vec3d) {
return vec3d.x * vec3d.x + vec3d.z * vec3d.z;
}
@@ -962,18 +1172,34 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
-
+
protected void checkBlockCollisions() {
+ // Tuinity start
+ this.checkBlockCollisions(false);
@@ -10233,7 +10233,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
BlockPosition blockposition = new BlockPosition(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D);
BlockPosition blockposition1 = new BlockPosition(axisalignedbb.maxX - 0.001D, axisalignedbb.maxY - 0.001D, axisalignedbb.maxZ - 0.001D);
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
-
+
if (this.world.areChunksLoadedBetween(blockposition, blockposition1)) {
- for (int i = blockposition.getX(); i <= blockposition1.getX(); ++i) {
- for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) {
@@ -10245,7 +10245,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
+ // Tuinity end - reorder iteration to more cache aware
blockposition_mutableblockposition.d(i, j, k);
IBlockData iblockdata = this.world.getType(blockposition_mutableblockposition);
-
+
+ // Tuinity start - move fire checking in here - reuse getType from this method
+ if (checkFire) {
+ if (!inFire && (iblockdata.a(TagsBlock.FIRE) || iblockdata.a(Blocks.LAVA))) {
@@ -10267,12 +10267,12 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
+ }
+ // Tuinity end - move fire checking in here - reuse getType from this method
}
-
+
}
@@ -1358,6 +1589,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return d3 * d3 + d4 * d4 + d5 * d5;
}
-
+
+ public final double getDistanceSquared(Entity other) { return this.h(other); } // Tuinity - OBFHELPER
public double h(Entity entity) {
return this.e(entity.getPositionVector());
@@ -10280,7 +10280,7 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
@@ -1945,9 +2177,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
float f1 = this.size.width * 0.8F;
AxisAlignedBB axisalignedbb = AxisAlignedBB.g((double) f1, 0.10000000149011612D, (double) f1).d(this.locX(), this.getHeadY(), this.locZ());
-
+
- return this.world.b(this, axisalignedbb, (iblockdata, blockposition) -> {
+ return ((WorldServer)this.world).collidesWithAnyBlockOrWorldBorder(this, axisalignedbb, false, false, (iblockdata, blockposition) -> { // Tuinity - use optimised method
return iblockdata.o(this.world, blockposition);
@@ -10288,48 +10288,48 @@ index d8787985ab4c94e9808332c15b3d16d4b52ba195..2b76b5a70280def08f239ff387407a9d
+ }); // Tuinity - use optimised method
}
}
-
+
@@ -1955,11 +2187,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return EnumInteractionResult.PASS;
}
-
+
- public boolean j(Entity entity) {
+ public final boolean hardCollidesWith(Entity other) { return this.j(other); } // Tuinity - OBFHELPER
+ public boolean j(Entity entity) { // Tuinity - diff on change, hard colliding entities override this
return entity.aZ() && !this.isSameVehicle(entity);
}
-
+
- public boolean aZ() {
+ public final boolean collisionBoxIsHard() { return this.aZ(); } // Tuinity - OBFHELPER
+ public boolean aZ() {// Tuinity - diff on change, hard colliding entities override this
return false;
}
-
+
@@ -2850,7 +3084,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.recursiveStream().forEach((entity) -> {
worldserver.chunkCheck(entity);
entity.az = true;
- Iterator iterator = entity.passengers.iterator();
+ Iterator iterator = new java.util.ArrayList<>(entity.passengers).iterator(); // Tuinity - copy list to guard against CME
-
+
while (iterator.hasNext()) {
Entity entity1 = (Entity) iterator.next();
@@ -3308,12 +3542,16 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.locBlock;
}
-
+
+ public final Object posLock = new Object(); // Tuinity - log detailed entity tick information
+
public Vec3D getMot() {
return this.mot;
}
-
+
public void setMot(Vec3D vec3d) {
+ synchronized (this.posLock) { // Tuinity
this.mot = vec3d;
+ } // Tuinity
}
-
+
public void setMot(double d0, double d1, double d2) {
@@ -3368,7 +3606,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
@@ -10347,23 +10347,23 @@ index 1e7f5957d879d1ba8cf2b29cf9397b8e204e4381..f983516b89cdf7ce7fdea8f5a5b1a29d
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -173,8 +173,10 @@ public abstract class EntityArrow extends IProjectile {
// Paper end
-
+
if (object != null && !flag) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, (MovingObjectPosition) object)) { // CraftBukkit - Call event // Paper - make cancellable // Tuinity - implement cancellation properly
this.a((MovingObjectPosition) object);
this.impulse = true;
+ } // Tuinity - implement cancellation properly
}
-
+
if (movingobjectpositionentity == null || this.getPierceLevel() <= 0) {
diff --git a/src/main/java/net/minecraft/server/EntityCat.java b/src/main/java/net/minecraft/server/EntityCat.java
index 8bc8dcf7dfe79c5522bc715ad60aeaab4b1d85da..675083e3952779e43bf8cc3175ad70458a79e49c 100644
--- a/src/main/java/net/minecraft/server/EntityCat.java
+++ b/src/main/java/net/minecraft/server/EntityCat.java
@@ -292,7 +292,7 @@ public class EntityCat extends EntityTameableAnimal {
-
+
WorldServer worldserver = worldaccess.getMinecraftWorld();
-
+
- if (worldserver instanceof WorldServer && ((WorldServer) worldserver).getStructureManager().a(this.getChunkCoordinates(), true, StructureGenerator.SWAMP_HUT).e()) {
+ if (worldserver instanceof WorldServer && ((WorldServer) worldserver).getStructureManager().getStructureStarts(this.getChunkCoordinates(), true, StructureGenerator.SWAMP_HUT, worldaccess).e()) { // Tuinity - fix deadlock on chunk gen
this.setCatType(10);
@@ -10375,12 +10375,12 @@ index 0840fdf3585407ec317f0326359619220c64db78..6b9b64539d2272070b523ed6b927de02
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
@@ -67,7 +67,9 @@ public abstract class EntityFireball extends IProjectile {
// Paper end
-
+
if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) { // CraftBukkit - Call event // Paper - make cancellable // Tuinity - implement cancellation properly
this.a(movingobjectposition);
+ } // Tuinity - implement cancellation properly
-
+
// CraftBukkit start - Fire ProjectileHitEvent
if (this.dead) {
diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -10389,14 +10389,14 @@ index a646dc9f030ad1f76ba2b7bb1bc7897cd34b648c..dd18eabd7104995f0e6a8ecb279a3872
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -124,8 +124,10 @@ public class EntityFireworks extends IProjectile {
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
-
+
if (!this.noclip) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) { // CraftBukkit - Call event // Paper - make cancellable // Tuinity - implement cancellation properly
this.a(movingobjectposition);
this.impulse = true;
+ } // Tuinity - implement cancellation properly
}
-
+
this.x();
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
index e97c7794e86c0518bcec0a0370bffbeab20e2623..0816ab54bc99bcf29356b56516e83759a3f2988f 100644
@@ -10405,12 +10405,12 @@ index e97c7794e86c0518bcec0a0370bffbeab20e2623..0816ab54bc99bcf29356b56516e83759
@@ -226,7 +226,9 @@ public class EntityFishingHook extends IProjectile {
private void m() {
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
-
+
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) { // CraftBukkit - Call event // Paper - make cancellable // Tuinity - implement cancellation properly
this.a(movingobjectposition);
+ } // Tuinity - implement cancellation properly
}
-
+
@Override
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index a88521745f9f9b6935a61db52db915ea483af227..8a5e2806e68e5f4431fd9563fae780861e87632f 100644
@@ -10428,7 +10428,7 @@ index a88521745f9f9b6935a61db52db915ea483af227..8a5e2806e68e5f4431fd9563fae78086
+ entityhuman = ((WorldServer)this.world).playersAffectingSpawning.isEmpty() ? null : ((WorldServer)this.world).playersAffectingSpawning.get(0);
+ }
+ // Tuinity end - optimise checkDespawn
-
+
if (entityhuman != null) {
double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
@@ -10436,7 +10436,7 @@ index f41aaa7623c052b9f4044898d1bdee898c03057a..d99cecc4075338d7b8f154ab94d8ac04
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -526,7 +526,7 @@ public class EntityItem extends Entity {
-
+
// Paper start - fix MC-4
public void setPositionRaw(double x, double y, double z) {
- if (com.destroystokyo.paper.PaperConfig.fixEntityPositionDesync) {
@@ -10458,7 +10458,7 @@ index b7a362bd9c5e9dae909b863335bae3a94d404a16..87b66c284208f12e9e7cd1c9950ada8d
+ this.world.getEntities(this, this.getBoundingBox(), IEntitySelector.pushable(this, world.paperConfig.fixClimbingBypassingCrammingRule), list); // Paper - fix climbing bypassing cramming rule
+ try {
+ // Tuinity end - reduce memory allocation from collideNearby
-
+
if (!list.isEmpty()) {
// Paper - move up
@@ -2908,6 +2912,9 @@ public abstract class EntityLiving extends Entity {
@@ -10468,22 +10468,22 @@ index b7a362bd9c5e9dae909b863335bae3a94d404a16..87b66c284208f12e9e7cd1c9950ada8d
+ } finally { // Tuinity start - reduce memory allocation from collideNearby
+ com.tuinity.tuinity.util.CachedLists.returnTempGetEntitiesList(list);
+ } // Tuinity end - reduce memory allocation from collideNearby
-
+
}
-
+
diff --git a/src/main/java/net/minecraft/server/EntityLlamaSpit.java b/src/main/java/net/minecraft/server/EntityLlamaSpit.java
index 7636a51a7ef0aa05b5b2aaa9d17e7b551dedac96..480a02a8f6ec7110f9af8f2037fdc09a7a54ef01 100644
--- a/src/main/java/net/minecraft/server/EntityLlamaSpit.java
+++ b/src/main/java/net/minecraft/server/EntityLlamaSpit.java
@@ -19,7 +19,9 @@ public class EntityLlamaSpit extends IProjectile {
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
-
+
if (movingobjectposition != null) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) { // CraftBukkit - Call event // Paper - make cancellable // Tuinity - implement cancellation properly
this.a(movingobjectposition);
+ } // Tuinity - implement cancellation properly
}
-
+
double d0 = this.locX() + vec3d.x;
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index a9a409eebabae11ab84cf9bcced1f9a030b4a479..173a210392d71cdfc551f095dc0d9c9040d22d3f 100644
@@ -10492,7 +10492,7 @@ index a9a409eebabae11ab84cf9bcced1f9a030b4a479..173a210392d71cdfc551f095dc0d9c90
@@ -528,6 +528,185 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
}
-
+
+ /* // TODO remove debug
+ this.networkManager.disableAutomaticFlush();
+
@@ -10693,9 +10693,9 @@ index 23017b5486530bcf76b3934cfa8621e8b4772b27..a4d94385ede0303417d676155c2c0b22
--- a/src/main/java/net/minecraft/server/EntityShulkerBullet.java
+++ b/src/main/java/net/minecraft/server/EntityShulkerBullet.java
@@ -206,7 +206,7 @@ public class EntityShulkerBullet extends IProjectile {
-
+
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
-
+
- if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
+ if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) { // Tuinity - implement cancellation properly
this.a(movingobjectposition);
@@ -10706,17 +10706,17 @@ index 3960a975e74ed81c45819fe5e0f01c6c18252982..81869215876d10a84ab27c0e6f41963c
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -74,6 +74,7 @@ public class EntityTrackerEntry {
-
+
public final void tick() { this.a(); } // Paper - OBFHELPER
public void a() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Tracker update"); // Tuinity
List list = this.tracker.getPassengers();
-
+
if (!list.equals(this.p)) {
@@ -156,7 +157,7 @@ public class EntityTrackerEntry {
// Paper end - remove allocation of Vec3D here
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
-
+
- if (!flag4 && this.o <= 400 && !this.q && this.r == this.tracker.isOnGround()) {
+ if (!flag4 && this.o <= 400 && !this.q && this.r == this.tracker.isOnGround() && !(com.tuinity.tuinity.config.TuinityConfig.sendFullPosForHardCollidingEntities && this.tracker.hardCollides())) { // Tuinity - send full pos for hard colliding entities to prevent collision problems due to desync
if ((!flag2 || !flag3) && !(this.tracker instanceof EntityArrow)) {
@@ -10729,14 +10729,14 @@ index 05b0090ae36cf61f67e26aad478df30c89f31941..30ba21ac1bced18a9d0946b7c3ed5597
@@ -170,8 +170,8 @@ public enum EnumDirection implements INamable {
return EnumDirection.q[MathHelper.a(i % EnumDirection.q.length)];
}
-
+
- @Nullable
- public static EnumDirection a(int i, int j, int k) {
+ @Nullable public static EnumDirection from(int i, int j, int k) { return a(i, j, k); } // Tuinity - OBFHELPER
+ @Nullable public static EnumDirection a(int i, int j, int k) {
return (EnumDirection) EnumDirection.r.get(BlockPosition.a(i, j, k));
}
-
+
diff --git a/src/main/java/net/minecraft/server/HeightMap.java b/src/main/java/net/minecraft/server/HeightMap.java
index 068b92c5c4ae112771757626ea75694e59f3d255..476da43b9f0ef35b4985f88e4784b1f8c5222af3 100644
--- a/src/main/java/net/minecraft/server/HeightMap.java
@@ -10744,7 +10744,7 @@ index 068b92c5c4ae112771757626ea75694e59f3d255..476da43b9f0ef35b4985f88e4784b1f8
@@ -101,6 +101,7 @@ public class HeightMap {
}
}
-
+
+ public final int get(int x, int z) { return this.a(x, z); } // Tuinity - OBFHELPER
public int a(int i, int j) {
return this.a(c(i, j));
@@ -10757,11 +10757,11 @@ index 068b92c5c4ae112771757626ea75694e59f3d255..476da43b9f0ef35b4985f88e4784b1f8
+ private static final Map k = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // Tuinity - decompile fix
HeightMap.Type[] aheightmap_type = values();
int i = aheightmap_type.length;
-
+
@@ -149,7 +150,7 @@ public class HeightMap {
-
+
});
-
+
- private Type(String s, HeightMap.Use heightmap_use, Predicate predicate) {
+ private Type(String s, HeightMap.Use heightmap_use, Predicate predicate) { // Tuinity - decompile fix
this.h = s;
@@ -10787,7 +10787,7 @@ index 180b6b58dc5663158db84b6f1257591439b48c31..eb0d794b7275af7f860e7c7b85a9e3b2
@@ -24,6 +24,36 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
}
// Paper end
-
+
+ // Tuinity start
+ default com.tuinity.tuinity.chunk.light.SWMRNibbleArray[] getBlockNibbles() {
+ throw new UnsupportedOperationException(this.getClass().getName());
@@ -10824,18 +10824,18 @@ index 180b6b58dc5663158db84b6f1257591439b48c31..eb0d794b7275af7f860e7c7b85a9e3b2
@@ -122,6 +152,7 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
@Nullable
NBTTagCompound j(BlockPosition blockposition);
-
+
+ default Stream getLightSources() { return this.m(); } // Tuinity - OBFHELPER
Stream m();
-
+
TickList n();
@@ -142,7 +173,9 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
return ashortlist[i];
}
-
+
+ default boolean isLit() { return this.r(); } // Tuinity - OBFHELPER
boolean r();
-
+
+ default void setLit(boolean lit) { this.b(lit); } // Tuinity - OBFHELPER
void b(boolean flag);
}
@@ -10845,7 +10845,7 @@ index 582a5695bac7d078e3022b8ee70c512c0680d992..5601088cd5024a40e8296bab979f43de
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
@@ -21,7 +21,7 @@ public class IChunkLoader implements AutoCloseable {
protected final RegionFileCache regionFileCache;
-
+
public IChunkLoader(File file, DataFixer datafixer, boolean flag) {
- this.regionFileCache = new RegionFileCache(file, flag); // Paper - nuke IOWorker
+ this.regionFileCache = new RegionFileCache(file, flag, true); // Paper - nuke IOWorker // Tuinity
@@ -10858,7 +10858,7 @@ index 25e54a1fadc5d31fb250a3f47524b4f345fc8cc6..cce0ac8a36bef3b9e5a2b95e0c3dd137
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -28,6 +28,11 @@ public interface ICollisionAccess extends IBlockAccess {
}
-
+
default boolean b(AxisAlignedBB axisalignedbb) {
+ // Tuinity start - allow overriding in WorldServer
+ return this.getCubes(axisalignedbb);
@@ -10870,7 +10870,7 @@ index 25e54a1fadc5d31fb250a3f47524b4f345fc8cc6..cce0ac8a36bef3b9e5a2b95e0c3dd137
});
@@ -46,6 +51,11 @@ public interface ICollisionAccess extends IBlockAccess {
}
-
+
default boolean b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate predicate) {
+ // Tuinity start - allow overriding in WorldServer
+ return this.getCubes(entity, axisalignedbb, predicate);
@@ -10887,7 +10887,7 @@ index 2639c17b7f6100533f33124f9e49990cd303d161..93f2ac996904ddefed04704e554209d0
@@ -55,16 +55,26 @@ public interface IEntityAccess {
return this.b(oclass, axisalignedbb, IEntitySelector.g);
}
-
+
+ // Tuinity start - optimise hard collision
+ /**
+ * Not guaranteed to only return hard colliding entities
@@ -10903,57 +10903,57 @@ index 2639c17b7f6100533f33124f9e49990cd303d161..93f2ac996904ddefed04704e554209d0
} else {
- AxisAlignedBB axisalignedbb1 = axisalignedbb.g(1.0E-7D);
+ AxisAlignedBB axisalignedbb1 = axisalignedbb.g(-1.0E-7D); // Tuinity - to comply with vanilla intersection rules, expand by -epsilon so we only get stuff we definitely collide with. expanding by +epsilon gives us stuff we don't collide with, which will screw over callers in some cases.
-
+
- return this.getEntities(entity, axisalignedbb1, predicate.and((entity1) -> {
+ if (predicate == null) predicate = (e) -> true; // Tuinity - allow nullable
+ predicate = predicate.and((entity1) -> { // Tuinity - optimise entity hard collisions // Tuinity - allow nullable
boolean flag;
-
+
- if (entity1.getBoundingBox().c(axisalignedbb1)) {
+ if (true || entity1.getBoundingBox().c(axisalignedbb1)) { // Tuinity - always true, wtf did they think this.getEntities(entity, axisalignedbb1) does?
label25:
{
if (entity == null) {
@@ -82,7 +92,7 @@ public interface IEntityAccess {
-
+
flag = false;
return flag;
- })).stream().map(Entity::getBoundingBox).map(VoxelShapes::a);
+ }); return ((entity != null && entity.hardCollides()) ? this.getEntities(entity, axisalignedbb1, predicate) : this.getHardCollidingEntities(entity, axisalignedbb1, predicate)).stream().map(Entity::getBoundingBox).map(VoxelShapes::a); // Tuinity - optimise entity hard collisions
}
}
-
+
@@ -204,12 +214,12 @@ public interface IEntityAccess {
}
-
+
@Nullable
- default T a(Class extends T> oclass, PathfinderTargetCondition pathfindertargetcondition, @Nullable EntityLiving entityliving, double d0, double d1, double d2, AxisAlignedBB axisalignedbb) {
+ default T a(Class extends T> oclass, PathfinderTargetCondition pathfindertargetcondition, @Nullable EntityLiving entityliving, double d0, double d1, double d2, AxisAlignedBB axisalignedbb) { // Tuinity - diff on change, override in World - this should be "get closest entity by class that matches path finder target condition"
return this.a(this.a(oclass, axisalignedbb, null), pathfindertargetcondition, entityliving, d0, d1, d2); // Paper - decompile fix
}
-
+
@Nullable
- default T b(Class extends T> oclass, PathfinderTargetCondition pathfindertargetcondition, @Nullable EntityLiving entityliving, double d0, double d1, double d2, AxisAlignedBB axisalignedbb) {
+ default T b(Class extends T> oclass, PathfinderTargetCondition pathfindertargetcondition, @Nullable EntityLiving entityliving, double d0, double d1, double d2, AxisAlignedBB axisalignedbb) { // Tuinity - diff on change, override in World - this should be "get closest entity by class that matches path finder target condition"
return this.a(this.b(oclass, axisalignedbb, null), pathfindertargetcondition, entityliving, d0, d1, d2); // Paper - decompile fix
}
-
+
diff --git a/src/main/java/net/minecraft/server/ILightAccess.java b/src/main/java/net/minecraft/server/ILightAccess.java
index be5384ee41290b24b0c419c3e8f4553db34b2399..df28f7a6bf4c650a22ddf046eae4d5e8ca5879a9 100644
--- a/src/main/java/net/minecraft/server/ILightAccess.java
+++ b/src/main/java/net/minecraft/server/ILightAccess.java
@@ -4,9 +4,10 @@ import javax.annotation.Nullable;
-
+
public interface ILightAccess {
-
+
- @Nullable
- IBlockAccess c(int i, int j);
+ default @Nullable IBlockAccess getFeaturesReadyChunk(int i, int j) { return this.c(i, j); } // Tuinity - OBFHELPER
+ @Nullable IBlockAccess c(int i, int j);
-
+
+ default void markLightSectionDirty(EnumSkyBlock enumskyblock, SectionPosition sectionposition) { this.a(enumskyblock, sectionposition); } // Tuinity - OBFHELPER
default void a(EnumSkyBlock enumskyblock, SectionPosition sectionposition) {}
-
+
IBlockAccess getWorld();
diff --git a/src/main/java/net/minecraft/server/IProjectile.java b/src/main/java/net/minecraft/server/IProjectile.java
index bbc089b41fcbe0141f13591db2cb44b9e688cac4..dc9f2a1a132b3a7925bd62aa1da0512afd90b8b1 100644
@@ -10961,12 +10961,12 @@ index bbc089b41fcbe0141f13591db2cb44b9e688cac4..dc9f2a1a132b3a7925bd62aa1da0512a
+++ b/src/main/java/net/minecraft/server/IProjectile.java
@@ -118,7 +118,7 @@ public abstract class IProjectile extends Entity {
}
-
+
protected void a(MovingObjectPosition movingobjectposition) {
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) return; // CraftBukkit - Call event // Paper - make cancellable
+ // Tuinity - proper cancellation requires moving this into the caller (see method overrides) - TODO this unfortunately means we need to manually inspect each call on update
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
-
+
if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
diff --git a/src/main/java/net/minecraft/server/LightEngineGraphSection.java b/src/main/java/net/minecraft/server/LightEngineGraphSection.java
index 13d067f48647dea63ef1bf3a2a3e0868074ba75f..04afd7f285db2f281a038e0be6f557b8a692936b 100644
@@ -10975,10 +10975,10 @@ index 13d067f48647dea63ef1bf3a2a3e0868074ba75f..04afd7f285db2f281a038e0be6f557b8
@@ -74,8 +74,10 @@ public abstract class LightEngineGraphSection extends LightEngineGraph {
return i == Long.MAX_VALUE ? this.b(j) : k + 1;
}
-
+
+ public final int getSource(long coordinate) { return this.b(coordinate); } // Tuinity - OBFHELPER
protected abstract int b(long i);
-
+
+ public final void update(long coordinate, int level, boolean flag) { this.b(coordinate, level, flag); } // Tuinity - OBFHELPER
public void b(long i, int j, boolean flag) {
this.a(Long.MAX_VALUE, i, j, flag);
@@ -10998,21 +10998,21 @@ index b98e60772bad7e06845b50fdc11e98c0ea775d3d..e0bbfe1422cbad811ecb43d7436380d8
private final LongSet o = new LongOpenHashSet();
private final LongSet p = new LongOpenHashSet();
@@ -247,7 +248,7 @@ public abstract class LightEngineStorage> e
-
+
this.p.clear();
this.j = false;
- ObjectIterator objectiterator = this.i.long2ObjectEntrySet().iterator();
+ ObjectIterator objectiterator = this.i_synchronized_map_real.long2ObjectEntrySet().fastIterator(); // Tuinity - use fast iterator to reduce entry creation
-
+
Entry entry;
long j;
@@ -284,7 +285,7 @@ public abstract class LightEngineStorage> e
}
-
+
this.n.clear();
- objectiterator = this.i.long2ObjectEntrySet().iterator();
+ objectiterator = this.i_synchronized_map_real.long2ObjectEntrySet().fastIterator(); // Tuinity - use fast iterator to reduce entry creation;
-
+
while (objectiterator.hasNext()) {
entry = (Entry) objectiterator.next();
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
@@ -11020,7 +11020,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
@@ -2,6 +2,11 @@ package net.minecraft.server;
-
+
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; // Paper
+// Tuinity start
@@ -11033,13 +11033,13 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
@@ -15,11 +20,12 @@ import org.apache.logging.log4j.Logger;
public class LightEngineThreaded extends LightEngine implements AutoCloseable {
-
+
private static final Logger LOGGER = LogManager.getLogger();
- private final ThreadedMailbox b;
+ private final ThreadedMailbox b; private ThreadedMailbox getExecutor() { return this.b; } // Tuinity - OBFHELPER
// Paper start
private static final int MAX_PRIORITIES = PlayerChunkMap.GOLDEN_TICKET + 2;
-
+
private boolean isChunkLightStatus(long pair) {
+ if (true) return true; // Tuinity - viewing ticket levels async can result in the viewing of transient levels, and LIGHT ticket isn't guaranteed to exist for all loading chunks thanks to really dumb unloading behaviors with the chunk system
PlayerChunk playerChunk = playerChunkMap.getVisibleChunk(pair);
@@ -11048,7 +11048,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
@@ -156,13 +162,218 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
private volatile int f = 5;
private final AtomicBoolean g = new AtomicBoolean();
-
+
+ // Tuinity start - replace light engine impl
+ protected final com.tuinity.tuinity.chunk.light.StarLightInterface theLightEngine;
+ public final boolean hasBlockLight;
@@ -11230,7 +11230,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
+ }
+ }, this.playerChunkMap.mainInvokingExecutor);
}
-
+
+ // override things from superclass
+
+ @Override
@@ -11262,12 +11262,12 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
+ // Tuinity end - replace light engine impl
+
public void close() {}
-
+
@Override
@@ -179,6 +390,15 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
public void a(BlockPosition blockposition) {
BlockPosition blockposition1 = blockposition.immutableCopy();
-
+
+ // Tuinity start - replace light engine impl
+ if (this.theLightEngine != null) {
+ this.scheduleLightWorkTask(blockposition1.getX() >> 4, blockposition1.getZ() >> 4, LightEngineThreaded.Update.POST_UPDATE, () -> {
@@ -11282,7 +11282,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
}, () -> {
@@ -187,6 +407,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
}
-
+
protected void a(ChunkCoordIntPair chunkcoordintpair) {
+ // Tuinity start - replace light impl
+ if (this.theLightEngine != null) {
@@ -11293,7 +11293,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
return 0;
}, LightEngineThreaded.Update.PRE_UPDATE, SystemUtils.a(() -> {
@@ -211,6 +436,14 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
-
+
@Override
public void a(SectionPosition sectionposition, boolean flag) {
+ // Tuinity start - replace light engine impl
@@ -11308,7 +11308,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
return 0;
}, LightEngineThreaded.Update.PRE_UPDATE, SystemUtils.a(() -> {
@@ -222,6 +455,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
-
+
@Override
public void a(ChunkCoordIntPair chunkcoordintpair, boolean flag) {
+ // Tuinity start - replace light impl
@@ -11320,7 +11320,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
super.a(chunkcoordintpair, flag);
}, () -> {
@@ -231,6 +469,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
-
+
@Override
public void a(EnumSkyBlock enumskyblock, SectionPosition sectionposition, @Nullable NibbleArray nibblearray, boolean flag) {
+ // Tuinity start - replace light impl
@@ -11334,13 +11334,13 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
@@ -240,6 +483,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
}));
}
-
+
+ private void scheduleTask(int x, int z, LightEngineThreaded.Update lightenginethreaded_update, Runnable runnable) { this.a(x, z, lightenginethreaded_update, runnable); } // Tuinity - OBFHELPER
private void a(int i, int j, LightEngineThreaded.Update lightenginethreaded_update, Runnable runnable) {
this.a(i, j, this.d.c(ChunkCoordIntPair.pair(i, j)), lightenginethreaded_update, runnable);
}
@@ -252,6 +496,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
-
+
@Override
public void b(ChunkCoordIntPair chunkcoordintpair, boolean flag) {
+ // Tuinity start - replace light impl
@@ -11354,7 +11354,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
@@ -264,6 +513,35 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
public CompletableFuture a(IChunkAccess ichunkaccess, boolean flag) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
-
+
+ // Tuinity start - replace light engine
+ if (this.theLightEngine != null) {
+ // make the completion of this future only depend on pre-update execution
@@ -11389,7 +11389,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
long pair = chunkcoordintpair.pair();
@@ -311,7 +589,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
}
-
+
public void queueUpdate() {
- if ((!this.queue.isEmpty() || super.a()) && this.g.compareAndSet(false, true)) { // Paper
+ if ((!this.queue.isEmpty() || (this.theLightEngine == null && super.a())) && this.g.compareAndSet(false, true)) { // Paper // Tuinity - replace light impl
@@ -11433,14 +11433,14 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..001ac05cf26237eec8a77c476e678ff6
+ //final long end = System.nanoTime(); // TODO remove debug
+ //System.out.println("Block updates took " + (end - start) * 1.0e-6 + "ms"); // TODO remove debug
}
-
+
public void a(int i) {
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index c61cd50df0c81f7ab12bd0c955fd6f07f2b02e64..d987483255195c0bde713a92676baced1eaff2b3 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -234,7 +234,7 @@ public class LoginListener implements PacketLoginInListener {
-
+
s = (new BigInteger(MinecraftEncryption.a("", this.server.getKeyPair().getPublic(), this.loginKey))).toString(16);
this.g = LoginListener.EnumProtocolState.AUTHENTICATING;
- this.networkManager.a(cipher, cipher1);
@@ -11454,7 +11454,7 @@ index ff74be14512a947e81b62d53e616131ca7d7f609..e79e773f2219f9a9ae076fcbc8108b79
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -38,6 +38,7 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
-
+
public final class MCUtil {
+ public static final double COLLISION_EPSILON = 1.0E-7; // Tuinity - Just in case mojang changes this...
public static final ThreadPoolExecutor asyncExecutor = new ThreadPoolExecutor(
@@ -11463,7 +11463,7 @@ index ff74be14512a947e81b62d53e616131ca7d7f609..e79e773f2219f9a9ae076fcbc8108b79
@@ -221,6 +222,63 @@ public final class MCUtil {
return getBlockKey(getBlockCoordinate(entity.locX()), getBlockCoordinate(entity.locY()), getBlockCoordinate(entity.locZ()));
}
-
+
+ // Tuinity start
+
+ static final int SECTION_X_BITS = 22;
@@ -11551,7 +11551,7 @@ index ccf2d0b090f0c360dfc7886bb0726e099acec42c..1768554b00ea0b7a57ebbed1f0bc5d8f
// We've just obliterated the main thread, this will prevent stop from dying when removing players
@@ -952,6 +954,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant // Spigot - Spigot > // CraftBukkit - cb > vanilla!
+ return "Tuinity"; // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
}
-
+
public CrashReport b(CrashReport crashreport) {
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 1558c5f8256f50be6850f1d7f70eee3e8ec76496..b92ca4a6de01f3f86367fb8dfe3591b08a3e9218 100644
@@ -11770,7 +11770,7 @@ index 1558c5f8256f50be6850f1d7f70eee3e8ec76496..b92ca4a6de01f3f86367fb8dfe3591b0
@@ -30,6 +30,13 @@ public abstract class NavigationAbstract {
private final Pathfinder s; public Pathfinder getPathfinder() { return this.s; } // Paper - OBFHELPER
private boolean t;
-
+
+ // Tuinity start
+ public boolean isViableForPathRecalculationChecking() {
+ return !this.needsPathRecalculation() &&
@@ -11782,23 +11782,23 @@ index 1558c5f8256f50be6850f1d7f70eee3e8ec76496..b92ca4a6de01f3f86367fb8dfe3591b0
this.g = Vec3D.ORIGIN;
this.h = BaseBlockPosition.ZERO;
@@ -85,7 +92,7 @@ public abstract class NavigationAbstract {
-
+
@Nullable
public PathEntity a(Stream stream, int i) {
- return this.a((Set) stream.collect(Collectors.toSet()), 8, false, i);
+ return this.a((Set) stream.collect(Collectors.toSet()), 8, false, i); // Tuinity - diff on change, inlined into SensorNearestBed
}
-
+
@Nullable
@@ -393,7 +400,7 @@ public abstract class NavigationAbstract {
}
-
+
public void b(BlockPosition blockposition) {
- if (this.c != null && !this.c.c() && this.c.e() != 0) {
+ if (this.c != null && !this.c.c() && this.c.e() != 0) { // Tuinity - diff on change - needed for isViableForPathRecalculationChecking()
PathPoint pathpoint = this.c.d();
Vec3D vec3d = new Vec3D(((double) pathpoint.a + this.a.locX()) / 2.0D, ((double) pathpoint.b + this.a.locY()) / 2.0D, ((double) pathpoint.c + this.a.locZ()) / 2.0D);
-
+
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b32c162cf6 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
@@ -11806,16 +11806,16 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
@@ -27,6 +27,8 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
-
+
+import io.netty.util.concurrent.AbstractEventExecutor; // Tuinity
+
public class NetworkManager extends SimpleChannelInboundHandler> {
-
+
private static final Logger LOGGER = LogManager.getLogger();
@@ -71,6 +73,39 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
EnumProtocol protocol;
// Paper end
-
+
+ // Tuinity start - allow controlled flushing
+ volatile boolean canFlush = true;
+ private final java.util.concurrent.atomic.AtomicInteger packetWrites = new java.util.concurrent.atomic.AtomicInteger();
@@ -11855,7 +11855,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
@@ -145,8 +180,63 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
if (MinecraftServer.getServer().isDebugging()) throwable.printStackTrace(); // Spigot
}
-
+
+ // Tuinity start - packet limiter
+ protected final Object PACKET_LIMIT_LOCK = new Object();
+ protected final com.tuinity.tuinity.util.IntervalledCounter allPacketCounts = com.tuinity.tuinity.config.TuinityConfig.allPacketsLimit != null ? new com.tuinity.tuinity.util.IntervalledCounter(
@@ -11926,7 +11926,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
}
// write the packets to the queue, then flush - antixray hooks there already
@@ -248,6 +338,14 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
-
+
private void dispatchPacket(Packet> packet, @Nullable GenericFutureListener extends Future super Void>> genericFutureListener) { this.b(packet, genericFutureListener); } // Paper - OBFHELPER
private void b(Packet> packet, @Nullable GenericFutureListener extends Future super Void>> genericfuturelistener) {
+ // Tuinity start - add flush parameter
@@ -11939,14 +11939,14 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
+ // Tuinity end - add flush parameter
EnumProtocol enumprotocol = EnumProtocol.a(packet);
EnumProtocol enumprotocol1 = (EnumProtocol) this.channel.attr(NetworkManager.c).get();
-
+
@@ -270,7 +368,7 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
try {
// Paper end
-
+
- ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
+ ChannelFuture channelfuture = (flush) ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Tuinity - add flush parameter
-
+
if (genericfuturelistener != null) {
channelfuture.addListener(genericfuturelistener);
@@ -290,39 +388,83 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
@@ -11967,7 +11967,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
+ if (enumprotocol != enumprotocol1) {
+ this.setProtocol(enumprotocol);
+ }
-
+
- // Paper start
- if (!isConnected()) {
- packet.onPacketDispatchFinish(player, null);
@@ -12019,7 +12019,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
+ if (enumprotocol != enumprotocol1) {
+ this.setProtocol(enumprotocol);
+ }
-
+
- channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
- // Paper start
- } catch (Exception e) {
@@ -12061,7 +12061,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
+ this.channel.eventLoop().execute(choice1 != null ? choice1 : choice2);
+ // Tuinity end - optimise packets that are not flushed
}
-
+
}
@@ -345,6 +487,8 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
}
@@ -12074,13 +12074,13 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
java.util.Iterator iterator = this.packetQueue.iterator();
@@ -352,16 +496,22 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
NetworkManager.QueuedPacket queued = iterator.next(); // poll -> peek
-
+
// Fix NPE (Spigot bug caused by handleDisconnection())
- if (queued == null) {
+ if (false && queued == null) { // Tuinity - diff on change, this logic is redundant: iterator guarantees ret of an element - on change, hook the flush logic here
return true;
}
-
+
Packet> packet = queued.getPacket();
if (!packet.isReady()) {
+ // Tuinity start - make only one flush call per sendPacketQueue() call
@@ -12100,7 +12100,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
@@ -438,10 +588,16 @@ public class NetworkManager extends SimpleChannelInboundHandler> {
return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
}
-
+
- public void a(Cipher cipher, Cipher cipher1) {
+ public void a(javax.crypto.SecretKey secretkey) { // Tuinity
this.n = true;
@@ -12115,7 +12115,7 @@ index fb1e3c705b8abee13695762cdfd0e9f1bfdb5ad8..6a0ec0105399066dede622b45c9471b3
+ }
+ // Tuinity end
}
-
+
public boolean isConnected() {
diff --git a/src/main/java/net/minecraft/server/NibbleArray.java b/src/main/java/net/minecraft/server/NibbleArray.java
index 4085426af03f032cf405bdfd1e40a8e5dc27c1d1..348d16ddec3b4da0b6b4e4f49916b966005b5259 100644
@@ -12135,8 +12135,8 @@ index 4085426af03f032cf405bdfd1e40a8e5dc27c1d1..348d16ddec3b4da0b6b4e4f49916b966
// Paper end
- @Nullable protected byte[] a;
+ @Nullable protected byte[] a; public final byte[] justGiveMeTheFuckingByteArrayNoCleanerBullshitJesusFuckingChrist() { return this.a; }
-
-
+
+
public NibbleArray() {}
@@ -74,7 +75,7 @@ public class NibbleArray {
}
@@ -12148,22 +12148,22 @@ index 4085426af03f032cf405bdfd1e40a8e5dc27c1d1..348d16ddec3b4da0b6b4e4f49916b966
// Paper end
if (abyte.length != 2048) {
@@ -162,7 +163,7 @@ public class NibbleArray {
-
+
public NibbleArray copy() { return this.b(); } // Paper - OBFHELPER
public NibbleArray b() {
- return this.a == null ? new NibbleArray() : new NibbleArray(this.a); // Paper - clone in ctor
+ return this.a == null ? new NibbleArray() : new NibbleArray(com.tuinity.tuinity.config.TuinityConfig.useNewLightEngine ? this.a.clone() : this.a); // Paper - clone in ctor // Tuinity - no longer clone in constructor
}
-
+
public String toString() {
diff --git a/src/main/java/net/minecraft/server/PacketCompressor.java b/src/main/java/net/minecraft/server/PacketCompressor.java
index 3cdd07cad85ef2d2c4b6c27a55a878695b4a7b12..50b2a8dfbdd0fe60e295d7c7214d7c99bcbeb19a 100644
--- a/src/main/java/net/minecraft/server/PacketCompressor.java
+++ b/src/main/java/net/minecraft/server/PacketCompressor.java
@@ -7,14 +7,18 @@ import java.util.zip.Deflater;
-
+
public class PacketCompressor extends MessageToByteEncoder {
-
+
- private final byte[] a = new byte[8192];
- private final Deflater b;
+ // Tuinity start - use Velocity natives
@@ -12171,7 +12171,7 @@ index 3cdd07cad85ef2d2c4b6c27a55a878695b4a7b12..50b2a8dfbdd0fe60e295d7c7214d7c99
+// private final Deflater b;
private int c;
+ private final com.velocitypowered.natives.compression.VelocityCompressor compressor;
-
+
public PacketCompressor(int i) {
this.c = i;
- this.b = new Deflater();
@@ -12179,7 +12179,7 @@ index 3cdd07cad85ef2d2c4b6c27a55a878695b4a7b12..50b2a8dfbdd0fe60e295d7c7214d7c99
+ this.compressor = com.velocitypowered.natives.util.Natives.compress.get().create(-1);
}
+ // Tuinity end
-
+
protected void encode(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf, ByteBuf bytebuf1) throws Exception {
int i = bytebuf.readableBytes();
@@ -24,24 +28,46 @@ public class PacketCompressor extends MessageToByteEncoder {
@@ -12224,9 +12224,9 @@ index 3cdd07cad85ef2d2c4b6c27a55a878695b4a7b12..50b2a8dfbdd0fe60e295d7c7214d7c99
- this.b.reset();
+ // Tuinity end
}
-
+
}
-
+
+ // Tuinity start
+ @Override
+ protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception {
@@ -12247,15 +12247,15 @@ index 23c850be0155c1ece807d244117a196488f0a13b..4bab19a52b400071e69b06b940ab6432
--- a/src/main/java/net/minecraft/server/PacketDecompressor.java
+++ b/src/main/java/net/minecraft/server/PacketDecompressor.java
@@ -10,13 +10,17 @@ import java.util.zip.Inflater;
-
+
public class PacketDecompressor extends ByteToMessageDecoder {
-
+
- private final Inflater a;
+ // Tuinity start - use Velocity natives
+ //private final Inflater a;
+ private final com.velocitypowered.natives.compression.VelocityCompressor compressor;
private int b;
-
+
public PacketDecompressor(int i) {
this.b = i;
- this.a = new Inflater();
@@ -12263,13 +12263,13 @@ index 23c850be0155c1ece807d244117a196488f0a13b..4bab19a52b400071e69b06b940ab6432
+ this.compressor = com.velocitypowered.natives.util.Natives.compress.get().create(-1);
}
+ // Tuinity end
-
+
protected void decode(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf, List