Skip to content

Commit

Permalink
Merge pull request #1863 from ManInMyVan/fix/multiactionsc-false
Browse files Browse the repository at this point in the history
fix MultiActionsC false with server opened inventories
  • Loading branch information
AoElite authored Dec 6, 2024
2 parents 97abaaf + d3fde80 commit d598ae0
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.event.PacketSendEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;

@CheckData(name = "MultiActionsC", experimental = true)
Expand All @@ -13,10 +14,12 @@ public MultiActionsC(GrimPlayer player) {
super(player);
}

private boolean serverOpenedInventoryThisTick;

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) {
String verbose = player.isSprinting && !player.isSwimming ? "sprinting" : "";
String verbose = player.isSprinting && !player.isSwimming && !serverOpenedInventoryThisTick ? "sprinting" : "";

if (player.packetStateData.isSlowedByUsingItem()) {
verbose += (verbose.isEmpty() ? "" : ", ") + "using";
Expand All @@ -27,5 +30,16 @@ public void onPacketReceive(PacketReceiveEvent event) {
player.onPacketCancel();
}
}

if (isTickPacket(event.getPacketType())) {
serverOpenedInventoryThisTick = false;
}
}

@Override
public void onPacketSend(PacketSendEvent event) {
if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW) {
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> serverOpenedInventoryThisTick = true);
}
}
}

0 comments on commit d598ae0

Please sign in to comment.