mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Move range check for block placing up
This commit is contained in:
parent
fc6a027549
commit
5392798da4
@ -1050,7 +1050,19 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1243,7 +1827,8 @@
|
||||
@@ -1230,6 +1814,11 @@
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
BlockHitResult movingobjectpositionblock = packet.getHitResult();
|
||||
Vec3 vec3d = movingobjectpositionblock.getLocation();
|
||||
+ // Paper start - improve distance check
|
||||
+ if (!Double.isFinite(vec3d.x) || !Double.isFinite(vec3d.y) || !Double.isFinite(vec3d.z)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - improve distance check
|
||||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||
|
||||
if (this.player.canInteractWithBlock(blockposition, 1.0D)) {
|
||||
@@ -1243,7 +1832,8 @@
|
||||
int i = this.player.level().getMaxY();
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
@ -1060,7 +1072,7 @@
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1257,7 +1842,7 @@
|
||||
@@ -1257,7 +1847,7 @@
|
||||
} else if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
|
||||
|
||||
@ -1069,7 +1081,7 @@
|
||||
this.player.swing(enumhand, true);
|
||||
}
|
||||
}
|
||||
@@ -1281,6 +1866,8 @@
|
||||
@@ -1281,6 +1871,8 @@
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -1078,10 +1090,12 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1883,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
@@ -1294,8 +1886,49 @@
|
||||
|
||||
if (f1 != this.player.getXRot() || f != this.player.getYRot()) {
|
||||
this.player.absRotateTo(f, f1);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
@ -1112,8 +1126,8 @@
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ }
|
||||
+ this.player.gameMode.firedInteract = false;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
@ -1126,7 +1140,7 @@
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +1949,7 @@
|
||||
@@ -1321,7 +1954,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@ -1135,7 +1149,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,6 +1970,13 @@
|
||||
@@ -1342,6 +1975,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
@ -1149,7 +1163,7 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), info.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(info);
|
||||
@@ -1349,10 +1984,20 @@
|
||||
@@ -1349,10 +1989,20 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@ -1172,7 +1186,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1367,7 +2012,17 @@
|
||||
@@ -1367,7 +2017,17 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -1190,7 +1204,7 @@
|
||||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +2031,18 @@
|
||||
@@ -1376,11 +2036,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@ -1209,7 +1223,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,27 +2056,44 @@
|
||||
@@ -1394,27 +2061,44 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1261,7 +1275,7 @@
|
||||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,19 +2110,37 @@
|
||||
@@ -1431,19 +2115,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
@ -1303,7 +1317,7 @@
|
||||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1451,10 +2148,10 @@
|
||||
@@ -1451,10 +2153,10 @@
|
||||
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
@ -1316,7 +1330,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2227,20 @@
|
||||
@@ -1530,14 +2232,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@ -1341,7 +1355,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1566,6 +2269,127 @@
|
||||
@@ -1566,6 +2274,127 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1469,7 +1483,7 @@
|
||||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,13 +2397,42 @@
|
||||
@@ -1573,13 +2402,42 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
@ -1517,7 +1531,7 @@
|
||||
this.disconnect((Component) Component.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1601,7 +2454,40 @@
|
||||
@@ -1601,7 +2459,40 @@
|
||||
@Override
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -1558,7 +1572,7 @@
|
||||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2495,29 @@
|
||||
@@ -1609,6 +2500,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
@ -1588,7 +1602,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1616,6 +2525,11 @@
|
||||
@@ -1616,6 +2530,11 @@
|
||||
switch (packet.getAction()) {
|
||||
case PRESS_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(true);
|
||||
@ -1600,7 +1614,7 @@
|
||||
break;
|
||||
case RELEASE_SHIFT_KEY:
|
||||
this.player.setShiftKeyDown(false);
|
||||
@@ -1691,6 +2605,12 @@
|
||||
@@ -1691,6 +2610,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) {
|
||||
@ -1613,7 +1627,7 @@
|
||||
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
|
||||
this.addPendingMessage(message);
|
||||
}
|
||||
@@ -1703,6 +2623,13 @@
|
||||
@@ -1703,6 +2628,13 @@
|
||||
return this.connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
@ -1627,7 +1641,7 @@
|
||||
public void switchToConfig() {
|
||||
this.waitingForSwitchToConfig = true;
|
||||
this.removePlayerFromWorld();
|
||||
@@ -1718,9 +2645,17 @@
|
||||
@@ -1718,9 +2650,17 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -1645,7 +1659,7 @@
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
|
||||
@@ -1733,20 +2668,58 @@
|
||||
@@ -1733,20 +2673,58 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
@ -1661,9 +1675,9 @@
|
||||
+ ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof Mob;
|
||||
+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem();
|
||||
|
||||
+ ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(ServerGamePacketListenerImpl.this.player);
|
||||
@ -1708,7 +1722,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2728,20 @@
|
||||
@@ -1755,19 +2733,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
@ -1732,7 +1746,7 @@
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,6 +2759,11 @@
|
||||
@@ -1785,6 +2764,11 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
@ -1744,7 +1758,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1795,7 +2774,26 @@
|
||||
@@ -1795,7 +2779,26 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1771,7 +1785,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +2807,7 @@
|
||||
@@ -1809,7 +2812,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@ -1780,7 +1794,7 @@
|
||||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2815,11 @@
|
||||
@@ -1817,11 +2820,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1795,7 +1809,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1833,16 +2831,27 @@
|
||||
@@ -1833,16 +2836,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
@ -1825,7 +1839,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1855,7 +2864,284 @@
|
||||
@@ -1855,7 +2869,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@ -2111,7 +2125,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1879,6 +3165,14 @@
|
||||
@@ -1879,6 +3170,14 @@
|
||||
|
||||
@Override
|
||||
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
||||
@ -2126,7 +2140,7 @@
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
this.player.resetLastActionTime();
|
||||
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) {
|
||||
@@ -1900,9 +3194,43 @@
|
||||
@@ -1900,9 +3199,43 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
|
||||
return;
|
||||
}
|
||||
@ -2171,7 +2185,7 @@
|
||||
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
}
|
||||
@@ -1917,6 +3245,7 @@
|
||||
@@ -1917,6 +3250,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -2179,7 +2193,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,6 +3274,43 @@
|
||||
@@ -1945,6 +3279,43 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@ -2223,7 +2237,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1964,7 +3330,19 @@
|
||||
@@ -1964,7 +3335,19 @@
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
|
||||
@ -2244,7 +2258,7 @@
|
||||
|
||||
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
|
||||
this.updateSignText(packet, list1);
|
||||
@@ -1972,6 +3350,7 @@
|
||||
@@ -1972,6 +3355,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
@ -2252,7 +2266,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,15 +3372,33 @@
|
||||
@@ -1993,15 +3377,33 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@ -2287,7 +2301,7 @@
|
||||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
|
||||
}
|
||||
@@ -2012,7 +3409,7 @@
|
||||
@@ -2012,7 +3414,7 @@
|
||||
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
|
||||
@ -2296,7 +2310,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2058,7 +3455,7 @@
|
||||
@@ -2058,7 +3460,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@ -2305,7 +2319,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2083,8 +3480,10 @@
|
||||
@@ -2083,8 +3485,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user