Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1.     [HarmonyPatch(typeof(BlockLight))]
  2.     [HarmonyPatch("GetBlockActivationCommands")]
  3.     public class AAAFyTy_BlockLightPOILights_Patch_GetBlockActivationCommands
  4.     {
  5.         static bool Prefix(BlockActivationCommand[] __result, BlockLight __instance, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
  6.         {
  7.  
  8.             bool flag = false;
  9.             ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
  10.             if (chunkCluster != null)
  11.             {
  12.                 IChunk chunkSync = chunkCluster.GetChunkSync(World.toChunkXZ(_blockPos.x), World.toChunkY(_blockPos.y), World.toChunkXZ(_blockPos.z));
  13.                 if (chunkSync != null)
  14.                 {
  15.                     BlockEntityData blockEntity = chunkSync.GetBlockEntity(_blockPos);
  16.                     if (blockEntity != null && blockEntity.bHasTransform)
  17.                     {
  18.                         Transform transform = blockEntity.transform.Find("MainLight");
  19.                         if (transform != null)
  20.                         {
  21.                             LightLOD component = transform.GetComponent<LightLOD>();
  22.                             if (component != null && component.GetLight() != null)
  23.                             {
  24.                                 flag = true;
  25.                             }
  26.                         }
  27.                     }
  28.                 }
  29.             }
  30.  
  31.             _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
  32.             __instance.cmds[0].enabled = (__instance.bRuntimeSwitch); //
  33.             __instance.cmds[1].enabled = (flag);
  34.             __result = __instance.cmds;
  35.             return false;
  36.  
  37.         }
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement