Append/trim extra data for spawn object packets with a 0 id

This commit is contained in:
Thinkofdeath 2014-03-10 19:25:15 +00:00
parent 00352f585a
commit 2a7ad3c2b2

View File

@ -1,6 +1,7 @@
package net.md_5.bungee; package net.md_5.bungee;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
/** /**
@ -112,12 +113,27 @@ public class EntityMap
if ( type == 60 || type == 90 ) if ( type == 60 || type == 90 )
{ {
int readId = packet.getInt( packetIdLength + idLength + 15 ); int readId = packet.getInt( packetIdLength + idLength + 15 );
int newId = -1;
if ( readId == serverEntityId ) if ( readId == serverEntityId )
{ {
packet.setInt( packetIdLength + idLength + 15, clientEntityId ); packet.setInt( packetIdLength + idLength + 15, clientEntityId );
newId = clientEntityId;
} else if ( readId == clientEntityId ) } else if ( readId == clientEntityId )
{ {
packet.setInt( packetIdLength + idLength + 15, serverEntityId ); packet.setInt( packetIdLength + idLength + 15, serverEntityId );
newId = clientEntityId;
}
if ( newId != -1 )
{
if ( newId == 0 && readId != 0 )
{ // Trim off the extra data
packet.readerIndex( readerIndex );
packet.capacity( packet.capacity() - 6 );
} else if ( newId != 0 && readId == 0 )
{ // Add on the extra data
packet.readerIndex( readerIndex );
packet.capacity( packet.capacity() + 6 );
}
} }
} }
} }