Search in sources :

Example 1 with UpdateSignC2SPacket

use of net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket 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 UpdateSignC2SPacket

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

the class BookCrash method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    delay = (delay >= getSetting(2).asSlider().getValue() ? 0 : delay + 1);
    if (delay > 0)
        return;
    ItemStack bookObj = new ItemStack(Items.WRITABLE_BOOK);
    NbtList list = new NbtList();
    NbtCompound tag = new NbtCompound();
    String author = "Bleach";
    String title = "\n Bleachhack Owns All \n";
    String size = "";
    int pages = Math.min(getSetting(4).asSlider().getValueInt(), 100);
    int pageChars = 210;
    if (getSetting(3).asMode().getMode() == 2) {
        IntStream chars = new Random().ints(0x80, 0x10FFFF - 0x800).map(i -> i < 0xd800 ? i : i + 0x800);
        size = chars.limit(pageChars * pages).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining());
    } else if (getSetting(3).asMode().getMode() == 1) {
        size = repeat(pages * pageChars, String.valueOf(0x10FFFF));
    } else if (getSetting(3).asMode().getMode() == 0) {
        IntStream chars = new Random().ints(0x20, 0x7E);
        size = chars.limit(pageChars * pages).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining());
    } else if (getSetting(3).asMode().getMode() == 3) {
        size = "wveb54yn4y6y6hy6hb54yb5436by5346y3b4yb343yb453by45b34y5by34yb543yb54y5 h3y4h97,i567yb64t5vr2c43rc434v432tvt4tvybn4n6n57u6u57m6m6678mi68,867,79o,o97o,978iun7yb65453v4tyv34t4t3c2cc423rc334tcvtvt43tv45tvt5t5v43tv5345tv43tv5355vt5t3tv5t533v5t45tv43vt4355t54fwveb54yn4y6y6hy6hb54yb5436by5346y3b4yb343yb453by45b34y5by34yb543yb54y5 h3y4h97,i567yb64t5vr2c43rc434v432tvt4tvybn4n6n57u6u57m6m6678mi68,867,79o,o97o,978iun7yb65453v4tyv34t4t3c2cc423rc334tcvtvt43tv45tvt5t5v43tv5345tv43tv5355vt5t3tv5t533v5t45tv43vt4355t54fwveb54yn4y6y6hy6hb54yb5436by5346y3b4yb343yb453by45b34y5by34yb543yb54y5 h3y4h97,i567yb64t5";
    }
    if (getSetting(0).asMode().getMode() == 2) {
        String text = "bh ontop";
        Random rand = new Random();
        for (int i = 0; i < getSetting(1).asSlider().getValue(); i++) {
            mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(new BlockPos(rand.nextInt(29999999), rand.nextInt(29999999), rand.nextInt(29999999)), text, text, text, text));
        }
    } else {
        for (int i = 0; i < pages; i++) {
            NbtString tString = NbtString.of(size);
            list.add(tString);
        }
        tag.putString("author", author);
        tag.putString("title", title);
        tag.put("pages", list);
        bookObj.setSubNbt("pages", list);
        bookObj.setNbt(tag);
        for (int i = 0; i < getSetting(1).asSlider().getValue(); i++) {
            if (getSetting(0).asMode().getMode() == 0) {
                Int2ObjectMap<ItemStack> map = new Int2ObjectOpenHashMap<>(1);
                map.put(0, bookObj);
                mc.player.networkHandler.sendPacket(new ClickSlotC2SPacket(0, 0, 0, 0, SlotActionType.PICKUP, bookObj, map));
            } else {
                mc.player.networkHandler.sendPacket(new CreativeInventoryActionC2SPacket(0, bookObj));
            }
        }
    }
}
Also used : Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) NbtCompound(net.minecraft.nbt.NbtCompound) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) NbtString(net.minecraft.nbt.NbtString) NbtString(net.minecraft.nbt.NbtString) ClickSlotC2SPacket(net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket) Random(java.util.Random) NbtList(net.minecraft.nbt.NbtList) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) IntStream(java.util.stream.IntStream) CreativeInventoryActionC2SPacket(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with UpdateSignC2SPacket

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

the class AutoSign method onOpenScreen.

@BleachSubscribe
public void onOpenScreen(EventOpenScreen event) {
    if (text.length < 3)
        return;
    if (event.getScreen() instanceof SignEditScreen) {
        event.setCancelled(true);
        if (getSetting(0).asToggle().getState()) {
            text = new String[] {};
            while (text.length < 4) {
                IntStream chars = new Random().ints(0, 0x10FFFF);
                int amount = getSetting(0).asToggle().getChild(0).asSlider().getValueInt();
                text = chars.limit(amount * 5).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining()).split("(?<=\\G.{" + amount + "})");
            }
        }
        SignBlockEntity sign = ((SignEditScreen) event.getScreen()).sign;
        mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), text[0], text[1], text[2], text[3]));
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) IntStream(java.util.stream.IntStream) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) ModuleCategory(org.bleachhack.module.ModuleCategory) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventOpenScreen(org.bleachhack.event.events.EventOpenScreen) Random(java.util.Random) Collectors(java.util.stream.Collectors) Module(org.bleachhack.module.Module) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SettingToggle(org.bleachhack.setting.module.SettingToggle) EventPacket(org.bleachhack.event.events.EventPacket) Random(java.util.Random) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) IntStream(java.util.stream.IntStream) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with UpdateSignC2SPacket

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

the class AutoSign method onOpenScreen.

@EventHandler
private void onOpenScreen(OpenScreenEvent event) {
    if (!(event.screen instanceof SignEditScreen) || text == null)
        return;
    SignBlockEntity sign = ((SignEditScreenAccessor) event.screen).getSign();
    mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), text[0], text[1], text[2], text[3]));
    event.cancel();
}
Also used : SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SignEditScreenAccessor(meteordevelopment.meteorclient.mixin.SignEditScreenAccessor) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with UpdateSignC2SPacket

use of net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket 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)

Aggregations

UpdateSignC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket)7 SignBlockEntity (net.minecraft.block.entity.SignBlockEntity)3 SignEditScreen (net.minecraft.client.gui.screen.ingame.SignEditScreen)3 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)3 Random (java.util.Random)2 IntStream (java.util.stream.IntStream)2 EventHandler (mathax.client.eventbus.EventHandler)2 EventHandler (meteordevelopment.orbit.EventHandler)2 GameJoinS2CPacket (net.minecraft.network.packet.s2c.play.GameJoinS2CPacket)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Collectors (java.util.stream.Collectors)1 SignEditScreenAccessor (mathax.client.mixin.SignEditScreenAccessor)1 SignEditScreenAccessor (meteordevelopment.meteorclient.mixin.SignEditScreenAccessor)1 ItemStack (net.minecraft.item.ItemStack)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 NbtList (net.minecraft.nbt.NbtList)1 NbtString (net.minecraft.nbt.NbtString)1 ClickSlotC2SPacket (net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket)1 CreativeInventoryActionC2SPacket (net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket)1 BlockPos (net.minecraft.util.math.BlockPos)1