Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public enum DiggingAction {
DROP_ITEM_STACK,
DROP_ITEM,
RELEASE_USE_ITEM,
SWAP_ITEM_WITH_OFFHAND;
SWAP_ITEM_WITH_OFFHAND,
UNKNOWN;

private static final DiggingAction[] VALUES = values();

Expand All @@ -34,6 +35,9 @@ public int getId() {
}

public static DiggingAction getById(int id) {
if (id < 0 || id >= (VALUES.length - 1)) {
return UNKNOWN;
}
return VALUES[id];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
*/
public enum InteractionHand {
MAIN_HAND,
OFF_HAND;
OFF_HAND,
UNKNOWN;

private static final InteractionHand[] VALUES = values();

Expand All @@ -35,6 +36,9 @@ public int getId() {
}

public static InteractionHand getById(int id) {
if (id < 0 || id >= (VALUES.length - 1)) {
return UNKNOWN;
}
return VALUES[id];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ public void setTabId(String tabID) {
}

public enum Action {
OPENED_TAB, CLOSED_SCREEN;
OPENED_TAB, CLOSED_SCREEN, UNKNOWN;

private static final Action[] VALUES = values();

public static Action getById(int id) {
if (id < 0 || id >= (VALUES.length - 1)) {
return UNKNOWN;
}
return VALUES[id];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ public enum Action {
REQUEST_STATS,

// This only exists on 1.7.10 -> 1.15.2
OPEN_INVENTORY_ACHIEVEMENT;
OPEN_INVENTORY_ACHIEVEMENT,
UNKNOWN;

private static final Action[] VALUES = values();

public static Action getById(int index) {
if (index < 0 || index >= (VALUES.length - 1)) {
return UNKNOWN;
}
return VALUES[index];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.protocol.player.InteractAction;
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
import com.github.retrooper.packetevents.util.Vector3f;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
Expand Down Expand Up @@ -57,14 +59,14 @@ public void read() {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
this.entityID = readInt();
byte typeIndex = readByte();
this.interactAction = InteractAction.VALUES[typeIndex];
this.interactAction = InteractAction.getById(typeIndex);
this.target = Optional.empty();
this.interactionHand = InteractionHand.MAIN_HAND;
this.sneaking = Optional.empty();
} else {
this.entityID = readVarInt();
int typeIndex = readVarInt();
this.interactAction = InteractAction.VALUES[typeIndex];
this.interactAction = InteractAction.getById(typeIndex);
if (interactAction == InteractAction.INTERACT_AT) {
float x = readFloat();
float y = readFloat();
Expand Down Expand Up @@ -164,7 +166,15 @@ public void setSneaking(Optional<Boolean> sneaking) {
}

public enum InteractAction {
INTERACT, ATTACK, INTERACT_AT;
INTERACT, ATTACK, INTERACT_AT, UNKNOWN;

public static final InteractAction[] VALUES = values();

public static InteractAction getById(int id) {
if (id < 0 || id >= (VALUES.length - 1)) {
return UNKNOWN;
}
return VALUES[id];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
import com.github.retrooper.packetevents.netty.buffer.ByteBufInputStream;
import com.github.retrooper.packetevents.netty.buffer.ByteBufOperator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t get why these imports need to be in this class.
Why did you touch this class at all? Nothing’s really been added.
Also, your TODO comment should probably be an issue instead.

import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.protocol.world.BlockFace;
Expand Down