3737import net .minecraft .client .renderer .entity .ItemRenderer ;
3838import net .minecraft .client .renderer .entity .RenderLayerParent ;
3939import net .minecraft .client .renderer .texture .OverlayTexture ;
40+ import net .minecraft .core .BlockPos ;
4041import net .minecraft .server .level .ServerLevel ;
4142import net .minecraft .server .level .ServerPlayer ;
4243import net .minecraft .util .Mth ;
@@ -276,18 +277,29 @@ public static void onLivingHurt(LivingHurtEvent event) {
276277
277278 @ SubscribeEvent
278279 public static void onLivingHeal (LivingHealEvent event ) {
280+ var entity = event .getEntity ();
281+ var level = entity .level ();
282+
283+ var box = entity .getBoundingBox ();
284+
285+ var min = BlockPos .containing (Math .floor (box .minX ) - 1 , Math .floor (box .minY ), Math .floor (box .minZ ) - 1 );
286+ var max = BlockPos .containing (Math .floor (box .maxX ) + 1 , Math .floor (entity .getEyeY ()) + 1 , Math .floor (box .maxZ ) + 1 );
287+
288+ // WHY!? (cuz of thread locks lol)
289+ if (!level .hasChunksAt (min , max ))
290+ return ;
291+
279292 if (event .getAmount () <= 0.5F )
280293 return ;
281294
282295 if (event .getEntity () instanceof Player player ) {
283296 ItemStack stack = EntityUtils .findEquippedCurio (player , ItemRegistry .HOLY_LOCKET .get ());
284- Level level = player .getCommandSenderWorld ();
285297
286298 if (!(stack .getItem () instanceof HolyLocketItem relic ) || NBTUtils .getBoolean (stack , TAG_TOGGLED , true ))
287299 return ;
288300
289301 for (LivingEntity target : level .getEntitiesOfClass (LivingEntity .class , player .getBoundingBox ().inflate (relic .getAbilityValue (stack , "belief" , "radius" ))).stream ()
290- .filter (player ::hasLineOfSight ).sorted (Comparator .comparing (entity -> entity .position ().distanceTo (player .position ()))).limit ((int ) relic .getAbilityValue (stack , "belief" , "count" )).toList ()) {
302+ .filter (player ::hasLineOfSight ).sorted (Comparator .comparing (possibleTarget -> possibleTarget .position ().distanceTo (player .position ()))).limit ((int ) relic .getAbilityValue (stack , "belief" , "count" )).toList ()) {
291303 if (target .getStringUUID ().equals (player .getStringUUID ()))
292304 continue ;
293305
@@ -309,9 +321,6 @@ public static void onLivingHeal(LivingHealEvent event) {
309321 relic .addCharge (stack , 1 );
310322 }
311323 } else {
312- LivingEntity entity = event .getEntity ();
313- Level level = entity .getCommandSenderWorld ();
314-
315324 for (ServerPlayer playerSearched : level .getEntitiesOfClass (ServerPlayer .class , event .getEntity ().getBoundingBox ().inflate (32 ))) {
316325 ItemStack stack = EntityUtils .findEquippedCurio (playerSearched , ItemRegistry .HOLY_LOCKET .get ());
317326
0 commit comments