Search in sources :

Example 6 with UpdateSignC2SPacket

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

the class ColorSigns method onPacketSend.

/* This works because the code to strip invalid characters from signs is flawed
	 * because it uses a replaceAll for all the formatting codes instead of matching
	 * all sections symbols, which means you can basically "stack" two formatting
	 * codes ontop of eachother like "&&66", it will when search and find the middle
	 * one and remove it to leave "&6" left which is still a valid formatting code.
	 * Paper has a patch for it to correct it so it doesn't work there */
@BleachSubscribe
public void onPacketSend(EventPacket.Send event) {
    if (event.getPacket() instanceof UpdateSignC2SPacket) {
        UpdateSignC2SPacket p = (UpdateSignC2SPacket) event.getPacket();
        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;
        }
    }
}
Also used : UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 7 with UpdateSignC2SPacket

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

the class AutoSign method onOpenScreen.

@EventHandler
private void onOpenScreen(OpenScreenEvent event) {
    if (!(event.screen instanceof SignEditScreen))
        return;
    SignBlockEntity sign = ((SignEditScreenAccessor) event.screen).getSign();
    String lineOne = Placeholders.apply(lineone.get().replace("%date%", getDate()));
    String lineTwo = Placeholders.apply(linetwo.get().replace("%date%", getDate()));
    String lineThree = Placeholders.apply(linethree.get().replace("%date%", getDate()));
    String lineFour = Placeholders.apply(linefour.get().replace("%date%", getDate()));
    mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), lineOne, lineTwo, lineThree, lineFour));
    event.cancel();
}
Also used : SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SignEditScreenAccessor(mathax.client.mixin.SignEditScreenAccessor) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) 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