@@ -48,6 +48,7 @@ public class VirtualHologramEntity {
4848 private float headYaw ;
4949 private boolean small = false ;
5050 private boolean marker = false ;
51+ private boolean sneaking = false ;
5152 private byte alwaysShowNametag ;
5253
5354 public VirtualHologramEntity (final UserConnection user , final int entityId ) {
@@ -61,7 +62,7 @@ public void setPosition(final double x, final double y, final double z) {
6162 this .locY = y ;
6263 this .locZ = z ;
6364
64- updateLocation (false );
65+ updateLocation ();
6566 }
6667
6768 public void setRelativePosition (final double x , final double y , final double z ) {
@@ -70,7 +71,7 @@ public void setRelativePosition(final double x, final double y, final double z)
7071 this .locY += y ;
7172 this .locZ += z ;
7273
73- updateLocation (false );
74+ updateLocation ();
7475 }
7576
7677 public void setRotation (final float yaw , final float pitch ) {
@@ -79,14 +80,14 @@ public void setRotation(final float yaw, final float pitch) {
7980 this .headYaw = yaw ;
8081 this .pitch = pitch ;
8182
82- updateLocation (false );
83+ updateLocation ();
8384 }
8485
8586 public void setHeadYaw (float yaw ) {
8687 if (this .headYaw == yaw ) return ;
8788 this .headYaw = yaw ;
8889
89- updateLocation (false );
90+ updateLocation ();
9091 }
9192
9293 public void syncState (final EntityPacketRewriter1_8 entityRewriter , final List <EntityData > entityDataList ) {
@@ -112,6 +113,7 @@ public void syncState(final EntityPacketRewriter1_8 entityRewriter, final List<E
112113 }
113114 }
114115 final boolean invisible = (flags & 0x20 ) != 0 ;
116+ sneaking = (flags & 0x02 ) != 0 ;
115117 small = (armorStandFlags & 0x01 ) != 0 ;
116118 marker = (armorStandFlags & 0x10 ) != 0 ;
117119
@@ -127,11 +129,11 @@ public void syncState(final EntityPacketRewriter1_8 entityRewriter, final List<E
127129 sendSpawnPacket (entityRewriter );
128130 } else {
129131 sendEntityDataUpdate (entityRewriter );
130- updateLocation (false );
132+ updateLocation ();
131133 }
132134 }
133135
134- private void updateLocation (final boolean remount ) {
136+ private void updateLocation () {
135137 if (entityIds == null ) {
136138 return ;
137139 }
@@ -145,26 +147,8 @@ private void updateLocation(final boolean remount) {
145147
146148 entityHeadLook .send (Protocol1_8To1_7_6_10 .class );
147149 } else if (currentState == State .HOLOGRAM ) {
148- if (remount ) {
149- PacketWrapper detach = PacketWrapper .create (ClientboundPackets1_7_2_5 .SET_ENTITY_LINK , user );
150- detach .write (Types .INT , entityIds [1 ]);
151- detach .write (Types .INT , -1 );
152- detach .write (Types .BOOLEAN , false );
153- detach .send (Protocol1_8To1_7_6_10 .class );
154- }
155-
156150 // Don't ask me where this offset is coming from
157151 teleportEntity (entityIds [0 ], locX , (locY + (marker ? 54.3625 : small ? 56 : 57 ) - 0.16 ), locZ , 0 , 0 ); // Skull
158-
159- if (remount ) {
160- teleportEntity (entityIds [1 ], locX , locY + 56.75 , locZ , 0 , 0 ); // Horse
161-
162- PacketWrapper attach = PacketWrapper .create (ClientboundPackets1_7_2_5 .SET_ENTITY_LINK , null , user );
163- attach .write (Types .INT , entityIds [1 ]);
164- attach .write (Types .INT , entityIds [0 ]);
165- attach .write (Types .BOOLEAN , false );
166- attach .send (Protocol1_8To1_7_6_10 .class );
167- }
168152 }
169153 }
170154
@@ -254,6 +238,7 @@ private void writeHologramMeta(PacketWrapper wrapper) {
254238
255239 // Directly write 1.7 entity data here since we are making them up
256240 final List <EntityData > entityDataList = new ArrayList <>();
241+ entityDataList .add (new EntityData (EntityDataIndex1_7_6_10 .ENTITY_FLAGS .getIndex (), EntityDataTypes1_7_6_10 .BYTE , (byte ) (sneaking ? 2 : 0 )));
257242 entityDataList .add (new EntityData (EntityDataIndex1_7_6_10 .ABSTRACT_AGEABLE_AGE .getIndex (), EntityDataTypes1_7_6_10 .INT , -1700000 ));
258243 entityDataList .add (new EntityData (EntityDataIndex1_7_6_10 .LIVING_ENTITY_BASE_NAME_TAG .getIndex (), EntityDataTypes1_7_6_10 .STRING , name ));
259244 entityDataList .add (new EntityData (EntityDataIndex1_7_6_10 .LIVING_ENTITY_BASE_NAME_TAG_VISIBILITY .getIndex (), EntityDataTypes1_7_6_10 .BYTE , alwaysShowNametag ));
@@ -271,12 +256,13 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
271256 entityIds = new int []{entityId };
272257 } else if (currentState == State .HOLOGRAM ) {
273258 final int [] entityIds = {entityId , additionalEntityId ()};
259+ final double offsetY = (locY + (marker ? 54.3625 : small ? 56 : 57 )) - 0.16 ;
274260
275261 final PacketWrapper spawnSkull = PacketWrapper .create (ClientboundPackets1_7_2_5 .ADD_ENTITY , user );
276262 spawnSkull .write (Types .VAR_INT , entityIds [0 ]);
277263 spawnSkull .write (Types .BYTE , (byte ) 66 );
278264 spawnSkull .write (Types .INT , (int ) (locX * 32.0 ));
279- spawnSkull .write (Types .INT , (int ) (locY * 32.0 ));
265+ spawnSkull .write (Types .INT , (int ) (offsetY * 32.0 ));
280266 spawnSkull .write (Types .INT , (int ) (locZ * 32.0 ));
281267 spawnSkull .write (Types .BYTE , (byte ) 0 );
282268 spawnSkull .write (Types .BYTE , (byte ) 0 );
@@ -286,14 +272,27 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
286272 final List <EntityData > squidEntityData = new ArrayList <>();
287273 squidEntityData .add (new EntityData (0 , EntityDataTypes1_8 .BYTE , (byte ) 32 ));
288274
289- spawnEntity (entityIds [0 ], EntityTypes1_8 .EntityType .SQUID .getId (), locX , locY , locZ , squidEntityData );
290- spawnEntity (entityIds [1 ], EntityTypes1_8 .EntityType .HORSE .getId (), locX , locY , locZ , new ArrayList <>());
275+ spawnEntity (entityIds [0 ], EntityTypes1_8 .EntityType .SQUID .getId (), locX , offsetY , locZ , squidEntityData );
276+ spawnEntity (entityIds [1 ], EntityTypes1_8 .EntityType .HORSE .getId (), locX , offsetY + 0.74 , locZ , new ArrayList <>());
291277
292278 this .entityIds = entityIds ;
293279 }
294280
295281 sendEntityDataUpdate (entityRewriter );
296- updateLocation (true );
282+ if (entityIds == null ) {
283+ return ;
284+ }
285+
286+ if (currentState == State .ZOMBIE ) {
287+ updateLocation ();
288+ } else {
289+ final PacketWrapper attach = PacketWrapper .create (ClientboundPackets1_7_2_5 .SET_ENTITY_LINK , user );
290+ attach .write (Types .INT , entityIds [1 ]);
291+ attach .write (Types .INT , entityIds [0 ]);
292+ attach .write (Types .BOOLEAN , false );
293+
294+ attach .send (Protocol1_8To1_7_6_10 .class );
295+ }
297296 }
298297
299298 public AABB getBoundingBox () {
0 commit comments