Search in sources :

Example 1 with ClientPlayerInteractionManager

use of net.minecraft.client.network.ClientPlayerInteractionManager in project EdenClient by HahaOO7.

the class AutoSheer method onTick.

private void onTick(ClientPlayerEntity player) {
    if (!enabled)
        return;
    ClientPlayerInteractionManager interactionManager = MinecraftClient.getInstance().interactionManager;
    if (interactionManager == null)
        return;
    Vec3d pos = player.getPos();
    PlayerInventory inv = player.getInventory();
    Hand shearHand;
    if (inv.getMainHandStack().getItem() == Items.SHEARS)
        shearHand = Hand.MAIN_HAND;
    else if (inv.offHand.get(0).getItem() == Items.SHEARS)
        shearHand = Hand.OFF_HAND;
    else
        return;
    if (shearHand == Hand.MAIN_HAND) {
        player.clientWorld.getEntitiesByClass(SheepEntity.class, player.getBoundingBox().expand(5), SheepEntity::isShearable).forEach(sheep -> {
            if (!sheep.isShearable())
                return;
            if (sheep.getPos().squaredDistanceTo(pos) < 25) {
                interactionManager.interactEntity(player, sheep, Hand.MAIN_HAND);
            }
        });
    } else {
        player.clientWorld.getEntitiesByClass(SheepEntity.class, player.getBoundingBox().expand(5), SheepEntity::isShearable).forEach(sheep -> {
            if (!sheep.isShearable())
                return;
            if (sheep.getPos().squaredDistanceTo(pos) < 25) {
                interactionManager.interactEntity(player, sheep, Hand.MAIN_HAND);
                interactionManager.interactEntity(player, sheep, Hand.OFF_HAND);
            }
        });
    }
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) SheepEntity(net.minecraft.entity.passive.SheepEntity) PlayerInventory(net.minecraft.entity.player.PlayerInventory) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with ClientPlayerInteractionManager

use of net.minecraft.client.network.ClientPlayerInteractionManager in project KiwiClient by TangyKiwi.

the class AutoTool method onTick.

@Subscribe
public void onTick(TickEvent event) {
    ClientPlayerInteractionManager interactionManager = mc.interactionManager;
    if (prevState == true && !interactionManager.isBreakingBlock()) {
        mc.player.getInventory().selectedSlot = slot;
    } else if (prevState != interactionManager.isBreakingBlock()) {
        slot = mc.player.getInventory().selectedSlot;
    }
    if (interactionManager.isBreakingBlock()) {
        BlockPos blockPos = ((ClientPlayerInteractionManagerAccessor) interactionManager).getCurrentBreakingPos();
        BlockState blockState = mc.world.getBlockState(blockPos);
        swap(blockState);
    }
    prevState = interactionManager.isBreakingBlock();
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) ClientPlayerInteractionManagerAccessor(com.tangykiwi.kiwiclient.mixin.ClientPlayerInteractionManagerAccessor) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with ClientPlayerInteractionManager

use of net.minecraft.client.network.ClientPlayerInteractionManager in project KiwiClient by TangyKiwi.

the class KiwiClient method onInitialize.

