@@ -177,15 +177,40 @@ private BaseEntity transformNbtData(BaseEntity state) {
177177 tagX .value ().intValue (), tagY .value ().intValue (), tagZ .value ().intValue ()
178178 );
179179 BlockVector3 newLeash = transform .apply (tilePosition .subtract (from )).add (to ).toBlockPoint ();
180- return new BaseEntity (state .getType (), LazyReference .computed (tag .toBuilder ()
180+ state = new BaseEntity (state .getType (), LazyReference .computed (tag .toBuilder ()
181181 .put ("Leash" , leashCompound .toBuilder ()
182182 .putInt ("X" , newLeash .x ())
183183 .putInt ("Y" , newLeash .y ())
184184 .putInt ("Z" , newLeash .z ())
185185 .build ()
186186 ).build ()));
187+ tag = state .getNbt ();
187188 }
188189 }
190+ LinIntArrayTag leashArray = tag .findTag ("leash" , LinTagType .intArrayTag ());
191+ if (leashArray != null ) {
192+ Vector3 tilePosition = Vector3 .at (
193+ leashArray .value ()[0 ], leashArray .value ()[1 ], leashArray .value ()[2 ]
194+ );
195+ BlockVector3 newLeash = transform .apply (tilePosition .subtract (from )).add (to ).toBlockPoint ();
196+ state = new BaseEntity (state .getType (), LazyReference .computed (tag .toBuilder ()
197+ .putIntArray ("leash" , new int []{newLeash .x (), newLeash .y (), newLeash .z ()})
198+ .build ()));
199+ tag = state .getNbt ();
200+ }
201+
202+ // Handle home position for mobs
203+ LinIntArrayTag homePosArray = tag .findTag ("home_pos" , LinTagType .intArrayTag ());
204+ if (homePosArray != null ) {
205+ Vector3 tilePosition = Vector3 .at (
206+ homePosArray .value ()[0 ], homePosArray .value ()[1 ], homePosArray .value ()[2 ]
207+ );
208+ BlockVector3 newLeash = transform .apply (tilePosition .subtract (from )).add (to ).toBlockPoint ();
209+ state = new BaseEntity (state .getType (), LazyReference .computed (tag .toBuilder ()
210+ .putIntArray ("home_pos" , new int []{newLeash .x (), newLeash .y (), newLeash .z ()})
211+ .build ()));
212+ tag = state .getNbt ();
213+ }
189214
190215 // Handle hanging entities (paintings, item frames, etc.)
191216
0 commit comments