summaryrefslogtreecommitdiffstats
path: root/nms-patches/PlayerConnection.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nms-patches/PlayerConnection.patch')
-rw-r--r--nms-patches/PlayerConnection.patch75
1 files changed, 37 insertions, 38 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index e4c3a7e2..dc4ef720 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -209,7 +209,7 @@
+
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
+ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8);
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
return;
@@ -222,14 +358,72 @@
@@ -325,7 +325,7 @@
});
}
-@@ -492,6 +694,15 @@
+@@ -490,6 +692,15 @@
}
public void a(PacketPlayInBEdit packetplayinbedit) {
@@ -341,7 +341,7 @@
ItemStack itemstack = packetplayinbedit.b();
if (!itemstack.isEmpty()) {
-@@ -516,11 +727,13 @@
+@@ -514,11 +725,13 @@
}
itemstack2.a("pages", (NBTBase) nbttaglist);
@@ -357,7 +357,7 @@
}
}
-@@ -560,7 +773,7 @@
+@@ -558,7 +771,7 @@
} else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -366,7 +366,7 @@
if (this.e == 0) {
this.syncPosition();
}
-@@ -570,13 +783,21 @@
+@@ -568,13 +781,21 @@
this.A = this.e;
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
}
@@ -389,7 +389,7 @@
double d0 = this.player.locX;
double d1 = this.player.locY;
double d2 = this.player.locZ;
-@@ -601,15 +822,33 @@
+@@ -599,15 +820,33 @@
++this.receivedMovePackets;
int i = this.receivedMovePackets - this.processedMovePackets;
@@ -400,7 +400,7 @@
+ this.lastTick = (int) (System.currentTimeMillis() / 50);
+
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
- PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getDisplayName().getString(), Integer.valueOf(i));
+ PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getDisplayName().getString(), i);
i = 1;
}
@@ -422,10 +422,10 @@
- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) {
+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9));
+ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9);
this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch);
return;
-@@ -655,6 +894,69 @@
+@@ -653,6 +892,69 @@
}
}
@@ -495,7 +495,7 @@
this.B = d12 >= -0.03125D;
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.dc() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
-@@ -672,10 +974,76 @@
+@@ -670,10 +972,76 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@@ -573,7 +573,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
-@@ -687,6 +1055,14 @@
+@@ -685,6 +1053,14 @@
this.teleportAwait = 0;
}
@@ -588,7 +588,7 @@
this.A = this.e;
this.player.setLocation(d0, d1, d2, f, f1);
this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
-@@ -694,6 +1070,7 @@
+@@ -692,6 +1068,7 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
@@ -596,7 +596,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.b();
-@@ -703,14 +1080,46 @@
+@@ -701,13 +1078,45 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
@@ -624,7 +624,6 @@
}
return;
-
case DROP_ITEM:
if (!this.player.isSpectator()) {
+ // limit how quickly items can be dropped
@@ -645,7 +644,7 @@
this.player.a(false);
}
-@@ -744,7 +1153,15 @@
+@@ -738,7 +1147,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
} else {
@@ -661,7 +660,7 @@
}
} else {
if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -764,10 +1181,12 @@
+@@ -757,10 +1174,12 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@@ -674,7 +673,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.d();
ItemStack itemstack = this.player.b(enumhand);
-@@ -780,6 +1199,13 @@
+@@ -773,6 +1192,13 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO));
} else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
@@ -688,7 +687,7 @@
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g());
}
-@@ -789,13 +1215,52 @@
+@@ -782,13 +1208,52 @@
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
@@ -728,7 +727,7 @@
+ player.playerInteractManager.firedInteract = false;
+ cancelled = player.playerInteractManager.interactResult;
+ } else {
-+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true, enumhand);
++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.getBlockPosition(), movingobjectposition.direction, itemstack, true, enumhand);
+ cancelled = event.useItemInHand() == Event.Result.DENY;
+ }
+ }
@@ -742,7 +741,7 @@
}
}
-@@ -815,13 +1280,18 @@
+@@ -808,13 +1273,18 @@
}
if (entity != null) {
@@ -763,7 +762,7 @@
public void a(PacketPlayInBoatMove packetplayinboatmove) {
PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer());
-@@ -834,11 +1304,26 @@
+@@ -827,11 +1297,26 @@
}
public void a(IChatBaseComponent ichatbasecomponent) {
@@ -791,7 +790,7 @@
if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown();
-@@ -864,6 +1349,15 @@
+@@ -857,6 +1342,15 @@
}
}
@@ -807,7 +806,7 @@
try {
this.networkManager.sendPacket(packet, genericfuturelistener);
} catch (Throwable throwable) {
-@@ -879,17 +1373,37 @@
+@@ -872,17 +1366,37 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
@@ -847,7 +846,7 @@
this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
} else {
this.player.resetIdleTimer();
-@@ -899,39 +1413,249 @@
+@@ -892,39 +1406,249 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -1104,7 +1103,7 @@
this.player.resetIdleTimer();
IJumpable ijumpable;
-@@ -1003,6 +1727,7 @@
+@@ -987,6 +1711,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
@@ -1112,7 +1111,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -1018,20 +1743,73 @@
+@@ -1002,20 +1727,73 @@
if (this.player.h(entity) < d0) {
EnumHand enumhand;
@@ -1187,7 +1186,7 @@
}
}
}
-@@ -1047,7 +1825,8 @@
+@@ -1031,7 +1809,8 @@
case PERFORM_RESPAWN:
if (this.player.viewingCredits) {
this.player.viewingCredits = false;
@@ -1197,7 +1196,7 @@
CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD);
} else {
if (this.player.getHealth() > 0.0F) {
-@@ -1070,14 +1849,20 @@
+@@ -1053,14 +1832,20 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
@@ -1220,7 +1219,7 @@
NonNullList nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
-@@ -1086,8 +1871,274 @@
+@@ -1069,8 +1854,274 @@
this.player.a(this.player.activeContainer, nonnulllist);
} else {
@@ -1496,7 +1495,7 @@
if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
this.player.f = true;
-@@ -1130,6 +2181,7 @@
+@@ -1113,6 +2164,7 @@
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
@@ -1504,7 +1503,7 @@
this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
this.player.activeContainer.a(this.player, packetplayinenchantitem.c());
-@@ -1161,6 +2213,43 @@
+@@ -1144,6 +2196,43 @@
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@@ -1548,15 +1547,15 @@
if (flag1 && flag2) {
if (itemstack.isEmpty()) {
-@@ -1184,6 +2273,7 @@
+@@ -1167,6 +2256,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
- if (oshort != null && packetplayintransaction.c() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
-@@ -1194,6 +2284,7 @@
+ if (oshort != null && packetplayintransaction.c() == oshort && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
+@@ -1177,6 +2267,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
@@ -1564,7 +1563,7 @@
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.b();
-@@ -1210,14 +2301,30 @@
+@@ -1193,14 +2284,30 @@
if (!tileentitysign.d() || tileentitysign.e() != this.player) {
this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
@@ -1596,7 +1595,7 @@
tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
-@@ -1226,6 +2333,7 @@
+@@ -1209,6 +2316,7 @@
}
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
@@ -1604,7 +1603,7 @@
if (this.g && packetplayinkeepalive.b() == this.h) {
int i = (int) (SystemUtils.b() - this.f);
-@@ -1239,7 +2347,17 @@
+@@ -1222,7 +2330,17 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
@@ -1623,7 +1622,7 @@
}
public void a(PacketPlayInSettings packetplayinsettings) {
-@@ -1247,5 +2365,47 @@
+@@ -1230,5 +2348,47 @@
this.player.a(packetplayinsettings);
}