Search in sources :

Example 1 with PlayerMoveC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket in project BleachHack by BleachDrinker420.

the class PacketFly method onSendPacket.

@BleachSubscribe
public void onSendPacket(EventPacket.Send event) {
    if (event.getPacket() instanceof PlayerMoveC2SPacket.LookAndOnGround) {
        event.setCancelled(true);
        return;
    }
    if (event.getPacket() instanceof PlayerMoveC2SPacket.Full) {
        event.setCancelled(true);
        PlayerMoveC2SPacket p = (PlayerMoveC2SPacket) event.getPacket();
        mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(p.getX(0), p.getY(0), p.getZ(0), p.isOnGround()));
    }
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with PlayerMoveC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket in project BleachHack by BleachDrinker420.

the class Solidify method onSendPacket.

@BleachSubscribe
public void onSendPacket(EventPacket.Send event) {
    if (getSetting(7).asToggle().getState()) {
        if (event.getPacket() instanceof VehicleMoveC2SPacket) {
            VehicleMoveC2SPacket packet = (VehicleMoveC2SPacket) event.getPacket();
            if (!mc.world.getChunkManager().isChunkLoaded((int) packet.getX() >> 4, (int) packet.getZ() >> 4)) {
                mc.player.getVehicle().updatePosition(mc.player.getVehicle().prevX, mc.player.getVehicle().prevY, mc.player.getVehicle().prevZ);
                event.setCancelled(true);
            }
        } else if (event.getPacket() instanceof PlayerMoveC2SPacket) {
            PlayerMoveC2SPacket packet = (PlayerMoveC2SPacket) event.getPacket();
            if (!mc.world.getChunkManager().isChunkLoaded((int) packet.getX(mc.player.getX()) >> 4, (int) packet.getZ(mc.player.getZ()) >> 4)) {
                event.setCancelled(true);
            }
        }
    }
}
Also used : VehicleMoveC2SPacket(net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with PlayerMoveC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket in project BleachHack by BleachDrinker420.

the class EntityControl method onSendPacket.

@BleachSubscribe
public void onSendPacket(EventPacket.Send event) {
    if (getSetting(6).asToggle().getState()) {
        if (event.getPacket() instanceof VehicleMoveC2SPacket) {
            VehicleMoveC2SPacket packet = (VehicleMoveC2SPacket) event.getPacket();
            packet.yaw = getSetting(6).asToggle().getChild(0).asSlider().getValueFloat();
            packet.pitch = getSetting(6).asToggle().getChild(1).asSlider().getValueFloat();
        } else if (event.getPacket() instanceof PlayerMoveC2SPacket && mc.player.hasVehicle() && getSetting(6).asToggle().getChild(2).asToggle().getState()) {
            PlayerMoveC2SPacket packet = (PlayerMoveC2SPacket) event.getPacket();
            packet.yaw = getSetting(6).asToggle().getChild(0).asSlider().getValueFloat();
            packet.pitch = getSetting(6).asToggle().getChild(1).asSlider().getValueFloat();
        }
    }
    if (getSetting(7).asToggle().getState() && event.getPacket() instanceof VehicleMoveC2SPacket && mc.player.hasVehicle()) {
        mc.interactionManager.interactEntity(mc.player, mc.player.getVehicle(), Hand.MAIN_HAND);
    }
}
Also used : VehicleMoveC2SPacket(net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with PlayerMoveC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket in project meteor-client by MeteorDevelopment.

the class Flight method onSendPacket.

/**
 * @see ServerPlayNetworkHandler#onPlayerMove(PlayerMoveC2SPacket)
 */
@EventHandler
private void onSendPacket(PacketEvent.Send event) {
    if (!(event.packet instanceof PlayerMoveC2SPacket) || antiKickMode.get() != AntiKickMode.Packet)
        return;
    PlayerMoveC2SPacket packet = (PlayerMoveC2SPacket) event.packet;
    long currentTime = System.currentTimeMillis();
    double currentY = packet.getY(Double.MAX_VALUE);
    if (currentY != Double.MAX_VALUE) {
        // maximum time we can be "floating" is 80 ticks, so 4 seconds max
        if (currentTime - lastModifiedTime > 1000 && lastY != Double.MAX_VALUE && mc.world.getBlockState(mc.player.getBlockPos().down()).isAir()) {
            // actual check is for >= -0.03125D but we have to do a bit more than that
            // probably due to compression or some shit idk
            ((PlayerMoveC2SPacketAccessor) packet).setY(lastY - 0.03130D);
            lastModifiedTime = currentTime;
        } else {
            lastY = currentY;
        }
    }
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) PlayerMoveC2SPacketAccessor(meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with PlayerMoveC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket in project meteor-client by MeteorDevelopment.

the class Blink method onSendPacket.

@EventHandler
private void onSendPacket(PacketEvent.Send event) {
    if (!(event.packet instanceof PlayerMoveC2SPacket))
        return;
    event.cancel();
    synchronized (packets) {
        PlayerMoveC2SPacket p = (PlayerMoveC2SPacket) event.packet;
        PlayerMoveC2SPacket prev = packets.size() == 0 ? null : packets.get(packets.size() - 1);
        if (prev != null && p.isOnGround() == prev.isOnGround() && p.getYaw(-1) == prev.getYaw(-1) && p.getPitch(-1) == prev.getPitch(-1) && p.getX(-1) == prev.getX(-1) && p.getY(-1) == prev.getY(-1) && p.getZ(-1) == prev.getZ(-1))
            return;
        packets.add(p);
    }
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)7 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)4 EventHandler (meteordevelopment.orbit.EventHandler)2 VehicleMoveC2SPacket (net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket)2 EventHandler (mathax.client.eventbus.EventHandler)1 PlayerMoveC2SPacketAccessor (meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor)1