-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1436 from Ayouuuu/combat-eat
Add BadPacketsV
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsV.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ac.grim.grimac.checks.impl.badpackets; | ||
|
||
import ac.grim.grimac.checks.Check; | ||
import ac.grim.grimac.checks.CheckData; | ||
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.protocol.item.ItemStack; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; | ||
|
||
@CheckData(name = "BadPacketsV", experimental = true) | ||
public class BadPacketsV extends Check implements PacketCheck { | ||
public BadPacketsV(GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY) { | ||
WrapperPlayClientInteractEntity interactEntity = new WrapperPlayClientInteractEntity(event); | ||
if (interactEntity.getAction() != WrapperPlayClientInteractEntity.InteractAction.ATTACK) return; | ||
if (!player.packetStateData.slowedByUsingItem) return; | ||
ItemStack itemInUse = player.getInventory().getItemInHand(player.packetStateData.eatingHand); | ||
if (flagAndAlert("UseItem=" + itemInUse.getType().getName().getKey()) && shouldModifyPackets()) { | ||
event.setCancelled(true); | ||
player.onPacketCancel(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters