private bool RequiresStand(BlockPos pos, Vec3i vector) { BlockMPBase block = Api.World.BlockAccessor.GetBlock(pos.X + vector.X, pos.Y + vector.Y, pos.Z + vector.Z) as BlockMPBase; if (block == null) { return(true); } BlockPos sidePos = new BlockPos(pos.X + vector.X, pos.Y + vector.Y, pos.Z + vector.Z); BEBehaviorMPBase bemp = Api.World.BlockAccessor.GetBlockEntity(sidePos)?.GetBehavior <BEBehaviorMPBase>(); if (bemp == null) { return(true); } BEBehaviorMPAxle bempaxle = bemp as BEBehaviorMPAxle; if (bempaxle == null) { if (bemp is BEBehaviorMPBrake || bemp is BEBehaviorMPCreativeRotor) { BlockFacing side = BlockFacing.FromNormal(vector); if (side != null && block.HasMechPowerConnectorAt(Api.World, sidePos, side.Opposite)) { return(false); } } return(true); } if (IsAttachedToBlock(Api.World.BlockAccessor, block, sidePos)) { return(false); } return(bempaxle.RequiresStand(sidePos, vector)); }
private bool RequiresStand(BlockPos pos, Vec3i vector) { try { BlockMPBase block = Api.World.BlockAccessor.GetBlock(pos.X + vector.X, pos.Y + vector.Y, pos.Z + vector.Z) as BlockMPBase; if (block == null) { return(true); } BlockPos sidePos = new BlockPos(pos.X + vector.X, pos.Y + vector.Y, pos.Z + vector.Z); BEBehaviorMPBase bemp = Api.World.BlockAccessor.GetBlockEntity(sidePos)?.GetBehavior <BEBehaviorMPBase>(); if (bemp == null) { return(true); } BEBehaviorMPAxle bempaxle = bemp as BEBehaviorMPAxle; if (bempaxle == null) { if (bemp is BEBehaviorMPBrake || bemp is BEBehaviorMPCreativeRotor) { BlockFacing side = BlockFacing.FromNormal(vector); if (side != null && block.HasMechPowerConnectorAt(Api.World, sidePos, side.Opposite)) { return(false); } } return(true); } if (IsAttachedToBlock(Api.World.BlockAccessor, block, sidePos)) { return(false); } return(bempaxle.RequiresStand(sidePos, vector)); } catch (Exception e) { #if DEBUG throw (e); #else Api.Logger.Error("Exception thrown in RequiresStand, will log exception but silently ignore it"); Api.Logger.Error("{0}", e); return(false); #endif } }