@Override
public void onInitialize() {
    mc = MinecraftClient.getInstance();
    Utils.mc = mc;
    CustomMatrix.begin(new MatrixStack());
    moduleManager = new ModuleManager();
    moduleManager.init();
    commandManager = new CommandManager();
    commandManager.init();
    discordRPC = new DiscordRP();
    discordRPC.start();
    EChestMemory eChestMemory = new EChestMemory();
    TickRate tickRate = new TickRate();
    eventBus.register(eChestMemory);
    eventBus.register(tickRate);
    eventBus.register(moduleManager);
    ClickGui.clickGui.initWindows();
    FabricLoader.getInstance().getModContainer("kiwiclient").ifPresent(modContainer -> {
        ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("kiwiclient:kiwitweaks"), "resourcepacks/kiwitweaks", modContainer, true);
    });
    UseItemCallback.EVENT.register((player, world, hand) -> {
        MinecraftClient mc = MinecraftClient.getInstance();
        ClientPlayerInteractionManager interactionManager = mc.interactionManager;
        if (mc.mouse.wasRightButtonClicked() && moduleManager.getModule(ArmorSwap.class).isEnabled()) {
            ItemStack stack = player.getMainHandStack();
            int currentItemIndex = player.getInventory().main.indexOf(stack);
            EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
            int armorIndexSlot = determineIndex(equipmentSlot);
            if (hand == Hand.MAIN_HAND && armorIndexSlot != -1) {
                SoundEvent sound = determineSound(stack.getItem());
                player.playSound(sound, 1.0F, 1.0F);
                interactionManager.clickSlot(player.playerScreenHandler.syncId, armorIndexSlot, currentItemIndex, SlotActionType.SWAP, player);
                return TypedActionResult.success(stack);
            }
        }
        return TypedActionResult.pass(ItemStack.EMPTY);
    });
    KeyBindingHelper.registerKeyBinding(zoomKey);
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) MatrixStack(net.minecraft.client.util.math.MatrixStack) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ModuleManager(com.tangykiwi.kiwiclient.modules.ModuleManager) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) SoundEvent(net.minecraft.sound.SoundEvent) CommandManager(com.tangykiwi.kiwiclient.command.CommandManager) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ClientPlayerInteractionManager

use of net.minecraft.client.network.ClientPlayerInteractionManager in project EdenClient by HahaOO7.

the class Nuker method onTick.

private void onTick(ClientPlayerEntity player) {
    if (!enabled)
        return;
    ClientPlayNetworkHandler nh = MinecraftClient.getInstance().getNetworkHandler();
    BlockState air = Blocks.AIR.getDefaultState();
    ClientPlayerInteractionManager im = MinecraftClient.getInstance().interactionManager;
    if (im == null)
        return;
    if (nh == null)
        return;
    if (limit > 1) {
        List<BlockPos> minableBlocks = getInstantMinableBlocksInRange(player);
        if (!minableBlocks.isEmpty()) {
            target = null;
            minableBlocks.forEach(p -> {
                nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
                nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
                player.clientWorld.setBlockState(p, air);
            });
            nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
            return;
        }
    }
    if (target == null || Vec3d.ofCenter(target).distanceTo(player.getEyePos()) > distance)
        findTarget(player);
    if (target == null)
        return;
    Direction dir = getHitDirectionForBlock(player, target);
    if (im.updateBlockBreakingProgress(target, dir))
        nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
    else
        target = null;
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) BlockState(net.minecraft.block.BlockState) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler)

Aggregations

ClientPlayerInteractionManager (net.minecraft.client.network.ClientPlayerInteractionManager)4 BlockState (net.minecraft.block.BlockState)2 Subscribe (com.google.common.eventbus.Subscribe)1 CommandManager (com.tangykiwi.kiwiclient.command.CommandManager)1 ClientPlayerInteractionManagerAccessor (com.tangykiwi.kiwiclient.mixin.ClientPlayerInteractionManagerAccessor)1 ModuleManager (com.tangykiwi.kiwiclient.modules.ModuleManager)1 EChestMemory (com.tangykiwi.kiwiclient.util.tooltip.EChestMemory)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 EquipmentSlot (net.minecraft.entity.EquipmentSlot)1 SheepEntity (net.minecraft.entity.passive.SheepEntity)1 PlayerInventory (net.minecraft.entity.player.PlayerInventory)1 ItemStack (net.minecraft.item.ItemStack)1 HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)1 PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)1 SoundEvent (net.minecraft.sound.SoundEvent)1 Hand (net.minecraft.util.Hand)1 Identifier (net.minecraft.util.Identifier)1 BlockPos (net.minecraft.util.math.BlockPos)1