From 0b554be10adc4b19f1a08cf29017ef5d7ff26395 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 24 Apr 2016 09:39:22 +1000 Subject: [PATCH] Strip / add velocity to SpawnEntity packets that require it when rewritten --- .../md_5/bungee/entitymap/EntityMap_1_8.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java index fb410644..8e631930 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java @@ -70,7 +70,7 @@ class EntityMap_1_8 extends EntityMap int[] ids = new int[ count ]; for ( int i = 0; i < count; i++ ) { - ids[ i ] = DefinedPacket.readVarInt( packet ); + ids[i] = DefinedPacket.readVarInt( packet ); } packet.readerIndex( readerIndex + packetIdLength ); packet.writerIndex( readerIndex + packetIdLength ); @@ -97,12 +97,24 @@ class EntityMap_1_8 extends EntityMap packet.skipBytes( 14 ); int position = packet.readerIndex(); int readId = packet.readInt(); + int changedId = readId; + if ( readId == oldId ) { - packet.setInt( position, newId ); + packet.setInt( position, changedId = newId ); } else if ( readId == newId ) { - packet.setInt( position, oldId ); + packet.setInt( position, changedId = oldId ); + } + + if ( readId > 0 && changedId <= 0 ) + { + packet.writerIndex( packet.writerIndex() - 3 * Short.BYTES ); + } else if ( changedId > 0 && readId <= 0 ) + { + packet.ensureWritable( 6 ); + packet.writerIndex( packet.writerIndex() + 3 * Short.BYTES ); + } } } else if ( packetId == 0x0C /* Spawn Player */ )