geforkt von Mirrors/Paper
Don't send updates over large distances
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
765eadbac1
Commit
f01afaf08f
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||||
@@ -156,6 +156,63 @@
|
@@ -156,6 +156,62 @@
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -58,13 +58,12 @@
|
|||||||
+import org.bukkit.inventory.EquipmentSlot;
|
+import org.bukkit.inventory.EquipmentSlot;
|
||||||
+import org.bukkit.inventory.InventoryView;
|
+import org.bukkit.inventory.InventoryView;
|
||||||
+import org.bukkit.inventory.SmithingInventory;
|
+import org.bukkit.inventory.SmithingInventory;
|
||||||
+import org.bukkit.util.NumberConversions;
|
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn {
|
public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn {
|
||||||
|
|
||||||
static final Logger LOGGER = LogManager.getLogger();
|
static final Logger LOGGER = LogManager.getLogger();
|
||||||
@@ -167,7 +224,9 @@
|
@@ -167,7 +223,9 @@
|
||||||
private long keepAliveTime;
|
private long keepAliveTime;
|
||||||
private boolean keepAlivePending;
|
private boolean keepAlivePending;
|
||||||
private long keepAliveChallenge;
|
private long keepAliveChallenge;
|
||||||
@ -75,7 +74,7 @@
|
|||||||
private int dropSpamTickCount;
|
private int dropSpamTickCount;
|
||||||
private double firstGoodX;
|
private double firstGoodX;
|
||||||
private double firstGoodY;
|
private double firstGoodY;
|
||||||
@@ -202,7 +261,33 @@
|
@@ -202,7 +260,31 @@
|
||||||
entityplayer.connection = this;
|
entityplayer.connection = this;
|
||||||
this.keepAliveTime = SystemUtils.getMillis();
|
this.keepAliveTime = SystemUtils.getMillis();
|
||||||
entityplayer.getTextFilter().join();
|
entityplayer.getTextFilter().join();
|
||||||
@ -91,8 +90,6 @@
|
|||||||
+ private int lastDropTick = MinecraftServer.currentTick;
|
+ private int lastDropTick = MinecraftServer.currentTick;
|
||||||
+ private int lastBookTick = MinecraftServer.currentTick;
|
+ private int lastBookTick = MinecraftServer.currentTick;
|
||||||
+ private int dropCount = 0;
|
+ private int dropCount = 0;
|
||||||
+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6;
|
|
||||||
+ private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7;
|
|
||||||
+
|
+
|
||||||
+ // Get position of last block hit for BlockDamageLevel.STOPPED
|
+ // Get position of last block hit for BlockDamageLevel.STOPPED
|
||||||
+ private double lastPosX = Double.MAX_VALUE;
|
+ private double lastPosX = Double.MAX_VALUE;
|
||||||
@ -109,7 +106,7 @@
|
|||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.resetPosition();
|
this.resetPosition();
|
||||||
@@ -251,7 +336,7 @@
|
@@ -251,7 +333,7 @@
|
||||||
this.server.getProfiler().push("keepAlive");
|
this.server.getProfiler().push("keepAlive");
|
||||||
long i = SystemUtils.getMillis();
|
long i = SystemUtils.getMillis();
|
||||||
|
|
||||||
@ -118,7 +115,7 @@
|
|||||||
if (this.keepAlivePending) {
|
if (this.keepAlivePending) {
|
||||||
this.disconnect(new ChatMessage("disconnect.timeout"));
|
this.disconnect(new ChatMessage("disconnect.timeout"));
|
||||||
} else {
|
} else {
|
||||||
@@ -263,15 +348,21 @@
|
@@ -263,15 +345,21 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.server.getProfiler().pop();
|
this.server.getProfiler().pop();
|
||||||
@ -140,7 +137,7 @@
|
|||||||
this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
|
this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,16 +386,46 @@
|
@@ -295,16 +383,46 @@
|
||||||
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +185,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
|
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
|
||||||
@@ -371,7 +492,34 @@
|
@@ -371,7 +489,34 @@
|
||||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||||
|
|
||||||
@ -224,7 +221,7 @@
|
|||||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8);
|
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8);
|
||||||
this.connection.send(new PacketPlayOutVehicleMove(entity));
|
this.connection.send(new PacketPlayOutVehicleMove(entity));
|
||||||
return;
|
return;
|
||||||
@@ -401,14 +549,72 @@
|
@@ -401,14 +546,72 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||||
@ -297,7 +294,7 @@
|
|||||||
this.player.getLevel().getChunkSource().move(this.player);
|
this.player.getLevel().getChunkSource().move(this.player);
|
||||||
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
|
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
|
||||||
this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity);
|
this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity);
|
||||||
@@ -427,7 +633,7 @@
|
@@ -427,7 +630,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) {
|
public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel());
|
||||||
@ -306,7 +303,7 @@
|
|||||||
this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||||
this.lastGoodX = this.awaitingPositionFromClient.x;
|
this.lastGoodX = this.awaitingPositionFromClient.x;
|
||||||
this.lastGoodY = this.awaitingPositionFromClient.y;
|
this.lastGoodY = this.awaitingPositionFromClient.y;
|
||||||
@@ -437,6 +643,7 @@
|
@@ -437,6 +640,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.awaitingPositionFromClient = null;
|
this.awaitingPositionFromClient = null;
|
||||||
@ -314,7 +311,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -444,7 +651,7 @@
|
@@ -444,7 +648,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
|
||||||
@ -323,7 +320,7 @@
|
|||||||
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
||||||
|
|
||||||
Objects.requireNonNull(recipebookserver);
|
Objects.requireNonNull(recipebookserver);
|
||||||
@@ -474,6 +681,12 @@
|
@@ -474,6 +678,12 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
|
||||||
@ -336,7 +333,7 @@
|
|||||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||||
|
|
||||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||||
@@ -483,6 +696,7 @@
|
@@ -483,6 +693,7 @@
|
||||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||||
|
|
||||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||||
@ -344,7 +341,7 @@
|
|||||||
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
|
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -715,6 +929,13 @@
|
@@ -715,6 +926,13 @@
|
||||||
|
|
||||||
if (container instanceof ContainerMerchant) {
|
if (container instanceof ContainerMerchant) {
|
||||||
ContainerMerchant containermerchant = (ContainerMerchant) container;
|
ContainerMerchant containermerchant = (ContainerMerchant) container;
|
||||||
@ -358,7 +355,7 @@
|
|||||||
|
|
||||||
containermerchant.setSelectionHint(i);
|
containermerchant.setSelectionHint(i);
|
||||||
containermerchant.tryMoveItems(i);
|
containermerchant.tryMoveItems(i);
|
||||||
@@ -724,6 +945,13 @@
|
@@ -724,6 +942,13 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||||
@ -372,7 +369,7 @@
|
|||||||
int i = packetplayinbedit.getSlot();
|
int i = packetplayinbedit.getSlot();
|
||||||
|
|
||||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||||
@@ -732,7 +960,7 @@
|
@@ -732,7 +957,7 @@
|
||||||
|
|
||||||
Objects.requireNonNull(list);
|
Objects.requireNonNull(list);
|
||||||
optional.ifPresent(list::add);
|
optional.ifPresent(list::add);
|
||||||
@ -381,7 +378,7 @@
|
|||||||
|
|
||||||
Objects.requireNonNull(list);
|
Objects.requireNonNull(list);
|
||||||
stream.forEach(list::add);
|
stream.forEach(list::add);
|
||||||
@@ -748,7 +976,7 @@
|
@@ -748,7 +973,7 @@
|
||||||
ItemStack itemstack = this.player.getInventory().getItem(i);
|
ItemStack itemstack = this.player.getInventory().getItem(i);
|
||||||
|
|
||||||
if (itemstack.is(Items.WRITABLE_BOOK)) {
|
if (itemstack.is(Items.WRITABLE_BOOK)) {
|
||||||
@ -390,7 +387,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,16 +1001,16 @@
|
@@ -773,16 +998,16 @@
|
||||||
|
|
||||||
this.updateBookPages(list, (s) -> {
|
this.updateBookPages(list, (s) -> {
|
||||||
return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s));
|
return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s));
|
||||||
@ -411,7 +408,7 @@
|
|||||||
return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered()));
|
return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered()));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -810,6 +1038,7 @@
|
@@ -810,6 +1035,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.addTagElement("pages", nbttaglist);
|
itemstack.addTagElement("pages", nbttaglist);
|
||||||
@ -419,7 +416,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -846,7 +1075,7 @@
|
@@ -846,7 +1072,7 @@
|
||||||
} else {
|
} else {
|
||||||
WorldServer worldserver = this.player.getLevel();
|
WorldServer worldserver = this.player.getLevel();
|
||||||
|
|
||||||
@ -428,7 +425,7 @@
|
|||||||
if (this.tickCount == 0) {
|
if (this.tickCount == 0) {
|
||||||
this.resetPosition();
|
this.resetPosition();
|
||||||
}
|
}
|
||||||
@@ -856,7 +1085,7 @@
|
@@ -856,7 +1082,7 @@
|
||||||
this.awaitingTeleportTime = this.tickCount;
|
this.awaitingTeleportTime = this.tickCount;
|
||||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||||
}
|
}
|
||||||
@ -437,7 +434,7 @@
|
|||||||
} else {
|
} else {
|
||||||
this.awaitingTeleportTime = this.tickCount;
|
this.awaitingTeleportTime = this.tickCount;
|
||||||
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
|
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
|
||||||
@@ -868,7 +1097,15 @@
|
@@ -868,7 +1094,15 @@
|
||||||
if (this.player.isPassenger()) {
|
if (this.player.isPassenger()) {
|
||||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||||
this.player.getLevel().getChunkSource().move(this.player);
|
this.player.getLevel().getChunkSource().move(this.player);
|
||||||
@ -453,7 +450,7 @@
|
|||||||
double d3 = this.player.getX();
|
double d3 = this.player.getX();
|
||||||
double d4 = this.player.getY();
|
double d4 = this.player.getY();
|
||||||
double d5 = this.player.getZ();
|
double d5 = this.player.getZ();
|
||||||
@@ -888,15 +1125,33 @@
|
@@ -888,15 +1122,33 @@
|
||||||
++this.receivedMovePacketCount;
|
++this.receivedMovePacketCount;
|
||||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||||
|
|
||||||
@ -489,7 +486,7 @@
|
|||||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9);
|
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9);
|
||||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||||
return;
|
return;
|
||||||
@@ -915,6 +1170,7 @@
|
@@ -915,6 +1167,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
|
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
|
||||||
@ -497,7 +494,7 @@
|
|||||||
double d12 = d8;
|
double d12 = d8;
|
||||||
|
|
||||||
d7 = d0 - this.player.getX();
|
d7 = d0 - this.player.getX();
|
||||||
@@ -936,7 +1192,71 @@
|
@@ -936,7 +1189,71 @@
|
||||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
|
if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
|
||||||
this.teleport(d3, d4, d5, f, f1);
|
this.teleport(d3, d4, d5, f, f1);
|
||||||
} else {
|
} else {
|
||||||
@ -570,7 +567,7 @@
|
|||||||
this.player.getLevel().getChunkSource().move(this.player);
|
this.player.getLevel().getChunkSource().move(this.player);
|
||||||
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
|
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
|
||||||
this.player.setOnGround(packetplayinflying.isOnGround());
|
this.player.setOnGround(packetplayinflying.isOnGround());
|
||||||
@@ -974,19 +1294,80 @@
|
@@ -974,19 +1291,80 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +652,7 @@
|
|||||||
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
|
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
|
||||||
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
|
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
|
||||||
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
|
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
|
||||||
@@ -998,6 +1379,14 @@
|
@@ -998,6 +1376,14 @@
|
||||||
this.awaitingTeleport = 0;
|
this.awaitingTeleport = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +667,7 @@
|
|||||||
this.awaitingTeleportTime = this.tickCount;
|
this.awaitingTeleportTime = this.tickCount;
|
||||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||||
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
||||||
@@ -1006,6 +1395,7 @@
|
@@ -1006,6 +1392,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
|
||||||
@ -678,7 +675,7 @@
|
|||||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||||
|
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
@@ -1016,14 +1406,46 @@
|
@@ -1016,14 +1403,46 @@
|
||||||
if (!this.player.isSpectator()) {
|
if (!this.player.isSpectator()) {
|
||||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||||
|
|
||||||
@ -727,7 +724,7 @@
|
|||||||
this.player.drop(false);
|
this.player.drop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,6 +1482,7 @@
|
@@ -1060,6 +1479,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
|
||||||
@ -735,22 +732,25 @@
|
|||||||
WorldServer worldserver = this.player.getLevel();
|
WorldServer worldserver = this.player.getLevel();
|
||||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||||
ItemStack itemstack = this.player.getItemInHand(enumhand);
|
ItemStack itemstack = this.player.getItemInHand(enumhand);
|
||||||
@@ -1072,6 +1495,14 @@
|
@@ -1069,9 +1489,16 @@
|
||||||
|
|
||||||
|
this.player.resetLastActionTime();
|
||||||
|
int i = this.player.level.getMaxBuildHeight();
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ double distanceSqr = this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
|
||||||
|
+ if (distanceSqr > 100.0D) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
if (blockposition.getY() < i) {
|
if (blockposition.getY() < i) {
|
||||||
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
- if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
||||||
+ // CraftBukkit start - Check if we can actually do something over this large a distance
|
+ if (this.awaitingPositionFromClient == null && distanceSqr < 64.0D && worldserver.mayInteract(this.player, blockposition)) { // CraftBukkit - reuse value
|
||||||
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||||
+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
|
|
||||||
+ if (reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ this.player.stopUsingItem(); // SPIGOT-4706
|
|
||||||
+ // CraftBukkit end
|
|
||||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||||
|
|
||||||
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
|
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
|
||||||
@@ -1095,12 +1526,51 @@
|
@@ -1095,12 +1522,51 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
|
||||||
@ -802,7 +802,7 @@
|
|||||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||||
|
|
||||||
if (enuminteractionresult.shouldSwing()) {
|
if (enuminteractionresult.shouldSwing()) {
|
||||||
@@ -1121,7 +1591,7 @@
|
@@ -1121,7 +1587,7 @@
|
||||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
@ -811,7 +811,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1136,6 +1606,7 @@
|
@@ -1136,6 +1602,7 @@
|
||||||
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
||||||
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
|
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
|
||||||
}
|
}
|
||||||
@ -819,7 +819,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1155,11 +1626,26 @@
|
@@ -1155,11 +1622,26 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
|
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
|
||||||
@ -847,7 +847,7 @@
|
|||||||
this.player.getTextFilter().leave();
|
this.player.getTextFilter().leave();
|
||||||
if (this.isSingleplayerOwner()) {
|
if (this.isSingleplayerOwner()) {
|
||||||
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||||
@@ -1174,6 +1660,15 @@
|
@@ -1174,6 +1656,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
||||||
@ -863,7 +863,7 @@
|
|||||||
try {
|
try {
|
||||||
this.connection.send(packet, genericfuturelistener);
|
this.connection.send(packet, genericfuturelistener);
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
@@ -1190,7 +1685,16 @@
|
@@ -1190,7 +1681,16 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
|
||||||
@ -880,7 +880,7 @@
|
|||||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||||
this.player.stopUsingItem();
|
this.player.stopUsingItem();
|
||||||
}
|
}
|
||||||
@@ -1199,11 +1703,18 @@
|
@@ -1199,11 +1699,18 @@
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
} else {
|
} else {
|
||||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||||
@ -899,7 +899,7 @@
|
|||||||
String s = StringUtils.normalizeSpace(packetplayinchat.getMessage());
|
String s = StringUtils.normalizeSpace(packetplayinchat.getMessage());
|
||||||
|
|
||||||
for (int i = 0; i < s.length(); ++i) {
|
for (int i = 0; i < s.length(); ++i) {
|
||||||
@@ -1217,20 +1728,42 @@
|
@@ -1217,20 +1724,42 @@
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel());
|
||||||
this.handleChat(ITextFilter.a.passThrough(s));
|
this.handleChat(ITextFilter.a.passThrough(s));
|
||||||
} else {
|
} else {
|
||||||
@ -946,7 +946,7 @@
|
|||||||
} else {
|
} else {
|
||||||
String s1 = itextfilter_a.getFiltered();
|
String s1 = itextfilter_a.getFiltered();
|
||||||
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1});
|
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1});
|
||||||
@@ -1241,28 +1774,198 @@
|
@@ -1241,28 +1770,198 @@
|
||||||
}, ChatMessageType.CHAT, this.player.getUUID());
|
}, ChatMessageType.CHAT, this.player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,7 +1149,7 @@
|
|||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
IJumpable ijumpable;
|
IJumpable ijumpable;
|
||||||
|
|
||||||
@@ -1320,6 +2023,7 @@
|
@@ -1320,6 +2019,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
|
||||||
@ -1157,7 +1157,7 @@
|
|||||||
WorldServer worldserver = this.player.getLevel();
|
WorldServer worldserver = this.player.getLevel();
|
||||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||||
|
|
||||||
@@ -1334,10 +2038,44 @@
|
@@ -1334,10 +2034,44 @@
|
||||||
|
|
||||||
if (this.player.distanceToSqr(entity) < 36.0D) {
|
if (this.player.distanceToSqr(entity) < 36.0D) {
|
||||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||||
@ -1203,7 +1203,7 @@
|
|||||||
if (enuminteractionresult.consumesAction()) {
|
if (enuminteractionresult.consumesAction()) {
|
||||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
|
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
|
||||||
if (enuminteractionresult.shouldSwing()) {
|
if (enuminteractionresult.shouldSwing()) {
|
||||||
@@ -1349,20 +2087,27 @@
|
@@ -1349,20 +2083,27 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteraction(EnumHand enumhand) {
|
public void onInteraction(EnumHand enumhand) {
|
||||||
@ -1234,7 +1234,7 @@
|
|||||||
} else {
|
} else {
|
||||||
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
|
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
|
||||||
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
|
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
|
||||||
@@ -1407,21 +2152,304 @@
|
@@ -1407,21 +2148,304 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
|
||||||
@ -1542,7 +1542,7 @@
|
|||||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||||
|
|
||||||
while (objectiterator.hasNext()) {
|
while (objectiterator.hasNext()) {
|
||||||
@@ -1456,6 +2484,7 @@
|
@@ -1456,6 +2480,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
|
||||||
@ -1550,7 +1550,7 @@
|
|||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
||||||
this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
|
this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
|
||||||
@@ -1483,6 +2512,43 @@
|
@@ -1483,6 +2508,43 @@
|
||||||
|
|
||||||
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
||||||
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
||||||
@ -1594,7 +1594,7 @@
|
|||||||
|
|
||||||
if (flag1 && flag2) {
|
if (flag1 && flag2) {
|
||||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
|
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
|
||||||
@@ -1505,6 +2571,7 @@
|
@@ -1505,6 +2567,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
|
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
|
||||||
@ -1602,7 +1602,7 @@
|
|||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
WorldServer worldserver = this.player.getLevel();
|
WorldServer worldserver = this.player.getLevel();
|
||||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||||
@@ -1521,18 +2588,37 @@
|
@@ -1521,18 +2584,37 @@
|
||||||
|
|
||||||
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
|
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
|
||||||
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
|
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
|
||||||
@ -1642,7 +1642,7 @@
|
|||||||
|
|
||||||
tileentitysign.setChanged();
|
tileentitysign.setChanged();
|
||||||
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
|
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
|
||||||
@@ -1542,6 +2628,7 @@
|
@@ -1542,6 +2624,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
||||||
@ -1650,7 +1650,7 @@
|
|||||||
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
||||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||||
|
|
||||||
@@ -1556,7 +2643,17 @@
|
@@ -1556,7 +2639,17 @@
|
||||||
@Override
|
@Override
|
||||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
|
||||||
@ -1669,7 +1669,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1565,8 +2662,50 @@
|
@@ -1565,8 +2658,50 @@
|
||||||
this.player.updateOptions(packetplayinsettings);
|
this.player.updateOptions(packetplayinsettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren