Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HarmonyPatch(typeof(BlockLight))]
- [HarmonyPatch("GetBlockActivationCommands")]
- public class AAAFyTy_BlockLightPOILights_Patch_GetBlockActivationCommands
- {
- static bool Prefix(BlockActivationCommand[] __result, BlockLight __instance, WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
- {
- bool flag = false;
- ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
- if (chunkCluster != null)
- {
- IChunk chunkSync = chunkCluster.GetChunkSync(World.toChunkXZ(_blockPos.x), World.toChunkY(_blockPos.y), World.toChunkXZ(_blockPos.z));
- if (chunkSync != null)
- {
- BlockEntityData blockEntity = chunkSync.GetBlockEntity(_blockPos);
- if (blockEntity != null && blockEntity.bHasTransform)
- {
- Transform transform = blockEntity.transform.Find("MainLight");
- if (transform != null)
- {
- LightLOD component = transform.GetComponent<LightLOD>();
- if (component != null && component.GetLight() != null)
- {
- flag = true;
- }
- }
- }
- }
- }
- _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer(), false);
- __instance.cmds[0].enabled = (__instance.bRuntimeSwitch); //
- __instance.cmds[1].enabled = (flag);
- __result = __instance.cmds;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement