Skip to content

Commit

Permalink
Fixed block selection on 1.17
Browse files Browse the repository at this point in the history
- Upgraded ProtocolLib to latest snapshot
- Updated PlayerInteractionListener#onPacketReceiving()
  • Loading branch information
josemmo committed Jun 25, 2021
1 parent 7eea618 commit dcaf704
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.7.0-SNAPSHOT</version>
<version>4.7.0-20210624.212914-2</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,21 @@ public void onPlayerQuit(PlayerQuitEvent event) {

@Override
public void onPacketReceiving(PacketEvent event) {
EnumWrappers.EntityUseAction action = event.getPacket().getEntityUseActions().read(0);
Player player = event.getPlayer();

// Get task responsible for handling this event
UUID uuid = player.getUniqueId();
SelectBlockTask task = instances.get(uuid);
if (task == null) return;

// Get action
EnumWrappers.EntityUseAction action;
if (Internals.MINECRAFT_VERSION < 17) {
action = event.getPacket().getEntityUseActions().read(0);
} else {
action = event.getPacket().getEnumEntityUseActions().read(0).getAction();
}

// Player left clicked an entity
if (action == EnumWrappers.EntityUseAction.ATTACK) {
event.setCancelled(true);
Expand Down

0 comments on commit dcaf704

Please sign in to comment.