Package net.minecraft.util.io.netty.buffer

Examples of net.minecraft.util.io.netty.buffer.ByteBuf


     * Convert the compressed image to encoded text.
     * @return The encoded text.
     */
    public String toEncodedText() {
      if (encoded == null) {
        final ByteBuf buffer = Unpooled.wrappedBuffer(getData());
        String computed = "data:" + mime + ";base64," +
          Base64.encode(buffer).toString(Charsets.UTF_8);
       
        encoded = computed;
      }
View Full Code Here


      for (String segment : Splitter.on(";").split(encoded)) {
        if (segment.startsWith("data:")) {
          this.mime = segment.substring(5);
        } else if (segment.startsWith("base64,")) {
          byte[] encoded = segment.substring(7).getBytes(Charsets.UTF_8);
          ByteBuf decoded = Base64.decode(Unpooled.wrappedBuffer(encoded));
         
          // Read into a byte array
          byte[] data = new byte[decoded.readableBytes()];
          decoded.readBytes(data);
          this.data = data;
        } else {
          // We will ignore these segments
        }
      }
View Full Code Here

        marker = NetworkMarker.getNetworkMarker(event);
      }
     
      // Process output handler
      if (packet != null && event != null && NetworkMarker.hasOutputHandlers(marker)) {
        ByteBuf packetBuffer = ctx.alloc().buffer();
        ENCODE_BUFFER.invoke(vanillaEncoder, ctx, packet, packetBuffer);

        // Let each handler prepare the actual output
        byte[] data = processor.processOutput(event, marker, getBytes(packetBuffer));
       
View Full Code Here

    // We'll take care of NULL packets as well
    output.writeBoolean(handle != null);

    try {
      if (MinecraftReflection.isUsingNetty()) {
        ByteBuf buffer = createPacketBuffer();
        MinecraftMethods.getPacketWriteByteBufMethod().invoke(handle, buffer);
       
        output.writeInt(buffer.readableBytes());
        buffer.readBytes(output, buffer.readableBytes());
       
      } else {
        // Call the write-method
        output.writeInt(-1);
        getMethodLazily(writeMethods, handle.getClass(), "write", DataOutput.class).
View Full Code Here

        handle = StructureCache.newPacket(type);
       
      // Call the read method
      try {
        if (MinecraftReflection.isUsingNetty()) {
          ByteBuf buffer = createPacketBuffer();
          buffer.writeBytes(input, input.readInt());
         
          MinecraftMethods.getPacketReadByteBufMethod().invoke(handle, buffer);
        } else {
          if (input.readInt() != -1)
            throw new IllegalArgumentException("Cannot load a packet from 1.7.2 in 1.6.4.");
View Full Code Here

    }

    private void a(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {
        channelhandlercontext.pipeline().firstContext().writeAndFlush(bytebuf).addListener(ChannelFutureListener.CLOSE);
    }

    private ByteBuf a(String s) {
        ByteBuf bytebuf = Unpooled.buffer();

        bytebuf.writeByte(255);
        char[] achar = s.toCharArray();

        bytebuf.writeShort(achar.length);
        char[] achar1 = achar;
        int i = achar.length;

        for (int j = 0; j < i; ++j) {
            char c0 = achar1[j];

            bytebuf.writeChar(c0);
        }
View Full Code Here

    }

    protected ByteBuf a(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {
        int i = bytebuf.readableBytes();
        byte[] abyte = this.a(bytebuf);
        ByteBuf bytebuf1 = channelhandlercontext.alloc().heapBuffer(this.a.getOutputSize(i));

        bytebuf1.writerIndex(this.a.update(abyte, 0, i, bytebuf1.array(), bytebuf1.arrayOffset()));
        return bytebuf1;
    }
View Full Code Here

    private void a(ServerPing serverping) {
        File file1 = this.d("server-icon.png");

        if (file1.isFile()) {
            ByteBuf bytebuf = Unpooled.buffer();

            try {
                BufferedImage bufferedimage = ImageIO.read(file1);

                Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
                Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
                ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf));
                ByteBuf bytebuf1 = Base64.encode(bytebuf);

                serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
            } catch (Exception exception) {
                i.error("Couldn\'t load server icon", exception);
            } finally {
                bytebuf.release();
            }
View Full Code Here

TOP

Related Classes of net.minecraft.util.io.netty.buffer.ByteBuf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.