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;
}
}
}
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();
}
Aggregations