use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project meteor-rejects by AntiCope.
the class AutoExtinguish method extinguishFire.
private void extinguishFire(BlockPos blockPos) {
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, net.minecraft.util.math.Direction.UP));
mc.player.swingHand(Hand.MAIN_HAND);
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, net.minecraft.util.math.Direction.UP));
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project BleachHack by BleachDrinker420.
the class AutoTotem method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (holdingTotem && mc.player.getOffHandStack().getItem() != Items.TOTEM_OF_UNDYING) {
delay = Math.max(getSetting(2).asSlider().getValueInt(), delay);
}
holdingTotem = mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING;
if (delay > 0) {
delay--;
return;
}
if (holdingTotem || (!mc.player.getOffHandStack().isEmpty() && !getSetting(0).asToggle().getState())) {
return;
}
// Cancel at all non-survival-inventory containers
if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) {
for (int i = 9; i < 45; i++) {
if (mc.player.getInventory().getStack(i >= 36 ? i - 36 : i).getItem() == Items.TOTEM_OF_UNDYING) {
boolean itemInOffhand = !mc.player.getOffHandStack().isEmpty();
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 45, 0, SlotActionType.PICKUP, mc.player);
if (itemInOffhand)
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
delay = getSetting(1).asSlider().getValueInt();
return;
}
}
} else {
// If the player is in another inventory, atleast check the hotbar for anything to swap
for (int i = 0; i < 9; i++) {
if (mc.player.getInventory().getStack(i).getItem() == Items.TOTEM_OF_UNDYING) {
if (i != mc.player.getInventory().selectedSlot) {
mc.player.getInventory().selectedSlot = i;
mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(i));
}
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
delay = getSetting(1).asSlider().getValueInt();
return;
}
}
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project BleachHack by BleachDrinker420.
the class BowBot method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (!(mc.player.getMainHandStack().getItem() instanceof RangedWeaponItem) || !mc.player.isUsingItem())
return;
if (getSetting(0).asToggle().getState()) {
if (mc.player.getMainHandStack().getItem() == Items.CROSSBOW && (float) mc.player.getItemUseTime() / (float) CrossbowItem.getPullTime(mc.player.getMainHandStack()) >= 1f) {
mc.player.stopUsingItem();
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
mc.interactionManager.interactItem(mc.player, mc.world, Hand.MAIN_HAND);
} else if (mc.player.getMainHandStack().getItem() == Items.BOW && BowItem.getPullProgress(mc.player.getItemUseTime()) >= getSetting(0).asToggle().getChild(0).asSlider().getValueFloat()) {
mc.player.stopUsingItem();
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
}
}
// Credit: https://github.com/Wurst-Imperium/Wurst7/blob/master/src/main/java/net/wurstclient/hacks/BowAimbotHack.java
SettingToggle aimToggle = getSetting(1).asToggle();
if (aimToggle.getState()) {
LivingEntity target = Streams.stream(mc.world.getEntities()).filter(e -> EntityUtils.isAttackable(e, true) && (!aimToggle.getChild(3).asToggle().getState() || mc.player.canSee(e))).filter(e -> (aimToggle.getChild(0).asToggle().getState() && EntityUtils.isPlayer(e)) || (aimToggle.getChild(1).asToggle().getState() && EntityUtils.isMob(e)) || (aimToggle.getChild(2).asToggle().getState() && EntityUtils.isAnimal(e))).sorted(Comparator.comparing(mc.player::distanceTo)).map(e -> (LivingEntity) e).findFirst().orElse(null);
if (target == null)
return;
// set velocity
float velocity = (72000 - mc.player.getItemUseTimeLeft()) / 20F;
velocity = Math.min(1f, (velocity * velocity + velocity * 2) / 3);
// set position to aim at
Vec3d newTargetVec = target.getPos().add(target.getVelocity());
double d = mc.player.getEyePos().distanceTo(target.getBoundingBox().offset(target.getVelocity()).getCenter());
double x = newTargetVec.x + (newTargetVec.x - target.getX()) * d - mc.player.getX();
double y = newTargetVec.y + (newTargetVec.y - target.getY()) * d + target.getHeight() * 0.5 - mc.player.getY() - mc.player.getEyeHeight(mc.player.getPose());
double z = newTargetVec.z + (newTargetVec.z - target.getZ()) * d - mc.player.getZ();
// set yaw
mc.player.setYaw((float) Math.toDegrees(Math.atan2(z, x)) - 90);
// calculate needed pitch
double hDistance = Math.sqrt(x * x + z * z);
double hDistanceSq = hDistance * hDistance;
float g = 0.006F;
float velocitySq = velocity * velocity;
float velocityPow4 = velocitySq * velocitySq;
float neededPitch = (float) -Math.toDegrees(Math.atan((velocitySq - Math.sqrt(velocityPow4 - g * (g * hDistanceSq + 2 * y * velocitySq))) / (g * hDistance)));
// set pitch
if (Float.isNaN(neededPitch)) {
WorldUtils.facePos(target.getX(), target.getY() + target.getHeight() / 2, target.getZ());
} else {
mc.player.setPitch(neededPitch);
}
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.
the class InstaAutoCity method doMine.
private void doMine() {
--delayLeft;
if (!mining) {
if (rotate.get())
Rotations.rotate(Rotations.getYaw(mineTarget), Rotations.getPitch(mineTarget));
if (swing.get())
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
else
mc.player.swingHand(Hand.MAIN_HAND);
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, mineTarget, direction));
mining = true;
}
if (delayLeft <= 0) {
if (rotate.get())
Rotations.rotate(Rotations.getYaw(mineTarget), Rotations.getPitch(mineTarget));
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, mineTarget, direction));
delayLeft = delay.get();
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.
the class SelfProtect method sendStopPackets.
private void sendStopPackets(BlockPos blockPos) {
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, blockPos, Direction.UP));
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
}
Aggregations