Search in sources :

Example 6 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project Wurst7 by Wurst-Imperium.

the class ExtraElytraHack method sendStartStopPacket.

private void sendStartStopPacket() {
    ClientCommandC2SPacket packet = new ClientCommandC2SPacket(MC.player, ClientCommandC2SPacket.Mode.START_FALL_FLYING);
    MC.player.networkHandler.sendPacket(packet);
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket)

Example 7 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project Wurst7 by Wurst-Imperium.

the class SneakHack method sendSneakPacket.

private void sendSneakPacket(Mode mode) {
    ClientPlayerEntity player = MC.player;
    ClientCommandC2SPacket packet = new ClientCommandC2SPacket(player, mode);
    player.networkHandler.sendPacket(packet);
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 8 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class EntityDesync method entityEvent.

@EventTarget
public void entityEvent(EventReceivePacket event) {
    if (event.getPacket() instanceof ClientCommandC2SPacket) {
        ClientCommandC2SPacket packet = (ClientCommandC2SPacket) event.getPacket();
        if (packet.getMode() == Mode.PRESS_SHIFT_KEY) {
            ChatUtils.tellPlayer("Dismounted");
            this.toggle();
        }
    }
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) EventTarget(dev.hypnotic.event.EventTarget)

Example 9 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project JexClient by DustinRepo.

the class MixinClientPlayerEntity method tickMovePre.

@Inject(method = "tickMovement", at = @At("HEAD"), cancellable = true)
public void tickMovePre(CallbackInfo ci) {
    new EventPlayerUpdates(EventPlayerUpdates.Mode.PRE).run();
    ++this.ticksSinceSprintingChanged;
    if (this.ticksLeftToDoubleTapSprint > 0) {
        --this.ticksLeftToDoubleTapSprint;
    }
    this.updateNausea();
    boolean bl = this.input.jumping;
    boolean bl2 = this.input.sneaking;
    boolean bl3 = this.isWalking();
    this.inSneakingPose = !this.getAbilities().flying && !this.isSwimming() && this.wouldPoseNotCollide(EntityPose.CROUCHING) && (this.isSneaking() || !this.isSleeping() && !this.wouldPoseNotCollide(EntityPose.STANDING));
    this.input.tick(this.shouldSlowDown());
    this.client.getTutorialManager().onMovement(this.input);
    if ((this.isUsingItem() || AutoEat.isEating) && !this.hasVehicle()) {
        EventSlowdown eventSlowdown = new EventSlowdown(EventSlowdown.State.USE_ITEM).run();
        if (!eventSlowdown.isCancelled()) {
            Input var10000 = this.input;
            var10000.movementSideways *= 0.2F;
            var10000 = this.input;
            var10000.movementForward *= 0.2F;
            this.ticksLeftToDoubleTapSprint = 0;
        }
    }
    boolean bl4 = false;
    if (this.ticksToNextAutojump > 0) {
        --this.ticksToNextAutojump;
        bl4 = true;
        this.input.jumping = true;
    }
    if (!this.noClip) {
        this.pushOutOfBlocks(this.getX() - (double) this.getWidth() * 0.35D, this.getZ() + (double) this.getWidth() * 0.35D);
        this.pushOutOfBlocks(this.getX() - (double) this.getWidth() * 0.35D, this.getZ() - (double) this.getWidth() * 0.35D);
        this.pushOutOfBlocks(this.getX() + (double) this.getWidth() * 0.35D, this.getZ() - (double) this.getWidth() * 0.35D);
        this.pushOutOfBlocks(this.getX() + (double) this.getWidth() * 0.35D, this.getZ() + (double) this.getWidth() * 0.35D);
    }
    if (bl2) {
        this.ticksLeftToDoubleTapSprint = 0;
    }
    boolean bl5 = (float) this.getHungerManager().getFoodLevel() > 6.0F || this.getAbilities().allowFlying;
    if ((this.onGround || this.isSubmergedInWater()) && !bl2 && !bl3 && this.isWalking() && !this.isSprinting() && bl5 && !this.isUsingItem() && !this.hasStatusEffect(StatusEffects.BLINDNESS)) {
        if (this.ticksLeftToDoubleTapSprint <= 0 && !this.client.options.sprintKey.isPressed()) {
            this.ticksLeftToDoubleTapSprint = 7;
        } else {
            this.setSprinting(true);
        }
    }
    if (!this.isSprinting() && (!this.isTouchingWater() || this.isSubmergedInWater()) && this.isWalking() && bl5 && !this.isUsingItem() && !this.hasStatusEffect(StatusEffects.BLINDNESS) && this.client.options.sprintKey.isPressed()) {
        this.setSprinting(true);
    }
    boolean bl8;
    if (this.isSprinting()) {
        bl8 = !this.input.hasForwardMovement() || !bl5;
        boolean bl7 = bl8 || this.horizontalCollision || this.isTouchingWater() && !this.isSubmergedInWater();
        if (this.isSwimming()) {
            if (!this.onGround && !this.input.sneaking && bl8 || !this.isTouchingWater()) {
                this.setSprinting(false);
            }
        } else if (bl7) {
            this.setSprinting(false);
        }
    }
    bl8 = false;
    if (this.getAbilities().allowFlying) {
        if (this.client.interactionManager.isFlyingLocked()) {
            if (!this.getAbilities().flying) {
                this.getAbilities().flying = true;
                bl8 = true;
                this.sendAbilitiesUpdate();
            }
        } else if (!bl && this.input.jumping && !bl4) {
            if (this.abilityResyncCountdown == 0) {
                this.abilityResyncCountdown = 7;
            } else if (!this.isSwimming()) {
                this.getAbilities().flying = !this.getAbilities().flying;
                bl8 = true;
                this.sendAbilitiesUpdate();
                this.abilityResyncCountdown = 0;
            }
        }
    }
    if (this.input.jumping && !bl8 && !bl && !this.getAbilities().flying && !this.hasVehicle() && !this.isClimbing()) {
        ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST);
        if (itemStack.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack) && this.checkFallFlying()) {
            this.networkHandler.sendPacket(new ClientCommandC2SPacket(this, ClientCommandC2SPacket.Mode.START_FALL_FLYING));
        }
    }
    this.falling = this.isFallFlying();
    if (this.isTouchingWater() && this.input.sneaking && this.shouldSwimInFluids()) {
        this.knockDownwards();
    }
    int j;
    if (this.isSubmergedIn(FluidTags.WATER)) {
        j = this.isSpectator() ? 10 : 1;
        this.underwaterVisibilityTicks = MathHelper.clamp(this.underwaterVisibilityTicks + j, 0, 600);
    } else if (this.underwaterVisibilityTicks > 0) {
        this.isSubmergedIn(FluidTags.WATER);
        this.underwaterVisibilityTicks = MathHelper.clamp(this.underwaterVisibilityTicks - 10, 0, 600);
    }
    if (this.getAbilities().flying && this.isCamera()) {
        j = 0;
        if (this.input.sneaking) {
            --j;
        }
        if (this.input.jumping) {
            ++j;
        }
        if (j != 0) {
            this.setVelocity(this.getVelocity().add(0.0D, (double) ((float) j * this.getAbilities().getFlySpeed() * 3.0F), 0.0D));
        }
    }
    if (this.hasJumpingMount()) {
        JumpingMount jumpingMount = (JumpingMount) this.getVehicle();
        if (this.field_3938 < 0) {
            ++this.field_3938;
            if (this.field_3938 == 0) {
                this.mountJumpStrength = 0.0F;
            }
        }
        if (bl && !this.input.jumping) {
            this.field_3938 = -10;
            jumpingMount.setJumpStrength(MathHelper.floor(this.getMountJumpStrength() * 100.0F));
            this.startRidingJump();
        } else if (!bl && this.input.jumping) {
            this.field_3938 = 0;
            this.mountJumpStrength = 0.0F;
        } else if (bl) {
            ++this.field_3938;
            if (this.field_3938 < 10) {
                this.mountJumpStrength = (float) this.field_3938 * 0.1F;
            } else {
                this.mountJumpStrength = 0.8F + 2.0F / (float) (this.field_3938 - 9) * 0.1F;
            }
        }
    } else {
        this.mountJumpStrength = 0.0F;
    }
    super.tickMovement();
    if (this.onGround && this.getAbilities().flying && !this.client.interactionManager.isFlyingLocked()) {
        this.getAbilities().flying = false;
        this.sendAbilitiesUpdate();
    }
    new EventPlayerUpdates(EventPlayerUpdates.Mode.POST).run();
    ci.cancel();
}
Also used : Input(net.minecraft.client.input.Input) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 10 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project Client by MatHax.

