@@ -49,6 +49,7 @@ public class VirtualHologramEntity {
49
49
private boolean small = false ;
50
50
private boolean marker = false ;
51
51
private boolean sneaking = false ;
52
+ private boolean gravity = false ;
52
53
private byte alwaysShowNametag ;
53
54
54
55
public VirtualHologramEntity (final UserConnection user , final int entityId ) {
@@ -116,12 +117,15 @@ public void syncState(final EntityPacketRewriter1_8 entityRewriter, final List<E
116
117
sneaking = (flags & 0x02 ) != 0 ;
117
118
small = (armorStandFlags & 0x01 ) != 0 ;
118
119
marker = (armorStandFlags & 0x10 ) != 0 ;
120
+ gravity = (armorStandFlags & 0x02 ) == 0 ;
119
121
120
122
State prevState = currentState ;
121
123
if (invisible && name != null ) {
122
124
currentState = State .HOLOGRAM ;
123
- } else {
125
+ } else if ( gravity ) {
124
126
currentState = State .ZOMBIE ;
127
+ } else {
128
+ currentState = State .ZOMBIE_NO_GRAVITY ;
125
129
}
126
130
127
131
if (currentState != prevState ) {
@@ -146,21 +150,25 @@ private void updateLocation() {
146
150
entityHeadLook .write (Types .BYTE , (byte ) ((headYaw / 360f ) * 256 ));
147
151
148
152
entityHeadLook .send (Protocol1_8To1_7_6_10 .class );
149
- } else if (currentState == State .HOLOGRAM ) {
153
+ } else if (currentState == State .HOLOGRAM || currentState == State . ZOMBIE_NO_GRAVITY ) {
150
154
// Don't ask me where this offset is coming from
151
- teleportEntity (entityIds [0 ], locX , (locY + getOffset ()), locZ , 0 , 0 ); // Skull
155
+ teleportEntity (entityIds [1 ], locX , (locY + getOffset ()), locZ , 0 , 0 ); // Squid
152
156
}
153
157
}
154
158
155
159
private double getOffset () {
156
- double baseOffset = 54.35 ;
157
-
158
- if (marker ) {
159
- return baseOffset ;
160
- } else if (small ) {
161
- return baseOffset + 0.9875 ;
160
+ if (currentState == State .HOLOGRAM ) {
161
+ double baseOffset = 54.35 ;
162
+
163
+ if (marker ) {
164
+ return baseOffset ;
165
+ } else if (small ) {
166
+ return baseOffset + 0.9875 ;
167
+ } else {
168
+ return baseOffset + (0.9875 * 2 );
169
+ }
162
170
} else {
163
- return baseOffset + ( 0.9875 * 2 ) ;
171
+ return - 0.4 ;
164
172
}
165
173
}
166
174
@@ -202,7 +210,7 @@ public void sendEntityDataUpdate(final EntityPacketRewriter1_8 entityRewriter) {
202
210
}
203
211
final PacketWrapper setEntityData = PacketWrapper .create (ClientboundPackets1_7_2_5 .SET_ENTITY_DATA , user );
204
212
205
- if (currentState == State .ZOMBIE ) {
213
+ if (currentState == State .ZOMBIE || currentState == State . ZOMBIE_NO_GRAVITY ) {
206
214
writeZombieMeta (entityRewriter , setEntityData );
207
215
} else if (currentState == State .HOLOGRAM ) {
208
216
writeHologramMeta (setEntityData );
@@ -246,7 +254,7 @@ private void writeZombieMeta(final EntityPacketRewriter1_8 entityRewriter, final
246
254
}
247
255
248
256
private void writeHologramMeta (PacketWrapper wrapper ) {
249
- wrapper .write (Types .INT , entityIds [1 ]);
257
+ wrapper .write (Types .INT , entityIds [0 ]);
250
258
251
259
// Directly write 1.7 entity data here since we are making them up
252
260
final List <EntityData > entityDataList = new ArrayList <>();
@@ -266,25 +274,19 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
266
274
spawnEntity (entityId , EntityTypes1_8 .EntityType .ZOMBIE .getId (), locX , locY , locZ , new ArrayList <>());
267
275
268
276
entityIds = new int []{entityId };
269
- } else if (currentState == State .HOLOGRAM ) {
277
+ } else if (currentState == State .ZOMBIE_NO_GRAVITY || currentState == State . HOLOGRAM ) {
270
278
final int [] entityIds = {entityId , additionalEntityId ()};
271
279
272
- final PacketWrapper spawnSkull = PacketWrapper .create (ClientboundPackets1_7_2_5 .ADD_ENTITY , user );
273
- spawnSkull .write (Types .VAR_INT , entityIds [0 ]);
274
- spawnSkull .write (Types .BYTE , (byte ) 66 );
275
- spawnSkull .write (Types .INT , (int ) (locX * 32.0 ));
276
- spawnSkull .write (Types .INT , (int ) ((locY + getOffset ()) * 32.0 ));
277
- spawnSkull .write (Types .INT , (int ) (locZ * 32.0 ));
278
- spawnSkull .write (Types .BYTE , (byte ) 0 );
279
- spawnSkull .write (Types .BYTE , (byte ) 0 );
280
- spawnSkull .write (Types .INT , 0 );
281
- spawnSkull .send (Protocol1_8To1_7_6_10 .class );
282
-
283
280
final List <EntityData > squidEntityData = new ArrayList <>();
284
281
squidEntityData .add (new EntityData (0 , EntityDataTypes1_8 .BYTE , (byte ) 32 ));
285
282
286
- spawnEntity (entityIds [0 ], EntityTypes1_8 .EntityType .SQUID .getId (), locX , locY + getOffset (), locZ , squidEntityData );
287
- spawnEntity (entityIds [1 ], EntityTypes1_8 .EntityType .HORSE .getId (), locX , locY + (getOffset () + 0.68 ), locZ , new ArrayList <>());
283
+ if (currentState == State .HOLOGRAM ) {
284
+ spawnEntity (entityIds [0 ], EntityTypes1_8 .EntityType .HORSE .getId (), locX , locY + (getOffset () + 0.68 ), locZ , new ArrayList <>());
285
+ } else {
286
+ spawnEntity (entityIds [0 ], EntityTypes1_8 .EntityType .ZOMBIE .getId (), locX , locY , locZ , new ArrayList <>());
287
+ }
288
+
289
+ spawnEntity (entityIds [1 ], EntityTypes1_8 .EntityType .SQUID .getId (), locX , locY + getOffset (), locZ , squidEntityData );
288
290
289
291
this .entityIds = entityIds ;
290
292
}
@@ -298,8 +300,8 @@ public void sendSpawnPacket(final EntityPacketRewriter1_8 entityRewriter) {
298
300
updateLocation ();
299
301
} else {
300
302
final PacketWrapper attach = PacketWrapper .create (ClientboundPackets1_7_2_5 .SET_ENTITY_LINK , user );
301
- attach .write (Types .INT , entityIds [1 ]);
302
303
attach .write (Types .INT , entityIds [0 ]);
304
+ attach .write (Types .INT , entityIds [1 ]);
303
305
attach .write (Types .BOOLEAN , false );
304
306
305
307
attach .send (Protocol1_8To1_7_6_10 .class );
@@ -334,6 +336,6 @@ public void deleteEntity() {
334
336
}
335
337
336
338
private enum State {
337
- HOLOGRAM , ZOMBIE
339
+ HOLOGRAM , ZOMBIE , ZOMBIE_NO_GRAVITY
338
340
}
339
341
}
0 commit comments