@@ -94,9 +94,9 @@ public static void init() {}
9494 }
9595
9696 cPacketPlayOutSpawnEntity = NMS .getConstructor (NMS .getPacketClass ("PacketPlayOutSpawnEntity" ),
97- (subVer <= 13 ) ?
98- MethodType .methodType (void .class , NMS .mcEntityClass , int .class , int . class ) :
99- MethodType .methodType (void .class , NMS .mcEntityClass , int .class ));
97+ (subVer <= 13 ) ? MethodType . methodType ( void . class , NMS . mcEntityClass , int . class , int . class )
98+ : ( subVer <= 20 ) ? MethodType .methodType (void .class , NMS .mcEntityClass , int .class )
99+ : MethodType .methodType (void .class , NMS .mcEntityClass , int .class , NMS . mcBlockPositionClass ));
100100
101101 if (subVer <= 12 ) {
102102 cItemStack = NMS .getConstructor (NMS .mcItemStackClass , MethodType .methodType (void .class , NMS .mcItemClass , int .class , int .class ));
@@ -202,19 +202,29 @@ protected static Object getItemFrame(Object itemStack, Location location, BlockF
202202
203203
204204 /**
205- * 获取生成 ItemFrame 的包
205+ * Get spawn packet of ItemFrame
206206 */
207207 protected static Object getSpawnPacket (Object itemFrame , int intDirection ) throws Throwable {
208208 int subVer = NMS .getSubVer ();
209209 if (subVer <= 13 ) {
210210 /* ItemFrame, ItemFrameID:71, Data:Facing(int) */
211211 return cPacketPlayOutSpawnEntity .invoke (itemFrame , 71 , intDirection );
212- } else {
212+ } else if ( subVer <= 20 ) {
213213 /* ItemFrame, Data:Facing(int) */
214214 return cPacketPlayOutSpawnEntity .invoke (itemFrame , intDirection );
215+ } else {
216+ throw new RuntimeException ("SpawnPacket in 1.21+ requires a BlockPosition!" );
215217 }
216218 }
217219
220+ /**
221+ * version >= 1.21
222+ * Get spawn packet of ItemFrame
223+ */
224+ protected static Object getSpawnPacket (Object itemFrame , int intDirection , Object blockPosition ) throws Throwable {
225+ return cPacketPlayOutSpawnEntity .invoke (itemFrame , intDirection , blockPosition );
226+ }
227+
218228 /**
219229 * 获取 NMS map
220230 */
0 commit comments