the class AutoMountBypassDupe method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
        toggle();
        mc.player.closeHandledScreen();
        return;
    }
    if (timer <= 0)
        timer = delay.get();
    else {
        timer--;
        return;
    }
    int slots = getInvSize(mc.player.getVehicle());
    for (Entity e : mc.world.getEntities()) {
        if (e.distanceTo(mc.player) < 5 && e instanceof AbstractDonkeyEntity && ((AbstractDonkeyEntity) e).isTame())
            entity = (AbstractDonkeyEntity) e;
    }
    if (entity == null)
        return;
    if (sneak) {
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
        mc.player.setSneaking(false);
        sneak = false;
        return;
    }
    if (slots == -1) {
        if (entity.hasChest() || mc.player.getMainHandStack().getItem() == Items.CHEST) {
            mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
        } else {
            int slot = InvUtils.findInHotbar(Items.CHEST).slot();
            if (!InvUtils.swap(slot, true)) {
                error("Cannot find chest in your hotbar, disabling...");
                toggle();
            }
        }
    } else if (slots == 0) {
        if (isDupeTime()) {
            if (!slotsToThrow.isEmpty()) {
                if (faceDown.get())
                    Rotations.rotate(mc.player.getYaw(), 90, 99, this::drop);
                else
                    drop();
            } else {
                for (int i = 2; i < getDupeSize() + 1; i++) {
                    slotsToThrow.add(i);
                }
            }
        } else {
            mc.player.closeHandledScreen();
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
            mc.player.setSneaking(true);
            sneak = true;
        }
    } else if (!(mc.currentScreen instanceof HorseScreen))
        mc.player.openRidingInventory();
    else if (slots > 0) {
        if (slotsToMove.isEmpty()) {
            boolean empty = true;
            for (int i = 2; i <= slots; i++) {
                if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                    empty = false;
                    break;
                }
            }
            if (empty) {
                for (int i = slots + 2; i < mc.player.currentScreenHandler.getStacks().size(); i++) {
                    if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                        if (mc.player.currentScreenHandler.getSlot(i).getStack().getItem() == Items.CHEST)
                            continue;
                        if (!(mc.player.currentScreenHandler.getSlot(i).getStack().getItem() instanceof BlockItem && ((BlockItem) mc.player.currentScreenHandler.getSlot(i).getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && shulkersOnly.get())
                            continue;
                        slotsToMove.add(i);
                        if (slotsToMove.size() >= slots)
                            break;
                    }
                }
            } else {
                noCancel = true;
                mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
                noCancel = false;
                return;
            }
        }
        if (!slotsToMove.isEmpty()) {
            for (int i : slotsToMove) {
                InvUtils.quickMove().from(i).to(0);
            }
            slotsToMove.clear();
        }
    }
}
Also used : AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) Entity(net.minecraft.entity.Entity) LlamaEntity(net.minecraft.entity.passive.LlamaEntity) HorseScreen(net.minecraft.client.gui.screen.ingame.HorseScreen) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

ClientCommandC2SPacket (net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket)31 Vec3d (net.minecraft.util.math.Vec3d)9 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)8 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)5 Subscribe (com.google.common.eventbus.Subscribe)4 Entity (net.minecraft.entity.Entity)4 BlockItem (net.minecraft.item.BlockItem)4 Block (net.minecraft.block.Block)3 HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)3 BlockHitResult (net.minecraft.util.hit.BlockHitResult)3 EventTarget (dev.hypnotic.event.EventTarget)2 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)2 HorseScreen (net.minecraft.client.gui.screen.ingame.HorseScreen)2 InventoryScreen (net.minecraft.client.gui.screen.ingame.InventoryScreen)2 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)2 PositionedSoundInstance (net.minecraft.client.sound.PositionedSoundInstance)2 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)2 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)2 Mode (net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode)2 Hand (net.minecraft.util.Hand)2