Fix handling of Title packet for 1.11 and maintain backwards compat with 1.10 and earlier

This commit is contained in:
Shane 2016-11-14 19:27:44 +00:00 committed by md_5
parent 9ecdde2292
commit 95a269df7a

View File

@ -28,11 +28,20 @@ public class Title extends DefinedPacket
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
action = Action.values()[readVarInt( buf )];
int index = readVarInt( buf );
// If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value.
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_10 && index <= 2 )
{
index++;
}
action = Action.values()[index];
switch ( action )
{
case TITLE:
case SUBTITLE:
case ACTIONBAR:
text = readString( buf );
break;
case TIMES:
@ -46,11 +55,20 @@ public class Title extends DefinedPacket
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeVarInt( action.ordinal(), buf );
int index = readVarInt( buf );
// If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value.
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_10 && index <= 2 )
{
index++;
}
action = Action.values()[index];
switch ( action )
{
case TITLE:
case SUBTITLE:
case ACTIONBAR:
writeString( text, buf );
break;
case TIMES:
@ -72,6 +90,7 @@ public class Title extends DefinedPacket
TITLE,
SUBTITLE,
ACTIONBAR,
TIMES,
CLEAR,
RESET