0x09 C09PacketHeldItemChange
Player changes their selected hotbar slot.
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| slotId | short | The hotbar slot being selected (0-8) |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Slot ID | short | Hotbar slot 0-8 |
MCP References
NetHandlerPlayServer.processHeldItemChange()Handler Interface
INetHandlerPlayServerVanilla Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
Deobfuscated MCP 1.8.9 source of C09PacketHeldItemChange, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/client/C09PacketHeldItemChange.java) at build time and verified present.
Deep Dive
Role in the protocol
C09 carries one int: the hotbar slot index the client is switching to. The server's processHeldItemChange validates 0 <= slot < 9 and sets the player's currentItem, which changes the server-side held item used for reach, damage, block breaking and what other players see. It is the cheapest stateful packet in the play state: no position, no timestamp, so clients can spam it freely, which is exactly why silent-switch modules rely on it.
Vanilla handling
NetHandlerPlayServer.processHeldItemChange: if the slot is within the hotbar, set inventory.currentItem and mark the player active; otherwise log a warning. The client-side vanilla path is EntityPlayerSP/PlayerControllerMP updating the slot when the user scrolls. Because the server trusts the packet entirely, any module that sends C09 with a different slot than the visible one desynchronizes the server's view of the held item.
Why clients touch it
Three families across the ten clients. (1) Silent switching: Scaffold (Tenacity ScaffoldModule, Rise 5.99 Scaffold, Sigma Scaffold) sends C09 to the block slot while the visible hotbar stays put, and cancels incoming C09 echoes. (2) Tool/weapon automation: Rise 6.2.4 NewNewBreaker switches to the best tool before breaking, KillAura (Rise 6.2.4/6.1.30) swaps weapons for 1.9+ style switching. (3) Consumable routing: AutoPotion/AutoSoup/AutoGap/AutoHead/AutoEat (Memeware, Rise 5.99, Sigma) switch to the food/potion slot, use the item, then switch back. November Recode 2.0 adds an InventoryManager that tracks the C09/S09 streams and re-syncs the slot, and a NoSlowDown that switches away and back; LiquidSense Dev's AutoHead, AutoArmor, AutoADL and the NoFall MLG save all use the silent-switch pair.
Exploit surface
The packet is unthrottled, so modules can switch slots 20 times per tick. The detectability comes from the server comparing the packet slot to the client's own S09PacketHeldItemChange echoes and to attack/place packets: an aura that attacks with a sword while C09 says a block is held gets flagged by rotation+slot correlation checks. Silent switch modules therefore cancel the visible slot change or re-send it after the action.
Server-Side Handling
processHeldItemChange validates the slot range and sets inventory.currentItem. There is no rate limit and no validation against the client's last known slot. The side effect is that the server-side held item drives entity equipment broadcasts (S04PacketEntityEquipment) and the player's attack/place behavior.
Protocol Analysis
Single VarInt slot field. Sent in PLAY state only. Vanilla sends it on scroll wheel input; modules send it via PacketUtil.sendPacket, addToSendQueue, or addToSendQueueNoEvent (Tenacity). Silent-switch modules cancel the packet when it matches the player's real current slot so the visible hotbar never moves.
Anti-Cheat Landscape
Anti-cheats correlate C09 with C02/C08/C07: switching to a sword then attacking with reach is normal, but attacking while the C09 stream says a block is held trips slot-consistency checks on Verus and newer NCP. The fix in clients is to send C09 to the weapon slot before the attack and back after, or to cancel the switch entirely and spoof the attack slot.
implementation Implementation Cases
The slot-switch packet that silent everything depends on. Scaffold switches to blocks invisibly, breakers grab the best tool, and consumable modules hop to the potion slot and back. The server trusts the int, so the entire game is keeping the visible slot in sync with the action slot.
Switch the server-side held item to the block slot without moving the visible hotbar.
Tenacity ScaffoldModule sends C09 to the target slot via addToSendQueueNoEvent (line ~80), cancels incoming C09 packets that would reveal the switch (line ~150), and restores the original slot with a second C09 (line ~183). Rise 5.99 Scaffold sends C09 only when the computed block slot differs from the player's current slot, and cancels all C09 on the send event.
// ===== FILE: Tenacity 6.0, dev/tenacity/module/impl/player/ScaffoldModule.java =====
package dev.tenacity.module.impl.player;
import dev.tenacity.event.IEventListener;
import dev.tenacity.event.impl.packet.PacketSendEvent;
import dev.tenacity.event.impl.player.BlockPlaceableEvent;
import dev.tenacity.event.impl.player.MotionEvent;
import dev.tenacity.module.Module;
import dev.tenacity.module.ModuleCategory;
import dev.tenacity.setting.impl.BooleanSetting;
import dev.tenacity.setting.impl.ModeSetting;
import dev.tenacity.setting.impl.NumberSetting;
import dev.tenacity.util.misc.ChatUtil;
import dev.tenacity.util.misc.MathUtil;
import dev.tenacity.util.misc.RaycastUtil;
import dev.tenacity.util.misc.TimerUtil;
import dev.tenacity.util.player.InventoryUtil;
import dev.tenacity.util.player.MovementUtil;
import dev.tenacity.util.player.RotationUtil;
import net.minecraft.block.BlockAir;
import net.minecraft.block.material.Material;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.network.play.client.C0APacketAnimation;
import net.minecraft.network.play.client.C0BPacketEntityAction;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import org.lwjgl.input.Keyboard;
import org.lwjgl.util.vector.Vector2f;
public final class ScaffoldModule extends Module {
private final BooleanSetting sprint = new BooleanSetting("Sprint", true),
swing = new BooleanSetting("Swing", true),
rotate = new BooleanSetting("Rotate", true),
tower = new BooleanSetting("Tower", true);
private final NumberSetting searchRange = new NumberSetting("Search Range", 3, 1, 6, 1),
bruteForceRayCastIntensity = new NumberSetting("Brute Force Intensity", 5, 1, 10, 1);
private final ModeSetting switchItemMode = new ModeSetting("Switch Item Mode", "Client", "Server"),
swingMode = new ModeSetting("Swing Mode", "Client", "Server"),
rotationMode = new ModeSetting("Rotation Mode", "Enum", "Brute Force RayCast"),
towerMode = new ModeSetting("Tower Mode", "Vanilla", "BlocksMC", "Verus", "Vulcan");
private BlockCache blockCache, lastBlockCache;
private int startSlot, slot, lastSlot;
private final TimerUtil timerUtil = new TimerUtil();
private float yaw, pitch;
public ScaffoldModule() {
super("Scaffold", "Automatically bridges for you", ModuleCategory.PLAYER);
swingMode.addParent(swing, BooleanSetting::isEnabled);
rotationMode.addParent(rotate, BooleanSetting::isEnabled);
towerMode.addParent(tower, BooleanSetting::isEnabled);
bruteForceRayCastIntensity.addParent(rotationMode, rotation -> rotationMode.isMode("Brute Force RayCast"));
initializeSettings(sprint, searchRange, rotate, rotationMode, bruteForceRayCastIntensity, switchItemMode, swing, swingMode, tower, towerMode);
}
private final IEventListener<BlockPlaceableEvent> onBlockPlaceableEvent = event -> {
placeBlock();
};
private final IEventListener<MotionEvent> onMotionEvent = event -> {
slot = InventoryUtil.getBlockSlot();
if(sprint.isEnabled())
mc.gameSettings.keyBindSprint.pressed = true;
else {
mc.gameSettings.keyBindSprint.pressed = false;
mc.thePlayer.setSprinting(false);
}
if(slot != -1) {
if(switchItemMode.isMode("Client") && mc.thePlayer.inventory.currentItem != slot)
mc.thePlayer.inventory.currentItem = slot;
if(switchItemMode.isMode("Server") && lastSlot != slot) {
mc.getNetHandler().addToSendQueueNoEvent(new C09PacketHeldItemChange(slot));
lastSlot = slot;
}
}
if(event.isPre()) {
blockCache = getBlockCache();
if(blockCache != null)
lastBlockCache = blockCache;
final float sensitivityMultiplier = RotationUtil.getSensitivityMultiplier();
final float fixedYaw = yaw - yaw % sensitivityMultiplier;
final float fixedPitch = pitch - pitch % sensitivityMultiplier;
event.setYaw(fixedYaw);
event.setPitch(fixedPitch);
// Have to do this or else watchdog will delete your blocks
if(mc.thePlayer.onGround) {
mc.thePlayer.motionX *= 0.91f;
mc.thePlayer.motionZ *= 0.91f;
}
if(tower.isEnabled() && mc.gameSettings.keyBindJump.isKeyDown() && blockCache != null) {
switch (towerMode.getCurrentMode()) {
case "Vanilla":
mc.thePlayer.motionY = 0.42f;
break;
}
switch (towerMode.getCurrentMode()) {
case "BlocksMC":
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
mc.thePlayer.motionY = 0.42f;
}
if (Keyboard.isKeyDown(Keyboard.KEY_W) || Keyboard.isKeyDown(Keyboard.KEY_A) || Keyboard.isKeyDown(Keyboard.KEY_D) || Keyboard.isKeyDown(Keyboard.KEY_S)) {
mc.thePlayer.motionY = 0.15f;
}
switch (towerMode.getCurrentMode()) {
case "Verus":
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
mc.thePlayer.motionY = MathUtil.getRandomInRange(0.4, 0.5);
if (mc.thePlayer.serverSprintState) {
mc.getNetHandler().addToSendQueueNoEvent(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SPRINTING));
mc.thePlayer.serverSprintState = false;
} else {
mc.getNetHandler().addToSendQueueNoEvent(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.START_SPRINTING));
mc.thePlayer.serverSprintState = false;
}
if (timerUtil.hasTimeElapsed(4000, true)) {
ChatUtil.error("Warning, towering further may result in a silent flag, please proceed with caution");
}
}
}
switch (towerMode.getCurrentMode()) {
case "Vulcan":
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
mc.thePlayer.motionY = 0.2f;
if (timerUtil.hasTimeElapsed(4000, true)) {
ChatUtil.error("Warning, towering further may result in a silent flag, please proceed with caution");
}
}
}
}
}
}
};
private final IEventListener<PacketSendEvent> onPacketSendEvent = event -> {
if(event.getPacket() instanceof C09PacketHeldItemChange) {
final C09PacketHeldItemChange c09 = (C09PacketHeldItemChange) event.getPacket();
if(switchItemMode.isMode("Server")) {
startSlot = c09.getSlotId();
event.cancel();
}
}
};
@Override
public void onEnable() {
if (mc == null || mc.thePlayer == null) {
return;
}
if (mc.thePlayer.inventory == null) {
return;
}
startSlot = mc.thePlayer.inventory.currentItem;
slot = lastSlot = -1;
blockCache = lastBlockCache = null;
yaw = MovementUtil.getMoveYaw() + 180;
pitch = 80;
super.onEnable();
}
@Override
public void onDisable() {
if(mc.thePlayer.inventory.currentItem != startSlot || lastSlot != startSlot) {
if(switchItemMode.isMode("Client"))
mc.thePlayer.inventory.currentItem = startSlot;
else
mc.getNetHandler().addToSendQueueNoEvent(new C09PacketHeldItemChange(startSlot));
}
super.onDisable();
}
private void placeBlock() {
if(blockCache == null || lastBlockCache == null || slot == -1) return;
if(mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.inventory.getStackInSlot(slot),
lastBlockCache.getBlockPos(), lastBlockCache.getEnumFacing(), getHitVec())) {
if(rotate.isEnabled())
updateRotations();
if(swing.isEnabled()) {
if(swingMode.isMode("Client"))
mc.thePlayer.swingItem();
else
mc.getNetHandler().addToSendQueue(new C0APacketAnimation());
}
}
blockCache = null;
}
private void updateRotations() {
switch(rotationMode.getCurrentMode()) {
case "Enum":
this.yaw = (float) lastBlockCache.getEnumFacing().angleFromEnumFacing() - 180;
this.pitch = 77;
break;
case "Brute Force RayCast":
for (float yaw = MovementUtil.getMoveYaw() - 180; yaw < MovementUtil.getMoveYaw() + 180; yaw += bruteForceRayCastIntensity.getCurrentValue()) {
for (float pitch = 90; pitch > -90; pitch -= bruteForceRayCastIntensity.getCurrentValue()) {
final MovingObjectPosition cursor = RaycastUtil.getMouseOver(new Vector2f(yaw, pitch), searchRange.getCurrentValue());
if (cursor != null && cursor.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
BlockPos pos = cursor.getBlockPos();
if (pos.getX() == lastBlockCache.getBlockPos().getX() && pos.getY() == lastBlockCache.getBlockPos().getY() && pos.getZ() == lastBlockCache.getBlockPos().getZ()) {
this.yaw = yaw;
this.pitch = pitch;
break;
}
}
}
}
break;
}
}
private Vec3 getHitVec() {
double x = lastBlockCache.getBlockPos().getX() + 0.5,
y = lastBlockCache.getBlockPos().getY() + 0.5,
z = lastBlockCache.getBlockPos().getZ() + 0.5;
if(lastBlockCache.getEnumFacing() != EnumFacing.UP && lastBlockCache.getEnumFacing() != EnumFacing.DOWN) {
y += 0.5;
} else {
x += 0.3;
z += 0.3;
}
if(lastBlockCache.getEnumFacing() == EnumFacing.SOUTH || lastBlockCache.getEnumFacing() == EnumFacing.NORTH)
x += 0.15;
if(lastBlockCache.getEnumFacing() == EnumFacing.EAST || lastBlockCache.getEnumFacing() == EnumFacing.WEST)
z += 0.15;
return new Vec3(x, y, z);
}
private BlockCache getBlockCache() {
final BlockPos belowBlockPos = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1, mc.thePlayer.posZ);
if (mc.theWorld.getBlockState(belowBlockPos).getBlock() instanceof BlockAir) {
for (int x = 0; x < searchRange.getCurrentValue(); x++) {
for (int z = 0; z < searchRange.getCurrentValue(); z++) {
for (int i = 1; i > -3; i -= 2) {
final BlockPos blockPos = belowBlockPos.add(x * i, 0, z * i);
if (mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockAir) {
for (final EnumFacing direction : EnumFacing.values()) {
final BlockPos block = blockPos.offset(direction);
final Material material = mc.theWorld.getBlockState(block).getBlock().getMaterial();
if (material.isSolid() && !material.isLiquid())
return new BlockCache(block, direction.getOpposite());
}
}
}
}
}
}
return null;
}
public static final class BlockCache {
private final BlockPos blockPos;
private final EnumFacing enumFacing;
public BlockCache(final BlockPos blockPos, final EnumFacing enumFacing) {
this.blockPos = blockPos;
this.enumFacing = enumFacing;
}
public BlockPos getBlockPos() {
return blockPos;
}
public EnumFacing getEnumFacing() {
return enumFacing;
}
}
}
// NOTE (AI): Tenacity 6.0 ScaffoldModule: complete file. Silent C09 switch (line ~80), cancellation of C09 echoes (lines ~150-151), restore-to-start-slot (line ~183), plus C0B sprint toggling around placement (lines ~122-125).
Break blocks (including through walls) while automatically switching to the best tool via C09.
Finds the target block with a raycast or surroundings scan, computes the best tool slot with SlotUtil, sends C09 to that slot, digs with C07, then switches back to the original slot. On attack events it also swaps to the weapon slot. The breaker mode determines target selection (Through Walls / Surroundings).
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/player/NewNewBreaker.java =====
package com.alan.clients.module.impl.player;
import com.alan.clients.component.impl.player.RotationComponent;
import com.alan.clients.component.impl.player.Slot;
import com.alan.clients.component.impl.player.rotationcomponent.MovementFix;
import com.alan.clients.component.impl.render.NotificationComponent;
import com.alan.clients.event.Listener;
import com.alan.clients.event.Priorities;
import com.alan.clients.event.annotations.EventLink;
import com.alan.clients.event.impl.motion.PreUpdateEvent;
import com.alan.clients.event.impl.other.AttackEvent;
import com.alan.clients.event.impl.other.TeleportEvent;
import com.alan.clients.event.impl.other.WorldChangeEvent;
import com.alan.clients.event.impl.render.Render2DEvent;
import com.alan.clients.event.impl.render.Render3DEvent;
import com.alan.clients.module.Module;
import com.alan.clients.module.api.Category;
import com.alan.clients.module.api.ModuleInfo;
import com.alan.clients.util.packet.PacketUtil;
import com.alan.clients.util.player.PlayerUtil;
import com.alan.clients.util.player.SlotUtil;
import com.alan.clients.util.render.RenderUtil;
import com.alan.clients.util.rotation.RotationUtil;
import com.alan.clients.util.vector.Vector2f;
import com.alan.clients.value.impl.BooleanValue;
import com.alan.clients.value.impl.ModeValue;
import com.alan.clients.value.impl.NumberValue;
import com.alan.clients.value.impl.SubMode;
import lombok.Getter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockBed;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.ArrayList;
@ModuleInfo(aliases = {"module.player.breaker.name"}, description = "module.player.breaker.description", category = Category.PLAYER)
public class NewNewBreaker extends Module {
public final ModeValue mode = new ModeValue("Mode", this)
.add(new SubMode("Through Walls"))
.add(new SubMode("Surroundings"))
.setDefault("Through Walls");
private final NumberValue Range = new NumberValue("Range", this, 4, 1, 5, 0.1);
public final BooleanValue rotate = new BooleanValue("Rotate", this, true);
public final BooleanValue movementCorrection = new BooleanValue("Movement Correction", this, false);
public final BooleanValue whitelistFriendlyBed = new BooleanValue("Whitelist Friendly Bed", this, false);
public final BooleanValue hitCheck = new BooleanValue("Aura Check", this, false);
private final NumberValue fastBreakNormal = new NumberValue("FastBreak", this, 0, 0, 1, 0.1);
private final NumberValue fastBreakBed = new NumberValue("FastBreak bed", this, 0, 0, 1, 0.1);
private final NumberValue airMultipalyer = new NumberValue("Air Multiplier", this, 1, 0, 3, 0.1);
private float hardness;
private float damagetoblock;
private int attackTicks;
private boolean notify = true;
private int usedItem, delay, rotateTime;
private Vec3 teleport;
private BlockPos coordsBed;
private BlockPos blockToBreak;
@Getter
boolean breaking = false;
@Override
public void onDisable() {
mc.playerController.curBlockDamageMP = 0;
}
@Override
public void onEnable() {
hardness = 0;
damagetoblock = 0;
}
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<WorldChangeEvent> onWorldChange = event -> {
notify = true;
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<TeleportEvent> onTeleport = event -> {
if (mc.thePlayer.getDistance(event.getPosX(), event.getPosY(), event.getPosZ()) > 30) {
if (notify) {
notify = false;
NotificationComponent.post("Breaker","Whitelisted bed");
}
teleport = new Vec3(event.getPosX(), event.getPosY(), event.getPosZ());
}
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<PreUpdateEvent> onPreUpdate = event -> {
Module scaffold = getModule(Scaffold.class);
if (scaffold == null || scaffold.isEnabled()) {
return;
}
EntityPlayerSP player = mc.thePlayer;
attackTicks++;
delay--;
if (delay > 0 || (whitelistFriendlyBed.getValue() && teleport != null && player.getDistanceSq(teleport.xCoord, teleport.yCoord, teleport.zCoord) < 1500)) {
return;
}
boolean foundbed = false;
int bedX = 0;
int bedY = 0;
int bedZ = 0;
for (int x = -Range.getValue().intValue()+1; x <= Range.getValue().intValue()+1; x++) {
for (int y = -Range.getValue().intValue()+1; y <= Range.getValue().intValue()+1; y++) {
for (int z = -Range.getValue().intValue()+1; z <= Range.getValue().intValue()+1; z++) {
Block block = PlayerUtil.blockRelativeToPlayer(x, y, z);
if (block instanceof BlockBed) {
foundbed = true;
bedX = x;
bedY = y;
bedZ = z;
BlockPos blockPos = new BlockPos(player.posX + x, player.posY + y, player.posZ + z);
if (damagetoblock <= 0) {
if (coordsBed != null) {
if (blockPos.distanceSq(mc.thePlayer.getPosition()) < coordsBed.distanceSq(mc.thePlayer.getPosition())) {
coordsBed = blockPos;
}
} else {
coordsBed = blockPos;
}
}
}
}
}
}
ArrayList<BlockPos> nearblocks = new ArrayList<>();
if (foundbed) {
breaking = true;
int airblocks = 0;
nearblocks.add(new BlockPos(bedX + 1, bedY, bedZ));
nearblocks.add(new BlockPos(bedX - 1, bedY, bedZ));
nearblocks.add(new BlockPos(bedX, bedY, bedZ + 1));
nearblocks.add(new BlockPos(bedX, bedY, bedZ - 1));
nearblocks.add(new BlockPos(bedX, bedY + 1, bedZ));
for (int i = 0; i < nearblocks.size(); i++) {
BlockPos blockPos = nearblocks.get(i);
Block block = PlayerUtil.blockRelativeToPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ());
if (block instanceof BlockBed) {
nearblocks.remove(i);
nearblocks.add(new BlockPos(blockPos.getX() + 1, blockPos.getY(), blockPos.getZ()));
nearblocks.add(new BlockPos(blockPos.getX() - 1, blockPos.getY(), blockPos.getZ()));
nearblocks.add(new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ() + 1));
nearblocks.add(new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ() - 1));
nearblocks.add(new BlockPos(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ()));
break;
}
}
for (int i = 0; i < nearblocks.size(); i++) {
BlockPos blockPos = nearblocks.get(i);
Block block = PlayerUtil.blockRelativeToPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ());
if (block instanceof BlockAir) {
airblocks++;
}
}
if (airblocks > 0 || !this.mode.getValue().getName().equals("Surroundings")) {
blockToBreak = coordsBed;
} else {
float minHardness = 99999999;
for (BlockPos blockPos : nearblocks) {
Block block = PlayerUtil.blockRelativeToPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ());
if (block.getBlockHardness() < minHardness && !(block instanceof BlockBed)) {
minHardness = block.getBlockHardness();
if (damagetoblock <= 0) {
blockToBreak = new BlockPos(player.posX + blockPos.getX(), player.posY + blockPos.getY(), player.posZ + blockPos.getZ());
}
}
}
for (int i = 0; i < nearblocks.size(); i++) {
BlockPos blockPos = nearblocks.get(i);
Block block = PlayerUtil.blockRelativeToPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ());
if (minHardness == block.getBlockHardness() && blockPos.add(player.getPosition()).distance(player.getPosition()) < blockToBreak.distance(player.getPosition())) {
if (damagetoblock <= 0) {
blockToBreak = new BlockPos(player.posX + blockPos.getX(), player.posY + blockPos.getY(), player.posZ + blockPos.getZ());
}
}
}
}
if (blockToBreak.distance(player.getPosition()) <= Range.getValue().floatValue()) {
if (rotate.getValue()) {
rotate(blockToBreak);
}
// player.swingItem();
int slot = SlotUtil.findTool(blockToBreak);
// final BlockDamageEvent bdEvent = new BlockDamageEvent(this.mc.thePlayer, this.mc.thePlayer.worldObj, blockToBreak);
// Client.INSTANCE.getEventBus().handle(bdEvent);
if (slot != -1) PacketUtil.send(new C09PacketHeldItemChange(slot));
if (slot != -1) hardness = SlotUtil.getPlayerRelativeBlockHardness(player, mc.theWorld, blockToBreak, slot);
else hardness = SlotUtil.getPlayerRelativeBlockHardness(player, mc.theWorld, blockToBreak, getComponent(Slot.class).getItemIndex());
if (!mc.thePlayer.onGround) hardness *= airMultipalyer.getValue().floatValue();
if (damagetoblock == 0) {
PacketUtil.send(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockToBreak, EnumFacing.DOWN));
}
mc.thePlayer.swingItem();
damagetoblock += hardness;
mc.theWorld.sendBlockBreakProgress(player.getEntityId(), blockToBreak, (int) (damagetoblock * 10 - 1));
if (damagetoblock >= (PlayerUtil.blockRelativeToPlayer(blockToBreak.getX(), blockToBreak.getY(), blockToBreak.getZ()) instanceof BlockBed ? 1-fastBreakBed.getValue().floatValue() : 1-fastBreakNormal.getValue().floatValue())) {
damagetoblock = 0;
PacketUtil.send(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockToBreak, EnumFacing.DOWN));
mc.playerController.onPlayerDestroyBlock(blockToBreak, EnumFacing.UP);
}
if (slot != -1) PacketUtil.send(new C09PacketHeldItemChange(getComponent(Slot.class).getItemIndex()));
// final BlockDamageEvent bdEvent = new BlockDamageEvent(this.mc.thePlayer, this.mc.thePlayer.worldObj, blockToBreak);
// Client.INSTANCE.getEventBus().handle(bdEvent);
// float xd = SlotUtil.getPlayerRelativeBlockHardness(mc.thePlayer, mc.theWorld, blockToBreak, getComponent(SlotComponent.class).getItemIndex());
// usedItem = getComponent(SlotComponent.class).getItemIndex();
// if (!mc.thePlayer.onGround) xd *= airMultipalyer.getValue().floatValue();
// mc.playerController.curBlockDamageMP += xd;
// mc.theWorld.sendBlockBreakProgress(mc.thePlayer.getEntityId(), blockToBreak, (int) (mc.playerController.curBlockDamageMP * 10 - 1));
//
// if (mc.playerController.curBlockDamageMP >= 1) {
// mc.thePlayer.swingItem();
// PacketUtil.send(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockToBreak, EnumFacing.DOWN));
// mc.playerController.onPlayerDestroyBlock(blockToBreak, EnumFacing.DOWN);
// mc.playerController.curBlockDamageMP = 0;
// }
}
} else {
if (breaking) {
damagetoblock = 0;
}
breaking = false;
}
mc.playerController.curBlockDamageMP = damagetoblock;
};
@EventLink
public final Listener<AttackEvent> onAttackEvent = event -> {
if(whitelistFriendlyBed.getValue() ){
attackTicks = 0;
} else if (attackTicks < 10) {
attackTicks++;
}
if (attackTicks < 10) {
breaking = true;
} else {
breaking = false;
}
};
@EventLink
public final Listener<Render2DEvent> onRender2D = event -> {
if (breaking) {
final ScaledResolution scaledResolution = event.getScaledResolution();
final double y = scaledResolution.getScaledHeight() * 0.80;
RenderUtil.drawRoundedGradientRect((scaledResolution.getScaledWidth() - (mc.playerController.curBlockDamageMP * 100)) / 2, y, mc.playerController.curBlockDamageMP * 100, 10, 4,
getTheme().getFirstColor(), getTheme().getSecondColor(), true);
RenderUtil.color(Color.WHITE);
}
};
@EventLink
public final Listener<Render3DEvent> onRender3D = event -> {
if (breaking) {
try {
double x1 = blockToBreak.getX() - mc.getRenderManager().renderPosX;
double y1 = blockToBreak.getY() - mc.getRenderManager().renderPosY;
double z1 = blockToBreak.getZ() - mc.getRenderManager().renderPosZ;
double x2 = x1 + 1.0;
double y2 = y1 + 1.0;
double z2 = z1 + 1.0;
renderBoundingBox(x1, y1, z1, x2, y2, z2);
} catch (NullPointerException e) {
}
}
};
private void renderBoundingBox(double x1, double y1, double z1, double x2, double y2, double z2) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glLineWidth(2.0f);
GL11.glBegin(GL11.GL_LINES);
if (coordsBed == blockToBreak) {
GL11.glColor3f(255, 0, 0);
} else {
GL11.glColor3f(255, 255, 255);
}
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x2, y1, z1);
GL11.glVertex3d(x2, y1, z1);
GL11.glVertex3d(x2, y2, z1);
GL11.glVertex3d(x2, y2, z1);
GL11.glVertex3d(x1, y2, z1);
GL11.glVertex3d(x1, y2, z1);
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y1, z2);
GL11.glVertex3d(x2, y1, z1);
GL11.glVertex3d(x2, y1, z2);
GL11.glVertex3d(x2, y2, z1);
GL11.glVertex3d(x2, y2, z2);
GL11.glVertex3d(x1, y2, z1);
GL11.glVertex3d(x1, y2, z2);
GL11.glVertex3d(x1, y1, z2);
GL11.glVertex3d(x2, y1, z2);
GL11.glVertex3d(x2, y1, z2);
GL11.glVertex3d(x2, y2, z2);
GL11.glVertex3d(x2, y2, z2);
GL11.glVertex3d(x1, y2, z2);
GL11.glVertex3d(x1, y2, z2);
GL11.glVertex3d(x1, y1, z2);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glPopMatrix();
}
public void rotate(BlockPos block) {
if (!this.rotate.getValue()) return;
final Vector2f rotations = RotationUtil.calculate(block);
RotationComponent.setRotations(rotations, 10, movementCorrection.getValue() ? MovementFix.NORMAL : MovementFix.OFF);
mc.objectMouseOver.setBlockPos(block);
mc.objectMouseOver.sideHit = EnumFacing.UP;
mc.objectMouseOver.hitVec = new Vec3(Math.random(), 1, Math.random());
mc.objectMouseOver.typeOfHit = MovingObjectPosition.MovingObjectType.BLOCK;
}
}
// NOTE (AI): Rise 6.2.4 NewNewBreaker: complete file. C09 tool switch at line ~203 (to best tool) and line ~220 (back to the item index), C07 digging, rotation and movement correction. Demonstrates the component-based Slot API of Rise 6.x.
Switch to the soup/potion slot, consume, and return to the combat slot, all with C09.
On low health, find a soup/potion in the hotbar or inventory, send C09 to that slot, send the C08 use packet, then send C09 back to the original slot. Memeware AutoSoup also sends C07 RELEASE_USE_ITEM and calls stopUsingItem to end the eat state cleanly so the server does not keep the player stuck eating.
// ===== FILE: Memeware 7.3, me/memewaredevs/client/module/combat/AutoSoup.java =====
package me.memewaredevs.client.module.combat;
import me.hippo.api.lwjeb.annotation.Handler;
import me.memewaredevs.client.util.misc.Timer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemSoup;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import me.memewaredevs.client.event.events.UpdateEvent;
import me.memewaredevs.client.module.Module;
import java.util.function.Consumer;
public class AutoSoup extends Module {
private final Timer time = new Timer();
public AutoSoup() {
super("Auto Soup", 0, Module.Category.COMBAT);
}
@Handler
public Consumer<UpdateEvent> update = e -> {
if (mc.thePlayer.getHealth() < mc.thePlayer.getMaxHealth() - 10.0f && time.delay(50.0f)) {
if (hotbarHasSoups()) {
useSoup();
} else {
getSoupFromInventory();
time.reset();
}
}
};
private boolean hotbarHasSoups() {
for (int index = 36; index < 45; ++index) {
final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (itemStack == null || !(itemStack.getItem() instanceof ItemSoup)) {
continue;
}
return true;
}
return false;
}
private void getSoupFromInventory() {
int index;
ItemStack itemStack;
int item = -1;
boolean found = false;
for (index = 36; index >= 9; --index) {
itemStack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (itemStack == null || !(itemStack.getItem() instanceof ItemSoup)) {
continue;
}
item = index;
found = true;
break;
}
if (found) {
for (index = 0; index < 45; ++index) {
itemStack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (itemStack == null) {
continue;
}
if (itemStack.getItem() != Items.bowl || index < 36 || index > 44) {
break;
}
mc.playerController.windowClick(0, index, 0, 0, mc.thePlayer);
mc.playerController.windowClick(0, -999, 0, 0, mc.thePlayer);
break;
}
mc.playerController.windowClick(0, item, 0, 1, mc.thePlayer);
}
}
private void useSoup() {
int index;
ItemStack itemStack;
int item = -1;
boolean found = false;
for (index = 36; index < 45; ++index) {
itemStack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (itemStack == null || !(itemStack.getItem() instanceof ItemSoup)) {
continue;
}
item = index;
found = true;
break;
}
if (found) {
for (index = 0; index < 45; ++index) {
itemStack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (itemStack == null || itemStack.getItem() != Items.bowl || index < 36 || index > 44) {
continue;
}
mc.playerController.windowClick(0, index, 0, 0, mc.thePlayer);
mc.playerController.windowClick(0, -999, 0, 0, mc.thePlayer);
}
final int slot = mc.thePlayer.inventory.currentItem;
mc.thePlayer.inventory.currentItem = item - 36;
mc.playerController.updateController();
mc.thePlayer.sendQueue
.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
mc.thePlayer.sendQueue
.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(
C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
mc.thePlayer.stopUsingItem();
mc.thePlayer.inventory.currentItem = slot;
}
}
}
// NOTE (AI): Memeware 7.3 AutoSoup: complete file. C09 to the soup slot, C08 to eat (line ~107), C09 back to the original slot (line ~109), C07 release + stopUsingItem to close the use state.
Track the server-visible hotbar slot from the C09 and S09 streams and re-sync the slot when modules desync it.
EventPacket.Out records the slot from every outgoing C09; EventPacket.In records it from every S09 echo. sync() re-sends C09 with the real currentItem when the tracked slot diverges, which is how AutoPot and AutoPlay restore the hotbar after their silent switches.
// ===== FILE: November Recode 2.0, management/inventory/InventoryManager.java =====
/* November.lol © 2023 */
package lol.november.management.inventory;
import lol.november.November;
import lol.november.listener.bus.Listener;
import lol.november.listener.bus.Subscribe;
import lol.november.listener.event.net.EventPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.network.play.server.S09PacketHeldItemChange;
/**
* @author Gavin
* @since 2.0.0
*/
public class InventoryManager {
/**
* The {@link Minecraft} game instance
*/
private final Minecraft mc = Minecraft.getMinecraft();
private int slot = -1;
public InventoryManager() {
November.bus().subscribe(this);
}
@Subscribe
private final Listener<EventPacket.Out> packetOut = event -> {
if (event.get() instanceof C09PacketHeldItemChange packet) {
slot = packet.getSlotId();
}
};
@Subscribe
private final Listener<EventPacket.In> packetIn = event -> {
if (event.get() instanceof S09PacketHeldItemChange packet) {
slot = packet.getHeldItemHotbarIndex();
}
};
public int slot() {
if (slot == -1) return slot = mc.thePlayer.inventory.currentItem;
return slot;
}
public void sync() {
if (slot != mc.thePlayer.inventory.currentItem) {
mc.thePlayer.sendQueue.addToSendQueue(
new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)
);
}
}
public ItemStack itemStack() {
return mc.thePlayer.inventory.getStackInSlot(slot());
}
}
// NOTE (AI): The packetOut listener records the slot from every outgoing C09, the packetIn listener from every S09 echo. sync() re-sends C09 with the real currentItem when the tracked slot diverges, which is how AutoPot and AutoPlay restore the hotbar after silent switches.
Packet-eat golden heads: C09 to the head slot, the C08 use, C09 back to the combat slot.
Below the health threshold with no mouse held, find a head (id 397) in the hotbar, then send the C09/C08/C09 triple with a delay gate; golden apples use the key-binding path instead.
// ===== FILE: LiquidSense Dev, me/AquaVit/liquidSense/modules/combat/AutoHead.java =====
package me.AquaVit.liquidSense.modules.combat;
import net.ccbluex.liquidbounce.event.EventTarget;
import net.ccbluex.liquidbounce.features.module.Module;
import net.ccbluex.liquidbounce.features.module.ModuleCategory;
import net.ccbluex.liquidbounce.features.module.ModuleInfo;
import net.ccbluex.liquidbounce.value.BoolValue;
import net.ccbluex.liquidbounce.value.IntegerValue;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.potion.Potion;
import net.ccbluex.liquidbounce.event.MotionEvent;
import net.ccbluex.liquidbounce.utils.timer.TimeUtils;
import net.ccbluex.liquidbounce.value.FloatValue;
import org.lwjgl.input.Mouse;
import java.util.Random;
@ModuleInfo(name = "AutoHead", description = "AutoHead", category = ModuleCategory.COMBAT)
public class AutoHead extends Module {
private boolean eatingApple;
private int switched = -1;
public static boolean doingStuff = false;
private final TimeUtils timer = new TimeUtils();
private final BoolValue eatHeads = new BoolValue("EatHead", true);
private final BoolValue eatApples = new BoolValue("EatApples", true);
private final FloatValue health = new FloatValue("Health", 10.0F, 1.0F, 20.0F);
private final IntegerValue delay = new IntegerValue("Delay", 750, 100, 2000);
@Override
public void onEnable() {
this.eatingApple = doingStuff = false;
switched = -1;
timer.reset();
super.onEnable();
}
@Override
public void onDisable() {
doingStuff = false;
if (eatingApple) {
repairItemPress();
repairItemSwitch();
}
super.onDisable();
}
private void repairItemPress() {
if (mc.gameSettings != null) {
final KeyBinding keyBindUseItem = mc.gameSettings.keyBindUseItem;
if (keyBindUseItem != null) keyBindUseItem.pressed = false;
}
}
@EventTarget
public void onUpdate(MotionEvent event) {
if (mc.thePlayer == null) return;
final InventoryPlayer inventory = mc.thePlayer.inventory;
if (inventory == null) return;
doingStuff = false;
if (!Mouse.isButtonDown(0) && !Mouse.isButtonDown(1)) {
final KeyBinding useItem = mc.gameSettings.keyBindUseItem;
if (!this.timer.hasReached(delay.get())) {
eatingApple = false;
repairItemPress();
repairItemSwitch();
return;
}
if (mc.thePlayer.capabilities.isCreativeMode || mc.thePlayer.isPotionActive(Potion.regeneration) ||mc.thePlayer.getHealth() >= health.get()) {
this.timer.reset();
if (eatingApple) {
eatingApple = false;
repairItemPress();
repairItemSwitch();
}
return;
}
for (int i = 0; i < 2; i++) {
final boolean doEatHeads = i != 0;
if (doEatHeads) {
if (!this.eatHeads.get()) continue;
} else {
if (!this.eatApples.get()) {
eatingApple = false;
repairItemPress();
repairItemSwitch();
continue;
}
}
int slot;
if (doEatHeads) {
slot = this.getItemFromHotbar(397);
} else {
slot = this.getItemFromHotbar(322);
}
if (slot == -1) continue;
final int tempSlot = inventory.currentItem;
doingStuff = true;
if (doEatHeads) {
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(slot));
mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(inventory.getCurrentItem()));
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(tempSlot));
timer.reset();
} else {
inventory.currentItem = slot;
useItem.pressed = true;
if (eatingApple) continue; // no message spam
eatingApple = true;
this.switched = tempSlot;
}
}
}
}
private void repairItemSwitch() {
final EntityPlayerSP p = mc.thePlayer;
if (p == null) return;
final InventoryPlayer inventory = p.inventory;
if (inventory == null) return;
int switched = this.switched;
if (switched == -1) return;
inventory.currentItem = switched;
switched = -1;
this.switched = switched;
}
private int getItemFromHotbar(final int id) {
for (int i = 0; i < 9; i++) {
if (mc.thePlayer.inventory.mainInventory[i] != null) {
final ItemStack is = mc.thePlayer.inventory.mainInventory[i];
final Item item = is.getItem();
if (Item.getIdFromItem(item) == id) {
return i;
}
}
}
return -1;
}
}
// NOTE (AI): The head path is the C09 + C08 + C09 triple: switch to the head slot, send the item-use C08 with the now-held stack, switch back. The apple path instead presses the real use-item key and restores the slot on release.
Switch to the armor-hotbar slot with C09 for the C08 equip placement, then switch back.
move() with a hotbar item sends C09(item), C08(placement with the slot's stack), C09(current); non-hotbar items use the window-click path. Gated by InventoryUtils.CLICK_TIMER and a random delay.
// ===== FILE: LiquidSense Dev, net/ccbluex/liquidbounce/features/module/modules/combat/AutoArmor.java =====
/*
* LiquidBounce Hacked Client
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
* https://github.com/CCBlueX/LiquidBounce/
*/
package net.ccbluex.liquidbounce.features.module.modules.combat;
import net.ccbluex.liquidbounce.event.EventTarget;
import net.ccbluex.liquidbounce.event.Render3DEvent;
import net.ccbluex.liquidbounce.features.module.Module;
import net.ccbluex.liquidbounce.features.module.ModuleCategory;
import net.ccbluex.liquidbounce.features.module.ModuleInfo;
import net.ccbluex.liquidbounce.injection.implementations.IItemStack;
import net.ccbluex.liquidbounce.utils.InventoryUtils;
import net.ccbluex.liquidbounce.utils.MovementUtils;
import net.ccbluex.liquidbounce.utils.item.ArmorComparator;
import net.ccbluex.liquidbounce.utils.item.ArmorPiece;
import net.ccbluex.liquidbounce.utils.timer.TimeUtils;
import net.ccbluex.liquidbounce.value.BoolValue;
import net.ccbluex.liquidbounce.value.IntegerValue;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.network.play.client.C0DPacketCloseWindow;
import net.minecraft.network.play.client.C16PacketClientStatus;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@ModuleInfo(name = "AutoArmor", description = "Automatically equips the best armor in your inventory.", category = ModuleCategory.COMBAT)
public class AutoArmor extends Module {
public static final ArmorComparator ARMOR_COMPARATOR = new ArmorComparator();
private final IntegerValue maxDelayValue = new IntegerValue("MaxDelay", 200, 0, 400) {
@Override
protected void onChanged(final Integer oldValue, final Integer newValue) {
final int minDelay = minDelayValue.get();
if (minDelay > newValue) set(minDelay);
}
};
private final IntegerValue minDelayValue = new IntegerValue("MinDelay", 100, 0, 400) {
@Override
protected void onChanged(final Integer oldValue, final Integer newValue) {
final int maxDelay = maxDelayValue.get();
if (maxDelay < newValue) set(maxDelay);
}
};
private final BoolValue invOpenValue = new BoolValue("InvOpen", false);
private final BoolValue simulateInventory = new BoolValue("SimulateInventory", true);
private final BoolValue noMoveValue = new BoolValue("NoMove", false);
private final IntegerValue itemDelayValue = new IntegerValue("ItemDelay", 0, 0, 5000);
private final BoolValue hotbarValue = new BoolValue("Hotbar", true);
private long delay;
@EventTarget
public void onRender3D(final Render3DEvent event) {
if ((mc.thePlayer.capabilities.allowFlying && mc.thePlayer.capabilities.isFlying) || !InventoryUtils.CLICK_TIMER.hasTimePassed(delay) ||
(mc.thePlayer.openContainer != null && mc.thePlayer.openContainer.windowId != 0))
return;
// Find best armor
final Map<Integer, List<ArmorPiece>> armorPieces = IntStream.range(0, 36).filter(i -> {
final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
return itemStack != null && itemStack.getItem() instanceof ItemArmor && (i < 9 || System.currentTimeMillis() - ((IItemStack) (Object) itemStack).getItemDelay() >= itemDelayValue.get());
})
.mapToObj(i -> new ArmorPiece(mc.thePlayer.inventory.getStackInSlot(i), i))
.collect(Collectors.groupingBy(ArmorPiece::getArmorType));
final ArmorPiece[] bestArmor = new ArmorPiece[4];
for (final Map.Entry<Integer, List<ArmorPiece>> armorEntry : armorPieces.entrySet()) {
bestArmor[armorEntry.getKey()] = armorEntry.getValue().stream()
.max(ARMOR_COMPARATOR).orElse(null);
}
// Swap armor
for (int i = 0; i < 4; i++) {
final ArmorPiece armorPiece = bestArmor[i];
if (armorPiece == null)
continue;
int armorSlot = 3 - i;
final ArmorPiece oldArmor = new ArmorPiece(mc.thePlayer.inventory.armorItemInSlot(armorSlot), -1);
if (oldArmor.getItemStack() == null || !(oldArmor.getItemStack().getItem() instanceof ItemArmor) ||
ARMOR_COMPARATOR.compare(oldArmor, armorPiece) < 0) {
if (oldArmor.getItemStack() != null && move(8 - armorSlot, true))
return;
if (move(armorPiece.getSlot(), false))
return;
}
}
}
/**
* Shift+Left clicks the specified item
*
* @param item Slot of the item to click
* @param isArmorSlot
* @return True if it is unable to move the item
*/
private boolean move(int item, boolean isArmorSlot) {
if (!isArmorSlot && item < 9 && hotbarValue.get()) {
mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(item));
mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventoryContainer.getSlot(item).getStack()));
mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());
return true;
} else if (!(noMoveValue.get() && MovementUtils.isMoving()) && (!invOpenValue.get() || mc.currentScreen instanceof GuiInventory) && item != -1) {
final boolean openInventory = simulateInventory.get() && !(mc.currentScreen instanceof GuiInventory);
if (openInventory)
mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));
mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, isArmorSlot ? item : (item < 9 ? item + 36 : item), 0, 1, mc.thePlayer);
delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());
if (openInventory)
mc.getNetHandler().addToSendQueue(new C0DPacketCloseWindow());
return true;
}
return false;
}
}
// NOTE (AI): The move() method is the C08 and C09 hit: for hotbar armor it sends C09 to the item slot, the C08 placement with the slot's stack (which equips the armor server-side), then C09 back to the current slot.
Silently flash an iron sword slot that carries a single Sharpness II enchantment and a custom lore, using a C09 pair.
Every update, scan the hotbar NBT for an iron sword with exactly one enchantment (id 16, level 2) and a display Lore tag, then send C09(slot) followed by C09(current) back-to-back.
// ===== FILE: LiquidSense Dev, me/AquaVit/liquidSense/modules/misc/AutoADL.java =====
package me.AquaVit.liquidSense.modules.misc;
import net.ccbluex.liquidbounce.event.EventTarget;
import net.ccbluex.liquidbounce.event.UpdateEvent;
import net.ccbluex.liquidbounce.features.module.Module;
import net.ccbluex.liquidbounce.features.module.ModuleCategory;
import net.ccbluex.liquidbounce.features.module.ModuleInfo;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
@ModuleInfo(name = "AutoADL", description = "go fuck yourself", category = ModuleCategory.MISC)
public class AutoADL extends Module {
@EventTarget
public void onUpdate(UpdateEvent e) {
ItemStack[] items = getHotbarItems();
for (int i = 0; i < items.length; i++) {
ItemStack item = items[i];
if (item != null && item.getItem() == Items.iron_sword && item.getEnchantmentTagList() != null && item.getEnchantmentTagList().tagCount() == 1) {
NBTTagCompound enchantment = (NBTTagCompound) item.getEnchantmentTagList().get(0);
if ((enchantment.getInteger("id") == 16 && enchantment.getInteger("lvl") == 2)) {
if (item.hasDisplayName()) {
if (item.getTagCompound().getCompoundTag("display").getTag("Lore") != null) {
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(i));
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
System.out.println("send packet" + enchantment);
}
}
}
}
}
}
private ItemStack[] getHotbarItems() {
ItemStack[] results = new ItemStack[9];
for (int i = 0; i < 9; i++) {
results[i] = mc.thePlayer.inventory.mainInventory[i];
}
return results;
}
}
// NOTE (AI): The C09 pair is sent back-to-back to the flagged sword slot and back to the current slot every update while the sword matches the NBT filter (single enchantment, Sharpness II id 16 level 2, custom lore). The filter targets a specific legacy server item glitch.
MLG save: switch to a water bucket or web block with C09 when a fall would miss the ground, place it, then switch back.
When the fall would end without ground and a collision is found below, find water_bucket or web in the hotbar, send C09(index), place via sendUseItem or onPlayerRightClick, then send C09(current) back. The rest of the file is the onGround spoof family documented in the C03 impl.
// ===== FILE: LiquidSense Dev, net/ccbluex/liquidbounce/features/module/modules/player/NoFall.java =====
/*
* LiquidBounce Hacked Client
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
* https://github.com/CCBlueX/LiquidBounce/
*/
package net.ccbluex.liquidbounce.features.module.modules.player;
import me.AquaVit.liquidSense.modules.movement.Flight;
import net.ccbluex.liquidbounce.LiquidBounce;
import net.ccbluex.liquidbounce.event.*;
import net.ccbluex.liquidbounce.features.module.Module;
import net.ccbluex.liquidbounce.features.module.ModuleCategory;
import net.ccbluex.liquidbounce.features.module.ModuleInfo;
import net.ccbluex.liquidbounce.features.module.modules.movement.Fly;
import net.ccbluex.liquidbounce.features.module.modules.movement.Speed;
import net.ccbluex.liquidbounce.features.module.modules.render.FreeCam;
import net.ccbluex.liquidbounce.utils.MovementUtils;
import net.ccbluex.liquidbounce.utils.RotationUtils;
import net.ccbluex.liquidbounce.utils.VecRotation;
import net.ccbluex.liquidbounce.utils.block.BlockUtils;
import net.ccbluex.liquidbounce.utils.misc.FallingPlayer;
import net.ccbluex.liquidbounce.utils.timer.TickTimer;
import net.ccbluex.liquidbounce.value.BoolValue;
import net.ccbluex.liquidbounce.value.FloatValue;
import net.ccbluex.liquidbounce.value.ListValue;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import net.minecraft.potion.Potion;
import net.minecraft.util.*;
import java.util.ArrayList;
import java.util.List;
@ModuleInfo(name = "NoFall", description = "Prevents you from taking fall damage.", category = ModuleCategory.PLAYER)
public class NoFall extends Module {
public final ListValue modeValue = new ListValue("Mode", new String[]{"NewPacket","SpoofGround", "NoGround", "Packet", "AAC", "LAAC", "AAC3.3.11", "AAC3.3.15", "Spartan", "CubeCraft", "Hypixel","MLG","AAC4.4.0"}, "SpoofGround");
private float lastFall;
private int state;
private boolean jumped;
private final TickTimer spartanTimer = new TickTimer();
private final FloatValue minFallDistance = new FloatValue("MinMLGHeight", 5F, 2F, 50F);
private final TickTimer mlgTimer = new TickTimer();
private VecRotation currentMlgRotation;
private int currentMlgItemIndex;
private BlockPos currentMlgBlock;
private int hypixel;
private List<Packet<?>> packets = new ArrayList<>();
private boolean fakelag = false;
public double fallDist = 0;
private boolean packetmodify = false;
Flight flight = (Flight) LiquidBounce.moduleManager.getModule(Flight.class);
Fly fly = (Fly) LiquidBounce.moduleManager.getModule(Fly.class);
private final BoolValue noSound = new BoolValue("NoSound", true);
@Override
public void onEnable() {
if (modeValue.get().equalsIgnoreCase("AAC4.4.0")) {
fakelag = false;
packetmodify = false;
}
}
@EventTarget(ignoreCondition = true)
public void onUpdate(UpdateEvent event) {
if(mc.thePlayer.onGround)
jumped = false;
if(mc.thePlayer.motionY > 0)
jumped = true;
if (!getState() || LiquidBounce.moduleManager.getModule(FreeCam.class).getState())
return;
if(BlockUtils.collideBlock(mc.thePlayer.getEntityBoundingBox(), block -> block instanceof BlockLiquid) ||
BlockUtils.collideBlock(new AxisAlignedBB(mc.thePlayer.getEntityBoundingBox().maxX, mc.thePlayer.getEntityBoundingBox().maxY, mc.thePlayer.getEntityBoundingBox().maxZ, mc.thePlayer.getEntityBoundingBox().minX, mc.thePlayer.getEntityBoundingBox().minY - 0.01D, mc.thePlayer.getEntityBoundingBox().minZ), block -> block instanceof BlockLiquid))
return;
switch(modeValue.get().toLowerCase()) {
case "hypixel":
if (fallDist > mc.thePlayer.fallDistance)
fallDist = 0;
if (mc.thePlayer.motionY < 0 && mc.thePlayer.fallDistance > 2.124 && !checkVoid(mc.thePlayer) && isBlockUnder() && !mc.thePlayer.isSpectator() && !mc.thePlayer.capabilities.allowFlying) {
double motionY = mc.thePlayer.motionY;
double fallingDist = mc.thePlayer.fallDistance - fallDist;
double realDist = fallingDist + -((motionY - 0.08D) * 0.9800000190734863D);
if (realDist >= 3) {
mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true));
fallDist = mc.thePlayer.fallDistance;
if(noSound.get()) mc.thePlayer.fallDistance = 0f;
}
}
break;
case "packet":
if(mc.thePlayer.fallDistance > 2F)
mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true));
break;
case "cubecraft":
if(mc.thePlayer.fallDistance > 2F) {
mc.thePlayer.onGround = false;
mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
}
break;
case "aac":
if(mc.thePlayer.fallDistance > 2F) {
mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true));
state = 2;
}else if(state == 2 && mc.thePlayer.fallDistance < 2) {
mc.thePlayer.motionY = 0.1D;
state = 3;
return;
}
switch(state) {
case 3:
mc.thePlayer.motionY = 0.1D;
state = 4;
break;
case 4:
mc.thePlayer.motionY = 0.1D;
state = 5;
break;
case 5:
mc.thePlayer.motionY = 0.1D;
state = 1;
break;
}
break;
case "laac":
if(!jumped && mc.thePlayer.onGround && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInWater()
&& !mc.thePlayer.isInWeb)
mc.thePlayer.motionY = -6;
break;
case "aac3.3.11":
if(mc.thePlayer.fallDistance > 2) {
mc.thePlayer.motionX = mc.thePlayer.motionZ = 0;
mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX,
mc.thePlayer.posY - 10E-4D, mc.thePlayer.posZ, mc.thePlayer.onGround));
mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true));
}
break;
case "aac3.3.15":
if(mc.thePlayer.fallDistance > 2) {
if(!mc.isIntegratedServerRunning())
mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX,
Double.NaN, mc.thePlayer.posZ, false));
mc.thePlayer.fallDistance = -9999;
}
break;
case "spartan":
spartanTimer.update();
if(mc.thePlayer.fallDistance > 1.5 && spartanTimer.hasTimePassed(10)) {
mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX,
mc.thePlayer.posY + 10, mc.thePlayer.posZ, true));
mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX,
mc.thePlayer.posY - 10, mc.thePlayer.posZ, true));
spartanTimer.reset();
}
break;
case "newpacket":
if (!MovementUtils.isOnGround(0.001)) {
if (mc.thePlayer.motionY < -0.08)
mc.thePlayer.fallDistance -= mc.thePlayer.motionY;
if ((mc.thePlayer.fallDistance > 2F) && (!mc.thePlayer.onGround)) {
mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true));
}
} else
mc.thePlayer.fallDistance = 0;
break;
}
}
@EventTarget
private void onMotionUpdate(MotionEvent event) {
if (modeValue.get().equalsIgnoreCase("NewPacket")) {
if (mc.thePlayer.onGround) {
fallDist = 0;
} else if (mc.thePlayer.motionY < 0) {
fallDist -= mc.thePlayer.motionY;
}
}
if (modeValue.get().equalsIgnoreCase("AAC4.4.0")) {
final EventState eventState = event.getEventState();
if (eventState == EventState.PRE) {
if (!inVoid()) {
if (fakelag) {
fakelag = false;
if (packets.size() > 0) {
for (Packet<?> packet : packets) {
mc.thePlayer.sendQueue.addToSendQueue(packet);
}
packets.clear();
}
}
return;
}
if (mc.thePlayer.onGround && fakelag) {
fakelag = false;
if (packets.size() > 0) {
for (Packet<?> packet : packets) {
mc.thePlayer.sendQueue.addToSendQueue(packet);
}
packets.clear();
}
return;
}
if (mc.thePlayer.fallDistance > 3 && fakelag) {
packetmodify = true;
mc.thePlayer.fallDistance = 0;
}
if (inAir(4.0, 1.0)) {
return;
}
if (!fakelag) {
fakelag = true;
}
}
}
if (modeValue.get().equalsIgnoreCase("MLG")){
if (event.getEventState() == EventState.PRE) {
currentMlgRotation = null;
mlgTimer.update();
if (!mlgTimer.hasTimePassed(10))
return;
if (mc.thePlayer.fallDistance > minFallDistance.get()) {
FallingPlayer fallingPlayer = new FallingPlayer(
mc.thePlayer.posX,
mc.thePlayer.posY,
mc.thePlayer.posZ,
mc.thePlayer.motionX,
mc.thePlayer.motionY,
mc.thePlayer.motionZ,
mc.thePlayer.rotationYaw,
mc.thePlayer.moveStrafing,
mc.thePlayer.moveForward
);
double maxDist = mc.playerController.getBlockReachDistance() + 1.5;
FallingPlayer.CollisionResult collision = fallingPlayer.findCollision((int) Math.ceil((1.0 / mc.thePlayer.motionY) * (-maxDist)));
if (collision == null)
return;
boolean ok = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.eyeHeight, mc.thePlayer.posZ).distanceTo(new Vec3(collision.getPos()).addVector(0.5, 0.5, 0.5)) < mc.playerController.getBlockReachDistance() + Math.sqrt(0.75);
if (mc.thePlayer.motionY < (collision.getPos().getY() + 1) - mc.thePlayer.posY) {
ok = true;
}
if (!ok)
return;
int index = -1;
for (int i = 36; i < 45; i++) {
ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
if (itemStack != null && (itemStack.getItem() == Items.water_bucket || itemStack.getItem() instanceof ItemBlock && ((ItemBlock) itemStack.getItem()).getBlock() == Blocks.web)) {
index = i - 36;
if (mc.thePlayer.inventory.currentItem == index)
break;
}
}
if (index == -1)
return;
currentMlgItemIndex = index;
currentMlgBlock = collision.getPos();
if (mc.thePlayer.inventory.currentItem != index) {
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(index));
}
currentMlgRotation = RotationUtils.faceBlock(collision.getPos());
currentMlgRotation.getRotation().toPlayer(mc.thePlayer);
}
} else if (currentMlgRotation != null) {
ItemStack stack = mc.thePlayer.inventoryContainer.getSlot(currentMlgItemIndex + 36).getStack();
if (stack.getItem() instanceof ItemBucket) {
mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, stack);
} else {
Vec3i dirVec = EnumFacing.UP.getDirectionVec();
if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, stack, currentMlgBlock, EnumFacing.UP, new Vec3(dirVec.getX() * 0.5, dirVec.getY() * 0.5, dirVec.getZ() * 0.5).add(new Vec3(currentMlgBlock)))) {
mlgTimer.reset();
}
}
if (mc.thePlayer.inventory.currentItem != currentMlgItemIndex)
mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
}
}
public static boolean isBlockUnder() {
if (mc.thePlayer.posY < 0.0D) {
return false;
} else {
int off = 0;
while(true) {
if (off >= (int)mc.thePlayer.posY + 2) {
return false;
}
AxisAlignedBB bb = mc.thePlayer.getEntityBoundingBox().offset(0.0D, (double)(-off), 0.0D);
if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb).isEmpty()) {
return true;
}
off += 2;
}
}
}
public static int getJumpEffect() {
return mc.thePlayer.isPotionActive(Potion.jump)?mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1:0;
}
@EventTarget
public void onPacket(PacketEvent event) {
final Packet<?> packet = event.getPacket();
final String mode = modeValue.get();
if (mode.equalsIgnoreCase("AAC4.4.0")) {
if (packet instanceof C03PacketPlayer && fakelag) {
event.cancelEvent();
if (packetmodify) {
((C03PacketPlayer) packet).onGround = true;
packetmodify = false;
}
packets.add(packet);
}
}
if(packet instanceof C03PacketPlayer && mode.equalsIgnoreCase("SpoofGround")){
((C03PacketPlayer) packet).onGround = true;
}
if(packet instanceof C03PacketPlayer && mode.equalsIgnoreCase("NoGround")){
((C03PacketPlayer) packet).onGround = true;
}
}
@EventTarget
public void onMove(MoveEvent event) {
if(BlockUtils.collideBlock(mc.thePlayer.getEntityBoundingBox(), block -> block instanceof BlockLiquid) || BlockUtils.collideBlock(new AxisAlignedBB(mc.thePlayer.getEntityBoundingBox().maxX, mc.thePlayer.getEntityBoundingBox().maxY, mc.thePlayer.getEntityBoundingBox().maxZ, mc.thePlayer.getEntityBoundingBox().minX, mc.thePlayer.getEntityBoundingBox().minY - 0.01D, mc.thePlayer.getEntityBoundingBox().minZ), block -> block instanceof BlockLiquid))
return;
if (modeValue.get().equalsIgnoreCase("laac")) {
if (!jumped && !mc.thePlayer.onGround && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInWater() && !mc.thePlayer.isInWeb && mc.thePlayer.motionY < 0D) {
event.setX(0);
event.setZ(0);
}
}
}
public boolean inVoid() {
if (mc.thePlayer.posY < 0) {
return false;
}
for (int off = 0; off < mc.thePlayer.posY + 2; off += 2) {
AxisAlignedBB bb = new AxisAlignedBB(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, mc.thePlayer.posX, off, mc.thePlayer.posZ);
if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb).isEmpty()) {
return true;
}
}
return false;
}
private boolean isVoid(int X, int Z, EntityLivingBase entity){
Fly fly = (Fly) LiquidBounce.moduleManager.getModule(Fly.class);
if (fly.getState()) {
return false;
}
if (mc.thePlayer.posY < 0.0) {
return true;
}
for (int off = 0; off < entity.posY + 2; off += 2) {
AxisAlignedBB bb = entity.getEntityBoundingBox().offset(X,-off,Z);
if (mc.theWorld.getCollidingBoundingBoxes(entity, bb).isEmpty()) {
continue;
}
return false;
}
return true;
}
private boolean checkVoid(EntityLivingBase entity) {
for(int x = -1; x <= 0; ++x) {
for(int z = -1; z <= 0; ++z) {
if (this.isVoid(x, z, entity)) {
return true;
}
}
}
return false;
}
public boolean inAir(double height, double plus) {
if (mc.thePlayer.posY < 0)
return false;
for (int off = 0; off < height; off += plus) {
AxisAlignedBB bb = new AxisAlignedBB(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, mc.thePlayer.posX, mc.thePlayer.posY - off, mc.thePlayer.posZ);
if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, bb).isEmpty()) {
return true;
}
}
return false;
}
@EventTarget(ignoreCondition = true)
public void onJump(final JumpEvent event) {
jumped = true;
}
@Override
public String getTag() {
return modeValue.get();
}
}
// NOTE (AI): The C09 usage is the MLG mode: when a fall would miss the ground, it finds a water bucket or web block in the hotbar, sends C09 to that slot, places it through sendUseItem or onPlayerRightClick, then sends C09 back. The rest of the file is the onGround spoof family shared with the C03 impl.
anticheat Anti-Cheat Checks
The held item change packet reports the new hotbar slot. It is a thin packet, but it is the trigger for autotool, fastswitch and slot desync checks. Autotool modules switch to the best tool right before a block break or attack, so the switch timing relative to dig and use-entity packets is the signal. The slot value itself must be in range 0 to 8, and the change must match the server's view of the player's inventory, which makes out-of-range and repeated-identical-slot checks cheap and effective.
Flags hotbar switches that are faster than humanly possible while the player is in combat or using an item.
Listens to PlayerItemHeldEvent. It first allows scroll-like changes, adjacent slots or a 0 to 8 wrap, so fast scrolling is not flagged. If the switch is non-adjacent, TPS is at least 19, ping is below the max (default 400), the last switch happened within 50 ms, and the player did something combat- or item-related in the last 750 ms, it flags with +25 VL and cancels the event at 50 VL, otherwise syncing the inventory. Violation decays 25 per 120 seconds.
// ===== FILE: Photon-GitHub-AntiCheatAddition, src/main/java/de/photon/anticheataddition/modules/checks/fastswitch/Fastswitch.java =====
package de.photon.anticheataddition.modules.checks.fastswitch;
import de.photon.anticheataddition.modules.ViolationModule;
import de.photon.anticheataddition.user.User;
import de.photon.anticheataddition.user.data.TimeKey;
import de.photon.anticheataddition.util.inventory.InventoryUtil;
import de.photon.anticheataddition.util.mathematics.MathUtil;
import de.photon.anticheataddition.util.minecraft.ping.PingProvider;
import de.photon.anticheataddition.util.minecraft.tps.TPSProvider;
import de.photon.anticheataddition.util.violationlevels.Flag;
import de.photon.anticheataddition.util.violationlevels.ViolationLevelManagement;
import de.photon.anticheataddition.util.violationlevels.ViolationManagement;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemHeldEvent;
public final class Fastswitch extends ViolationModule implements Listener
{
public static final Fastswitch INSTANCE = new Fastswitch();
private final int cancelVl = loadInt(".cancel_vl", 50);
private final int maxPing = loadInt(".max_ping", 400);
private static final int MIN_SWITCH_DELAY = 50;
private Fastswitch()
{
super("Fastswitch");
}
/**
* Used to acknowledge if somebody can be legit.
* I.e. that players can scroll very fast, but then the neighbor slot is always the one that gets called next.
*/
private static boolean canBeLegit(final int oldSlot, final int newHeldItemSlot)
{
return (oldSlot == 0 && newHeldItemSlot == 8) ||
(oldSlot == 8 && newHeldItemSlot == 0) ||
MathUtil.absDiff(oldSlot, newHeldItemSlot) <= 1;
}
@EventHandler(ignoreCancelled = true)
public void onPlayerItemHeld(PlayerItemHeldEvent event)
{
final var user = User.getUser(event.getPlayer());
if (User.isUserInvalid(user, this) ||
// Tps are high enough
!TPSProvider.INSTANCE.atLeastTPS(19) ||
// Prevent the detection of scrolling
canBeLegit(event.getPreviousSlot(), event.getNewSlot())) return;
// Already switched in the given timeframe
if (user.getTimeMap().at(TimeKey.FASTSWITCH_HOTBAR_SWITCH).recentlyUpdated(MIN_SWITCH_DELAY) &&
// The ping is valid and in the borders that are set in the config.
PingProvider.INSTANCE.atMostMaxPing(user.getPlayer(), maxPing) &&
// User has done something except switching slots all the time.
(user.getTimeMap().at(TimeKey.COMBAT).recentlyUpdated(750) || user.getTimeMap().at(TimeKey.RIGHT_CLICK_ITEM_EVENT).recentlyUpdated(750)))
{
getManagement().flag(Flag.of(user)
.setAddedVl(25)
.setCancelAction(cancelVl, () -> event.setCancelled(true))
.setEventNotCancelledAction(() -> InventoryUtil.syncUpdateInventory(user.getPlayer())));
}
user.getTimeMap().at(TimeKey.FASTSWITCH_HOTBAR_SWITCH).update();
}
@Override
protected ViolationManagement createViolationManagement()
{
return ViolationLevelManagement.builder(this).loadThresholdsToManagement().withDecay(120, 25).build();
}
}
// NOTE (AI): Photon runs on the Bukkit PlayerItemHeldEvent, which fires from the same held-item packet the C09 carries.Flags client-held slot changes that repeat the same slot without a server-side slot change in between.
Two WActions: one on WrapperPlayClientHeldItemChange, one on WrapperPlayServerHeldItemChange. When the server sends a slot change, didServerSlot is set and the next client change is accepted as the echo. Otherwise a client change that equals the last slot increments a buffer that flags at 6 and decays by 3 on a legitimate change. This catches clients that spam the held-item packet to desync the server's hand tracking.
// ===== FILE: funkemunky-KauriV3, Anticheat/src/main/java/dev/brighten/ac/check/impl/packet/badpackets/SlotChange.java =====
package dev.brighten.ac.check.impl.packet.badpackets;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerHeldItemChange;
import dev.brighten.ac.api.check.CheckType;
import dev.brighten.ac.check.Check;
import dev.brighten.ac.check.CheckData;
import dev.brighten.ac.check.WAction;
import dev.brighten.ac.data.APlayer;
import dev.brighten.ac.utils.annotation.Bind;
@CheckData(name = "SlotChange", checkId = "slotchange", description = "Detects invalid slot changes.", type = CheckType.BADPACKETS)
public class SlotChange extends Check {
public SlotChange(APlayer player) {
super(player);
}
private boolean didServerSlot = false;
private int lastSlot = -1, buffer;
private static final int BUFFER_MAX = 6;
@Bind
WAction<WrapperPlayClientHeldItemChange> heldItemSlot = packet -> {
if(didServerSlot) {
didServerSlot = false;
lastSlot = packet.getSlot();
return;
}
if(packet.getSlot() == lastSlot) {
if(++buffer > BUFFER_MAX) {
flag("Bad slot change detected at index %i", packet.getSlot());
}
debug("Invalid slot change detected! Slot: %i, buffer: %i/%i", packet.getSlot(), buffer, BUFFER_MAX);
} else if(buffer > 0) {
buffer = Math.max(buffer - 3, 0);
}
};
@Bind
WAction<WrapperPlayServerHeldItemChange> serverSlot = packet -> {
didServerSlot = true;
};
}
// NOTE (AI): The check listens to both the client and server held-item packets so a server-side forced switch is not mistaken for a repeated client change.Fails any held item change whose slot is outside the hotbar range 0 to 8.
handleReceivePlayPacket matches HELD_ITEM_CHANGE, decodes WrapperPlayClientHeldItemChange and fails when the slot is below 0 or above 8. The comment notes those values are physically impossible to send from the vanilla client.
// ===== FILE: amnoah-BetterAnticheat, core/src/main/java/better/anticheat/core/check/impl/misc/ImpossibleSlotCheck.java =====
package better.anticheat.core.check.impl.misc;
import better.anticheat.core.BetterAnticheat;
import better.anticheat.core.check.Check;
import better.anticheat.core.check.CheckInfo;
import better.anticheat.core.player.Player;
import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
/**
* This check looks for impossible slot values.
*/
@CheckInfo(name = "ImpossibleSlot", category = "misc")
public class ImpossibleSlotCheck extends Check {
public ImpossibleSlotCheck(BetterAnticheat plugin, Player player) {
super(plugin, player);
}
@Override
public void handleReceivePlayPacket(PacketPlayReceiveEvent event) {
/*
* Minecraft's hotbar slots are numbered 0-8 internally. Any value outside of these is physically impossible to
* send.
*/
if (event.getPacketType() != PacketType.Play.Client.HELD_ITEM_CHANGE) return;
final WrapperPlayClientHeldItemChange wrapper = new WrapperPlayClientHeldItemChange(event);
final int slot = wrapper.getSlot();
if (slot < 0 || slot > 8) fail();
}
}
// NOTE (AI): The minimal form of the held-slot validity idea; no timing or inventory state is consulted.Cancels held item change packets carrying out-of-bounds slot ids before they reach the server.
PreViaPacketReceiveListener on HELD_ITEM_CHANGE: decodes the slot and, if it is greater than 8 or below 0, flags with the slot in the verbose data, cancels the packet and calls onPacketCancel so the inventory state stays coherent.
// ===== FILE: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsY.java =====
package ac.grim.grimac.checks.impl.badpackets;
import ac.grim.grimac.api.storage.verbose.Verbose;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.PreViaPacketReceiveListener;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;
@CheckData(name = "BadPacketsY", stableKey = "grim.badpackets.oob_slot", description = "Sent out of bounds slot id")
public class BadPacketsY extends Check implements PreViaPacketReceiveListener {
private static final Verbose V = Verbose.of("slot={sint}");
public BadPacketsY(GrimPlayer player) {
super(player);
}
@Override
public void onPreViaPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) {
final int slot = new WrapperPlayClientHeldItemChange(event).getSlot();
if (slot > 8 || slot < 0) { // ban
if (flag(V.write(verbose()).sint(slot)) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
}
}
}
}
// NOTE (AI): The pre-Via listener runs before protocol translation, which matters for ViaVersion rewrites of the held-item packet.Flags slot changes made within one tick of starting and stopping a block break, the autotool signature.
ClassicHeuristic subscribed to movement packets, which tick counters, BLOCK_DIG for break start and stop, and HELD_ITEM_SLOT_IN. If a slot change arrives within one tick after START_DESTROY_BLOCK and the player stops digging within one tick, the heuristic marks it suspicious and, when the switched slot equals the last one, accumulates a violation that flags at 4. Repeated offenses apply the DMG_LIGHT attack nerf.
// ===== FILE: intave-intave, src/main/java/de/jpx3/intave/check/combat/heuristics/other/ToolSwitchHeuristic.java =====
/*
* Copyright 2026 Intave
*
* This software is licensed under the PolyForm Perimeter License 1.0.0.
* You may use this software for any purpose, except for providing to
* others any product that competes with the software.
*
* A copy of the license is available at:
* https://polyformproject.org/licenses/perimeter/1.0.0/
*/
package de.jpx3.intave.check.combat.heuristics.other;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers;
import de.jpx3.intave.check.combat.Heuristics;
import de.jpx3.intave.check.combat.heuristics.ClassicHeuristic;
import de.jpx3.intave.check.combat.heuristics.HeuristicsClassicType;
import de.jpx3.intave.module.linker.packet.ListenerPriority;
import de.jpx3.intave.module.linker.packet.PacketId;
import de.jpx3.intave.module.linker.packet.PacketSubscription;
import de.jpx3.intave.module.mitigate.AttackNerfStrategy;
import de.jpx3.intave.user.User;
import de.jpx3.intave.user.meta.CheckCustomMetadata;
import org.bukkit.entity.Player;
import static de.jpx3.intave.module.linker.packet.PacketId.Client.*;
public class ToolSwitchHeuristic extends ClassicHeuristic<ToolSwitchHeuristic.ToolSwitchHeuristicMeta> {
public ToolSwitchHeuristic(Heuristics parentCheck) {
super(parentCheck, HeuristicsClassicType.TOOL_SWITCH, ToolSwitchHeuristicMeta.class);
}
@PacketSubscription(
priority = ListenerPriority.HIGH,
packetsIn = {
POSITION, POSITION_LOOK, LOOK, FLYING, VEHICLE_MOVE
}
)
public void receiveMovementPacket(PacketEvent event) {
Player player = event.getPlayer();
ToolSwitchHeuristicMeta meta = metaOf(player);
meta.ticksSinceLastBreak++;
meta.ticksSinceLastStop++;
}
@PacketSubscription(
priority = ListenerPriority.HIGH,
packetsIn = {
PacketId.Client.BLOCK_DIG
}
)
public void receiveBlockBreakAction(PacketEvent event) {
Player player = event.getPlayer();
PacketContainer packet = event.getPacket();
EnumWrappers.PlayerDigType digType = packet.getPlayerDigTypes().read(0);
ToolSwitchHeuristicMeta meta = metaOf(player);
// Update breaking state ticks
if (digType == EnumWrappers.PlayerDigType.START_DESTROY_BLOCK) {
meta.ticksSinceLastBreak = 0;
} else if (digType == EnumWrappers.PlayerDigType.STOP_DESTROY_BLOCK) {
meta.ticksSinceLastStop = 0;
}
}
@PacketSubscription(
priority = ListenerPriority.HIGH,
packetsIn = {
PacketId.Client.HELD_ITEM_SLOT_IN
}
)
public void receiveHeldItemSlotChange(PacketEvent event) {
Player player = event.getPlayer();
PacketContainer packet = event.getPacket();
User user = userOf(player);
int currentSlot = user.meta().inventory().handSlot();
Integer slot = packet.getIntegers().read(0);
ToolSwitchHeuristicMeta meta = metaOf(player);
// If a block break was recently started something is suspicious
if (meta.ticksSinceLastBreak <= 1) {
meta.suspiciousBreakStart = true;
meta.lastSlot = currentSlot;
}
if (meta.suspiciousBreakStart && meta.ticksSinceLastStop <= 1 && meta.lastSlot == slot) {
meta.suspiciousBreakStart = false;
// Violate if buffer is too high
if (++meta.vl > 3) {
flag(
user,
"sent suspicious slot packets while breaking blocks",
meta.ticksSinceLastStop + " ticks since stopping"
);
// Apply damage cancel if this happens too often
if (++meta.cancelVl > 1) {
user.nerf(AttackNerfStrategy.DMG_LIGHT, "205");
}
meta.vl = 0;
}
}
}
public static class ToolSwitchHeuristicMeta extends CheckCustomMetadata {
public int ticksSinceLastBreak;
public int ticksSinceLastStop;
public int lastSlot;
public boolean suspiciousBreakStart;
public int vl;
public int cancelVl;
}
}
// NOTE (AI): The heuristic counters advance on every movement packet, which is how the one-tick window is measured.Related Packets
Wiki Cross-Reference
Wire field is a 2-byte short slot 0-8 (readShort/writeShort), stored as int in the 1.8.9 class.
PLAY serverbound 0x09; server checks 0-8 then sets currentItem and rebroadcasts the held equipment.
Vanilla sends on scroll; modules spoof it for silent switching without moving the visible hotbar.
MCP 1.8.9 C09PacketHeldItemChange implements Packet
1.8.9 callers: PlayerControllerMP.syncCurrentPlayItem sends new C09PacketHeldItemChange (line 386): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/client/multiplayer/PlayerControllerMP.java
Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.
Vanilla Internals
Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.
Module Analyses Using C09PacketHeldItemChange
Full source walkthroughs of the modules and anti-cheats that use this packet.