Fix handling of Title packet for 1.11 and maintain backwards compat with 1.10 and earlier
This commit is contained in:
parent
9ecdde2292
commit
95a269df7a
@ -28,11 +28,20 @@ public class Title extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
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 )
|
switch ( action )
|
||||||
{
|
{
|
||||||
case TITLE:
|
case TITLE:
|
||||||
case SUBTITLE:
|
case SUBTITLE:
|
||||||
|
case ACTIONBAR:
|
||||||
text = readString( buf );
|
text = readString( buf );
|
||||||
break;
|
break;
|
||||||
case TIMES:
|
case TIMES:
|
||||||
@ -46,11 +55,20 @@ public class Title extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
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 )
|
switch ( action )
|
||||||
{
|
{
|
||||||
case TITLE:
|
case TITLE:
|
||||||
case SUBTITLE:
|
case SUBTITLE:
|
||||||
|
case ACTIONBAR:
|
||||||
writeString( text, buf );
|
writeString( text, buf );
|
||||||
break;
|
break;
|
||||||
case TIMES:
|
case TIMES:
|
||||||
@ -72,6 +90,7 @@ public class Title extends DefinedPacket
|
|||||||
|
|
||||||
TITLE,
|
TITLE,
|
||||||
SUBTITLE,
|
SUBTITLE,
|
||||||
|
ACTIONBAR,
|
||||||
TIMES,
|
TIMES,
|
||||||
CLEAR,
|
CLEAR,
|
||||||
RESET
|
RESET
|
||||||
|
Loading…
Reference in New Issue
Block a user