Search in sources :

Example 1 with GameJoinS2CPacket

use of net.minecraft.network.packet.s2c.play.GameJoinS2CPacket in project meteor-rejects by AntiCope.

the class ColorSigns method onPacketSend.

@EventHandler
private void onPacketSend(PacketEvent.Send event) {
    if (event.packet instanceof GameJoinS2CPacket) {
        checkWarning();
        return;
    }
    if (!(event.packet instanceof UpdateSignC2SPacket))
        return;
    UpdateSignC2SPacket p = (UpdateSignC2SPacket) event.packet;
    for (int l = 0; l < p.getText().length; l++) {
        String newText = p.getText()[l].replaceAll("(?i)\u00a7|&([0-9A-FK-OR])", "\u00a7\u00a7$1$1");
        p.getText()[l] = newText;
    }
    event.packet = p;
}
Also used : GameJoinS2CPacket(net.minecraft.network.packet.s2c.play.GameJoinS2CPacket) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with GameJoinS2CPacket

use of net.minecraft.network.packet.s2c.play.GameJoinS2CPacket in project Client by MatHax.

the class ColorSigns method onPacketSend.

@EventHandler
private void onPacketSend(PacketEvent.Send event) {
    if (event.packet instanceof GameJoinS2CPacket) {
        checkWarning();
        return;
    }
    if (!(event.packet instanceof UpdateSignC2SPacket))
        return;
    UpdateSignC2SPacket p = (UpdateSignC2SPacket) event.packet;
    for (int l = 0; l < p.getText().length; l++) {
        String newText = p.getText()[l].replaceAll("(?i)\u00a7|&([0-9A-FK-OR])", "\u00a7\u00a7$1$1");
        p.getText()[l] = newText;
    }
    event.packet = p;
}
Also used : GameJoinS2CPacket(net.minecraft.network.packet.s2c.play.GameJoinS2CPacket) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventHandler(mathax.client.eventbus.EventHandler)

Example 3 with GameJoinS2CPacket

use of net.minecraft.network.packet.s2c.play.GameJoinS2CPacket in project Hypnotic-Client by Hypnotic-Development.

the class Search method receivePacket.

@EventTarget
public void receivePacket(EventReceivePacket event) {
    if (event.getPacket() instanceof DisconnectS2CPacket || event.getPacket() instanceof GameJoinS2CPacket || event.getPacket() instanceof PlayerRespawnS2CPacket) {
        reset();
    } else if (event.getPacket() instanceof BlockUpdateS2CPacket) {
        BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
        queuedBlocks.add(Pair.of(packet.getPos(), packet.getState()));
    } else if (event.getPacket() instanceof ExplosionS2CPacket) {
        ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
        for (BlockPos pos : packet.getAffectedBlocks()) {
            queuedBlocks.add(Pair.of(pos, Blocks.AIR.getDefaultState()));
        }
    } else if (event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
        ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
        packet.visitUpdates((pos, state) -> queuedBlocks.add(Pair.of(pos.toImmutable(), state)));
    } else if (event.getPacket() instanceof ChunkDataS2CPacket) {
        ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.getPacket();
        ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
        queuedChunks.add(cp);
        queuedUnloads.remove(cp);
    } else if (event.getPacket() instanceof UnloadChunkS2CPacket) {
        UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) event.getPacket();
        queuedUnloads.add(new ChunkPos(packet.getX(), packet.getZ()));
    }
}
Also used : Color(java.awt.Color) ExplosionS2CPacket(net.minecraft.network.packet.s2c.play.ExplosionS2CPacket) Category(dev.hypnotic.module.Category) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) BlockUpdateS2CPacket(net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket) HashSet(java.util.HashSet) Future(java.util.concurrent.Future) Pair(org.apache.commons.lang3.tuple.Pair) EventTarget(dev.hypnotic.event.EventTarget) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Map(java.util.Map) PlayerRespawnS2CPacket(net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket) Chunk(net.minecraft.world.chunk.Chunk) BlockState(net.minecraft.block.BlockState) ExecutorService(java.util.concurrent.ExecutorService) ChunkDeltaUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket) EventRender3D(dev.hypnotic.event.events.EventRender3D) WorldUtils(dev.hypnotic.utils.world.WorldUtils) GameJoinS2CPacket(net.minecraft.network.packet.s2c.play.GameJoinS2CPacket) Set(java.util.Set) ChunkPos(net.minecraft.util.math.ChunkPos) VoxelShapes(net.minecraft.util.shape.VoxelShapes) BlockPos(net.minecraft.util.math.BlockPos) RenderUtils(dev.hypnotic.utils.render.RenderUtils) VoxelShape(net.minecraft.util.shape.VoxelShape) Executors(java.util.concurrent.Executors) Blocks(net.minecraft.block.Blocks) ExecutionException(java.util.concurrent.ExecutionException) UnloadChunkS2CPacket(net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket) EventReceivePacket(dev.hypnotic.event.events.EventReceivePacket) Entry(java.util.Map.Entry) Mod(dev.hypnotic.module.Mod) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) ChunkDataS2CPacket(net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket) BlockUpdateS2CPacket(net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket) ExplosionS2CPacket(net.minecraft.network.packet.s2c.play.ExplosionS2CPacket) PlayerRespawnS2CPacket(net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket) GameJoinS2CPacket(net.minecraft.network.packet.s2c.play.GameJoinS2CPacket) ChunkDataS2CPacket(net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) UnloadChunkS2CPacket(net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket) ChunkDeltaUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket) DisconnectS2CPacket(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket) EventTarget(dev.hypnotic.event.EventTarget)

Aggregations

GameJoinS2CPacket (net.minecraft.network.packet.s2c.play.GameJoinS2CPacket)3 UpdateSignC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket)2 EventTarget (dev.hypnotic.event.EventTarget)1 EventReceivePacket (dev.hypnotic.event.events.EventReceivePacket)1 EventRender3D (dev.hypnotic.event.events.EventRender3D)1 Category (dev.hypnotic.module.Category)1 Mod (dev.hypnotic.module.Mod)1 RenderUtils (dev.hypnotic.utils.render.RenderUtils)1 WorldUtils (dev.hypnotic.utils.world.WorldUtils)1 Color (java.awt.Color)1 ArrayDeque (java.util.ArrayDeque)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Queue (java.util.Queue)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1