001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.server.packets.play.out; 019 020import io.netty.buffer.ByteBuf; 021import net.tridentsdk.server.netty.Codec; 022import net.tridentsdk.server.netty.packet.OutPacket; 023 024public class PacketPlayOutMaps extends OutPacket { 025 026 protected int itemDamage; 027 protected int scale; 028 protected int length; 029 protected byte[] icons; // array must be 3 * larger than length 030 protected byte columns; 031 protected byte rows; 032 protected byte x; 033 protected byte y; 034 protected int columnLength; 035 protected byte[] data; 036 037 @Override 038 public int id() { 039 return 0x34; 040 } 041 042 public int itemDamage() { 043 return this.itemDamage; 044 } 045 046 public int scale() { 047 return this.scale; 048 } 049 050 public int length() { 051 return this.length; 052 } 053 054 public byte[] icons() { 055 return this.icons; 056 } 057 058 public byte columns() { 059 return this.columns; 060 } 061 062 public byte rows() { 063 return this.rows; 064 } 065 066 public byte x() { 067 return this.x; 068 } 069 070 public byte y() { 071 return this.y; 072 } 073 074 public int columnLength() { 075 return this.columnLength; 076 } 077 078 public byte[] data() { 079 return this.data; 080 } 081 082 @Override 083 public void encode(ByteBuf buf) { 084 Codec.writeVarInt32(buf, this.itemDamage); 085 buf.writeByte(this.scale); 086 Codec.writeVarInt32(buf, this.length); 087 088 buf.writeBytes(this.icons); 089 buf.writeByte((int) this.columns); 090 091 if ((int) this.columns <= 0) { 092 return; 093 } 094 095 buf.writeByte((int) this.rows); 096 buf.writeByte((int) this.x); 097 buf.writeByte((int) this.y); 098 099 Codec.writeVarInt32(buf, this.columnLength); 100 buf.writeBytes(this.data); // here I'm not sure if I'm doing it right 101 } 102}