@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -196,6 +196,71 @@
|
||||
@@ -198,6 +198,71 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -245,7 +310,7 @@
|
||||
@@ -247,7 +312,7 @@
|
||||
private boolean waitingForSwitchToConfig;
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
@@ -81,7 +81,7 @@
|
||||
this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection());
|
||||
this.player = entityplayer;
|
||||
entityplayer.connection = this;
|
||||
@@ -254,9 +319,25 @@
|
||||
@@ -256,9 +321,25 @@
|
||||
|
||||
Objects.requireNonNull(minecraftserver);
|
||||
this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile);
|
||||
@@ -108,7 +108,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -311,6 +392,7 @@
|
||||
@@ -313,6 +394,7 @@
|
||||
this.chatSpamThrottler.tick();
|
||||
this.dropSpamThrottler.tick();
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
@@ -116,7 +116,7 @@
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -374,6 +456,12 @@
|
||||
@@ -376,6 +458,12 @@
|
||||
@Override
|
||||
public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel());
|
||||
@@ -129,7 +129,7 @@
|
||||
this.player.setLastClientInput(packetplayinsteervehicle.input());
|
||||
}
|
||||
|
||||
@@ -399,6 +487,13 @@
|
||||
@@ -401,6 +489,13 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -143,7 +143,7 @@
|
||||
double d0 = entity.getX();
|
||||
double d1 = entity.getY();
|
||||
double d2 = entity.getZ();
|
||||
@@ -413,7 +508,33 @@
|
||||
@@ -415,7 +510,33 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -176,9 +176,9 @@
|
||||
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
||||
+ // CraftBukkit end
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
this.send(PacketPlayOutVehicleMove.fromEntity(entity));
|
||||
return;
|
||||
@@ -453,14 +574,76 @@
|
||||
@@ -455,14 +576,67 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@@ -188,7 +188,7 @@
|
||||
if (flag && (flag2 || !flag3)) {
|
||||
entity.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
this.send(PacketPlayOutVehicleMove.fromEntity(entity));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,16 +203,7 @@
|
||||
+ this.hasMoved = true;
|
||||
+ }
|
||||
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
|
||||
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
|
||||
+
|
||||
+ // If the packet contains movement information then we update the To location with the correct XYZ.
|
||||
+ to.setX(packetplayinvehiclemove.getX());
|
||||
+ to.setY(packetplayinvehiclemove.getY());
|
||||
+ to.setZ(packetplayinvehiclemove.getZ());
|
||||
+
|
||||
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
||||
+ to.setYaw(packetplayinvehiclemove.getYRot());
|
||||
+ to.setPitch(packetplayinvehiclemove.getXRot());
|
||||
+ Location to = CraftLocation.toBukkit(packetplayinvehiclemove.position(), player.getWorld(), packetplayinvehiclemove.yRot(), packetplayinvehiclemove.xRot());
|
||||
+
|
||||
+ // Prevent 40 event-calls for less than a single pixel of movement >.>
|
||||
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
|
||||
@@ -255,15 +246,15 @@
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position());
|
||||
Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
@@ -498,6 +681,7 @@
|
||||
}
|
||||
|
||||
@@ -499,6 +673,7 @@
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
this.player.hasChangedDimension();
|
||||
this.awaitingPositionFromClient = null;
|
||||
+ this.player.serverLevel().getChunkSource().move(this.player); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -521,6 +705,7 @@
|
||||
@@ -528,6 +703,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel());
|
||||
@@ -271,7 +262,7 @@
|
||||
this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering());
|
||||
}
|
||||
|
||||
@@ -541,6 +726,12 @@
|
||||
@@ -548,6 +724,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
||||
@@ -284,7 +275,7 @@
|
||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -550,6 +741,7 @@
|
||||
@@ -557,6 +739,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
@@ -292,7 +283,7 @@
|
||||
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
|
||||
|
||||
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1));
|
||||
@@ -796,6 +988,13 @@
|
||||
@@ -866,6 +1049,13 @@
|
||||
Container container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof ContainerMerchant containermerchant) {
|
||||
@@ -306,7 +297,7 @@
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -809,6 +1008,13 @@
|
||||
@@ -879,6 +1069,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||
@@ -320,7 +311,7 @@
|
||||
int i = packetplayinbedit.slot();
|
||||
|
||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -829,12 +1035,16 @@
|
||||
@@ -899,12 +1096,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> list, int i) {
|
||||
@@ -338,7 +329,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,12 +1055,13 @@
|
||||
@@ -915,12 +1116,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
@@ -354,7 +345,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,7 +1123,7 @@
|
||||
@@ -982,7 +1184,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
|
||||
@@ -363,7 +354,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -927,7 +1138,15 @@
|
||||
@@ -997,7 +1199,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -379,7 +370,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -949,15 +1168,33 @@
|
||||
@@ -1019,15 +1229,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@@ -415,7 +406,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -979,6 +1216,7 @@
|
||||
@@ -1049,6 +1277,7 @@
|
||||
boolean flag2 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
||||
@@ -423,7 +414,7 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -997,9 +1235,75 @@
|
||||
@@ -1067,9 +1296,75 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
@@ -500,7 +491,7 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1049,6 +1353,7 @@
|
||||
@@ -1119,6 +1414,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
@@ -508,7 +499,7 @@
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1077,10 +1382,62 @@
|
||||
@@ -1147,10 +1443,62 @@
|
||||
}
|
||||
|
||||
public void teleport(double d0, double d1, double d2, float f, float f1) {
|
||||
@@ -572,7 +563,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
if (++this.awaitingTeleport == Integer.MAX_VALUE) {
|
||||
this.awaitingTeleport = 0;
|
||||
@@ -1088,12 +1445,20 @@
|
||||
@@ -1158,12 +1506,20 @@
|
||||
|
||||
this.player.teleportSetPosition(positionmoverotation, set);
|
||||
this.awaitingPositionFromClient = this.player.position();
|
||||
@@ -590,131 +581,131 @@
|
||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
if (this.player.hasClientLoaded()) {
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
@@ -1104,14 +1469,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
@@ -1175,14 +1531,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
|
||||
- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.cserver.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)"));
|
||||
- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.cserver.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.drop(false);
|
||||
}
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
|
||||
@@ -1149,6 +1546,7 @@
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)"));
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1221,6 +1609,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||
@@ -1171,6 +1569,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -1244,6 +1633,7 @@
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1207,6 +1606,7 @@
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1281,6 +1671,7 @@
|
||||
@Override
|
||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinblockplace.getHand();
|
||||
@@ -1221,6 +1621,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1687,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
+ double d1 = this.player.getY() + (double) this.player.getEyeHeight();
|
||||
+ double d2 = this.player.getZ();
|
||||
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
+ double d1 = this.player.getY() + (double) this.player.getEyeHeight();
|
||||
+ double d2 = this.player.getZ();
|
||||
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
|
||||
+
|
||||
+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
+ float f7 = f4 * f5;
|
||||
+ float f8 = f3 * f5;
|
||||
+ double d3 = player.blockInteractionRange();
|
||||
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player));
|
||||
+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
+ float f7 = f4 * f5;
|
||||
+ float f8 = f3 * f5;
|
||||
+ double d3 = player.blockInteractionRange();
|
||||
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player));
|
||||
+
|
||||
+ boolean cancelled;
|
||||
+ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ } else {
|
||||
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
|
||||
+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) {
|
||||
+ cancelled = player.gameMode.interactResult;
|
||||
+ } else {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation());
|
||||
+ boolean cancelled;
|
||||
+ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ } else {
|
||||
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
|
||||
+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) {
|
||||
+ cancelled = player.gameMode.interactResult;
|
||||
+ } else {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation());
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ }
|
||||
+ player.gameMode.firedInteract = false;
|
||||
+ }
|
||||
+ player.gameMode.firedInteract = false;
|
||||
+ }
|
||||
+
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event
|
||||
+ if (itemstack.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event
|
||||
+ if (itemstack.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
@@ -1245,7 +1686,7 @@
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
@@ -1321,7 +1753,7 @@
|
||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -723,7 +714,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1266,6 +1707,13 @@
|
||||
@@ -1342,6 +1774,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails disconnectiondetails) {
|
||||
@@ -737,7 +728,7 @@
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(disconnectiondetails);
|
||||
@@ -1273,10 +1721,18 @@
|
||||
@@ -1349,10 +1788,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@@ -757,7 +748,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1291,7 +1747,16 @@
|
||||
@@ -1367,7 +1814,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
||||
@@ -774,7 +765,7 @@
|
||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1300,11 +1765,18 @@
|
||||
@@ -1376,11 +1832,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@@ -793,7 +784,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1318,7 +1790,7 @@
|
||||
@@ -1394,7 +1857,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -802,7 +793,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
|
||||
|
||||
this.chatMessageChain.append(completablefuture, (filteredtext) -> {
|
||||
@@ -1326,19 +1798,36 @@
|
||||
@@ -1402,19 +1865,36 @@
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
});
|
||||
@@ -841,7 +832,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1355,19 +1844,37 @@
|
||||
@@ -1431,19 +1911,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> {
|
||||
@@ -882,7 +873,7 @@
|
||||
} catch (SignedMessageChain.a signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1375,10 +1882,10 @@
|
||||
@@ -1451,10 +1949,10 @@
|
||||
|
||||
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
||||
|
||||
@@ -895,7 +886,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
||||
@@ -1454,14 +1961,20 @@
|
||||
@@ -1530,14 +2028,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@@ -919,7 +910,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,6 +2003,116 @@
|
||||
@@ -1566,6 +2070,116 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1027,7 @@
|
||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||
|
||||
@@ -1497,13 +2120,33 @@
|
||||
@@ -1573,13 +2187,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||
@@ -1073,7 +1064,7 @@
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1525,13 +2168,62 @@
|
||||
@@ -1601,7 +2235,33 @@
|
||||
@Override
|
||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||
@@ -1107,36 +1098,37 @@
|
||||
this.player.swing(packetplayinarmanimation.getHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1609,6 +2269,29 @@
|
||||
public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel());
|
||||
+ // CraftBukkit start
|
||||
+ if (this.player.isRemoved()) return;
|
||||
+ switch (packetplayinentityaction.getAction()) {
|
||||
+ case PRESS_SHIFT_KEY:
|
||||
+ case RELEASE_SHIFT_KEY:
|
||||
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY);
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
if (this.player.hasClientLoaded()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.player.isRemoved()) return;
|
||||
+ switch (packetplayinentityaction.getAction()) {
|
||||
+ case PRESS_SHIFT_KEY:
|
||||
+ case RELEASE_SHIFT_KEY:
|
||||
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY);
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ case START_SPRINTING:
|
||||
+ case STOP_SPRINTING:
|
||||
+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
|
||||
+ this.cserver.getPluginManager().callEvent(e2);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ case START_SPRINTING:
|
||||
+ case STOP_SPRINTING:
|
||||
+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
|
||||
+ this.cserver.getPluginManager().callEvent(e2);
|
||||
+
|
||||
+ if (e2.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
|
||||
@@ -1608,6 +2300,12 @@
|
||||
+ if (e2.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
IJumpable ijumpable;
|
||||
@@ -1691,6 +2374,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||
@@ -1149,104 +1141,104 @@
|
||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a));
|
||||
this.addPendingMessage(playerchatmessage);
|
||||
}
|
||||
@@ -1635,6 +2333,7 @@
|
||||
@@ -1718,6 +2407,7 @@
|
||||
@Override
|
||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
if (this.player.hasClientLoaded()) {
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
@@ -1733,13 +2423,51 @@
|
||||
|
||||
@@ -1649,13 +2348,51 @@
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
|
||||
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
|
||||
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
|
||||
+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem();
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
|
||||
+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem();
|
||||
+
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(player);
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+
|
||||
+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ // Refresh the current leash state
|
||||
+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) {
|
||||
+ // Refresh the current entity metadata
|
||||
+ entity.refreshEntityData(player);
|
||||
+ // SPIGOT-7136 - Allays
|
||||
+ if (entity instanceof Allay) {
|
||||
+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList())));
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(player);
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ // Refresh the current leash state
|
||||
+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
|
||||
+ }
|
||||
+
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
|
||||
@@ -1671,19 +2408,20 @@
|
||||
+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) {
|
||||
+ // Refresh the current entity metadata
|
||||
+ entity.refreshEntityData(player);
|
||||
+ // SPIGOT-7136 - Allays
|
||||
+ if (entity instanceof Allay) {
|
||||
+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList())));
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand);
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
- this.performInteraction(enumhand, EntityHuman::interactOn);
|
||||
+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand, Vec3D vec3d) {
|
||||
this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> {
|
||||
return entity1.interactAt(entityplayer, vec3d, enumhand1);
|
||||
- });
|
||||
+ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack() {
|
||||
- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) {
|
||||
+ // CraftBukkit
|
||||
+ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) {
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1701,6 +2439,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) {
|
||||
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return;
|
||||
}
|
||||
+
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
|
||||
@@ -1755,19 +2483,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
- this.performInteraction(enumhand, EntityHuman::interactOn);
|
||||
+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
@@ -1724,7 +2467,7 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand, Vec3D vec3d) {
|
||||
this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> {
|
||||
return entity1.interactAt(entityplayer, vec3d, enumhand1);
|
||||
- });
|
||||
+ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack() {
|
||||
- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) {
|
||||
+ // CraftBukkit
|
||||
+ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) {
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1785,6 +2514,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1809,7 +2543,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@@ -1255,7 +1247,7 @@
|
||||
this.resetPosition();
|
||||
CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD);
|
||||
} else {
|
||||
@@ -1732,11 +2475,11 @@
|
||||
@@ -1817,11 +2551,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1269,7 +1261,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1749,15 +2492,21 @@
|
||||
@@ -1834,15 +2568,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||
@@ -1293,7 +1285,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1770,7 +2519,284 @@
|
||||
@@ -1855,7 +2595,284 @@
|
||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1579,7 +1571,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1816,7 +2842,21 @@
|
||||
@@ -1901,7 +2918,21 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1602,7 +1594,7 @@
|
||||
|
||||
if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
@@ -1832,6 +2872,7 @@
|
||||
@@ -1917,6 +2948,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||
@@ -1610,7 +1602,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1875,6 +2916,43 @@
|
||||
@@ -1945,6 +2977,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -1654,7 +1646,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1902,6 +2980,7 @@
|
||||
@@ -1972,6 +3041,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||
@@ -1662,7 +1654,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||
@@ -1923,7 +3002,17 @@
|
||||
@@ -1993,7 +3063,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||
@@ -1681,7 +1673,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1982,7 +3071,7 @@
|
||||
@@ -2058,7 +3138,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -1690,7 +1682,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2007,8 +3096,10 @@
|
||||
@@ -2083,8 +3163,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user