2014-07-06 08:50:02 +02:00
|
|
|
From b4ccfcda70b29d207685f5ca29f5f405d4f1ed6e Mon Sep 17 00:00:00 2001
|
2014-07-06 05:55:30 +02:00
|
|
|
From: Zach Brown <Zbob750@live.com>
|
2014-07-06 08:50:02 +02:00
|
|
|
Date: Sun, 6 Jul 2014 01:49:28 -0500
|
2014-07-06 05:55:30 +02:00
|
|
|
Subject: [PATCH] Make players in main tick loop feature configurable
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
2014-07-06 08:50:02 +02:00
|
|
|
index 93b974a..1bf5d73 100644
|
2014-07-06 05:55:30 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
|
|
@@ -27,6 +27,8 @@ import org.bukkit.event.inventory.InventoryType;
|
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
|
|
+
|
|
|
|
public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
|
|
|
|
|
|
private static final Logger bL = LogManager.getLogger();
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -175,13 +177,18 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2014-07-06 05:55:30 +02:00
|
|
|
return 1.62F;
|
|
|
|
}
|
|
|
|
|
|
|
|
- // Spigot start
|
|
|
|
- private AxisAlignedBB groundCheck = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
|
2014-07-06 08:50:02 +02:00
|
|
|
+ private boolean playerTickMainLoop = PaperSpigotConfig.playerTickMainLoop;
|
|
|
|
|
2014-07-06 05:55:30 +02:00
|
|
|
public void h() {
|
|
|
|
- groundCheck.b( locX - 0.3, locY - 0.1, locZ - 0.3, locX + 0.3, locY, locZ + 0.3 );
|
|
|
|
- onGround = world.c(groundCheck);
|
|
|
|
- // Spigot end
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ // Spigot start
|
|
|
|
+ AxisAlignedBB groundCheck = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
|
|
|
|
+ groundCheck.b( locX - 0.3, locY - 0.1, locZ - 0.3, locX + 0.3, locY, locZ + 0.3 );
|
|
|
|
+ onGround = world.c(groundCheck);
|
|
|
|
+ // Spigot end
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
if (this.joining) {
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -261,14 +268,19 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2014-07-06 05:55:30 +02:00
|
|
|
if (this.bX > 0L && this.server.getIdleTimeout() > 0 && MinecraftServer.ar() - this.bX > (long) (this.server.getIdleTimeout() * 1000 * 60)) {
|
|
|
|
this.playerConnection.disconnect("You have been idle for too long!");
|
|
|
|
}
|
|
|
|
- // Spigot start
|
|
|
|
- this.i();
|
|
|
|
- if ( Double.isNaN( previousY ) )
|
|
|
|
- {
|
|
|
|
+
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ // Spigot start
|
|
|
|
+ this.i();
|
|
|
|
+ if ( Double.isNaN( previousY ) )
|
|
|
|
+ {
|
|
|
|
+ previousY = locY;
|
|
|
|
+ }
|
|
|
|
+ this.b(locY - previousY, onGround);
|
|
|
|
previousY = locY;
|
|
|
|
}
|
|
|
|
- this.b(locY - previousY, onGround);
|
|
|
|
- previousY = locY;
|
|
|
|
+ // PaperSpigot end
|
|
|
|
}
|
|
|
|
|
|
|
|
private double previousY = Double.NaN;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2014-07-06 08:50:02 +02:00
|
|
|
index d5f3b7b..04eead9 100644
|
2014-07-06 05:55:30 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -182,6 +182,8 @@ public class PlayerConnection implements PacketPlayInListener {
|
|
|
|
this.player.a(packetplayinsteervehicle.c(), packetplayinsteervehicle.d(), packetplayinsteervehicle.e(), packetplayinsteervehicle.f());
|
|
|
|
}
|
|
|
|
|
|
|
|
+ private boolean playerTickMainLoop = PaperSpigotConfig.playerTickMainLoop;
|
|
|
|
+
|
|
|
|
public void a(PacketPlayInFlying packetplayinflying) {
|
|
|
|
// CraftBukkit start - Check for NaN
|
|
|
|
if (Double.isNaN(packetplayinflying.x) || Double.isNaN(packetplayinflying.y) || Double.isNaN(packetplayinflying.z) || Double.isNaN(packetplayinflying.stance)) {
|
|
|
|
@@ -291,6 +293,12 @@ public class PlayerConnection implements PacketPlayInListener {
|
2014-07-06 05:55:30 +02:00
|
|
|
f1 = packetplayinflying.h();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.onGround = packetplayinflying.i();
|
|
|
|
+ this.player.i();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end;
|
|
|
|
this.player.V = 0.0F;
|
|
|
|
this.player.setLocation(d1, d2, d3, f, f1);
|
|
|
|
if (this.player.vehicle != null) {
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -309,6 +317,11 @@ public class PlayerConnection implements PacketPlayInListener {
|
2014-07-06 05:55:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.player.isSleeping()) {
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.i();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch);
|
|
|
|
worldserver.playerJoinedWorld(this.player);
|
|
|
|
return;
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -352,6 +365,11 @@ public class PlayerConnection implements PacketPlayInListener {
|
2014-07-06 05:55:30 +02:00
|
|
|
f3 = packetplayinflying.h();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.i();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
this.player.V = 0.0F;
|
|
|
|
this.player.setLocation(this.y, this.z, this.q, f2, f3);
|
|
|
|
if (!this.checkMovement) {
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -382,6 +400,11 @@ public class PlayerConnection implements PacketPlayInListener {
|
2014-07-06 05:55:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.player.move(d4, d5, d6);
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.onGround = packetplayinflying.i();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
this.player.checkMovement(d4, d5, d6);
|
|
|
|
double d11 = d5;
|
|
|
|
|
2014-07-06 08:50:02 +02:00
|
|
|
@@ -423,7 +446,17 @@ public class PlayerConnection implements PacketPlayInListener {
|
2014-07-06 05:55:30 +02:00
|
|
|
this.f = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.onGround = packetplayinflying.i();
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
this.minecraftServer.getPlayerList().d(this.player);
|
|
|
|
+ // PaperSpigot start - Make player tick in main loop configurable
|
2014-07-06 08:50:02 +02:00
|
|
|
+ if (!playerTickMainLoop) {
|
2014-07-06 05:55:30 +02:00
|
|
|
+ this.player.b(this.player.locY - d0, packetplayinflying.i());
|
|
|
|
+ }
|
|
|
|
+ // PaperSpigot end
|
|
|
|
} else if (this.e % 20 == 0) {
|
|
|
|
this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch);
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
|
|
index 7bda065..4f9f660 100644
|
|
|
|
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
|
|
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
|
|
@@ -135,4 +135,13 @@ public class PaperSpigotConfig
|
|
|
|
{
|
|
|
|
interactLimit = getInt( "settings.player-interaction-limit", 2 );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static boolean playerTickMainLoop;
|
|
|
|
+ private static void playerTickMainLoop()
|
|
|
|
+ {
|
|
|
|
+ playerTickMainLoop = getBoolean( "settings.player-tick-in-main-loop", false );
|
|
|
|
+ if ( playerTickMainLoop ) {
|
|
|
|
+ Bukkit.getLogger().log( Level.INFO, "Ticking players in the main loop. This may cause gameplay abnormalities" );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
|
|
|
1.9.1
|
|
|
|
|