1
1
package de .epiceric .shopchest .nms .v1_21_R2 ;
2
2
3
+ import java .lang .reflect .Field ;
4
+ import java .util .List ;
5
+ import java .util .Optional ;
6
+
7
+ import org .bukkit .Location ;
8
+ import org .bukkit .craftbukkit .v1_21_R2 .util .CraftChatMessage ;
9
+ import org .bukkit .entity .Player ;
10
+
3
11
import de .epiceric .shopchest .nms .FakeArmorStand ;
4
- import io .netty .buffer .Unpooled ;
5
- import net .minecraft .network .FriendlyByteBuf ;
6
12
import net .minecraft .network .chat .Component ;
7
- import net .minecraft .network .protocol .game .ClientboundTeleportEntityPacket ;
13
+ import net .minecraft .network .protocol .game .ClientboundEntityPositionSyncPacket ;
8
14
import net .minecraft .network .syncher .EntityDataAccessor ;
9
15
import net .minecraft .network .syncher .SynchedEntityData ;
10
16
import net .minecraft .world .entity .Entity ;
11
17
import net .minecraft .world .entity .EntityType ;
18
+ import net .minecraft .world .entity .PositionMoveRotation ;
12
19
import net .minecraft .world .entity .decoration .ArmorStand ;
13
- import org .bukkit .Location ;
14
- import org .bukkit .craftbukkit .v1_21_R2 .util .CraftChatMessage ;
15
- import org .bukkit .entity .Player ;
16
-
17
- import java .lang .reflect .Field ;
18
- import java .util .List ;
19
- import java .util .Optional ;
20
+ import net .minecraft .world .phys .Vec3 ;
20
21
21
22
public class FakeArmorStandImpl extends FakeEntityImpl <String > implements FakeArmorStand {
22
23
@@ -35,7 +36,8 @@ public class FakeArmorStandImpl extends FakeEntityImpl<String> implements FakeAr
35
36
final Field dataCustomNameField = Entity .class .getDeclaredField (ObfuscatedFieldNames .DATA_CUSTOM_NAME );
36
37
dataCustomNameField .setAccessible (true );
37
38
DATA_CUSTOM_NAME = forceCast (dataCustomNameField .get (null ));
38
- final Field dataCustomNameVisibleField = Entity .class .getDeclaredField (ObfuscatedFieldNames .DATA_CUSTOM_NAME_VISIBLE );
39
+ final Field dataCustomNameVisibleField = Entity .class
40
+ .getDeclaredField (ObfuscatedFieldNames .DATA_CUSTOM_NAME_VISIBLE );
39
41
dataCustomNameVisibleField .setAccessible (true );
40
42
DATA_CUSTOM_NAME_VISIBLE = forceCast (dataCustomNameVisibleField .get (null ));
41
43
} catch (ReflectiveOperationException e ) {
@@ -71,23 +73,17 @@ protected int getDataItemCount() {
71
73
protected void addSpecificData (List <SynchedEntityData .DataValue <?>> packedItems , String name ) {
72
74
packedItems .add (SynchedEntityData .DataValue .create (DATA_SHARED_FLAGS_ID , INVISIBLE_FLAG ));
73
75
packedItems .add (SynchedEntityData .DataValue .create (DATA_CUSTOM_NAME , Optional .ofNullable (
74
- CraftChatMessage .fromStringOrNull (name )
75
- )));
76
+ CraftChatMessage .fromStringOrNull (name ))));
76
77
packedItems .add (SynchedEntityData .DataValue .create (DATA_CUSTOM_NAME_VISIBLE , true ));
77
78
packedItems .add (SynchedEntityData .DataValue .create (ArmorStand .DATA_CLIENT_FLAGS , MARKER_FLAG ));
78
79
}
79
80
80
81
@ Override
81
82
public void setLocation (Location location , Iterable <Player > receivers ) {
82
- final FriendlyByteBuf buffer = new FriendlyByteBuf (Unpooled .buffer ());
83
- buffer .writeVarInt (entityId );
84
- buffer .writeDouble (location .getX ());
85
- buffer .writeDouble (location .getY () + MARKER_ARMOR_STAND_OFFSET );
86
- buffer .writeDouble (location .getZ ());
87
- buffer .writeByte (0 );
88
- buffer .writeByte (0 );
89
- buffer .writeBoolean (false );
90
- final ClientboundTeleportEntityPacket positionPacket = ClientboundTeleportEntityPacket .STREAM_CODEC .decode (buffer );
83
+ final Vec3 pos = new Vec3 (location .getX (), location .getY () + MARKER_ARMOR_STAND_OFFSET , location .getZ ());
84
+ final PositionMoveRotation positionMoveRotation = new PositionMoveRotation (pos , Vec3 .ZERO , 0f , 0f );
85
+ final ClientboundEntityPositionSyncPacket positionPacket = new ClientboundEntityPositionSyncPacket (entityId ,
86
+ positionMoveRotation , false );
91
87
sendPacket (positionPacket , receivers );
92
88
}
93
89
0 commit comments